diff --git a/.gitignore b/.gitignore
index 11da3e2..1e5457c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*/build
*/*.wts
+*/*.ppm
diff --git a/README.md b/README.md
index 9cee18c..0c2dea7 100644
--- a/README.md
+++ b/README.md
@@ -8,9 +8,10 @@ I wrote this project to get familiar with tensorrt API, and also to share and le
All the models are implemented in pytorch first, and export a weights file xxx.wts, and then use tensorrt to load weights, define network and do inference. Some pytorch implementations can be found in my repo [Pytorchx](https://github.com/wang-xinyu/pytorchx), the remaining are from polular open-source pytorch implementations.
-# News
+## News
- `22 May 2020`. A new branch [trt4](https://github.com/wang-xinyu/tensorrtx/tree/trt4) created, which is using TensorRT 4 API. Now the master branch is using TensorRT 7 API. But only `yolov4` has been migrated to TensorRT 7 API for now. The rest will be migrated soon. And a tutorial for `migarating from TensorRT 4 to 7` provided.
+- `28 May 2020`. arcface LResNet50E-IR model from [deepinsight/insightface](https://github.com/deepinsight/insightface) implemented. We got 333fps on GTX1080.
## Tutorials
@@ -47,6 +48,7 @@ Following models are implemented.
|[yolov3-spp](./yolov3-spp)| darknet-53, weights from [ultralytics/yolov3](https://github.com/ultralytics/yolov3) |
|[yolov4](./yolov4)| CSPDarknet53, weights from [AlexeyAB/darknet](https://github.com/AlexeyAB/darknet#pre-trained-models), pytorch implementation from [ultralytics/yolov3](https://github.com/ultralytics/yolov3) |
|[retinaface](./retinaface)| resnet-50, weights from [biubug6/Pytorch_Retinaface](https://github.com/biubug6/Pytorch_Retinaface) |
+|[arcface](./arcface)| LResNet50E-IR, weights from [deepinsight/insightface](https://github.com/deepinsight/insightface) |
## Tricky Operations
@@ -68,6 +70,7 @@ Some tricky operations encountered in these models, already solved, but might ha
|hsigmoid| hard sigmoid is implemented as a plugin, hsigmoid and hswish are used in mobilenetv3 |
|retinaface output decode| implement a plugin to decode bbox, confidence and landmarks, see retinaface. |
|mish| mish activation is implemented as a plugin, mish is used in yolov4 |
+|prelu| mxnet's prelu activation with trainable gamma is implemented as a plugin, used in arcface |
## Speed Benchmark
@@ -80,6 +83,7 @@ Some tricky operations encountered in these models, already solved, but might ha
| YOLOv4(CSPDarknet53) | Xeon E5-2620/GTX1080 | 8 | FP16 | 608x608 | 41.3 |
| RetinaFace(resnet50) | TX2 | 1 | FP16 | 384x640 | 15 |
| RetinaFace(resnet50) | Xeon E5-2620/GTX1080 | 1 | FP32 | 928x1600 | 15 |
+| ArcFace(LResNet50E-IR) | Xeon E5-2620/GTX1080 | 1 | FP32 | 112x112 | 333 |
Detection net FPS test including inference and nms time, excluding image preprocess time.
diff --git a/arcface/CMakeLists.txt b/arcface/CMakeLists.txt
new file mode 100644
index 0000000..db0e030
--- /dev/null
+++ b/arcface/CMakeLists.txt
@@ -0,0 +1,41 @@
+cmake_minimum_required(VERSION 2.6)
+
+project(arcface)
+
+add_definitions(-std=c++11)
+
+option(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_BUILD_TYPE Debug)
+
+find_package(CUDA REQUIRED)
+
+set(CUDA_NVCC_PLAGS ${CUDA_NVCC_PLAGS};-std=c++11;-g;-G;-gencode;arch=compute_30;code=sm_30)
+
+include_directories(${PROJECT_SOURCE_DIR}/include)
+if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
+ message("embed_platform on")
+ include_directories(/usr/local/cuda/targets/aarch64-linux/include)
+ link_directories(/usr/local/cuda/targets/aarch64-linux/lib)
+else()
+ message("embed_platform off")
+ include_directories(/usr/local/cuda/include)
+ link_directories(/usr/local/cuda/lib64)
+endif()
+
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -Wfatal-errors -D_MWAITXINTRIN_H_INCLUDED")
+
+cuda_add_library(myplugins SHARED ${PROJECT_SOURCE_DIR}/prelu.cu)
+
+find_package(OpenCV)
+include_directories(OpenCV_INCLUDE_DIRS)
+
+add_executable(arcface-r50 ${PROJECT_SOURCE_DIR}/arcface-r50.cpp)
+target_link_libraries(arcface-r50 nvinfer)
+target_link_libraries(arcface-r50 cudart)
+target_link_libraries(arcface-r50 myplugins)
+target_link_libraries(arcface-r50 ${OpenCV_LIBS})
+
+add_definitions(-O2 -pthread)
+
diff --git a/arcface/README.md b/arcface/README.md
new file mode 100644
index 0000000..902114b
--- /dev/null
+++ b/arcface/README.md
@@ -0,0 +1,47 @@
+# arcface
+
+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 two images used in this project are joey0.ppm and joey1.ppm, download them from [Google Drive.](https://drive.google.com/drive/folders/1ctqpkRCRKyBZRCNwo9Uq4eUoMRLtFq1e)
+
+
+
+
+
+## Run
+
+```
+1. generate arcface-r50.wts from mxnet implementation with LResNet50E-IR,ArcFace@ms1m-refine-v1 pretrained model
+
+git clone https://github.com/deepinsight/insightface
+cd insightface/deploy
+// copy tensorrtx/arcface/gen_wts.py to here(insightface/deploy)
+// download model-r50-am-lfw.zip and unzip here(insightface/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
+
+2. put arcface-r50.wts into tensorrtx/arcface, build and run
+
+cd tensorrtx/arcface
+// download joey0.ppm and joey1.ppm, and put here(tensorrtx/arcface)
+mkdir build
+cd build
+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
+
+3. check the output log, latency and similarity score.
+```
+
+## 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
+
+## More Information
+
+See the readme in [home page.](https://github.com/wang-xinyu/tensorrtx)
diff --git a/arcface/arcface-r50.cpp b/arcface/arcface-r50.cpp
new file mode 100644
index 0000000..ac0079c
--- /dev/null
+++ b/arcface/arcface-r50.cpp
@@ -0,0 +1,403 @@
+#include
+#include
+#include