mirror of
https://github.com/yunjey/pytorch-tutorial.git
synced 2025-07-08 02:29:04 +08:00
Fixed Test error when encoder(image).
When we load an image for the sample, we have to make sure that the image has three color channel (RGB) because it might be grayscale. So we should convert it for sampling.
This commit is contained in:
@ -14,7 +14,7 @@ from PIL import Image
|
||||
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
||||
|
||||
def load_image(image_path, transform=None):
|
||||
image = Image.open(image_path)
|
||||
image = Image.open(image_path).convert('RGB')
|
||||
image = image.resize([224, 224], Image.LANCZOS)
|
||||
|
||||
if transform is not None:
|
||||
|
Reference in New Issue
Block a user