Hi, thank you for sharing this code.
Is that correct if the model converted from the Pytorch is slower than from the MXnet?
I try to re-convert mobile0.25 retinaface PyTorch model to ncnn, But the speed is much slower than the one you provided (., ie: 1000ms compare to 200ms). I strickly set one core of CPU running.
Any comment is really appropriated, thanks.
What is the hardware / platform / operating system etc .. ?
My system is Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz. Ubuntu 18.04
Your model: [https://github.com/nihui/ncnn-assets/tree/master/models] is very fast.
my model: train retinaface mobilenet0.25 pytorch [https://github.com/biubug6/Pytorch_Retinaface] -> port to ncnn ( instruction from wiki) -> using retinaface.cpp ( edit Mat in, extract string ,... ). but the speed is so much slower.
Note: Using one core CPU.
thank you.
I would suggest you to download Netron this will allow you to open the .param files of NCNN models and expect the model structure. What I expect is happening is that the structure of the model you converted is probably not as optimized as the one from the ncnn-assets repo. The first thing to watch out for is that the model you converted is actually a completely different architecture than the one from ncnn-assets. This can be small details like input size, number of channels or large difference in how output processing is implemented. I expect this is the case and you'll have to look into what parts are so much less efficient. A good way to do this is to use add your model to the benchmark script and build NCNN with -DNCNN_BENCHMARK=ON. This will print per layer inference time and will probably point you in the right direction of why the performance is so much worse.
However if the architecture is not so different than common issues for slow downs are:
I hope this helps, in general I suspect the model you converted is either a completely different architecture (a lot heavier) or the conversion method you used didn't produce a NCNN friendly model due to some combination of pytorch operations used in the model. Either way if you post the .param file of the model you converted it will be easier to tell exactly what is the issue.
Thank you for your very detailed explanation,
After carefully follow your guide, I have successfully executed my ncnn pytorch with the same inference time as yours.
@quocnhat is have same probelm. Can share your code? Thanks you.,
if you use pytorch to train retinaFace, follow this git may help. (https://github.com/biubug6/Face-Detector-1MB-with-landmark/tree/master/Face_Detector_ncnn)
Thanks you, is very help.