deepinsight / deepinsight/insightface

Export insightface models to ONNX and inference with TensorRT

Open
#1,350 5 comments 4 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
29.7k
Forks
6.1k
PR merge metrics
No merged PRs in 30d

Description

Hello everyone, here are some scripts that can convert insightface params to onnx model. These scripts have been sorted out various methods of exporting MXNet params or insightface params on the GitHub or CSDN, and can export various models of insightface, **RetinaFace**, **arcface**, **2d106det** and **gender-age** models are all supported. The repo address is: [https://github.com/linghu8812/tensorrt_inference](https://github.com/linghu8812/tensorrt_inference)

supported models|scripts
---|---
RetinaFace|[export_retinaface](https://github.com/linghu8812/tensorrt_inference/blob/master/project/RetinaFace/export_onnx.py)
arcface|[export_arcface](https://github.com/linghu8812/tensorrt_inference/blob/master/project/arcface/export_onnx.py)
2d106det|[export_2d106det](https://github.com/linghu8812/tensorrt_inference/blob/master/project/face_alignment/export_onnx.py)
gender-age|[export_gender-age](https://github.com/linghu8812/tensorrt_inference/blob/master/project/gender-age/export_onnx.py)

### Export RetinaFace params to ONNX

For RetinaFace model, RetinaFace-R50, RetinaFace-MobileNet0.25 and RetinaFaceAntiCov are both supported. copy [project/RetinaFace/export_onnx.py](https://github.com/linghu8812/tensorrt_inference/blob/master/project/RetinaFace/export_onnx.py) to `./detection/RetinaFace` or `./detection/RetinaFaceAntiCov`, with the following comman can export those models.

- export resnet50 model
```
python3 export_onnx.py
```
- export mobilenet 0.25 model
```
python3 export_onnx.py --prefix ./model/mnet.25
```
- export RetinaFaceAntiCov model
```
python3 export_onnx.py --prefix ./model/mnet_cov2 --network net3l
```
An inference code with tensorrt has also been supplied, the following are inference results:

- RetinaFace-R50 result

![image](https://user-images.githubusercontent.com/36389436/101184216-6bb04400-368b-11eb-89e8-59db5958be7a.png)

- RetinaFaceAntiCov result

![image](https://user-images.githubusercontent.com/36389436/101184429-ab772b80-368b-11eb-87a3-e35845f10917.png)

### Export arcface params to ONNX

For arcface model, it has added reshape the shape of PRelu params, so the exported PRelu node structure is shown as following:

![image](https://user-images.githubusercontent.com/36389436/101187135-efb7fb00-368e-11eb-99f3-629c8d1a73da.png)

### Export gender-age and 2d106det params to ONNX

The following is a TensorRT result for 2d106det model, now it's run alone, not with retinaface

![image](https://user-images.githubusercontent.com/36389436/101187567-7bca2280-368f-11eb-8e5a-cd1e0adce2db.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.