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

liucong's avatar
liucong committed
3
## 论文
Your Name's avatar
Your Name committed
4

liucong's avatar
liucong committed
5
6
7
RetinaFace: Single-stage Dense Face Localisation in the Wild

- https://arxiv.org/pdf/1905.00641.pdf
Your Name's avatar
Your Name committed
8
9
10

## 模型结构

liucong's avatar
liucong committed
11
12
13
14
15
16
17
RetinaFace是一个经典的人脸检测模型, 采用SSD架构进行人脸检测。

<img src="./Doc/Image/RetinaFace_01.png" style="zoom:70%;" align=center>

## 算法原理

RetinaFace模型有几个主要特点:
Your Name's avatar
Your Name committed
18
19
20
21
22

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

liucong's avatar
liucong committed
23
## 环境配置
liucong's avatar
liucong committed
24

liucong's avatar
liucong committed
25
### Docker(方法一)
Your Name's avatar
Your Name committed
26

liucong's avatar
liucong committed
27
拉取镜像:
Your Name's avatar
Your Name committed
28

liucong's avatar
liucong committed
29
```
liucong's avatar
liucong committed
30
docker pull image.sourcefind.cn:5000/dcu/admin/base/migraphx:4.0.0-centos7.6-dtk23.04.1-py38-latest
Your Name's avatar
Your Name committed
31
32
```

liucong's avatar
liucong committed
33
34
35
36
37
38
39
40
41
创建并启动容器:

```
docker run --shm-size 16g --network=host --name=retinaface_migraphx --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v $PWD/retinaface_migraphx:/home/retinaface_migraphx -it <Your Image ID> /bin/bash

# 激活dtk
source /opt/dtk/env.sh
```

liucong's avatar
liucong committed
42
43
44
45
46
47
48
49
50
### Dockerfile(方法二)

```
cd ./docker
docker build --no-cache -t retinaface_migraphx:2.0 .

docker run --shm-size 16g --network=host --name=retinaface_migraphx --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v $PWD/retinaface_migraphx:/home/retinaface_migraphx -it <Your Image ID> /bin/bash
```

liucong's avatar
liucong committed
51
52
53
54
55
56
57
58
59
60
61
## 数据集

根据提供的样本数据,进行人脸检测。

## 推理

### Python版本推理

下面介绍如何运行Python代码示例,Python示例的详细说明见Doc目录下的Tutorial_Python.md。

#### 设置环境变量
liucong's avatar
liucong committed
62

shizhm's avatar
shizhm committed
63
64
65
66
```
export PYTHONPATH=/opt/dtk/lib:$PYTHONPATH
```

liucong's avatar
liucong committed
67
#### 安装依赖
liucong's avatar
liucong committed
68
69
70

```
# 进入python示例目录
shizhm's avatar
shizhm committed
71
cd <path_to_retinaface_migraphx>/Python
liucong's avatar
liucong committed
72
73

# 安装依赖
liucong's avatar
liucong committed
74
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
shizhm's avatar
shizhm committed
75
76
```

liucong's avatar
liucong committed
77
#### 运行示例
shizhm's avatar
shizhm committed
78
79

RetinaFace模型的推理示例程序是RetinaFace_infer_migraphx.py,在python目录下使用如下命令运行该推理示例:
liucong's avatar
liucong committed
80

shizhm's avatar
shizhm committed
81
```
liucong's avatar
liucong committed
82
83
84
python RetinaFace_infer_migraphx.py 
```

liucong's avatar
liucong committed
85
### C++版本推理
liucong's avatar
liucong committed
86

shizhm's avatar
shizhm committed
87
88
下面介绍如何运行C++代码示例,C++示例的详细说明见Doc目录下的Tutorial_Cpp.md。

Your Name's avatar
Your Name committed
89

liucong's avatar
liucong committed
90
#### 构建工程
Your Name's avatar
Your Name committed
91
92

```
Your Name's avatar
Your Name committed
93
rbuild build -d depend
Your Name's avatar
Your Name committed
94
95
```

liucong's avatar
liucong committed
96
#### 设置环境变量
Your Name's avatar
Your Name committed
97
98
99

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

Your Name's avatar
Your Name committed
100
```
shizhm's avatar
shizhm committed
101
export LD_LIBRARY_PATH=<path_to_retinaface_migraphx>/depend/lib64/:$LD_LIBRARY_PATH
Your Name's avatar
Your Name committed
102
103
104
105
106
107
108
109
```

然后执行:

```
source ~/.bashrc
```

liucong's avatar
liucong committed
110
#### 运行示例
Your Name's avatar
Your Name committed
111

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

```
shizhm's avatar
shizhm committed
115
# 进入retinaface migraphx工程根目录
shizhm's avatar
shizhm committed
116
cd <path_to_retinaface_migraphx> 
Your Name's avatar
Your Name committed
117

liucong's avatar
liucong committed
118
119
# 进入build目录
cd ./build/
Your Name's avatar
Your Name committed
120

liucong's avatar
liucong committed
121
122
# 执行示例程序
./RetinaFace
Your Name's avatar
Your Name committed
123
124
```

liucong's avatar
liucong committed
125
126
127
128
129
130
131
132
133
134
135
## result

### Python版本

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

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

### C++版本

C++程序运行结束后,会在build目录生成RetinaFace人脸检测结果图像。
Your Name's avatar
Your Name committed
136

liucong's avatar
liucong committed
137
<img src="./Resource/Images/Result_1.jpg" alt="Result" style="zoom:67%;" />
Your Name's avatar
Your Name committed
138

liucong's avatar
liucong committed
139
140
141
142
### 精度



liucong's avatar
liucong committed
143
144
145
146
147
148
149
150
## 应用场景

### 算法类别

`人脸检测`

### 热点应用行业

liucong's avatar
liucong committed
151
`金融`,`交通`,`教育`
liucong's avatar
liucong committed
152

shizhm's avatar
shizhm committed
153
## 源码仓库及问题反馈
Your Name's avatar
Your Name committed
154

liucong's avatar
liucong committed
155
https://developer.hpccube.com/codes/modelzoo/retinaface_migraphx
Your Name's avatar
Your Name committed
156

liucong's avatar
liucong committed
157
## 参考资料
Your Name's avatar
Your Name committed
158

liucong's avatar
liucong committed
159
https://github.com/biubug6/Pytorch_Retinaface