Skip to content

Commit

Permalink
Add: arcface-mobilefacenet (wang-xinyu#545)
Browse files Browse the repository at this point in the history
* add arcface-mobilefacenet

* Update arcface-mobilefacenet.cpp

* modify CMmakeLists.txt, add arcface-r100.cpp

* fix typos,resolve conflicts,update README.md

Co-authored-by: Admin <[email protected]>
  • Loading branch information
ybw108 and Admin authored May 17, 2021
1 parent 20fce2b commit 53ba7e9
Show file tree
Hide file tree
Showing 4 changed files with 937 additions and 8 deletions.
12 changes: 12 additions & 0 deletions arcface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,17 @@ target_link_libraries(arcface-r50 cudart)
target_link_libraries(arcface-r50 myplugins)
target_link_libraries(arcface-r50 ${OpenCV_LIBS})

add_executable(arcface-mobilefacenet ${PROJECT_SOURCE_DIR}/arcface-mobilefacenet.cpp)
target_link_libraries(arcface-mobilefacenet nvinfer)
target_link_libraries(arcface-mobilefacenet cudart)
target_link_libraries(arcface-mobilefacenet myplugins)
target_link_libraries(arcface-mobilefacenet ${OpenCV_LIBS})

add_executable(arcface-r100 ${PROJECT_SOURCE_DIR}/arcface-r100.cpp)
target_link_libraries(arcface-r100 nvinfer)
target_link_libraries(arcface-r100 cudart)
target_link_libraries(arcface-r100 myplugins)
target_link_libraries(arcface-r100 ${OpenCV_LIBS})

add_definitions(-O2 -pthread)

27 changes: 19 additions & 8 deletions arcface/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The mxnet implementation is from [deepinsight/insightface.](https://github.com/deepinsight/insightface)

The pretrained model is [LResNet50E-IR,ArcFace@ms1m-refine-v1.](https://github.com/deepinsight/insightface/wiki/Model-Zoo#32-lresnet50e-irarcfacems1m-refine-v1)
The pretrained models are from [LResNet50E-IR,ArcFace@ms1m-refine-v1](https://github.com/deepinsight/insightface/wiki/Model-Zoo#32-lresnet50e-irarcfacems1m-refine-v1), [LResNet100E-IR,ArcFace@ms1m-refine-v2](https://github.com/deepinsight/insightface/wiki/Model-Zoo#31-lresnet100e-irarcfacems1m-refine-v2) and [MobileFaceNet,ArcFace@ms1m-refine-v1](https://github.com/deepinsight/insightface/wiki/Model-Zoo#34-mobilefacenetarcfacems1m-refine-v1)

The two input images used in this project are joey0.ppm and joey1.ppm, download them from [Google Drive.](https://drive.google.com/drive/folders/1ctqpkRCRKyBZRCNwo9Uq4eUoMRLtFq1e). The input image is 112x112, and generated from `get_input()` in `insightface/deploy/face_model.py`, which is cropped and aligned face image.

Expand All @@ -12,13 +12,12 @@ The two input images used in this project are joey0.ppm and joey1.ppm, download

## Config

- FP16/FP32 can be selected by the macro `USE_FP16` in arcface-r50.cpp
- GPU id can be selected by the macro `DEVICE` in arcface-r50.cpp
- FP16/FP32 can be selected by the macro `USE_FP16` in arcface-r50/r100/mobilefacenet.cpp
- GPU id can be selected by the macro `DEVICE` in arcface-r50/r100/mobilefacenet.cpp

## Run

1. generate arcface-r50.wts from mxnet implementation with LResNet50E-IR,ArcFace@ms1m-refine-v1 pretrained model

1.Generate .wts file from mxnet implementation of pretrained model. The following example described how to generate arcface-r50.wts from mxnet implementation of LResNet50E-IR,ArcFace@ms1m-refine-v1.
```
git clone https://github.com/deepinsight/insightface
cd insightface
Expand All @@ -29,9 +28,10 @@ cd deploy
python gen_wts.py
// a file 'arcface-r50.wts' will be generated.
// the master branch of insightface should work, if not, you can checkout 94ad870abb3203d6f31b049b70dd080dc8f33fca
```
// arcface-r100.wts/arcface-mobilefacenet.wts can be generated in similar way from mxnet implementation of LResNet100E-IR,ArcFace@ms1m-refine-v1/MobileFaceNet,ArcFace@ms1m-refine-v1 pretrained model.
2. put arcface-r50.wts into tensorrtx/arcface, build and run
```
2.Put .wts file into tensorrtx/arcface, build and run

```
cd tensorrtx/arcface
Expand All @@ -42,9 +42,20 @@ cmake ..
make
sudo ./arcface-r50 -s // serialize model to plan file i.e. 'arcface-r50.engine'
sudo ./arcface-r50 -d // deserialize plan file and run inference
or
sudo ./arcface-r100 -s // serialize model to plan file i.e. 'arcface-r100.engine'
sudo ./arcface-r100 -d // deserialize plan file and run inference
or
sudo ./arcface-mobilefacenet -s // serialize model to plan file i.e. 'arcface-mobilefacenet.engine'
sudo ./arcface-mobilefacenet -d // deserialize plan file and run inference
```

3. check the output log, latency and similarity score.
3.Check the output log, latency and similarity score.

## More Information

Expand Down
Loading

0 comments on commit 53ba7e9

Please sign in to comment.