You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when i valuate my model, with shape(1, 3, 256, 256) imgTensor input, this Error raised up:
Traceback (most recent call last):
File "/home/elaine/su/track2/Person-reID-triplet-loss-master/my_test.py", line 432, in <module>
print(model(imgtrans))
File "/home/elaine/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in __call__
result = self.forward(*input, **kwargs)
File "/home/elaine/su/track2/Person-reID-triplet-loss-master/model.py", line 86, in forward
x, f = self.classifier(x)
File "/home/elaine/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in __call__
result = self.forward(*input, **kwargs)
File "/home/elaine/su/track2/Person-reID-triplet-loss-master/model.py", line 54, in forward
f = self.add_block(x)
File "/home/elaine/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in __call__
result = self.forward(*input, **kwargs)
File "/home/elaine/anaconda3/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
input = module(input)
File "/home/elaine/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in __call__
result = self.forward(*input, **kwargs)
File "/home/elaine/anaconda3/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 45, in forward
self._check_input_dim(input)
File "/home/elaine/anaconda3/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 123, in _check_input_dim
.format(input.dim()))
ValueError: expected 2D or 3D input (got 1D input)
I'm sure that the input tenor shape is (1, 3, 256, 256)
And i have changed mode of models into mode:eval()
print('-------test-----------')
model_structure = ft_net(opt.nclasses)
model = load_network(model_structure)
model = model.eval() # Change to test mode
model.train(False)
if use_gpu:
model = model.cuda()
with torch.no_grad():
# predicts = extract_feature_cls(model, dataloaders['val'], mode='cls')
# predicts = np.argmax(predicts, axis=0)
temimg = Image.open('/home/elaine/su/track2/Market/pytorch/image_query/000001.jpg')
imgtrans = data_transforms(temimg)
imgtrans = imgtrans.unsqueeze(0)
print(imgtrans.shape) # torch.Size([1, 3, 256, 256])
imgtrans = Variable(imgtrans.cuda())
print(model(imgtrans))
The text was updated successfully, but these errors were encountered:
Hi, have you ever met this Error?
I'm sure that the input tenor shape is (1, 3, 256, 256)
And i have changed mode of models into mode:eval()
The text was updated successfully, but these errors were encountered: