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

Before Change


        torch.Tensor: tensor of the form :math:`(C, H, W)`.

    
    if not type(image) == np.ndarray:
        raise TypeError("Input type is not a numpy.ndarray. Got {}".format(
            type(image)))

    if len(image.shape) > 3 or len(image.shape) < 2:
        raise ValueError("Input size must be a two or three dimensional array")

    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

After Change


    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))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

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: facebookresearch/pytext
Commit Name: e0afe32be948c78c8fc58b43ed013b88343f73ab
Time: 2019-05-24
Author: zsc@fb.com
File Name: pytext/config/serialize.py
Class Name:
Method Name: _union_from_json


Project Name: deepmipt/DeepPavlov
Commit Name: 1a6d4020c53e2b39e224616481528fad901cbd4e
Time: 2018-10-15
Author: yoptar@gmail.com
File Name: deeppavlov/core/commands/infer.py
Class Name:
Method Name: predict_on_stream