simple-faster-rcnn-pytorch
simple-faster-rcnn-pytorch copied to clipboard
RuntimeError: Expected object of type torch.DoubleTensor but found type torch.FloatTensor for argument #4 'other'
pytorch 4.0.1 windows: 10 cuda: 9.0 python: 3.6 when I run the demo:
trainer.load('C:\Users\25118\.torch\models\fasterrcnn_12211511_0.701052458187_torchvision_pretrain.pth') opt.caffe_pretrain=False # this model was trained from torchvision-pretrained model _bboxes, _labels, _scores = trainer.faster_rcnn.predict(img,visualize=True) vis_bbox(at.tonumpy(img[0]), at.tonumpy(_bboxes[0]), at.tonumpy(_labels[0]).reshape(-1), at.tonumpy(_scores[0]).reshape(-1))
it failed to find the dog, but if you set threshold from 0.7 to 0.6, you'll find it
I got this error:
RuntimeError Traceback (most recent call last)
C:\Users\25118\Anaconda3\lib\site-packages\model\faster_rcnn.py in new_f(*args, **kwargs) 17 def new_f(*args,**kwargs): 18 with t.no_grad(): ---> 19 return f(*args,**kwargs) 20 return new_f 21
C:\Users\25118\Anaconda3\lib\site-packages\model\faster_rcnn.py in predict(self, imgs, sizes, visualize) 220 for img in imgs: 221 size = img.shape[1:] --> 222 img = preprocess(at.tonumpy(img)) 223 prepared_imgs.append(img) 224 sizes.append(size)
C:\Users\25118\Anaconda3\lib\site-packages\data\dataset.py in preprocess(img, min_size, max_size) 72 else: 73 normalize = pytorch_normalze ---> 74 return normalize(img) 75 76
C:\Users\25118\Anaconda3\lib\site-packages\data\dataset.py in pytorch_normalze(img) 25 normalize = tvtsf.Normalize(mean=[0.485, 0.456, 0.406], 26 std=[0.229, 0.224, 0.225]) ---> 27 img = normalize(t.from_numpy(img)).float() 28 return img.numpy() 29
C:\Users\25118\Anaconda3\lib\site-packages\torchvision\transforms\transforms.py in call(self, tensor) 161 Tensor: Normalized Tensor image. 162 """ --> 163 return F.normalize(tensor, self.mean, self.std, self.inplace) 164 165 def repr(self):
C:\Users\25118\Anaconda3\lib\site-packages\torchvision\transforms\functional.py in normalize(tensor, mean, std, inplace) 206 mean = torch.tensor(mean, dtype=torch.float32) 207 std = torch.tensor(std, dtype=torch.float32) --> 208 tensor.sub_(mean[:, None, None]).div_(std[:, None, None]) 209 return tensor 210
RuntimeError: Expected object of type torch.DoubleTensor but found type torch.FloatTensor for argument #4 'other' what should I do to fix it? thanks for your answer!
i meet the same error
i meet the same error
did you fix it?
i meet the same error
did you fix it?
I have the same error!Did you saved this?
i meet the same error
did you fix it?
I have the same error!Did you saved this?
no how about you?
i meet the same error did you fix it? I have the same error!Did you saved this?
no how about you?
I change some code in the dataset.py pytorch_normalize img = normalize(t.from_numpy(img))to img = normalize(t.from_numpy(img)).float().It can run normaly.You can test it.
def pytorch_normalze(img): """ https://github.com/pytorch/vision/issues/223 return appr -1~1 RGB """ tensor = t.from_numpy(img) dtype = tensor.dtype mean = [0.485, 0.456, 0.406] std = [0.229, 0.224, 0.225] mean = t.as_tensor(mean, dtype=dtype, device=tensor.device) std = t.as_tensor(std, dtype=dtype, device=tensor.device) tensor.sub_(mean[:, None, None]).div_(std[:, None, None]) return tensor.numpy()
i meet the same error. @YangYangGirl's code is right. thanks!
the solutions mentioned above do not work for me. any other solutions?
the solutions mentioned above do not work for me. any other solutions?
metoo, and now? how did u fix it?