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:
Mohammad Hasan
2019-03-13 22:23:53 +06:00
committed by GitHub
parent 4896cefea1
commit b5793737c6

View File

@ -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:
@ -78,4 +78,4 @@ if __name__ == '__main__':
parser.add_argument('--hidden_size', type=int , default=512, help='dimension of lstm hidden states')
parser.add_argument('--num_layers', type=int , default=1, help='number of layers in lstm')
args = parser.parse_args()
main(args)
main(args)