|
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 [](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> |
| 1 | + |
0 commit comments