"configs/models/mistral/hf_mistral_7b_v0_2.py" did not exist on "16f29b25f142802c7cd7448d0c077237e4db2313"
README.md 4.18 KB
Newer Older
Your Name's avatar
Your Name committed
1
2
# YoloV5

liucong's avatar
liucong committed
3
## 论文
Your Name's avatar
Your Name committed
4

liucong's avatar
liucong committed
5

Your Name's avatar
Your Name committed
6
7
8

## 模型结构

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

<img src=./Doc/YOLOV5_01.jpg style="zoom:100%;" align=middle>

## 算法原理

liucong's avatar
liucong committed
15
YOLOv5算法通过将图像划分为不同大小的网格,预测每个网格中的目标类别和边界框,利用特征金字塔结构和自适应的模型缩放来实现高效准确的实时目标检测。
Your Name's avatar
Your Name committed
16

liucong's avatar
liucong committed
17
<img src=./Doc/YOLOV5_02.png style="zoom:100%;" align=middle>
Your Name's avatar
Your Name committed
18

liucong's avatar
liucong committed
19
## 环境配置
liucong's avatar
liucong committed
20

liucong's avatar
liucong committed
21
22
### Docker(方法一)

liucong's avatar
liucong committed
23
24
25
26
27
拉取镜像:

```plaintext
docker pull image.sourcefind.cn:5000/dcu/admin/base/migraphx:4.0.0-centos7.6-dtk23.04.1-py38-latest
```
liucong's avatar
liucong committed
28

liucong's avatar
liucong committed
29
创建并启动容器:
Your Name's avatar
Your Name committed
30

liucong's avatar
liucong committed
31
32
```plaintext
docker run --shm-size 16g --network=host --name=yolov5_migraphx --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v $PWD/yolov5_migraphx:/home/yolov5_migraphx -it <Your Image ID> /bin/bash
Your Name's avatar
Your Name committed
33

liucong's avatar
liucong committed
34
35
# 激活dtk
source /opt/dtk/env.sh
Your Name's avatar
Your Name committed
36
```
Your Name's avatar
Your Name committed
37

liucong's avatar
liucong committed
38
39
40
41
42
43
44
### Dockerfile(方法二)

```
cd ./docker
docker build --no-cache -t yolov5_migraphx:2.0 .

docker run --shm-size 16g --network=host --name=yolov5_migraphx --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v $PWD/yolov5_migraphx:/home/yolov5_migraphx -it <Your Image ID> /bin/bash
liucong's avatar
liucong committed
45
46
47

# 激活dtk
source /opt/dtk/env.sh
liucong's avatar
liucong committed
48
49
```

liucong's avatar
liucong committed
50
51
52
53
54
55
56
57
58
59
60
## 数据集

根据提供的样本数据,进行目标检测。

## 推理

### Python版本推理

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

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

shizhm's avatar
shizhm committed
62
63
64
65
```
export PYTHONPATH=/opt/dtk/lib:$PYTHONPATH
```

liucong's avatar
liucong committed
66
#### 安装依赖
liucong's avatar
liucong committed
67
68
69

```
# 进入python示例目录
shizhm's avatar
shizhm committed
70
cd <path_to_yolov5_migraphx>/Python
liucong's avatar
liucong committed
71
72

# 安装依赖
liucong's avatar
liucong committed
73
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
shizhm's avatar
shizhm committed
74
```
liucong's avatar
liucong committed
75

liucong's avatar
liucong committed
76
#### 运行示例
shizhm's avatar
shizhm committed
77

shizhm's avatar
shizhm committed
78
79
80
81
82
83
84
85
86
87
88
89
90
YoloV5模型的推理示例程序是YoloV5_infer_migraphx.py,使用如下命令运行该推理示例:

```
# 进入python目录
cd <path_to_yolov5_migraphx>

# 进入Python目录
cd Python/
```

1. 静态推理

```
shizhm's avatar
shizhm committed
91
python YoloV5_infer_migraphx.py --staticInfer
shizhm's avatar
shizhm committed
92
93
94
```

2. 动态推理
shizhm's avatar
shizhm committed
95
96

```
shizhm's avatar
shizhm committed
97
python YoloV5_infer_migraphx.py --dynamicInfer
liucong's avatar
liucong committed
98
99
```

liucong's avatar
liucong committed
100
### C++版本推理
liucong's avatar
liucong committed
101

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

Your Name's avatar
Your Name committed
104

liucong's avatar
liucong committed
105
#### 构建工程
Your Name's avatar
Your Name committed
106

Your Name's avatar
Your Name committed
107
```
Your Name's avatar
Your Name committed
108
109
110
rbuild build -d depend
```

liucong's avatar
liucong committed
111
#### 设置环境变量
Your Name's avatar
Your Name committed
112

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

Your Name's avatar
Your Name committed
115
```
shizhm's avatar
shizhm committed
116
export LD_LIBRARY_PATH=<path_to_yolov5_migraphx>/depend/lib64/:$LD_LIBRARY_PATH
Your Name's avatar
Your Name committed
117
118
119
120
121
122
123
124
```

然后执行:

```
source ~/.bashrc
```

liucong's avatar
liucong committed
125
#### 运行示例
Your Name's avatar
Your Name committed
126

shizhm's avatar
shizhm committed
127
YoloV5示例程序编译成功后,执行如下指令运行该示例:
Your Name's avatar
Your Name committed
128
129

```
shizhm's avatar
shizhm committed
130
# 进入yolov5 migraphx工程根目录
shizhm's avatar
shizhm committed
131
cd <path_to_yolov5_migraphx>
Your Name's avatar
Your Name committed
132

liucong's avatar
liucong committed
133
# 进入build目录
shizhm's avatar
shizhm committed
134
135
136
137
138
139
140
141
cd build/
```

1. 静态推理

```
./YOLOV5 0
```
Your Name's avatar
Your Name committed
142

shizhm's avatar
shizhm committed
143
144
145
146
2. 动态推理

```
./YOLOV5 1
Your Name's avatar
Your Name committed
147
```
Your Name's avatar
Your Name committed
148

liucong's avatar
liucong committed
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
## result

### Python版本

静态推理:

python程序运行结束后,会在当前目录生成YOLOV5静态推理检测结果可视化图像。

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

动态推理:

python程序运行结束后,会在当前目录生成YoloV5动态推理检测结果可视化图像。

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

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

### C++版本

静态推理:

C++程序运行结束后,会在build目录生成YOLOV5静态推理检测结果可视化图像。

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

动态推理:

C++程序运行结束后,会在build目录生成YoloV5动态shape推理检测结果可视化图像。
178
179

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

181
<img src="./Resource/Images/Result1.jpg" alt="Result" style="zoom:50%;" />
Your Name's avatar
Your Name committed
182

liucong's avatar
liucong committed
183
184
185
186
### 精度



liucong's avatar
liucong committed
187
188
189
190
191
192
193
194
195
196
## 应用场景

### 算法类别

`目标检测`

### 热点应用行业

`交通`,`教育`,`化工`

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

liucong's avatar
liucong committed
199
https://developer.hpccube.com/codes/modelzoo/yolov5_migraphx
Your Name's avatar
Your Name committed
200

liucong's avatar
liucong committed
201
## 参考资料
Your Name's avatar
Your Name committed
202

liucong's avatar
liucong committed
203
https://github.com/ultralytics/yolov5