I load my pretrained pytorch but i cant predict a single image
Part of Code:
from torchvision import transforms
transform = transforms.Compose([ #[1]
transforms.Resize(256), #[2]
transforms.ToTensor(), #[4]
transforms.Normalize( #[5]
mean=[0.485, 0.456, 0.406], #[6]
std=[0.229, 0.224, 0.225] #[7]
)])
from PIL import Image
img = Image.open("/content/gdrive/My Drive/DCN(data)/Valid/Covid/ryct.2020200034.fig2.jpeg")
img_t = transform(img)
batch_t = torch.unsqueeze(img_t, 3)
batch_t.size()
model.eval()
out = model(batch_t)
print(out.shape)
out
ERROR:
RuntimeError Traceback (most recent call last)
in ()
1 model.eval()
----> 2 out = model(batch_t)
3 print(out.shape)
4 out
6 frames
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py in conv2d_forward(self, input, weight)
340 _pair(0), self.dilation, self.groups)
341 return F.conv2d(input, weight, self.bias, self.stride,
–> 342 self.padding, self.dilation, self.groups)
343
344 def forward(self, input):
RuntimeError: Given groups=1, weight of size 8 3 3 3, expected input[3, 256, 276, 1] to have 3 channels, but got 256 channels instead