README.md 3.78 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
47
48
### 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
49
50
51
52
53
54
55
56
57
58
59
## 数据集

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

## 推理

### Python版本推理

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

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

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

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

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

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

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

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

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

liucong's avatar
liucong committed
88
### C++版本推理
liucong's avatar
liucong committed
89

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

liucong's avatar
liucong committed
92

liucong's avatar
liucong committed
93
#### 构建工程
Your Name's avatar
Your Name committed
94

Your Name's avatar
Your Name committed
95
```
Your Name's avatar
Your Name committed
96
97
98
rbuild build -d depend
```

liucong's avatar
liucong committed
99
#### 设置环境变量
Your Name's avatar
Your Name committed
100

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

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

然后执行:

```
source ~/.bashrc
```

liucong's avatar
liucong committed
113
#### 运行示例
Your Name's avatar
Your Name committed
114

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

```
shizhm's avatar
shizhm committed
118
# 进入yolov7 migraphx工程根目录
shizhm's avatar
shizhm committed
119
cd <path_to_yolov7_migraphx> 
Your Name's avatar
Your Name committed
120

liucong's avatar
liucong committed
121
122
# 进入build目录
cd ./build/
Your Name's avatar
Your Name committed
123

liucong's avatar
liucong committed
124
125
# 执行示例程序
./YOLOV7
Your Name's avatar
Your Name committed
126
```
Your Name's avatar
Your Name committed
127

liucong's avatar
liucong committed
128
129
130
131
132
133
134
135
136
137
138
## 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
139

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

liucong's avatar
liucong committed
142
143
144
145
### 精度



liucong's avatar
liucong committed
146
147
148
149
150
151
152
## 应用场景

### 算法类别

`目标检测`

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

liucong's avatar
liucong committed
154
`交通`,`教育`,`化工`
Your Name's avatar
Your Name committed
155

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

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

liucong's avatar
liucong committed
160
## 参考资料
Your Name's avatar
Your Name committed
161

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