PyTorch: predict images

Hi everybody,

I want to predict different images using my trained network.
For some reasons this code works only with one image, if I want to use different others images this doesn’t work.

I got the error:

RuntimeError: invalid argument 2: size '[-1 x 400]' is invalid for input with 880 elements at /opt/conda/conda-bld/pytorch_1532579805626/work/aten/src/TH/THStorage.cpp:80

So why this works only with one picture?

This is full code here:

import torch
from pytorch import Net
import torchvision.transforms as transforms
from PIL import Image
import numpy as np

transform = transforms.Compose([
    transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))

image ="plane.png").convert('RGB')
x = transform(image)
x = x.unsqueeze(0)
pix = np.array(x) #convert image to numpy array
net = Net()

img = torch.from_numpy(pix)

net = torch.load('pytorch_Network2.h5')
idx_to_class = {
    0: 'airplane',
    1: 'automobile',
    2: 'bird',
    3: 'cat',
    4: 'deer',
    5: 'dog',
    6: 'frog',
    7: 'horse',
    8: 'ship',
    9: 'truck'

output = net(img)
pred = torch.argmax(output, 1)

for p in pred:
    cls = idx_to_class[p.item()]

What is the dimension of images? Are all in same dimension?

Only accept images with 860x368 dimension

Solution is to resize image to certain size. In my situation it is
image = image.resize((860, 368))