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

Your Name's avatar
Your Name committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## 构建安装

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

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

### 安装Opencv依赖

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

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

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

Your Name's avatar
Your Name committed
35
36
37
38
- **MIGraphX2.3.0及以上版本需要c++17**


### 安装OpenCV并构建工程
Your Name's avatar
Your Name committed
39
40

```
Your Name's avatar
Your Name committed
41
rbuild build -d depend
Your Name's avatar
Your Name committed
42
43
```

Your Name's avatar
Your Name committed
44
45
46
47
48
### 设置环境变量

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

**Centos**:
Your Name's avatar
Your Name committed
49
50

```
Your Name's avatar
Your Name committed
51
52
53
54
55
export LD_LIBRARY_PATH=<path_to_migraphx_samples>/depend/lib64/:$LD_LIBRARY_PATH
```

**Ubuntu**:

Your Name's avatar
Your Name committed
56
```
Your Name's avatar
Your Name committed
57
58
59
60
61
62
63
64
65
66
67
68
export LD_LIBRARY_PATH=<path_to_migraphx_samples>/depend/lib/:$LD_LIBRARY_PATH
```

然后执行:

```
source ~/.bashrc
```

## 推理

### C++版本推理
Your Name's avatar
Your Name committed
69

Your Name's avatar
Your Name committed
70
成功编译RetinaFace工程后,在build目录下输入如下命令运行该示例:
Your Name's avatar
Your Name committed
71

Your Name's avatar
Your Name committed
72
73
74
75
76
77
78
```
./MIGraphX_Samples 0
```

程序运行结束会在build目录生成RetinaFace人脸检测结果图像。

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

Your Name's avatar
Your Name committed
80
81
82
### python版本推理

RetinaFace模型的推理示例程序是RetinaFace_infer_migraphx.py,进入python文件夹使用如下命令运行该推理示例:
Your Name's avatar
Your Name committed
83
84

```
Your Name's avatar
Your Name committed
85
86
87
88
89
90
91
# 进入python示例目录
cd ./Python

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

# 运行程序
Your Name's avatar
Your Name committed
92
93
94
95
96
python RetinaFace_infer_migraphx.py 
```

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

Your Name's avatar
Your Name committed
97
<img src="./Resource/Images/Result_2.jpg" alt="Result_2" style="zoom:67%;" />
Your Name's avatar
Your Name committed
98
99
100
101
102
103
104
105

## 历史版本

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

## 参考

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