Skip to content

Commit e47add3

Browse files
committed
add files
0 parents  commit e47add3

File tree

1,175 files changed

+929657
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,175 files changed

+929657
-0
lines changed

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/yolov7-main.iml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE.md

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# Official YOLOv7
2+
3+
Implementation of paper - [YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors](https://arxiv.org/abs/2207.02696)
4+
5+
<div align="center">
6+
<a href="./">
7+
<img src="./figure/performance.png" width="79%"/>
8+
</a>
9+
</div>
10+
11+
## Web Demo
12+
13+
- Integrated into [Huggingface Spaces 🤗](https://huggingface.co/spaces/akhaliq/yolov7) using [Gradio](https://github.com/gradio-app/gradio). Try out the Web Demo [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/akhaliq/yolov7)
14+
15+
## Performance
16+
17+
MS COCO
18+
19+
| Model | Test Size | AP<sup>test</sup> | AP<sub>50</sub><sup>test</sup> | AP<sub>75</sub><sup>test</sup> | batch 1 fps | batch 32 average time |
20+
| :-- | :-: | :-: | :-: | :-: | :-: | :-: |
21+
| [**YOLOv7**](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt) | 640 | **51.4%** | **69.7%** | **55.9%** | 161 *fps* | 2.8 *ms* |
22+
| [**YOLOv7-X**](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7x.pt) | 640 | **53.1%** | **71.2%** | **57.8%** | 114 *fps* | 4.3 *ms* |
23+
| | | | | | | |
24+
| [**YOLOv7-W6**](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-w6.pt) | 1280 | **54.9%** | **72.6%** | **60.1%** | 84 *fps* | 7.6 *ms* |
25+
| [**YOLOv7-E6**](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-e6.pt) | 1280 | **56.0%** | **73.5%** | **61.2%** | 56 *fps* | 12.3 *ms* |
26+
| [**YOLOv7-D6**](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-d6.pt) | 1280 | **56.6%** | **74.0%** | **61.8%** | 44 *fps* | 15.0 *ms* |
27+
| [**YOLOv7-E6E**](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-e6e.pt) | 1280 | **56.8%** | **74.4%** | **62.1%** | 36 *fps* | 18.7 *ms* |
28+
29+
## Installation
30+
31+
Docker environment (recommended)
32+
<details><summary> <b>Expand</b> </summary>
33+
34+
``` bash
35+
# create the docker container, you can change the share memory size if you have more.
36+
nvidia-docker run --name yolov7 -it -v your_coco_path/:/coco/ -v your_code_path/:/yolov7 --shm-size=64g nvcr.io/nvidia/pytorch:21.08-py3
37+
38+
# apt install required packages
39+
apt update
40+
apt install -y zip htop screen libgl1-mesa-glx
41+
42+
# pip install required packages
43+
pip install seaborn thop
44+
45+
# go to code folder
46+
cd /yolov7
47+
```
48+
49+
</details>
50+
51+
## Testing
52+
53+
[`yolov7.pt`](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt) [`yolov7x.pt`](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7x.pt) [`yolov7-w6.pt`](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-w6.pt) [`yolov7-e6.pt`](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-e6.pt) [`yolov7-d6.pt`](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-d6.pt) [`yolov7-e6e.pt`](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-e6e.pt)
54+
55+
``` bash
56+
python test.py --data data/coco.yaml --img 640 --batch 32 --conf 0.001 --iou 0.65 --device 0 --weights yolov7.pt --name yolov7_640_val
57+
```
58+
59+
You will get the results:
60+
61+
```
62+
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.51206
63+
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.69730
64+
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.55521
65+
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.35247
66+
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.55937
67+
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.66693
68+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.38453
69+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.63765
70+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.68772
71+
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.53766
72+
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.73549
73+
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.83868
74+
```
75+
76+
To measure accuracy, download [COCO-annotations for Pycocotools](http://images.cocodataset.org/annotations/annotations_trainval2017.zip).
77+
78+
## Training
79+
80+
Data preparation
81+
82+
``` bash
83+
bash scripts/get_coco.sh
84+
```
85+
86+
* Download MS COCO dataset images ([train](http://images.cocodataset.org/zips/train2017.zip), [val](http://images.cocodataset.org/zips/val2017.zip), [test](http://images.cocodataset.org/zips/test2017.zip)) and [labels](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/coco2017labels-segments.zip). If you have previously used a different version of YOLO, we strongly recommend that you delete `train2017.cache` and `val2017.cache` files, and redownload [labels](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/coco2017labels-segments.zip)
87+
88+
Single GPU training
89+
90+
``` bash
91+
# train p5 models
92+
python train.py --workers 8 --device 0 --batch-size 32 --data data/coco.yaml --img 640 640 --cfg cfg/training/yolov7.yaml --weights '' --name yolov7 --hyp data/hyp.scratch.p5.yaml
93+
94+
# train p6 models
95+
python train_aux.py --workers 8 --device 0 --batch-size 16 --data data/coco.yaml --img 1280 1280 --cfg cfg/training/yolov7-w6.yaml --weights '' --name yolov7-w6 --hyp data/hyp.scratch.p6.yaml
96+
```
97+
98+
Multiple GPU training
99+
100+
``` bash
101+
# train p5 models
102+
python -m torch.distributed.launch --nproc_per_node 4 --master_port 9527 train.py --workers 8 --device 0,1,2,3 --sync-bn --batch-size 128 --data data/coco.yaml --img 640 640 --cfg cfg/training/yolov7.yaml --weights '' --name yolov7 --hyp data/hyp.scratch.p5.yaml
103+
104+
# train p6 models
105+
python -m torch.distributed.launch --nproc_per_node 8 --master_port 9527 train_aux.py --workers 8 --device 0,1,2,3,4,5,6,7 --sync-bn --batch-size 128 --data data/coco.yaml --img 1280 1280 --cfg cfg/training/yolov7-w6.yaml --weights '' --name yolov7-w6 --hyp data/hyp.scratch.p6.yaml
106+
```
107+
108+
## Transfer learning
109+
110+
[`yolov7_training.pt`](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7_training.pt) [`yolov7x_training.pt`](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7x_training.pt) [`yolov7-w6_training.pt`](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-w6_training.pt) [`yolov7-e6_training.pt`](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-e6_training.pt) [`yolov7-d6_training.pt`](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-d6_training.pt) [`yolov7-e6e_training.pt`](https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-e6e_training.pt)
111+
112+
Single GPU finetuning for custom dataset
113+
114+
``` bash
115+
# finetune p5 models
116+
python train.py --workers 8 --device 0 --batch-size 32 --data data/custom.yaml --img 640 640 --cfg cfg/training/yolov7-custom.yaml --weights 'yolov7_training.pt' --name yolov7-custom --hyp data/hyp.scratch.custom.yaml
117+
118+
# finetune p6 models
119+
python train_aux.py --workers 8 --device 0 --batch-size 16 --data data/custom.yaml --img 1280 1280 --cfg cfg/training/yolov7-w6-custom.yaml --weights 'yolov7-w6_training.pt' --name yolov7-w6-custom --hyp data/hyp.scratch.custom.yaml
120+
```
121+
122+
## Re-parameterization
123+
124+
See [reparameterization.ipynb](tools/reparameterization.ipynb)
125+
126+
## Inference
127+
128+
``` bash
129+
python detect.py --weights yolov7.pt --conf 0.25 --img-size 640 --source inference/images/horses.jpg
130+
```
131+
132+
<div align="center">
133+
<a href="./">
134+
<img src="./figure/horses_prediction.jpg" width="59%"/>
135+
</a>
136+
</div>
137+
138+
## Citation
139+
140+
```
141+
@article{wang2022yolov7,
142+
title={{YOLOv7}: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors},
143+
author={Wang, Chien-Yao and Bochkovskiy, Alexey and Liao, Hong-Yuan Mark},
144+
journal={arXiv preprint arXiv:2207.02696},
145+
year={2022}
146+
}
147+
```
148+
149+
## Teaser
150+
151+
Yolov7-mask & YOLOv7-pose
152+
153+
<div align="center">
154+
<a href="./">
155+
<img src="./figure/mask.png" width="56%"/>
156+
</a>
157+
<a href="./">
158+
<img src="./figure/pose.png" width="42%"/>
159+
</a>
160+
</div>
161+
162+
## Acknowledgements
163+
164+
<details><summary> <b>Expand</b> </summary>
165+
166+
* [https://github.com/AlexeyAB/darknet](https://github.com/AlexeyAB/darknet)
167+
* [https://github.com/WongKinYiu/yolor](https://github.com/WongKinYiu/yolor)
168+
* [https://github.com/WongKinYiu/PyTorch_YOLOv4](https://github.com/WongKinYiu/PyTorch_YOLOv4)
169+
* [https://github.com/WongKinYiu/ScaledYOLOv4](https://github.com/WongKinYiu/ScaledYOLOv4)
170+
* [https://github.com/Megvii-BaseDetection/YOLOX](https://github.com/Megvii-BaseDetection/YOLOX)
171+
* [https://github.com/ultralytics/yolov3](https://github.com/ultralytics/yolov3)
172+
* [https://github.com/ultralytics/yolov5](https://github.com/ultralytics/yolov5)
173+
* [https://github.com/DingXiaoH/RepVGG](https://github.com/DingXiaoH/RepVGG)
174+
* [https://github.com/JUGGHM/OREPA_CVPR2022](https://github.com/JUGGHM/OREPA_CVPR2022)
175+
176+
</details>

__pycache__/test.cpython-37.pyc

11 KB
Binary file not shown.

cfg/baseline/r50-csp.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# parameters
2+
nc: 80 # number of classes
3+
depth_multiple: 1.0 # model depth multiple
4+
width_multiple: 1.0 # layer channel multiple
5+
6+
# anchors
7+
anchors:
8+
- [12,16, 19,36, 40,28] # P3/8
9+
- [36,75, 76,55, 72,146] # P4/16
10+
- [142,110, 192,243, 459,401] # P5/32
11+
12+
# CSP-ResNet backbone
13+
backbone:
14+
# [from, number, module, args]
15+
[[-1, 1, Stem, [128]], # 0-P1/2
16+
[-1, 3, ResCSPC, [128]],
17+
[-1, 1, Conv, [256, 3, 2]], # 2-P3/8
18+
[-1, 4, ResCSPC, [256]],
19+
[-1, 1, Conv, [512, 3, 2]], # 4-P3/8
20+
[-1, 6, ResCSPC, [512]],
21+
[-1, 1, Conv, [1024, 3, 2]], # 6-P3/8
22+
[-1, 3, ResCSPC, [1024]], # 7
23+
]
24+
25+
# CSP-Res-PAN head
26+
head:
27+
[[-1, 1, SPPCSPC, [512]], # 8
28+
[-1, 1, Conv, [256, 1, 1]],
29+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
30+
[5, 1, Conv, [256, 1, 1]], # route backbone P4
31+
[[-1, -2], 1, Concat, [1]],
32+
[-1, 2, ResCSPB, [256]], # 13
33+
[-1, 1, Conv, [128, 1, 1]],
34+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
35+
[3, 1, Conv, [128, 1, 1]], # route backbone P3
36+
[[-1, -2], 1, Concat, [1]],
37+
[-1, 2, ResCSPB, [128]], # 18
38+
[-1, 1, Conv, [256, 3, 1]],
39+
[-2, 1, Conv, [256, 3, 2]],
40+
[[-1, 13], 1, Concat, [1]], # cat
41+
[-1, 2, ResCSPB, [256]], # 22
42+
[-1, 1, Conv, [512, 3, 1]],
43+
[-2, 1, Conv, [512, 3, 2]],
44+
[[-1, 8], 1, Concat, [1]], # cat
45+
[-1, 2, ResCSPB, [512]], # 26
46+
[-1, 1, Conv, [1024, 3, 1]],
47+
48+
[[19,23,27], 1, IDetect, [nc, anchors]], # Detect(P3, P4, P5)
49+
]

0 commit comments

Comments
 (0)