README.md 2.43 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;
- 多任务训练,提供额外的监督信息。

shizhm's avatar
shizhm committed
15
## Python版本推理
liucong's avatar
liucong committed
16

shizhm's avatar
shizhm committed
17
下面介绍如何运行Python代码示例,Python示例的详细说明见Doc目录下的Tutorial_Python.md。
liucong's avatar
liucong committed
18

shizhm's avatar
shizhm committed
19
### 下载镜像
Your Name's avatar
Your Name committed
20

liucong's avatar
liucong committed
21
拉取推理的docker镜像,RetinaFace工程推荐的镜像如下:
Your Name's avatar
Your Name committed
22
23

```python
liucong's avatar
liucong committed
24
docker pull sugonhub/migraphx:3.2.1-centos7.6-dtk-23.04.1-py38
Your Name's avatar
Your Name committed
25
26
```

shizhm's avatar
shizhm committed
27
### 设置Python环境变量
liucong's avatar
liucong committed
28

shizhm's avatar
shizhm committed
29
30
31
32
33
```
export PYTHONPATH=/opt/dtk/lib:$PYTHONPATH
```

### 安装依赖
liucong's avatar
liucong committed
34

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

liucong's avatar
liucong committed
37
38
```
# 进入python示例目录
shizhm's avatar
shizhm committed
39
cd <path_to_retinaface_migraphx>/Python
liucong's avatar
liucong committed
40
41
42

# 安装依赖
pip install -r requirements.txt
shizhm's avatar
shizhm committed
43
44
45
46
47
```

### 运行示例

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

shizhm's avatar
shizhm committed
49
```
liucong's avatar
liucong committed
50
51
52
53
54
55
56
57
58
python RetinaFace_infer_migraphx.py 
```

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

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

## C++版本推理

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

### 下载镜像

liucong's avatar
liucong committed
63
下载MIGraphX镜像: 
liucong's avatar
liucong committed
64

shizhm's avatar
shizhm committed
65
```
liucong's avatar
liucong committed
66
docker pull sugonhub/migraphx:3.2.1-centos7.6-dtk-23.04.1-py38
shizhm's avatar
shizhm committed
67
```
liucong's avatar
liucong committed
68

Your Name's avatar
Your Name committed
69

shizhm's avatar
shizhm committed
70
### 构建工程
Your Name's avatar
Your Name committed
71
72

```
Your Name's avatar
Your Name committed
73
rbuild build -d depend
Your Name's avatar
Your Name committed
74
75
```

Your Name's avatar
Your Name committed
76
77
78
79
### 设置环境变量

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

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

然后执行:

```
source ~/.bashrc
```

shizhm's avatar
shizhm committed
90
### 运行示例
Your Name's avatar
Your Name committed
91

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

```
shizhm's avatar
shizhm committed
95
# 进入retinaface migraphx工程根目录
shizhm's avatar
shizhm committed
96
cd <path_to_retinaface_migraphx> 
Your Name's avatar
Your Name committed
97

liucong's avatar
liucong committed
98
99
# 进入build目录
cd ./build/
Your Name's avatar
Your Name committed
100

liucong's avatar
liucong committed
101
102
# 执行示例程序
./RetinaFace
Your Name's avatar
Your Name committed
103
104
```

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

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

shizhm's avatar
shizhm committed
109
## 源码仓库及问题反馈
Your Name's avatar
Your Name committed
110
111
112
113
114
115

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

## 参考

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