README.md 3.48 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
12
13
14
15
16
YOLOV7是2022年最新出现的一种YOLO系列目标检测模型,在论文 [YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors](https://arxiv.org/abs/2207.02696)中提出。

<img src="./Doc/YoloV7模型结构.png" alt="YOLOV7_02" style="zoom:67%;" />

## 算法原理

Your Name's avatar
Your Name committed
17
YoloV7模型的网络结构包括三个部分:input、backbone和head。与yolov5不同的是,将neck层与head层合称为head层,实际上的功能是一样的。各个部分的功能和yolov5相同,如backbone用于提取特征,head用于预测。yolov7依旧基于anchor based的方法,同时在网络架构上增加E-ELAN层,并将REP层也加入进来,方便后续部署,同时在训练时,在head时,新增Aux_detect用于辅助检测。
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
23
24
25
拉取镜像:

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

liucong's avatar
liucong committed
27
创建并启动容器:
Your Name's avatar
Your Name committed
28

liucong's avatar
liucong committed
29
30
```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
31

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

liucong's avatar
liucong committed
36
37
38
39
40
41
42
43
44
45
46
## 数据集

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

## 推理

### Python版本推理

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

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

shizhm's avatar
shizhm committed
48
49
50
51
```
export PYTHONPATH=/opt/dtk/lib:$PYTHONPATH
```

liucong's avatar
liucong committed
52
#### 安装依赖
liucong's avatar
liucong committed
53
54
55

```
# 进入python示例目录
shizhm's avatar
shizhm committed
56
cd <path_to_yolov7_migraphx>/Python
liucong's avatar
liucong committed
57
58

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

liucong's avatar
liucong committed
62
#### 运行示例
shizhm's avatar
shizhm committed
63
64

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

shizhm's avatar
shizhm committed
66
```
liucong's avatar
liucong committed
67
68
69
70
71
72
73
74
python YoloV7_infer_migraphx.py \
	--imgpath 测试图像路径 \ 
	--modelpath onnx模型路径 \
	--objectThreshold 判断是否有物体阈值,默认0.5 \
	--confThreshold 置信度阈值,默认0.25 \
	--nmsThreshold nms阈值,默认0.5 \
```

liucong's avatar
liucong committed
75
### C++版本推理
liucong's avatar
liucong committed
76

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

liucong's avatar
liucong committed
79

liucong's avatar
liucong committed
80
#### 构建工程
Your Name's avatar
Your Name committed
81

Your Name's avatar
Your Name committed
82
```
Your Name's avatar
Your Name committed
83
84
85
rbuild build -d depend
```

liucong's avatar
liucong committed
86
#### 设置环境变量
Your Name's avatar
Your Name committed
87

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

Your Name's avatar
Your Name committed
90
```
shizhm's avatar
shizhm committed
91
export LD_LIBRARY_PATH=<path_to_yolov7_migraphx>/depend/lib64/:$LD_LIBRARY_PATH
Your Name's avatar
Your Name committed
92
93
94
95
96
97
98
99
```

然后执行:

```
source ~/.bashrc
```

liucong's avatar
liucong committed
100
#### 运行示例
Your Name's avatar
Your Name committed
101

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

```
shizhm's avatar
shizhm committed
105
# 进入yolov7 migraphx工程根目录
shizhm's avatar
shizhm committed
106
cd <path_to_yolov7_migraphx> 
Your Name's avatar
Your Name committed
107

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

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

liucong's avatar
liucong committed
115
116
117
118
119
120
121
122
123
124
125
## 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
126

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

liucong's avatar
liucong committed
129
130
131
132
133
134
135
## 应用场景

### 算法类别

`目标检测`

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

liucong's avatar
liucong committed
137
`交通`,`教育`,`化工`
Your Name's avatar
Your Name committed
138

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

liucong's avatar
liucong committed
141
https://developer.hpccube.com/codes/modelzoo/yolov7_migraphx
Your Name's avatar
Your Name committed
142
143
144

## 参考

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