shouxieai / tensorRT_Pro

C++ library based on tensorrt integration
MIT License
2.62k stars 549 forks source link

scrfd 10g model (attached) is unable to detect any faces in sample images #190

Closed cyrusbehr closed 1 year ago

cyrusbehr commented 1 year ago

I've modified the code in app_scrfd.cpp to load my own scrfd 10g (which can be downloaded here) instead of the default one. The only other thing I've changed is the batch size, from 6 to 1, here.

When I then build the trt model and run inference using the example code, it is unable to find any faces in any of the sample images in workspace/inference/.

If I then load the model directly with onnxruntime C++ and run inference, I can find faces in all of those same images. Can you please download and test the scrfd model and tell me what is missing there.

cyrusbehr commented 1 year ago

Here are the images when I run them with the same model onnxruntime c++. Faces detected in all. Therefore I'm wondering if there could be something in the model that is not supported by your implementation code. Is there any chance you can please download and run the model.

car_landmarks gril_landmarks group_landmarks yq_landmarks zand_landmarks zgjr_landmarks

cyrusbehr commented 1 year ago

Or is there something special I'm supposed to do when exporting from pytorch to onnx. And if so, could you share what that is with me please.

cyrusbehr commented 1 year ago

I was able to solve the issue by following the instructions here: https://github.com/namdvt/SCRFD_FaceDetection_TensorRT#export-scrfd-onnx

To summarize, my model had the following output dimensions:

image (1)

While the model needs to have these output dimensions:

image

Using the code above, I was able to export the model from pytorch to onnx with the correct output dimensions.