README.md 3 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 sugonhub/migraphx:3.2.1-centos7.6-dtk-23.04.1-py38
Your Name's avatar
Your Name committed
31
32
```

liucong's avatar
liucong committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
创建并启动容器:

```
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
```

## 数据集

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

## 推理

### Python版本推理

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

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

shizhm's avatar
shizhm committed
54
55
56
57
```
export PYTHONPATH=/opt/dtk/lib:$PYTHONPATH
```

liucong's avatar
liucong committed
58
#### 安装依赖
liucong's avatar
liucong committed
59

shizhm's avatar
shizhm committed
60
61
- 安装DTK版的Pytorch和torchvision,下载地址:https://cancon.hpccube.com:65024/4/main/pytorch,https://cancon.hpccube.com:65024/4/main/vision

liucong's avatar
liucong committed
62
63
```
# 进入python示例目录
shizhm's avatar
shizhm committed
64
cd <path_to_retinaface_migraphx>/Python
liucong's avatar
liucong committed
65
66
67

# 安装依赖
pip install -r requirements.txt
shizhm's avatar
shizhm committed
68
69
```

liucong's avatar
liucong committed
70
#### 运行示例
shizhm's avatar
shizhm committed
71
72

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

shizhm's avatar
shizhm committed
74
```
liucong's avatar
liucong committed
75
76
77
python RetinaFace_infer_migraphx.py 
```

liucong's avatar
liucong committed
78
### C++版本推理
liucong's avatar
liucong committed
79

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

Your Name's avatar
Your Name committed
82

liucong's avatar
liucong committed
83
#### 构建工程
Your Name's avatar
Your Name committed
84
85

```
Your Name's avatar
Your Name committed
86
rbuild build -d depend
Your Name's avatar
Your Name committed
87
88
```

liucong's avatar
liucong committed
89
#### 设置环境变量
Your Name's avatar
Your Name committed
90
91
92

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

Your Name's avatar
Your Name committed
93
```
shizhm's avatar
shizhm committed
94
export LD_LIBRARY_PATH=<path_to_retinaface_migraphx>/depend/lib64/:$LD_LIBRARY_PATH
Your Name's avatar
Your Name committed
95
96
97
98
99
100
101
102
```

然后执行:

```
source ~/.bashrc
```

liucong's avatar
liucong committed
103
#### 运行示例
Your Name's avatar
Your Name committed
104

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

```
shizhm's avatar
shizhm committed
108
# 进入retinaface migraphx工程根目录
shizhm's avatar
shizhm committed
109
cd <path_to_retinaface_migraphx> 
Your Name's avatar
Your Name committed
110

liucong's avatar
liucong committed
111
112
# 进入build目录
cd ./build/
Your Name's avatar
Your Name committed
113

liucong's avatar
liucong committed
114
115
# 执行示例程序
./RetinaFace
Your Name's avatar
Your Name committed
116
117
```

liucong's avatar
liucong committed
118
119
120
121
122
123
124
125
126
127
128
## 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
129

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

liucong's avatar
liucong committed
132
133
134
135
136
137
138
139
140
141
## 应用场景

### 算法类别

`人脸检测`

### 热点应用行业

`金融``交通``教育`

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

liucong's avatar
liucong committed
144
https://developer.hpccube.com/codes/modelzoo/retinaface_migraphx
Your Name's avatar
Your Name committed
145
146
147

## 参考

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