模型性能
安装
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 update
apt install - y zip htop screen libgl1- mesa- glx
pip install seaborn thop
cd / yolov7
训练
单卡训练
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
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
多卡训练
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
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
迁移训练
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
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
验证
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
推断
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 ONNX with NMS (and inference)
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