{"id":15025591,"url":"https://github.com/wongkinyiu/yolor","last_synced_at":"2025-05-15T15:05:16.868Z","repository":{"id":37591494,"uuid":"357011329","full_name":"WongKinYiu/yolor","owner":"WongKinYiu","description":"implementation of paper - You Only Learn One Representation: Unified Network for Multiple Tasks (https://arxiv.org/abs/2105.04206)","archived":false,"fork":false,"pushed_at":"2023-12-16T11:13:57.000Z","size":3510,"stargazers_count":1987,"open_issues_count":216,"forks_count":518,"subscribers_count":32,"default_branch":"main","last_synced_at":"2024-10-29T17:40:26.376Z","etag":null,"topics":["darknet","explicit","implicit","pytorch","representation","scaled-yolov4","unified-network","yolo","yolor","yolov4","yolov4-csp"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WongKinYiu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-12T00:25:05.000Z","updated_at":"2024-10-17T12:02:17.000Z","dependencies_parsed_at":"2024-10-26T11:22:32.850Z","dependency_job_id":"4f6fc63d-92e4-48ac-99a8-81f5149526d4","html_url":"https://github.com/WongKinYiu/yolor","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WongKinYiu%2Fyolor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WongKinYiu%2Fyolor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WongKinYiu%2Fyolor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WongKinYiu%2Fyolor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WongKinYiu","download_url":"https://codeload.github.com/WongKinYiu/yolor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254364270,"owners_count":22058878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["darknet","explicit","implicit","pytorch","representation","scaled-yolov4","unified-network","yolo","yolor","yolov4","yolov4-csp"],"created_at":"2024-09-24T20:02:38.677Z","updated_at":"2025-05-15T15:05:16.846Z","avatar_url":"https://github.com/WongKinYiu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YOLOR\nimplementation of paper - [You Only Learn One Representation: Unified Network for Multiple Tasks](https://arxiv.org/abs/2105.04206)\n\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/you-only-learn-one-representation-unified/real-time-object-detection-on-coco)](https://paperswithcode.com/sota/real-time-object-detection-on-coco?p=you-only-learn-one-representation-unified)\n\n![Unified Network](https://github.com/WongKinYiu/yolor/blob/main/figure/unifued_network.png)\n\n\u003cimg src=\"https://github.com/WongKinYiu/yolor/blob/main/figure/performance.png\" height=\"480\"\u003e\n\nTo get the results on the table, please use [this branch](https://github.com/WongKinYiu/yolor/tree/paper).\n\n| Model | Test Size | AP\u003csup\u003etest\u003c/sup\u003e | AP\u003csub\u003e50\u003c/sub\u003e\u003csup\u003etest\u003c/sup\u003e | AP\u003csub\u003e75\u003c/sub\u003e\u003csup\u003etest\u003c/sup\u003e | batch1 throughput | batch32 inference |\n| :-- | :-: | :-: | :-: | :-: | :-: | :-: |\n| **YOLOR-CSP** | 640 | **52.8%** | **71.2%** | **57.6%** | 106 *fps* | 3.2 *ms* |\n| **YOLOR-CSP-X** | 640 | **54.8%** | **73.1%** | **59.7%** | 87 *fps* | 5.5 *ms* |\n| **YOLOR-P6** | 1280 | **55.7%** | **73.3%** | **61.0%** | 76 *fps* | 8.3 *ms* |\n| **YOLOR-W6** | 1280 | **56.9%** | **74.4%** | **62.2%** | 66 *fps* | 10.7 *ms* |\n| **YOLOR-E6** | 1280 | **57.6%** | **75.2%** | **63.0%** | 45 *fps* | 17.1 *ms* |\n| **YOLOR-D6** | 1280 | **58.2%** | **75.8%** | **63.8%** | 34 *fps* | 21.8 *ms* |\n|  |  |  |  |  |  |  |\n| **YOLOv4-P5** | 896 | **51.8%** | **70.3%** | **56.6%** | 41 *fps* (old) | - |\n| **YOLOv4-P6** | 1280 | **54.5%** | **72.6%** | **59.8%** | 30 *fps* (old) | - |\n| **YOLOv4-P7** | 1536 | **55.5%** | **73.4%** | **60.8%** | 16 *fps* (old) | - |\n|  |  |  |  |  |  |  |\n* Fix the speed bottleneck on our NFS, many thanks to NCHC, TWCC, and NARLabs support teams.\n\n\n| Model | Test Size | AP\u003csup\u003eval\u003c/sup\u003e | AP\u003csub\u003e50\u003c/sub\u003e\u003csup\u003eval\u003c/sup\u003e | AP\u003csub\u003e75\u003c/sub\u003e\u003csup\u003eval\u003c/sup\u003e | AP\u003csub\u003eS\u003c/sub\u003e\u003csup\u003eval\u003c/sup\u003e | AP\u003csub\u003eM\u003c/sub\u003e\u003csup\u003eval\u003c/sup\u003e | AP\u003csub\u003eL\u003c/sub\u003e\u003csup\u003eval\u003c/sup\u003e | weights |\n| :-- | :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: | \n| [**YOLOv4-CSP**](/cfg/yolov4_csp.cfg) | 640 | **49.1%** | **67.7%** | **53.8%** | **32.1%** | **54.4%** | **63.2%** | - |\n| [**YOLOR-CSP**](/cfg/yolor_csp.cfg) | 640 | **49.2%** | **67.6%** | **53.7%** | **32.9%** | **54.4%** | **63.0%** | [weights](https://github.com/WongKinYiu/yolor/releases/download/weights/yolor_csp.pt) |\n| [**YOLOR-CSP***](/cfg/yolor_csp.cfg) | 640 | **50.0%** | **68.7%** | **54.3%** | **34.2%** | **55.1%** | **64.3%** | [weights](https://github.com/WongKinYiu/yolor/releases/download/weights/yolor_csp_star.pt) |\n|  |  |  |  |  |  |  |\n| [**YOLOv4-CSP-X**](/cfg/yolov4_csp_x.cfg) | 640 | **50.9%** | **69.3%** | **55.4%** | **35.3%** | **55.8%** | **64.8%** | - |\n| [**YOLOR-CSP-X**](/cfg/yolor_csp_x.cfg) | 640 | **51.1%** | **69.6%** | **55.7%** | **35.7%** | **56.0%** | **65.2%** | [weights](https://github.com/WongKinYiu/yolor/releases/download/weights/yolor_csp_x.pt) |\n| [**YOLOR-CSP-X***](/cfg/yolor_csp_x.cfg) | 640 | **51.5%** | **69.9%** | **56.1%** | **35.8%** | **56.8%** | **66.1%** | [weights](https://github.com/WongKinYiu/yolor/releases/download/weights/yolor_csp_x_star.pt) |\n|  |  |  |  |  |  |  |\n\nDeveloping...\n\n| Model | Test Size | AP\u003csup\u003etest\u003c/sup\u003e | AP\u003csub\u003e50\u003c/sub\u003e\u003csup\u003etest\u003c/sup\u003e | AP\u003csub\u003e75\u003c/sub\u003e\u003csup\u003etest\u003c/sup\u003e | AP\u003csub\u003eS\u003c/sub\u003e\u003csup\u003etest\u003c/sup\u003e | AP\u003csub\u003eM\u003c/sub\u003e\u003csup\u003etest\u003c/sup\u003e | AP\u003csub\u003eL\u003c/sub\u003e\u003csup\u003etest\u003c/sup\u003e |\n| :-- | :-: | :-: | :-: | :-: | :-: | :-: | :-: |\n| **YOLOR-CSP** | 640 | **51.1%** | **69.6%** | **55.7%** | **31.7%** | **55.3%** | **64.7%** |\n| **YOLOR-CSP-X** | 640 | **53.0%** | **71.4%** | **57.9%** | **33.7%** | **57.1%** | **66.8%** |\n\nTrain from scratch for 300 epochs...\n\n| Model | Info | Test Size | AP |\n| :-- | :-- | :-: | :-: |\n| **YOLOR-CSP** | [evolution](https://github.com/ultralytics/yolov3/issues/392) | 640 | **48.0%** |\n| **YOLOR-CSP** | [strategy](https://openaccess.thecvf.com/content/ICCV2021W/LPCV/html/Wang_Exploring_the_Power_of_Lightweight_YOLOv4_ICCVW_2021_paper.html) | 640 | **50.0%** |\n| **YOLOR-CSP** | [strategy](https://openaccess.thecvf.com/content/ICCV2021W/LPCV/html/Wang_Exploring_the_Power_of_Lightweight_YOLOv4_ICCVW_2021_paper.html) + [simOTA](https://arxiv.org/abs/2107.08430) | 640 | **51.1%** |\n|  |  |  |  |\n| **YOLOR-CSP-X** | [strategy](https://openaccess.thecvf.com/content/ICCV2021W/LPCV/html/Wang_Exploring_the_Power_of_Lightweight_YOLOv4_ICCVW_2021_paper.html) | 640 | **51.5%** |\n| **YOLOR-CSP-X** | [strategy](https://openaccess.thecvf.com/content/ICCV2021W/LPCV/html/Wang_Exploring_the_Power_of_Lightweight_YOLOv4_ICCVW_2021_paper.html) + [simOTA](https://arxiv.org/abs/2107.08430) | 640 | **53.0%** |\n\n## Installation\n\nDocker environment (recommended)\n\u003cdetails\u003e\u003csummary\u003e \u003cb\u003eExpand\u003c/b\u003e \u003c/summary\u003e\n\n```\n# create the docker container, you can change the share memory size if you have more.\nnvidia-docker run --name yolor -it -v your_coco_path/:/coco/ -v your_code_path/:/yolor --shm-size=64g nvcr.io/nvidia/pytorch:20.11-py3\n\n# apt install required packages\napt update\napt install -y zip htop screen libgl1-mesa-glx\n\n# pip install required packages\npip install seaborn thop\n\n# install mish-cuda if you want to use mish activation\n# https://github.com/thomasbrandon/mish-cuda\n# https://github.com/JunnYu/mish-cuda\ncd /\ngit clone https://github.com/JunnYu/mish-cuda\ncd mish-cuda\npython setup.py build install\n\n# install pytorch_wavelets if you want to use dwt down-sampling module\n# https://github.com/fbcotter/pytorch_wavelets\ncd /\ngit clone https://github.com/fbcotter/pytorch_wavelets\ncd pytorch_wavelets\npip install .\n\n# go to code folder\ncd /yolor\n```\n\n\u003c/details\u003e\n\nColab environment\n\u003cdetails\u003e\u003csummary\u003e \u003cb\u003eExpand\u003c/b\u003e \u003c/summary\u003e\n  \n```\ngit clone https://github.com/WongKinYiu/yolor\ncd yolor\n\n# pip install required packages\npip install -qr requirements.txt\n\n# install mish-cuda if you want to use mish activation\n# https://github.com/thomasbrandon/mish-cuda\n# https://github.com/JunnYu/mish-cuda\ngit clone https://github.com/JunnYu/mish-cuda\ncd mish-cuda\npython setup.py build install\ncd ..\n\n# install pytorch_wavelets if you want to use dwt down-sampling module\n# https://github.com/fbcotter/pytorch_wavelets\ngit clone https://github.com/fbcotter/pytorch_wavelets\ncd pytorch_wavelets\npip install .\ncd ..\n```\n\n\u003c/details\u003e\n\nPrepare COCO dataset\n\u003cdetails\u003e\u003csummary\u003e \u003cb\u003eExpand\u003c/b\u003e \u003c/summary\u003e\n\n```\ncd /yolor\nbash scripts/get_coco.sh\n```\n\n\u003c/details\u003e\n\nPrepare pretrained weight\n\u003cdetails\u003e\u003csummary\u003e \u003cb\u003eExpand\u003c/b\u003e \u003c/summary\u003e\n\n```\ncd /yolor\nbash scripts/get_pretrain.sh\n```\n\n\u003c/details\u003e\n\n## Testing\n\n[`yolor_p6.pt`](https://github.com/WongKinYiu/yolor/releases/download/weights/yolor_p6.pt)\n\n```\npython test.py --data data/coco.yaml --img 1280 --batch 32 --conf 0.001 --iou 0.65 --device 0 --cfg cfg/yolor_p6.cfg --weights yolor_p6.pt --name yolor_p6_val\n```\n\nYou will get the results:\n\n```\n Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.52510\n Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.70718\n Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.57520\n Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.37058\n Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.56878\n Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.66102\n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.39181\n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.65229\n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.71441\n Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.57755\n Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.75337\n Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.84013\n```\n\n## Training\n\nSingle GPU training:\n\n```\npython train.py --batch-size 8 --img 1280 1280 --data coco.yaml --cfg cfg/yolor_p6.cfg --weights '' --device 0 --name yolor_p6 --hyp hyp.scratch.1280.yaml --epochs 300\n```\n\nMultiple GPU training:\n\n```\npython -m torch.distributed.launch --nproc_per_node 2 --master_port 9527 train.py --batch-size 16 --img 1280 1280 --data coco.yaml --cfg cfg/yolor_p6.cfg --weights '' --device 0,1 --sync-bn --name yolor_p6 --hyp hyp.scratch.1280.yaml --epochs 300\n```\n\nTraining schedule in the paper:\n\n```\npython -m torch.distributed.launch --nproc_per_node 8 --master_port 9527 train.py --batch-size 64 --img 1280 1280 --data data/coco.yaml --cfg cfg/yolor_p6.cfg --weights '' --device 0,1,2,3,4,5,6,7 --sync-bn --name yolor_p6 --hyp hyp.scratch.1280.yaml --epochs 300\npython -m torch.distributed.launch --nproc_per_node 8 --master_port 9527 tune.py --batch-size 64 --img 1280 1280 --data data/coco.yaml --cfg cfg/yolor_p6.cfg --weights 'runs/train/yolor_p6/weights/last_298.pt' --device 0,1,2,3,4,5,6,7 --sync-bn --name yolor_p6-tune --hyp hyp.finetune.1280.yaml --epochs 450\npython -m torch.distributed.launch --nproc_per_node 8 --master_port 9527 train.py --batch-size 64 --img 1280 1280 --data data/coco.yaml --cfg cfg/yolor_p6.cfg --weights 'runs/train/yolor_p6-tune/weights/epoch_424.pt' --device 0,1,2,3,4,5,6,7 --sync-bn --name yolor_p6-fine --hyp hyp.finetune.1280.yaml --epochs 450\n```\n\n## Inference\n\n[`yolor_p6.pt`](https://github.com/WongKinYiu/yolor/releases/download/weights/yolor_p6.pt)\n\n```\npython detect.py --source inference/images/horses.jpg --cfg cfg/yolor_p6.cfg --weights yolor_p6.pt --conf 0.25 --img-size 1280 --device 0\n```\n\nYou will get the results:\n\n![horses](https://github.com/WongKinYiu/yolor/blob/main/inference/output/horses.jpg)\n\n## Citation\n\n```\n@article{wang2023you,\n  title={You Only Learn One Representation: Unified Network for Multiple Tasks},\n  author={Wang, Chien-Yao and Yeh, I-Hau and Liao, Hong-Yuan Mark},\n  journal={Journal of Information Science and Engineering},\n  year={2023}\n}\n```\n\n## Acknowledgements\n\n\u003cdetails\u003e\u003csummary\u003e \u003cb\u003eExpand\u003c/b\u003e \u003c/summary\u003e\n\n* [https://github.com/AlexeyAB/darknet](https://github.com/AlexeyAB/darknet)\n* [https://github.com/WongKinYiu/PyTorch_YOLOv4](https://github.com/WongKinYiu/PyTorch_YOLOv4)\n* [https://github.com/WongKinYiu/ScaledYOLOv4](https://github.com/WongKinYiu/ScaledYOLOv4)\n* [https://github.com/ultralytics/yolov3](https://github.com/ultralytics/yolov3)\n* [https://github.com/ultralytics/yolov5](https://github.com/ultralytics/yolov5)\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwongkinyiu%2Fyolor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwongkinyiu%2Fyolor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwongkinyiu%2Fyolor/lists"}