Closed CrHasher closed 1 year ago
Never mind this works:
def convert_to_rgb(img):
# Check the number of channels and convert to RGB if not 3 channels
if img.ndim == 2: # grayscale
img = color.gray2rgb(img)
elif img.shape[2] == 4: # RGBA
img = img[:, :, :3] # Drop the alpha channel
return img
#...
x = torch.tensor(convert_to_rgb(imread(img_file_path))).permute(2, 0, 1)[None, ...] / 255.
But please let me know if I'm doing it wrong.
Support for png files (or) example on how to open one:
The above does not work for PNG files.