e06eee5deec11dc03d6c4975eb9a57f2bc6edd30,kornia/utils/image.py,,image_to_tensor,#Any#,7

Before Change



    tensor: torch.Tensor = torch.from_numpy(image)

    if len(tensor.shape) == 2:
        tensor = torch.unsqueeze(tensor, dim=-1)

    return tensor.permute(2, 0, 1).squeeze_()  // CxHxW


def tensor_to_image(tensor: torch.Tensor) -> np.array:

After Change


            "Input size must be a two, three or four dimensional array")

    input_shape = image.shape
    if len(input_shape) == 2:
        tensor: torch.Tensor = hw_image_to_hw_tensor(image)
    elif len(input_shape) == 3:
        tensor: torch.Tensor = hwc_image_to_chw_tensor(image)
    elif len(input_shape) == 4:
        tensor: torch.Tensor = bhwc_image_to_bchw_tensor(image)
    else:
        raise ValueError("Cannot process image with shape {}".format(input_shape))
    return tensor


def hw_tensor_to_hw_image(tensor: torch.Tensor) -> np.array:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

Instances


Project Name: arraiy/torchgeometry
Commit Name: e06eee5deec11dc03d6c4975eb9a57f2bc6edd30
Time: 2019-05-28
Author: jiangwei1993@gmail.com
File Name: kornia/utils/image.py
Class Name:
Method Name: image_to_tensor


Project Name: arogozhnikov/einops
Commit Name: 680f4831e6c8f3102be8d99056b746b48ce34051
Time: 2018-09-27
Author: iamfullofspam@gmail.com
File Name: einops.py
Class Name:
Method Name: reduce


Project Name: idaholab/raven
Commit Name: 559e68fcac66c449772be2b21af92f502df70e5f
Time: 2019-11-07
Author: paul.talbot@inl.gov
File Name: framework/Driver.py
Class Name:
Method Name: checkVersions