opencv / opencv_zoo

Model Zoo For OpenCV DNN and Benchmarks.
Apache License 2.0
643 stars 191 forks source link

face_detection_yunet #31

Closed donaldlee2008 closed 2 years ago

donaldlee2008 commented 2 years ago

os:windows python: 3.6 opecv-python:4.5.4 face_detection_yunet/demo.py
cmd: python demo.py -i 3.jpg error: onnx_importer.cpp:203: error: (-210:Unsupported format or combination of formats) Failed to parse ONNX model: face_detection_yunet_2021sep.onnx in function 'cv::dnn::dnn4_v20211004::ONNXImporter::ONNXImporter'

fengyuentau commented 2 years ago

Did you test on WIndows CMD or WSL?

Solution: Follow the instructions in README to install git-lfs to pull models.

donaldlee2008 commented 2 years ago

Did you test on WIndows CMD or WSL?

WIndows CMD

bwmcin commented 2 years ago

Opened face_detection_yunet_2022mar.onnx in notepad+ and got this...

version https://git-lfs.github.com/spec/v1 oid sha256:50ef07f702a31741ca46a4c0d947773b64143b9362780237bf0d427d6c79bab7 size 345478

....and nothing else. Also, the file size is very small.

face_detection_yunet_2022_mar-act_int8-wt_int8-quantized.onnx has similar issue.

fengyuentau commented 2 years ago

@bwmcin You need to install git-lfs from https://git-lfs.github.com/ and run

cd your/opencv_zoo
git lfs install
git pull

Or clone a fresh copy of opencv_zoo after you install git-lfs:

git lfs install
git clone https://github.com/opencv/opencv_zoo
zihaomu commented 2 years ago

Hi @donaldlee2008, does git lfs install solve your problem?

deepti-pushpak commented 2 years ago

cv2.error: OpenCV(4.6.0) /io/opencv/modules/dnn/src/onnx/onnx_importer.cpp:260: error: (-210:Unsupported format or combination of formats) Failed to parse ONNX model: face_detection_yunet_2022mar.onnx in function 'ONNXImporter'

I am having the same issue on my ubuntu 20.04.4. Could anyone resolve this?

fengyuentau commented 2 years ago

@deepti-pushpak Follow the instructions in README to install git-lfs to pull models.

deepti-pushpak commented 2 years ago

@deepti-pushpak Follow the instructions in README to install git-lfs to pull models.

@fengyuentau I can't thank you enough. Your suggestion works! I am able to run the detection code now, that utilises onnx model file. Thank you for saving me tons of work. Also, I have an inquisitive query. 3 months ago, I was able to simply clone this repository from GitHub and used to run the code on my system without any further ado, but yesterday when I tried the same code it threw errors that I have already mentioned. After trying your suggestion, it works well now. However, could you please briefly explain, what is it that "git-lfs pull" did that my code works now? Thank you.

Radeeshp commented 1 year ago

I am not able to run this line : detector = cv2.FaceDetectorYN.create("face_detection_yunet_2023mar.onnx", "", (640, 480)) i have tried it with others files too. This is the error i get when i try to run this line

[ WARN:0@1.646] global loadsave.cpp:244 cv::findDecoder imread_('face_detection_yunet_2023mar.onnx'): can't open/read file: check file path/integrity Error: Unable to open file. Traceback (most recent call last): File "f:\EDUCATION\PROJECTS\FACE DETECTION\Face_detection_Yunet\Yunet_Code.py", line 21, in detector = cv2.FaceDetectorYN.create("face_detection_yunet_2023mar.onnx", "", (640, 480)) cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp:270: error: (-5:Bad argument) Can't read ONNX file: face_detection_yunet_2023mar.onnx in function 'cv::dnn::dnn4_v20221220::ONNXImporter::ONNXImporter'

JefferyChia commented 1 year ago

I follow the instructions in README to install git-lfs to pull models and re-run my model. However, the error still persists.

cv2.error: OpenCV(4.8.1) /io/opencv/modules/dnn/src/onnx/onnx_importer.cpp:279: error: (-210:Unsupported format or combination of formats) Failed to parse ONNX model: face_detection_yunet_2023mar.onnx in function 'ONNXImporter'

onnx model: face_detection_yunet_2023mar.onnx

can someone help?

fengyuentau commented 12 months ago

@JefferyChia Please doublecheck whether you correctly installed git-lfs and pulled the models with the following commands:

$ git lfs status

It prints git: 'lfs' is not a git command. See 'git --help'. if git-lfs is not installed.

$ echo "8f2383e4dd3cfbb4553ea8718107fc0423210dc964f9f4280604804ed2552fa4  face_detection_yunet_2023mar.onnx" | shasum -a 256 -c

It prints OK if face_detection_yunet_2023mar.onnx is pulled correctly.

JefferyChia commented 12 months ago

@fengyuentau I checked the status of git-lfs and the output is this:

On branch main Git LFS objects to be pushed to origin/main:

Git LFS objects to be committed:

Git LFS objects not staged for commit:

However, I got an error when I type in the echo command:

shasum: face_detection_yunet_2023mar.onnx: No such file or directory face_detection_yunet_2023mar.onnx: FAILED open or read shasum: WARNING: 1 listed file could not be read

Can you help me?

fengyuentau commented 12 months ago

You need to run demo and my commands in models/face_detection_yunet.

JefferyChia commented 12 months ago

Hey @fengyuentau, I think it runs well. However, now I have a new error:

Traceback (most recent call last): File "demo.py", line 101, in print('{} faces detected.'.format(results.shape[0])) AttributeError: 'NoneType' object has no attribute 'shape'

Is there an issue that I can refer on this?

fengyuentau commented 12 months ago

That means no faces are detected. It returns none in this case.

JefferyChia commented 12 months ago

@fengyuentau my input is a face, however, I am not sure why the error persists. Do I need to reshape the size of the image or is it unnecessary?

python3 demo.py -i human_faces.jpg

Human_faces

fengyuentau commented 12 months ago

These faces are way too big to be able to be detected by this model. Try to shrink this image to 1/4 of its original size and I can get the follow result,

result