README.md 3.81 KB
Newer Older
Your Name's avatar
Your Name committed
1
# YoloV7
shizhm's avatar
shizhm committed
2

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

liucong's avatar
liucong committed
5
6
7
YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors

- https://arxiv.org/pdf/2207.02696.pdf
Your Name's avatar
Your Name committed
8
9
10

## 模型结构

liucong's avatar
liucong committed
11
YOLOV7是2022年最新出现的一种YOLO系列目标检测模型,该模型的网络结构包括三个部分:input、backbone和head。
liucong's avatar
liucong committed
12

liucong's avatar
liucong committed
13
<img src="./Doc/YoloV7_model.png" alt="YOLOV7_02" style="zoom:67%;" />
liucong's avatar
liucong committed
14
15
16

## 算法原理

liucong's avatar
liucong committed
17
18
19
YOLOv7的作者提出了 Extended-ELAN (E-ELAN)结构。E-ELAN采用了ELAN类似的特征聚合和特征转移流程,仅在计算模块中采用了类似ShuffleNet的分组卷积、扩张模块和混洗模块,最终通过聚合模块融合特征。通过采用这种方法可以获得更加多样的特征,同时提高参数的计算和利用效率。

<img src="./Doc/YoloV7_suanfa.png" alt="YOLOV7_suanfa" style="zoom:67%;" />
Your Name's avatar
Your Name committed
20

liucong's avatar
liucong committed
21
## 环境配置
liucong's avatar
liucong committed
22

liucong's avatar
liucong committed
23
24
### Docker(方法一)

liucong's avatar
liucong committed
25
26
27
28
29
拉取镜像:

```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
30

liucong's avatar
liucong committed
31
创建并启动容器:
Your Name's avatar
Your Name committed
32

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

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

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

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

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

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

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

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

## 推理

### Python版本推理

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

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

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

liucong's avatar
liucong committed
68
#### 安装依赖
liucong's avatar
liucong committed
69
70
71

```
# 进入python示例目录
shizhm's avatar
shizhm committed
72
cd <path_to_yolov7_migraphx>/Python
liucong's avatar
liucong committed
73
74

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

liucong's avatar
liucong committed
78
#### 运行示例
shizhm's avatar
shizhm committed
79
80

YoloV7模型的推理示例程序是YoloV7_infer_migraphx.py,在Python目录下使用如下命令运行该推理示例:
liucong's avatar
liucong committed
81

shizhm's avatar
shizhm committed
82
```
liucong's avatar
liucong committed
83
84
85
86
87
88
89
90
python YoloV7_infer_migraphx.py \
	--imgpath 测试图像路径 \ 
	--modelpath onnx模型路径 \
	--objectThreshold 判断是否有物体阈值,默认0.5 \
	--confThreshold 置信度阈值,默认0.25 \
	--nmsThreshold nms阈值,默认0.5 \
```

liucong's avatar
liucong committed
91
### C++版本推理
liucong's avatar
liucong committed
92

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

liucong's avatar
liucong committed
95

liucong's avatar
liucong committed
96
#### 构建工程
Your Name's avatar
Your Name committed
97

Your Name's avatar
Your Name committed
98
```
Your Name's avatar
Your Name committed
99
100
101
rbuild build -d depend
```

liucong's avatar
liucong committed
102
#### 设置环境变量
Your Name's avatar
Your Name committed
103

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

Your Name's avatar
Your Name committed
106
```
shizhm's avatar
shizhm committed
107
export LD_LIBRARY_PATH=<path_to_yolov7_migraphx>/depend/lib64/:$LD_LIBRARY_PATH
Your Name's avatar
Your Name committed
108
109
110
111
112
113
114
115
```

然后执行:

```
source ~/.bashrc
```

liucong's avatar
liucong committed
116
#### 运行示例
Your Name's avatar
Your Name committed
117

liucong's avatar
liucong committed
118
成功编译YoloV7工程后,执行如下命令运行该示例:
Your Name's avatar
Your Name committed
119
120

```
shizhm's avatar
shizhm committed
121
# 进入yolov7 migraphx工程根目录
shizhm's avatar
shizhm committed
122
cd <path_to_yolov7_migraphx> 
Your Name's avatar
Your Name committed
123

liucong's avatar
liucong committed
124
125
# 进入build目录
cd ./build/
Your Name's avatar
Your Name committed
126

liucong's avatar
liucong committed
127
128
# 执行示例程序
./YOLOV7
Your Name's avatar
Your Name committed
129
```
Your Name's avatar
Your Name committed
130

liucong's avatar
liucong committed
131
132
133
134
135
136
137
138
139
140
141
## result

### Python版本

python程序运行结束后,会在当前目录生成目标检测图像。

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

### C++版本

C++程序运行结束后,会在build目录生成目标检测图像。
Your Name's avatar
Your Name committed
142

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

liucong's avatar
liucong committed
145
146
147
148
### 精度



liucong's avatar
liucong committed
149
150
151
152
153
154
155
## 应用场景

### 算法类别

`目标检测`

### 热点应用行业
Your Name's avatar
Your Name committed
156

liucong's avatar
liucong committed
157
`交通`,`教育`,`化工`
Your Name's avatar
Your Name committed
158

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

liucong's avatar
liucong committed
161
https://developer.hpccube.com/codes/modelzoo/yolov7_migraphx
Your Name's avatar
Your Name committed
162

liucong's avatar
liucong committed
163
## 参考资料
Your Name's avatar
Your Name committed
164

liucong's avatar
liucong committed
165
https://github.com/WongKinYiu/yolov7