README.md 2.99 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
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
```

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
63
下面介绍如何运行C++代码示例,C++示例的详细说明见Doc目录下的Tutorial_Cpp.md。

### 下载镜像

在光源中下载MIGraphX镜像: 
liucong's avatar
liucong committed
64

shizhm's avatar
shizhm committed
65
66
67
```
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:ort1.14.0_migraphx3.0.0-dtk22.10.1
```
liucong's avatar
liucong committed
68

Your Name's avatar
Your Name committed
69
70
71
72
73
74
75
76
### 安装Opencv依赖

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

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

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

Your Name's avatar
Your Name committed
81
82
83
84
- **MIGraphX2.3.0及以上版本需要c++17**


### 安装OpenCV并构建工程
Your Name's avatar
Your Name committed
85
86

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

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

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

**Centos**:
Your Name's avatar
Your Name committed
95
96

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

**Ubuntu**:

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

然后执行:

```
source ~/.bashrc
```

shizhm's avatar
shizhm committed
112
### 运行示例
Your Name's avatar
Your Name committed
113

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

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

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

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

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

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

shizhm's avatar
shizhm committed
131
## 源码仓库及问题反馈
Your Name's avatar
Your Name committed
132
133
134
135
136
137

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

## 参考

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