README.md 2.66 KB
Newer Older
Your Name's avatar
Your Name committed
1
# RetinaFace
shizhm's avatar
shizhm committed
2

Your Name's avatar
Your Name committed
3
4
## 模型介绍

Your Name's avatar
Your Name committed
5
RetinaFace是一个经典的人脸检测模型(https://arxiv.org/abs/1905.00641), 采用了SSD架构。
Your Name's avatar
Your Name committed
6
7
8
9
10
11
12
13
14

## 模型结构

RetinaFace模型 有几个主要特点:

- 采用 FPN 特征金字塔提取多尺度特征;
- 引入 SSH 算法的 Context Modeling;
- 多任务训练,提供额外的监督信息。

liucong's avatar
liucong committed
15
16
17
18
## python版本推理

下面介绍如何运行python代码示例,具体推理代码解析,在Doc/Tutorial_Python.md中有详细说明。

liucong's avatar
liucong committed
19
### 拉取镜像
Your Name's avatar
Your Name committed
20
21
22
23
24
25
26

在光源可拉取推理的docker镜像,RetinaFace工程推荐的镜像如下:

```python
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:ort1.14.0_migraphx3.0.0-dtk22.10.1
```

liucong's avatar
liucong committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
### 推理示例

RetinaFace模型的推理示例程序是RetinaFace_infer_migraphx.py,进入python文件夹使用如下命令运行该推理示例:

```
# 进入python示例目录
cd ./Python

# 安装依赖
pip install -r requirements.txt

# 运行程序
python RetinaFace_infer_migraphx.py 
```

程序运行结束会在当前目录生成RetinaFace检测结果图像。

<img src="./Resource/Images/Result_2.jpg" alt="Result_2" style="zoom:67%;" />

## C++版本推理

下面介绍如何运行C++代码示例,具体推理代码解析,在Doc/Tutorial_Cpp.md目录中有详细说明。

参考Python版本推理中的构建安装,在光源中拉取推理的docker镜像。

Your Name's avatar
Your Name committed
52
53
54
55
56
57
58
59
### 安装Opencv依赖

```python
cd <path_to_migraphx_samples>
sh ./3rdParty/InstallOpenCVDependences.sh
```

### 修改CMakeLists.txt
Your Name's avatar
Your Name committed
60

Your Name's avatar
Your Name committed
61
62
- 如果使用ubuntu系统,需要修改CMakeLists.txt中依赖库路径:
  将"${CMAKE_CURRENT_SOURCE_DIR}/depend/lib64/"修改为"${CMAKE_CURRENT_SOURCE_DIR}/depend/lib/"
Your Name's avatar
Your Name committed
63

Your Name's avatar
Your Name committed
64
65
66
67
- **MIGraphX2.3.0及以上版本需要c++17**


### 安装OpenCV并构建工程
Your Name's avatar
Your Name committed
68
69

```
Your Name's avatar
Your Name committed
70
rbuild build -d depend
Your Name's avatar
Your Name committed
71
72
```

Your Name's avatar
Your Name committed
73
74
75
76
77
### 设置环境变量

将依赖库依赖加入环境变量LD_LIBRARY_PATH,在~/.bashrc中添加如下语句:

**Centos**:
Your Name's avatar
Your Name committed
78
79

```
shizhm's avatar
shizhm committed
80
export LD_LIBRARY_PATH=<path_to_retinaface_migraphx>/depend/lib64/:$LD_LIBRARY_PATH
Your Name's avatar
Your Name committed
81
82
83
84
```

**Ubuntu**:

Your Name's avatar
Your Name committed
85
```
shizhm's avatar
shizhm committed
86
export LD_LIBRARY_PATH=<path_to_retinaface_migraphx>/depend/lib/:$LD_LIBRARY_PATH
Your Name's avatar
Your Name committed
87
88
89
90
91
92
93
94
```

然后执行:

```
source ~/.bashrc
```

liucong's avatar
liucong committed
95
### 推理示例
Your Name's avatar
Your Name committed
96

liucong's avatar
liucong committed
97
成功编译RetinaFace工程后,执行如下命令运行该示例:
Your Name's avatar
Your Name committed
98
99

```
liucong's avatar
liucong committed
100
# 进入migraphx samples工程根目录
shizhm's avatar
shizhm committed
101
cd <path_to_retinaface_migraphx> 
Your Name's avatar
Your Name committed
102

liucong's avatar
liucong committed
103
104
# 进入build目录
cd ./build/
Your Name's avatar
Your Name committed
105

liucong's avatar
liucong committed
106
107
# 执行示例程序
./RetinaFace
Your Name's avatar
Your Name committed
108
109
```

liucong's avatar
liucong committed
110
程序运行结束会在build目录生成RetinaFace人脸检测结果图像。
Your Name's avatar
Your Name committed
111

liucong's avatar
liucong committed
112
<img src="./Resource/Images/Result_1.jpg" alt="Result" style="zoom:67%;" />
Your Name's avatar
Your Name committed
113
114
115
116
117
118
119
120

## 历史版本

​		https://developer.hpccube.com/codes/modelzoo/retinaface_migraphx

## 参考

​		https://github.com/biubug6/Pytorch_Retinaface