Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected object of type torch.DoubleTensor but found type torch.FloatTensor for argument #2 'weight' #16

Open
zhukkang opened this issue May 12, 2018 · 10 comments

Comments

@zhukkang
Copy link

when test the model ,got the issue as below ,plz help to check the issue

RuntimeError Traceback (most recent call last)
in ()
17
18 print("start to detect ")
---> 19 bboxs, landmarks = mtcnn_detector.detect_face(img)
20 # print box_align
21

~/jupyter/DFACE/DFace/dface/core/detect.py in detect_face(self, img)
612 # pnet
613 if self.pnet_detector:
--> 614 boxes, boxes_align = self.detect_pnet(img)
615 if boxes_align is None:
616 return np.array([]), np.array([])

~/jupyter/DFACE/DFace/dface/core/detect.py in detect_pnet(self, im)
269
270 print('type of feed_imgs:',type(feed_imgs))
--> 271 cls_map, reg = self.pnet_detector(feed_imgs)
272
273 cls_map_np = image_tools.convert_chwTensor_to_hwcNumpy(cls_map.cpu())

/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
489 result = self._slow_forward(*input, **kwargs)
490 else:
--> 491 result = self.forward(*input, **kwargs)
492 for hook in self._forward_hooks.values():
493 hook_result = hook(self, input, result)

~/jupyter/DFACE/DFace/dface/core/models.py in forward(self, x)
95
96 def forward(self, x):
---> 97 x = self.pre_layer(x)
98 label = F.sigmoid(self.conv4_1(x))
99 offset = self.conv4_2(x)

@Lan-st
Copy link

Lan-st commented May 26, 2018

I met the same problem, I fix this problem by change "image = image.astype(np.float)" to "image = image.astype(np.float32)" in fuction convert_image_to_tensor, which is in the file image_tools.py

@wting861006
Copy link

@Lan-st I change "image = image.astype(np.float32)", got the new issues as below:
Traceback (most recent call last):
File "/Users/wangting/OneDrive/Pycharm/DeepLearning/dface/test_image.py", line 20, in
bboxs, landmarks = mtcnn_detector.detect_face(img)
File "/Users/wangting/OneDrive/Pycharm/DeepLearning/dface/dface/core/detect.py", line 618, in detect_face
boxes, boxes_align = self.detect_rnet(img, boxes_align)
File "/Users/wangting/OneDrive/Pycharm/DeepLearning/dface/dface/core/detect.py", line 390, in detect_rnet
tmp = np.zeros((tmph[i], tmpw[i], 3), dtype=np.float64)
ValueError: negative dimensions are not allowed

@guanfuchen
Copy link

/usr/bin/python /Users/cgf/GitHub/GitWeb/dface/test_image.py
/Users/cgf/GitHub/GitWeb/dface/dface/core/models.py:8: UserWarning: nn.init.xavier_uniform is now deprecated in favor of nn.init.xavier_uniform_.
nn.init.xavier_uniform(m.weight.data)
/Users/cgf/GitHub/GitWeb/dface/dface/core/models.py:9: UserWarning: nn.init.constant is now deprecated in favor of nn.init.constant_.
nn.init.constant(m.bias, 0.1)
Traceback (most recent call last):
File "/Users/cgf/GitHub/GitWeb/dface/test_image.py", line 24, in
bboxs, landmarks = mtcnn_detector.detect_face(img)
File "/Users/cgf/GitHub/GitWeb/dface/dface/core/detect.py", line 638, in detect_face
boxes, boxes_align = self.detect_rnet(img, boxes_align)
File "/Users/cgf/GitHub/GitWeb/dface/dface/core/detect.py", line 393, in detect_rnet
tmp = np.zeros((tmph[i], tmpw[i], 3), dtype=np.uint8)
ValueError: negative dimensions are not allowed

Process finished with exit code 1
same question as wting861006

@guanfuchen
Copy link

@wting861006,I meet the same error with you, but I am running the code in mac osx, it is ok if you use ubuntu. I think it may be a bug for mac running.

@wjy5446
Copy link

wjy5446 commented Jun 27, 2018

i also have same problem. i change the 'np.float', but it isn't solved.

@HPL123
Copy link

HPL123 commented Jun 28, 2018

@guanfuchen ,I uses ubuntu. But it is not solved

@HPL123
Copy link

HPL123 commented Jun 28, 2018

@wting861006 ,did you solved this problem?

@wting861006
Copy link

@HPL123 You can try use pytorch version<=0.2.0.I sloved it when use version as 0.2.0.

@HPL123
Copy link

HPL123 commented Jun 28, 2018

@wting861006 ,Thanks,I solved it by deleting “image = image.astype(np.float)”

@0xNF
Copy link

0xNF commented Nov 21, 2018

With respect to the deletion of image = image.astype(np.float), I am running this unmodified on an ubuntu box and it works, but I have to delete this line to get it to work under Windows.

Does anyone have any insight as to what the differences could be? Does it come down to PyTorch version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants