"research/object_detection/code_review.gwsq" did not exist on "056bea45a171df682a75943d6733a3c6a9d1b173"
README.md 2.95 KB
Newer Older
Your Name's avatar
Your Name committed
1
2
3
4
5
6
7
8
# YoloV5

## 模型介绍

YoloV5是一种单阶段目标检测算法,该算法在YOLOV4的基础上添加了一些新的改进思路,使其速度与精度都得到了极大的性能提升。

## 模型结构

Your Name's avatar
Your Name committed
9
YoloV5模型的主要改进思路有以下几点:
Your Name's avatar
Your Name committed
10
11
12
13
14
15

- 输入端的Mosaic数据增强、自适应锚框计算、自适应图像缩放操作;
- 主干网络的Focus结构与CSP结构;
- Neck端的FPN+PAN结构;
- 输出端的损失函数GIOU_Loss以及预测框筛选的DIOU_nms。

liucong's avatar
liucong committed
16
17
18
19
20
## python版本推理

下面介绍如何运行python代码示例,具体推理代码解析,在Doc/Tutorial_Python.md中有详细说明。

### 构建安装
Your Name's avatar
Your Name committed
21
22

在光源可拉取推理的docker镜像,YoloV5工程推荐的镜像如下:
Your Name's avatar
Your Name committed
23

Your Name's avatar
Your Name committed
24
25
26
```python
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:ort1.14.0_migraphx3.0.0-dtk22.10.1
```
Your Name's avatar
Your Name committed
27

liucong's avatar
liucong committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
### 推理示例

YoloV5模型的推理示例程序是YoloV5_infer_migraphx.py,使用如下命令运行该推理示例:

```
# 进入python示例目录
cd ./Python

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

# 运行程序
python YoloV5_infer_migraphx.py \
	--imgpath 测试图像路径 \ 
	--modelpath onnx模型路径 \
	--objectThreshold 判断是否有物体阈值,默认0.5 \
	--confThreshold 置信度阈值,默认0.25 \
	--nmsThreshold nms阈值,默认0.5 \
```

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

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

## C++版本推理

下面介绍如何运行C++代码示例,具体推理代码解析,在Doc/Tutorial_Cpp.md目录中有详细说明。

参考Python版本推理中的构建安装,在光源中拉取推理的docker镜像。

Your Name's avatar
Your Name committed
58
### 安装Opencv依赖
Your Name's avatar
Your Name committed
59

Your Name's avatar
Your Name committed
60
61
62
```python
cd <path_to_migraphx_samples>
sh ./3rdParty/InstallOpenCVDependences.sh
Your Name's avatar
Your Name committed
63
```
Your Name's avatar
Your Name committed
64
65
66
67
68
69
70
71
72
73
74

### 修改CMakeLists.txt

- 如果使用ubuntu系统,需要修改CMakeLists.txt中依赖库路径:
  将"${CMAKE_CURRENT_SOURCE_DIR}/depend/lib64/"修改为"${CMAKE_CURRENT_SOURCE_DIR}/depend/lib/"

- **MIGraphX2.3.0及以上版本需要c++17**


### 安装OpenCV并构建工程

Your Name's avatar
Your Name committed
75
```
Your Name's avatar
Your Name committed
76
77
78
79
rbuild build -d depend
```

### 设置环境变量
Your Name's avatar
Your Name committed
80

Your Name's avatar
Your Name committed
81
82
83
将依赖库依赖加入环境变量LD_LIBRARY_PATH,在~/.bashrc中添加如下语句:

**Centos**:
Your Name's avatar
Your Name committed
84
85

```
Your Name's avatar
Your Name committed
86
87
88
89
90
91
92
export LD_LIBRARY_PATH=<path_to_migraphx_samples>/depend/lib64/:$LD_LIBRARY_PATH
```

**Ubuntu**:

```
export LD_LIBRARY_PATH=<path_to_migraphx_samples>/depend/lib/:$LD_LIBRARY_PATH
Your Name's avatar
Your Name committed
93
94
```

Your Name's avatar
Your Name committed
95
96
97
98
99
100
然后执行:

```
source ~/.bashrc
```

liucong's avatar
liucong committed
101
### 推理示例
Your Name's avatar
Your Name committed
102

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

```
liucong's avatar
liucong committed
106
107
# 进入migraphx samples工程根目录
cd <path_to_migraphx_samples> 
Your Name's avatar
Your Name committed
108

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

liucong's avatar
liucong committed
112
113
# 执行示例程序
./YOLOV5
Your Name's avatar
Your Name committed
114
```
Your Name's avatar
Your Name committed
115

liucong's avatar
liucong committed
116
程序运行结束会在build目录生成YoloV5检测结果图像。
Your Name's avatar
Your Name committed
117

liucong's avatar
liucong committed
118
<img src="./Resource/Images/Result.jpg" alt="Result" style="zoom:50%;" />
Your Name's avatar
Your Name committed
119
120
121
122
123
124
125
126

## 历史版本

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

## 参考

​		https://github.com/ultralytics/yolov5