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

RuntimeError: Expected object of scalar type Double but got scalar type Float for argument #2 'weight' #33

Open
andkobe opened this issue Dec 19, 2019 · 2 comments

Comments

@andkobe
Copy link

andkobe commented Dec 19, 2019

你好,我在跑test_image.py时遇到这个问题
RuntimeError: Expected object of scalar type Double but got scalar type Float for argument #2 'weight',
打印如下:
Traceback (most recent call last):
File "E:/Code/MachineLearning/DFace-master/test_image.py", line 18, in
bboxs, landmarks = mtcnn_detector.detect_face(img)
File "E:\Code\MachineLearning\DFace-master\dface\core\detect.py", line 610, in detect_face
boxes, boxes_align = self.detect_pnet(img)
File "E:\Code\MachineLearning\DFace-master\dface\core\detect.py", line 271, in detect_pnet
cls_map, reg = self.pnet_detector(feed_imgs)
File "D:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "E:\Code\MachineLearning\DFace-master\dface\core\models.py", line 97, in forward
x = self.pre_layer(x)
File "D:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "D:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\container.py", line 92, in forward
input = module(input)
File "D:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "D:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\conv.py", line 343, in forward
return self.conv2d_forward(input, self.weight)
File "D:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\conv.py", line 340, in conv2d_forward
self.padding, self.dilation, self.groups)
RuntimeError: Expected object of scalar type Double but got scalar type Float for argument #2 'weight'

Process finished with exit code 1

有朋友遇到类似问题么?感谢!

@SimonFFL
Copy link

将./dface/core/image_tools.py文件中第20行改为:
return (transform(image) / 255).float()

@kuaikuaikim
Copy link
Owner

kuaikuaikim commented Nov 23, 2023 via email

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

3 participants