import math
import torch


def upsample_image(image, scale_factor=0.75, method='bicubic'):
    """
    Upsample image with the 1/scale_factor by using given method

    :param image: normed image tensor
    :param scale_factor: scale factor
    :param method: interpolation method
    :return: upsampled normed image tensor
    """
    upsample_scale_factor = 1/scale_factor
    scale_shape = (image.shape[2] * upsample_scale_factor, image.shape[3] * upsample_scale_factor)
    scale_shape = tuple(map(math.floor, scale_shape))
    upsampled_img = torch.nn.functional.interpolate(image, size=scale_shape, mode=method, align_corners=False)

    return upsampled_img