Code Monkey home page Code Monkey logo

Comments (4)

hpc203 avatar hpc203 commented on May 23, 2024

希望作者有空上传一下能跑通GPU的版本,感谢~

这套程序里,有的算法是基于pytorch框架运行的,有的是调用opencv运行的。在基于Pytorch框架运行的程序里,有device = 'cuda' if torch.cuda.is_available() else 'cpu'这行代码,它会根据运行设备自适应切换到cpu或者gpu环境的,而调用opencv的程序在cpu和gpu环境是通用的

from 10kinds-light-face-detector-align-recognition.

on-your-way avatar on-your-way commented on May 23, 2024

嗯,检测到cuda可用,device是'cuda',可是跑不通啊,各种错误

from 10kinds-light-face-detector-align-recognition.

on-your-way avatar on-your-way commented on May 23, 2024

比如pfld_mtcnn\detector.py报错如下:

Traceback (most recent call last):
File "D:/studyFiles/CV/face_detection/ten_kinds/Run_all_compare_time.py", line 78, in
mtcnn_result, _ = mtcnn_detect.detect(srcimg)
File "D:\studyFiles\CV\face_detection\ten_kinds\mtcnn_pfld_landmark.py", line 15, in detect
bounding_boxes, landmarks = self.mtcnn.detect(srcimg) ###landmarks: numpy array, n x 10 (x1, x2 ... x5, y1, y2 ..y5)
File "D:\studyFiles\CV\face_detection\ten_kinds\pfld_mtcnn\detector.py", line 392, in detect
boxes = run_first_stage(image, self.pnet, scale=s, threshold=self.thresholds[0])
File "D:\studyFiles\CV\face_detection\ten_kinds\pfld_mtcnn\detector.py", line 246, in run_first_stage
output = net(img)
File "D:\Softwares\Anaconda3\envs\pytorch_env\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\studyFiles\CV\face_detection\ten_kinds\pfld_mtcnn\detector.py", line 170, in forward
x = self.features(x)
File "D:\Softwares\Anaconda3\envs\pytorch_env\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\Softwares\Anaconda3\envs\pytorch_env\lib\site-packages\torch\nn\modules\container.py", line 119, in forward
input = module(input)
File "D:\Softwares\Anaconda3\envs\pytorch_env\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\Softwares\Anaconda3\envs\pytorch_env\lib\site-packages\torch\nn\modules\conv.py", line 399, in forward
return self._conv_forward(input, self.weight, self.bias)
File "D:\Softwares\Anaconda3\envs\pytorch_env\lib\site-packages\torch\nn\modules\conv.py", line 395, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same

from 10kinds-light-face-detector-align-recognition.

hpc203 avatar hpc203 commented on May 23, 2024

比如pfld_mtcnn\detector.py报错如下:

Traceback (most recent call last):
File "D:/studyFiles/CV/face_detection/ten_kinds/Run_all_compare_time.py", line 78, in
mtcnn_result, _ = mtcnn_detect.detect(srcimg)
File "D:\studyFiles\CV\face_detection\ten_kinds\mtcnn_pfld_landmark.py", line 15, in detect
bounding_boxes, landmarks = self.mtcnn.detect(srcimg) ###landmarks: numpy array, n x 10 (x1, x2 ... x5, y1, y2 ..y5)
File "D:\studyFiles\CV\face_detection\ten_kinds\pfld_mtcnn\detector.py", line 392, in detect
boxes = run_first_stage(image, self.pnet, scale=s, threshold=self.thresholds[0])
File "D:\studyFiles\CV\face_detection\ten_kinds\pfld_mtcnn\detector.py", line 246, in run_first_stage
output = net(img)
File "D:\Softwares\Anaconda3\envs\pytorch_env\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\studyFiles\CV\face_detection\ten_kinds\pfld_mtcnn\detector.py", line 170, in forward
x = self.features(x)
File "D:\Softwares\Anaconda3\envs\pytorch_env\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\Softwares\Anaconda3\envs\pytorch_env\lib\site-packages\torch\nn\modules\container.py", line 119, in forward
input = module(input)
File "D:\Softwares\Anaconda3\envs\pytorch_env\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\Softwares\Anaconda3\envs\pytorch_env\lib\site-packages\torch\nn\modules\conv.py", line 399, in forward
return self._conv_forward(input, self.weight, self.bias)
File "D:\Softwares\Anaconda3\envs\pytorch_env\lib\site-packages\torch\nn\modules\conv.py", line 395, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same

这个错误的原因很简单呀,就是网络结构model转换到gpu环境了,但是输入张量Input没有转换到gpu环境,因此你需要在输入张量Input后加上.to(device)
这是我编写程序的一个疏忽,当初这些网络都是轻量级的,我就在win10-cpu机器上编写程序,没有放在gpu设备上调试,请谅解

from 10kinds-light-face-detector-align-recognition.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.