종이 구현 -Yolov7 : 훈련 가능한 자유 비비를 실시간 객체 탐지기를위한 새로운 최첨단 세트
MS Coco
모델 | 테스트 크기 | AP 테스트 | AP 50 테스트 | AP 75 테스트 | 배치 1 fps | 배치 32 평균 시간 |
---|---|---|---|---|---|---|
yolov7 | 640 | 51.4% | 69.7% | 55.9% | 161 fps | 2.8ms |
yolov7-x | 640 | 53.1% | 71.2% | 57.8% | 114 fps | 4.3ms |
Yolov7-W6 | 1280 | 54.9% | 72.6% | 60.1% | 84 fps | 7.6ms |
yolov7-e6 | 1280 | 56.0% | 73.5% | 61.2% | 56 fps | 12.3ms |
yolov7-d6 | 1280 | 56.6% | 74.0% | 61.8% | 44 fps | 15.0ms |
yolov7-e6e | 1280 | 56.8% | 74.4% | 62.1% | 36 FPS | 18.7ms |
도커 환경 (권장)
# create the docker container, you can change the share memory size if you have more.
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
# apt install required packages
apt update
apt install -y zip htop screen libgl1-mesa-glx
# pip install required packages
pip install seaborn thop
# go to code folder
cd /yolov7
yolov7.pt
yolov7x.pt
yolov7-w6.pt
yolov7-e6.pt
yolov7-d6.pt
yolov7-e6e.pt
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
결과를 얻을 수 있습니다.
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.51206
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.69730
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.55521
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.35247
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.55937
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.66693
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.38453
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.63765
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.68772
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.53766
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.73549
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.83868
정확도를 측정하려면 pycocotools의 Coco-Annotations를 ./coco/annotations/instances_val2017.json
으로 다운로드하십시오.
데이터 준비
bash scripts/get_coco.sh
train2017.cache
및 val2017.cache
파일 및 레이블을 Redownload 라벨 삭제하는 것이 좋습니다.단일 GPU 교육
# train p5 models
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
# train p6 models
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
다중 GPU 훈련
# train p5 models
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
# train p6 models
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
yolov7_training.pt
yolov7x_training.pt
yolov7-w6_training.pt
yolov7-e6_training.pt
yolov7-d6_training.pt
yolov7-e6e_training.pt
사용자 정의 데이터 세트 용 단일 GPU FINETUNING
# finetune p5 models
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
# finetune p6 models
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
Reparameterization.ipynb를 참조하십시오
비디오 :
python detect.py --weights yolov7.pt --conf 0.25 --img-size 640 --source yourvideo.mp4
이미지 :
python detect.py --weights yolov7.pt --conf 0.25 --img-size 640 --source inference/images/horses.jpg
pytorch to coreml (및 MacOS/iOS의 추론)
NMS와 함께 onx에서 pytorch (및 추론)
python export.py --weights yolov7-tiny.pt --grid --end2end --simplify
--topk-all 100 --iou-thres 0.65 --conf-thres 0.35 --img-size 640 640 --max-wh 640
NMS와 함께 Tensorrt (및 추론)에서 pytorch
wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-tiny.pt
python export.py --weights ./yolov7-tiny.pt --grid --end2end --simplify --topk-all 100 --iou-thres 0.65 --conf-thres 0.35 --img-size 640 640
git clone https://github.com/Linaom1214/tensorrt-python.git
python ./tensorrt-python/export.py -o yolov7-tiny.onnx -e yolov7-tiny-nms.trt -p fp16
Pytorch는 다른 방법으로 Tensorrt입니다
wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-tiny.pt
python export.py --weights yolov7-tiny.pt --grid --include-nms
git clone https://github.com/Linaom1214/tensorrt-python.git
python ./tensorrt-python/export.py -o yolov7-tiny.onnx -e yolov7-tiny-nms.trt -p fp16
# Or use trtexec to convert ONNX to TensorRT engine
/usr/src/tensorrt/bin/trtexec --onnx=yolov7-tiny.onnx --saveEngine=yolov7-tiny-nms.trt --fp16
테스트 : Python 3.7.13, Pytorch 1.12.0+Cu113
code
yolov7-w6-pose.pt
kyypoint.ipynb를 참조하십시오.
code
yolov7-mask.pt
인스턴스를 참조하십시오.
code
yolov7-seg.pt
YOLOV7 예를 들어 세분화 (YOLOR + YOLOV5 + YOLACT)
모델 | 테스트 크기 | AP 박스 | AP 50 상자 | AP 75 상자 | AP 마스크 | AP 50 마스크 | AP 75 마스크 |
---|---|---|---|---|---|---|---|
yolov7-seg | 640 | 51.4% | 69.4% | 55.8% | 41.5% | 65.5% | 43.7% |
code
yolov7-u6.pt
분리 된 탈 머리를 가진 Yolov7 (Yolor + Yolov5 + Yolov6)
모델 | 테스트 크기 | ap val | AP 50 발 | AP 75 발 |
---|---|---|---|---|
Yolov7-U6 | 640 | 52.6% | 69.7% | 57.3% |
@inproceedings{wang2023yolov7,
title={{YOLOv7}: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors},
author={Wang, Chien-Yao and Bochkovskiy, Alexey and Liao, Hong-Yuan Mark},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
year={2023}
}
@article{wang2023designing,
title={Designing Network Design Strategies Through Gradient Path Analysis},
author={Wang, Chien-Yao and Liao, Hong-Yuan Mark and Yeh, I-Hau},
journal={Journal of Information Science and Engineering},
year={2023}
}
YOLOV7-SEMANTIC & YOLOV7-PANOPTIC & YOLOV7-CAPTION
YOLOV7-SEMANTIC & YOLOV7-Detection & Yolov7-Depth (NTUT 포함)
YOLOV7-3D- 검토 및 YOLOV7-LIDAR & YOLOV7-ROAD (NTUT 포함)