Giter Club home page Giter Club logo

yolov5-face-landmarks-opencv's Introduction

yolov5-face-landmarks-opencv

yolov5检测人脸和关键点,只依赖opencv库就可以运行,程序包含C++和Python两个版本的。 本套程序根据https://github.com/deepcam-cn/yolov5-face 里提供的训练模型.pt文件。转换成onnx文件, 然后使用opencv读取onnx文件做前向推理,onnx文件从百度云盘下载,下载 链接:https://pan.baidu.com/s/14qvEOB90CcVJwVC5jNcu3A 提取码:duwc

下载完成后,onnx文件存放目录里,C++版本的主程序是main_yolo.cpp,Python版本的主程序是main.py 。此外,还有一个main_export_onnx.py文件,它是读取pytorch训练模型.pt文件生成onnx文件的。 如果你想重新生成onnx文件,不能直接在该目录下运行的,你需要把文件拷贝到https://github.com/deepcam-cn/yolov5-face 的主目录里运行,就可以生成onnx文件。如果运行过程中没有报错中断,那就说明转换生成onnx文件成功, 并且opencv读取onnx文件做forward也正常。

我之所以发布这个文件,是因为在此之前我发布的一套使用opencv部署yolov5的程序里,转换生成onnx需要经过读取.pt文件生成.pth 文件和编写yolov5.py文件这两个步骤,这个挺麻烦的。然而最近我发现其实可以在读取.pt文件后直接生成.onnx文件的,这样就简化 了生成onnx文件的流程。

此外,我看到github上deepcam-cn更新了yolov5-face的程序,我的使用opencv做yolov5-face推理的程序也做了更新, 更新的程序发布在 https://github.com/hpc203/yolov5-face-landmarks-opencv-v2

yolov5-face-landmarks-opencv's People

Contributors

hpc203 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

yolov5-face-landmarks-opencv's Issues

unable to convert to onnx

Traceback (most recent call last):
File "/media/githubprj/face/yolov5-face/main_export_onnx.py", line 110, in
onnxmodel,img = test_export(opt)
File "/media/githubprj/face/yolov5-face/main_export_onnx.py", line 69, in test_export
x = m(x) # run
result = self.forward(*input, **kwargs)
File "/media/githubprj/face/yolov5-face/models/common.py", line 227, in forward
return torch.cat(x, self.d)
TypeError: expected Tensor as element 1 in argument 0, but got NoneType

I got the error while converting to onnx of the pretrained model yolov5n.pt

模型转换

作者你好,我在使用torch1.7环境转换的onnx模型,在使用你的脚本调用的时候onnx做预测的时候出现cv2.dnn.readNet(‘onnx路径’)提示 blob.type()==5 in function‘populateNet’,想问下你有没有这种情况,如何解决的?谢谢

关于opencv在进行执行forward()异常问题

您好,我可以成功得转成onnx,但opencv在进行执行forward()异常:
this->net.forward(outs, this->net.getUnconnectedOutLayersNames()); //0x000007FEFD8BB87D 处(位于 onnx.exe 中)有未经处理的异常: Microsoft C++ 异常: cv::Exception,位于内存位置 0x000000000028C370 处。
[ERROR:[email protected]] global C:\build\master_winpack-build-win64-vc15\opencv\modules\d
nn\src\dnn.cpp (3888) cv::dnn::dnn4_v20211220::Net::Impl::getLayerShapesRecursiv
ely Exception message: OpenCV(4.5.5) C:\build\master_winpack-build-win64-vc15\op
encv\modules\dnn\src\layers\reshape_layer.cpp:107: error: (-215:Assertion failed
) total(srcShape, srcRange.start, srcRange.end) == maskTotal in function 'cv::dn
n::computeShapeByReshapeMask'
由于刚接触AI,想知道具体原因,谢谢!

convert2onnx的脚本问题

您好,我在执行您的转换到onnx脚本的时候,出现了如下错误,请问可能是什么问题呢?
image

main_export_onnx.py

when run main_export_onnx.py , i get error:
Traceback (most recent call last):
File "/media/xxx/data1/githubprj/face/yolov5-face/main_export_onnx.py", line 110, in
onnxmodel,img = test_export(opt)
File "/media/xxx/data1/githubprj/face/yolov5-face/main_export_onnx.py", line 69, in test_export
x = m(x) # run
File "/media/data1/3rdtool/anaconda3/envs/yolov5face/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/media/xxx/data1/githubprj/face/yolov5-face/models/common.py", line 227, in forward
return torch.cat(x, self.d)
TypeError: expected Tensor as element 1 in argument 0, but got NoneType

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.