Home

Awesome

YOLOv4

This is PyTorch implementation of YOLOv4 which is based on ultralytics/yolov3.

development log

<details><summary> <b>Expand</b> </summary> </details>

Pretrained Models & Comparison

ModelTest SizeAP<sup>test</sup>AP<sub>50</sub><sup>test</sup>AP<sub>75</sub><sup>test</sup>AP<sub>S</sub><sup>test</sup>AP<sub>M</sub><sup>test</sup>AP<sub>L</sub><sup>test</sup>cfgweights
YOLOv464050.0%68.4%54.7%30.5%54.3%63.3%cfgweights
YOLOv4<sub>pacsp-s</sub>64039.0%57.8%42.4%20.6%42.6%50.0%cfgweights
YOLOv4<sub>pacsp</sub>64049.8%68.4%54.3%30.1%54.0%63.4%cfgweights
YOLOv4<sub>pacsp-x</sub>64052.2%70.5%56.8%32.7%56.3%65.9%cfgweights
YOLOv4<sub>pacsp-s-mish</sub>64040.8%59.5%44.3%22.4%44.6%51.8%cfgweights
YOLOv4<sub>pacsp-mish</sub>64050.9%69.4%55.5%31.2%55.0%64.7%cfgweights
YOLOv4<sub>pacsp-x-mish</sub>64052.8%71.1%57.5%33.6%56.9%66.6%cfgweights
ModelTest SizeAP<sup>val</sup>AP<sub>50</sub><sup>val</sup>AP<sub>75</sub><sup>val</sup>AP<sub>S</sub><sup>val</sup>AP<sub>M</sub><sup>val</sup>AP<sub>L</sub><sup>val</sup>cfgweights
YOLOv464049.7%68.2%54.3%32.9%54.8%63.7%cfgweights
YOLOv4<sub>pacsp-s</sub>64038.9%57.7%42.2%21.9%43.3%51.9%cfgweights
YOLOv4<sub>pacsp</sub>64049.4%68.1%53.8%32.7%54.2%64.0%cfgweights
YOLOv4<sub>pacsp-x</sub>64051.6%70.1%56.2%35.3%56.4%66.9%cfgweights
YOLOv4<sub>pacsp-s-mish</sub>64040.7%59.5%44.2%25.3%45.1%53.4%cfgweights
YOLOv4<sub>pacsp-mish</sub>64050.8%69.4%55.4%34.3%55.5%65.7%cfgweights
YOLOv4<sub>pacsp-x-mish</sub>64052.6%71.0%57.2%36.4%57.3%67.6%cfgweights
<details><summary> <b>archive</b> </summary>
ModelTest SizeAP<sup>val</sup>AP<sub>50</sub><sup>val</sup>AP<sub>75</sub><sup>val</sup>AP<sub>S</sub><sup>val</sup>AP<sub>M</sub><sup>val</sup>AP<sub>L</sub><sup>val</sup>cfgweights
YOLOv464048.4%67.1%52.9%31.7%53.8%62.0%cfgweights
YOLOv4<sub>pacsp-s</sub>64037.0%55.7%40.0%20.2%41.6%48.4%cfgweights
YOLOv4<sub>pacsp</sub>64047.7%66.4%52.0%32.3%53.0%61.7%cfgweights
YOLOv4<sub>pacsp-x</sub>64050.0%68.3%54.5%33.9%55.4%63.7%cfgweights
YOLOv4<sub>pacsp-s-mish</sub>64038.8%57.8%42.0%21.6%43.7%51.1%cfgweights
YOLOv4<sub>pacsp-mish</sub>64048.8%67.2%53.4%31.5%54.4%62.2%cfgweights
YOLOv4<sub>pacsp-x-mish</sub>64051.2%69.4%55.9%35.0%56.5%65.0%cfgweights
ModelTest SizeAP<sup>val</sup>AP<sub>50</sub><sup>val</sup>AP<sub>75</sub><sup>val</sup>AP<sub>S</sub><sup>val</sup>AP<sub>M</sub><sup>val</sup>AP<sub>L</sub><sup>val</sup>cfgweights
YOLOv467247.7%66.7%52.1%30.5%52.6%61.4%cfgweights
YOLOv4<sub>pacsp-s</sub>67236.6%55.5%39.6%21.2%41.1%47.0%cfgweights
YOLOv4<sub>pacsp</sub>67247.2%66.2%51.6%30.4%52.3%60.8%cfgweights
YOLOv4<sub>pacsp-x</sub>67249.3%68.1%53.6%31.8%54.5%63.6%cfgweights
YOLOv4<sub>pacsp-s-mish</sub>67238.6%57.7%41.8%22.3%43.5%49.3%cfgweights
(+BoF)64039.9%59.1%43.1%24.4%45.2%51.4%weights
YOLOv4<sub>pacsp-mish</sub>67248.1%66.9%52.3%30.8%53.4%61.7%cfgweights
(+BoF)64049.3%68.2%53.8%31.9%54.9%62.8%weights
YOLOv4<sub>pacsp-x-mish</sub>67250.0%68.5%54.4%32.9%54.9%64.0%cfgweights
(+BoF)64051.0%69.7%55.5%33.3%56.2%65.5%weights
</details>

Requirements

docker (recommanded):

# create the docker container, you can change the share memory size if you have more.
nvidia-docker run --name yolov4 -it -v your_coco_path/:/coco/ -v your_code_path/:/yolo --shm-size=64g nvcr.io/nvidia/pytorch:20.11-py3

# apt install required packages
apt update
apt install -y zip htop screen libgl1-mesa-glx

# pip install required packages
pip install seaborn thop

# install mish-cuda if you want to use mish activation
# https://github.com/thomasbrandon/mish-cuda
# https://github.com/JunnYu/mish-cuda
cd /
git clone https://github.com/JunnYu/mish-cuda
cd mish-cuda
python setup.py build install

# go to code folder
cd /yolo

local:

pip install -r requirements.txt

※ For running Mish models, please install https://github.com/thomasbrandon/mish-cuda

Training

python train.py --device 0 --batch-size 16 --img 640 640 --data coco.yaml --cfg cfg/yolov4-pacsp.cfg --weights '' --name yolov4-pacsp

Testing

python test.py --img 640 --conf 0.001 --batch 8 --device 0 --data coco.yaml --cfg cfg/yolov4-pacsp.cfg --weights weights/yolov4-pacsp.pt

Citation

@article{bochkovskiy2020yolov4,
  title={{YOLOv4}: Optimal Speed and Accuracy of Object Detection},
  author={Bochkovskiy, Alexey and Wang, Chien-Yao and Liao, Hong-Yuan Mark},
  journal={arXiv preprint arXiv:2004.10934},
  year={2020}
}
@inproceedings{wang2020cspnet,
  title={{CSPNet}: A New Backbone That Can Enhance Learning Capability of {CNN}},
  author={Wang, Chien-Yao and Mark Liao, Hong-Yuan and Wu, Yueh-Hua and Chen, Ping-Yang and Hsieh, Jun-Wei and Yeh, I-Hau},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops},
  pages={390--391},
  year={2020}
}

Acknowledgements