insightface
insightface copied to clipboard
scrfd how to convert to onnx?
While using scrfd2onnx.py, what should be the values of build_model_from_cfg, generate_inputs_and_wrap_model, and preprocess_example_input in from mmdet.core import (build_model_from_cfg, generate_inputs_and_wrap_model, preprocess_example_input)
Please follow the example from our readme. Default settings should work.
I receive the following error
ImportError: cannot import name 'build_model_from_cfg'
Even though I can run the following example from mmdetection successfully
from mmdet.apis import init_detector, inference_detector, show_result_pyplot
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
device = 'cuda:0'
model = init_detector(config_file, checkpoint_file, device=device)
device = 'cuda:0'
model = init_detector(config_file, checkpoint_file, device=device)
img = 'demo/demo.jpg'
result = inference_detector(model, img)
show_result_pyplot(model, img, result, score_thr=0.3)
Changing version of mmcv-full to 1.3.3, pip install -v -e .
and pip3 install onnx-simplifier
solved the problem. But now using scrfdgen2.5g_0.onnx
and bboxes, kpss = detector.detect(img, 0.5, input_size = (640, 640)) I get the following output.
I am having the same issue, can someone help me to figure this out?
Could anyone could convert scrfd model to onnx. examples are not working:
Traceback (most recent call last):
File "
@schliffen please run https://github.com/deepinsight/insightface/blob/master/detection/scrfd/tools/scrfd2onnx.py to generate onnx model
We are using https://github.com/deepinsight/insightface/blob/master/detection/scrfd/tools/scrfd2onnx.py and get the error!
Change from mmdet.core import (build_model_from_cfg, generate_inputs_and_wrap_model, preprocess_example_input) ==>>>>> from mmdet.core.export import build_model_from_cfg, preprocess_example_input, generate_inputs_and_wrap_model
Hi, @chenscottus , Did above suggestion worked?
I did the same but still same error of KeyError: 'SCRFD is not in the models registry'
I used "scrfd_2.5g_bnkps.py" as config file when converted the pth to onnx of 'scrfd_2.5g.pth'. Of course, the onnx file is generated. but when check the onnx file, the output is empty. what is issue?
scrfd_2.5g_bnkps.py and scrfd_2.5g.py are same. Only difference is "norm_cfg=dict(type='BN', requires_grad=True)" and "dict(type='GN', num_groups=16, requires_grad=True)". But, after converted pth into onnx with 'bnkps' config file, that onnx does not work. who can help me?
@fisakhan try input_size=(256,256)
new issue: ModuleNotFoundError: No module named 'mmdet.core'
new issue: ModuleNotFoundError: No module named 'mmdet.core'
Is this problem solved? I still cannot convert the pretrained scrfd_2.5 to onnx. It's still the error KeyError: 'SCRFD is not in the models registry'
Is this problem solved? I still cannot convert the pretrained scrfd_2.5 to onnx. It's still the error KeyError: 'SCRFD is not in the models registry'
You need to run /insightface/detection/scrfd/setup.py, but make sure that mmdet is NOT installed yet. The script will install it and automatically set its location to /insightface/detection/scrfd/mmdet, which contains the SCRFD model script file.