'ValueError: Input size must have a shape of (*, 3, H, W).Got torch.Size([1, 4, 258, 369])
I tried to run the following code on Google collab:
x_bgr: torch.Tensor = K.utils.image_to_tensor(np.array(PIL.Image.open(str(covid[1]))))
x_bgr = x_bgr[None,...].float() / 255.
x_rgb: torch.Tensor = K.color.bgr_to_rgb(x_bgr)
x_gray = K.color.rgb_to_grayscale(x_rgb)
I got this error:
ValueError Traceback (most recent call last)
<ipython-input-16-49608288d875> in <module>()
3 x_bgr = x_bgr[None,...].float() / 255.
4
----> 5 x_rgb: torch.Tensor = K.color.bgr_to_rgb(x_bgr)
6 x_gray = K.color.rgb_to_grayscale(x_rgb)
/usr/local/lib/python3.7/dist-packages/kornia/color/rgb.py in bgr_to_rgb(image)
46
47 if len(image.shape) < 3 or image.shape[-3] != 3:
---> 48 raise ValueError(f"Input size must have a shape of (*, 3, H, W).Got {image.shape}")
49
50 # flip image channels
ValueError: Input size must have a shape of (*, 3, H, W).Got torch.Size([1, 4, 258, 369])
How should i fix it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
