├── .github └── ISSUE_TEMPLATE │ ├── config.yml │ ├── feature_request.yml │ └── question.yml ├── .gitignore ├── .pre-commit-config.yaml ├── LICENSE ├── README.md ├── README_cn.md ├── assets ├── banner-YOLO.png ├── image3.jpg ├── picture.png ├── speed_comparision_v2.png ├── speed_comparision_v3.png ├── train_batch.jpg ├── voc_loss_curve.jpg ├── wechat_qrcode.png ├── yolov5s.jpg ├── yolov6lite_l_ncnn.jpg ├── yolov6s.jpg └── yoloxs.jpg ├── configs ├── base │ ├── README.md │ ├── README_cn.md │ ├── yolov6l_base.py │ ├── yolov6l_base_finetune.py │ ├── yolov6m_base.py │ ├── yolov6m_base_finetune.py │ ├── yolov6n_base.py │ ├── yolov6n_base_finetune.py │ ├── yolov6s_base.py │ └── yolov6s_base_finetune.py ├── experiment │ ├── eval_640_repro.py │ ├── yolov6n_with_eval_params.py │ ├── yolov6s_csp_scaled.py │ ├── yolov6t.py │ ├── yolov6t_csp_scaled.py │ └── yolov6t_finetune.py ├── mbla │ ├── README.md │ ├── README_cn.md │ ├── yolov6l_mbla.py │ ├── yolov6l_mbla_finetune.py │ ├── yolov6m_mbla.py │ ├── yolov6m_mbla_finetune.py │ ├── yolov6s_mbla.py │ ├── yolov6s_mbla_finetune.py │ ├── yolov6x_mbla.py │ └── yolov6x_mbla_finetune.py ├── qarepvgg │ ├── README.md │ ├── yolov6m_qa.py │ ├── yolov6n_qa.py │ └── yolov6s_qa.py ├── repopt │ ├── yolov6_tiny_hs.py │ ├── yolov6_tiny_opt.py │ ├── yolov6_tiny_opt_qat.py │ ├── yolov6n_hs.py │ ├── yolov6n_opt.py │ ├── yolov6n_opt_qat.py │ ├── yolov6s_hs.py │ ├── yolov6s_opt.py │ └── yolov6s_opt_qat.py ├── yolov6_lite │ ├── README.md │ ├── README_cn.md │ ├── yolov6_lite_l.py │ ├── yolov6_lite_l_finetune.py │ ├── yolov6_lite_m.py │ ├── yolov6_lite_m_finetune.py │ ├── yolov6_lite_s.py │ └── yolov6_lite_s_finetune.py ├── yolov6l.py ├── yolov6l6.py ├── yolov6l6_finetune.py ├── yolov6l_finetune.py ├── yolov6m.py ├── yolov6m6.py ├── yolov6m6_finetune.py ├── yolov6m_finetune.py ├── yolov6n.py ├── yolov6n6.py ├── yolov6n6_finetune.py ├── yolov6n_finetune.py ├── yolov6s.py ├── yolov6s6.py ├── yolov6s6_finetune.py └── yolov6s_finetune.py ├── data ├── coco.yaml ├── dataset.yaml ├── images │ ├── image1.jpg │ ├── image2.jpg │ └── image3.jpg └── voc.yaml ├── deploy ├── NCNN │ ├── Android │ │ ├── README.md │ │ ├── app │ │ │ ├── build.gradle │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── assets │ │ │ │ ├── yolov6-lite-l0.bin │ │ │ │ ├── yolov6-lite-l0.param │ │ │ │ ├── yolov6-lite-l1.bin │ │ │ │ ├── yolov6-lite-l1.param │ │ │ │ ├── yolov6-lite-l2.bin │ │ │ │ ├── yolov6-lite-l2.param │ │ │ │ ├── yolov6-lite-m.bin │ │ │ │ ├── yolov6-lite-m.param │ │ │ │ ├── yolov6-lite-s.bin │ │ │ │ └── yolov6-lite-s.param │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── tencent │ │ │ │ │ └── yolov6ncnn │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── Yolov6Ncnn.java │ │ │ │ ├── jni │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── ndkcamera.cpp │ │ │ │ ├── ndkcamera.h │ │ │ │ ├── yolo.cpp │ │ │ │ ├── yolo.h │ │ │ │ └── yolov6ncnn.cpp │ │ │ │ └── res │ │ │ │ ├── layout │ │ │ │ └── main.xml │ │ │ │ └── values │ │ │ │ └── strings.xml │ │ ├── build.gradle │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── local.properties │ │ └── settings.gradle │ ├── README.md │ ├── export_torchscript.py │ └── infer-ncnn-model.py ├── ONNX │ ├── OpenCV │ │ ├── README.md │ │ ├── coco.names │ │ ├── sample.jpg │ │ ├── yolo.py │ │ ├── yolo_video.py │ │ ├── yolov5 │ │ │ ├── CMakeLists.txt │ │ │ └── yolov5.cpp │ │ ├── yolov6 │ │ │ ├── CMakeLists.txt │ │ │ └── yolov6.cpp │ │ ├── yolox.py │ │ └── yolox │ │ │ ├── CMakeLists.txt │ │ │ └── yolox.cpp │ ├── README.md │ ├── YOLOv6-Dynamic-Batch-onnxruntime.ipynb │ ├── YOLOv6-Dynamic-Batch-tensorrt.ipynb │ ├── eval_trt.py │ └── export_onnx.py ├── OpenVINO │ ├── README.md │ └── export_openvino.py └── TensorRT │ ├── CMakeLists.txt │ ├── Processor.py │ ├── README.md │ ├── calibrator.py │ ├── eval_yolo_trt.py │ ├── logging.h │ ├── onnx_to_trt.py │ ├── tensorrt_processor.py │ ├── visualize.py │ └── yolov6.cpp ├── docs ├── About_training_size.md ├── About_training_size_cn.md ├── Convert_model.md ├── Test_NCNN_speed.md ├── Test_speed.md ├── Train_coco_data.md ├── Train_custom_data.md ├── Tutorial of Quantization.md ├── tutorial_repopt.md └── tutorial_voc.ipynb ├── hubconf.py ├── inference.ipynb ├── requirements.txt ├── tools ├── eval.py ├── infer.py ├── partial_quantization │ ├── README.md │ ├── eval.py │ ├── eval.yaml │ ├── partial_quant.py │ ├── ptq.py │ ├── sensitivity_analyse.py │ └── utils.py ├── qat │ ├── README.md │ ├── onnx_utils.py │ ├── qat_export.py │ └── qat_utils.py ├── quantization │ ├── mnn │ │ └── README.md │ ├── ppq │ │ ├── ProgramEntrance.py │ │ └── write_qparams_onnx2trt.py │ └── tensorrt │ │ ├── post_training │ │ ├── Calibrator.py │ │ ├── LICENSE │ │ ├── README.md │ │ ├── onnx_to_tensorrt.py │ │ └── quant.sh │ │ ├── requirements.txt │ │ └── training_aware │ │ └── QAT_quantizer.py └── train.py ├── tutorial.ipynb └── yolov6 ├── __init__.py ├── assigners ├── __init__.py ├── anchor_generator.py ├── assigner_utils.py ├── atss_assigner.py ├── iou2d_calculator.py └── tal_assigner.py ├── core ├── engine.py ├── evaler.py └── inferer.py ├── data ├── data_augment.py ├── data_load.py ├── datasets.py ├── vis_dataset.py └── voc2yolo.py ├── layers ├── common.py └── dbb_transforms.py ├── models ├── efficientrep.py ├── effidehead.py ├── end2end.py ├── heads │ ├── effidehead_distill_ns.py │ ├── effidehead_fuseab.py │ └── effidehead_lite.py ├── losses │ ├── loss.py │ ├── loss_distill.py │ ├── loss_distill_ns.py │ └── loss_fuseab.py ├── reppan.py ├── yolo.py └── yolo_lite.py ├── solver └── build.py └── utils ├── Arial.ttf ├── RepOptimizer.py ├── checkpoint.py ├── config.py ├── ema.py ├── envs.py ├── events.py ├── figure_iou.py ├── general.py ├── metrics.py ├── nms.py └── torch_utils.py /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: 🚀 Feature Request 2 | description: Suggest a YOLOv6 idea 3 | # title: " " 4 | labels: [enhancement] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thank you for submitting a YOLOv6 Feature Request! 10 | 11 | - type: checkboxes 12 | attributes: 13 | label: Search before asking 14 | description: > 15 | Please search the [issues](https://github.com/meituan/YOLOv6/issues) to see if a similar feature request already exists. 16 | options: 17 | - label: > 18 | I have searched the YOLOv6 [issues](https://github.com/meituan/YOLOv6/issues) and found no similar feature requests. 19 | required: true 20 | 21 | - type: textarea 22 | attributes: 23 | label: Description 24 | description: A short description of your feature. 25 | placeholder: | 26 | What new feature would you like to see in YOLOv6? (你希望YOLOv6可以支持哪些新功能?) 27 | validations: 28 | required: true 29 | 30 | - type: textarea 31 | attributes: 32 | label: Use case 33 | description: | 34 | Describe the use case of your feature request. It will help us understand and prioritize the feature request. 35 | placeholder: | 36 | How would this feature be used, and who would use it?(请描述一下这个新功能的应用场景?) 37 | 38 | - type: textarea 39 | attributes: 40 | label: Additional 41 | description: Anything else you would like to share? 42 | 43 | - type: checkboxes 44 | attributes: 45 | label: Are you willing to submit a PR? 46 | description: > 47 | (Optional) We encourage you to submit a [Pull Request](https://github.com/meituan/YOLOv6/pulls) (PR) to help improve YOLOv6 for everyone, especially if you have a good understanding of how to implement a fix or feature. 48 | options: 49 | - label: Yes I'd like to help by submitting a PR! 50 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.yml: -------------------------------------------------------------------------------- 1 | name: ❓ Question 2 | description: Ask a YOLOv6 question 3 | # title: " " 4 | labels: [question] 5 | body: 6 | - type: markdown 7 | attributes: 8 | value: | 9 | Thanks for your attention. We will try our best to solve your problem, but more concrete information is necessary to reproduce your problem. 10 | - type: checkboxes 11 | attributes: 12 | label: Before Asking 13 | description: > 14 | Please check and try following methods to solve it by yourself 15 | options: 16 | - label: > 17 | I have read the [README](https://github.com/meituan/YOLOv6/blob/main/README.md) carefully. 18 | 我已经仔细阅读了README上的操作指引。 19 | required: true 20 | - label: > 21 | I want to train my custom dataset, and I have read the [tutorials for training your custom data](https://github.com/meituan/YOLOv6/blob/main/docs/Train_custom_data.md) carefully and organize my dataset correctly; 22 | (FYI: We recommand you to apply the config files of xx_finetune.py.) 23 | 我想训练自定义数据集,我已经仔细阅读了训练自定义数据的教程,以及按照正确的目录结构存放数据集。(FYI: 我们推荐使用xx_finetune.py等配置文件训练自定义数据集。) 24 | required: False 25 | - label: > 26 | I have pulled the latest code of main branch to run again and the problem still existed. 27 | 我已经拉取了主分支上最新的代码,重新运行之后,问题仍不能解决。 28 | required: true 29 | 30 | 31 | - type: checkboxes 32 | attributes: 33 | label: Search before asking 34 | description: > 35 | Please search the [issues](https://github.com/meituan/YOLOv6/issues) to see if a similar question already exists. 36 | options: 37 | - label: > 38 | I have searched the YOLOv6 [issues](https://github.com/meituan/YOLOv6/issues) and found no similar questions. 39 | required: true 40 | 41 | - type: textarea 42 | attributes: 43 | label: Question 44 | description: What is your question? 45 | placeholder: | 46 | 💡 ProTip! Include as much information as possible (screenshots, logs, tracebacks, training commands etc.) to receive the most helpful response. 47 | (请仔细阅读上面的信息先进行问题排查,如果仍不能解决您的问题,请将问题尽可能地描述详细,以及提供相关命令、超参配置、报错日志等信息或截图,以便更快地定位和解决问题。) 48 | validations: 49 | required: true 50 | 51 | - type: textarea 52 | attributes: 53 | label: Additional 54 | description: Anything else you would like to share? 55 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | **/*.pyc 6 | 7 | # C extensions 8 | 9 | # Distribution / packaging 10 | 11 | .Python 12 | videos/ 13 | build/ 14 | runs/ 15 | weights/ 16 | develop-eggs/ 17 | dist/ 18 | downloads/ 19 | eggs/ 20 | .eggs/ 21 | parts/ 22 | sdist/ 23 | var/ 24 | wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | .hypothesis/ 50 | .pytest_cache/ 51 | 52 | # Translations 53 | *.mo 54 | *.pot 55 | 56 | # Django stuff: 57 | *.log 58 | local_settings.py 59 | db.sqlite3 60 | 61 | # Flask stuff: 62 | instance/ 63 | .webassets-cache 64 | 65 | # Scrapy stuff: 66 | .scrapy 67 | 68 | # Sphinx documentation 69 | docs/_build/ 70 | 71 | # PyBuilder 72 | target/ 73 | 74 | # Jupyter Notebook 75 | .ipynb_checkpoints 76 | 77 | # pyenv 78 | .python-version 79 | 80 | # celery beat schedule file 81 | celerybeat-schedule 82 | 83 | # SageMath parsed files 84 | *.sage.py 85 | 86 | # Environments 87 | .env 88 | .venv 89 | env/ 90 | venv/ 91 | ENV/ 92 | env.bak/ 93 | venv.bak/ 94 | 95 | # Spyder project settings 96 | .spyderproject 97 | .spyproject 98 | 99 | # Rope project settings 100 | .ropeproject 101 | 102 | # custom 103 | .DS_Store 104 | 105 | # Pytorch 106 | *.pth 107 | 108 | #vscode 109 | .vscode/* 110 | 111 | #user scripts 112 | *.sh 113 | 114 | # model files 115 | *.onnx 116 | *.pt 117 | *.engine 118 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # See https://pre-commit.com for more information 2 | # See https://pre-commit.com/hooks.html for more hooks 3 | repos: 4 | - repo: https://github.com/pre-commit/pre-commit-hooks 5 | rev: v3.2.0 6 | hooks: 7 | - id: trailing-whitespace 8 | - id: end-of-file-fixer 9 | - id: check-yaml 10 | - id: check-added-large-files 11 | -------------------------------------------------------------------------------- /assets/banner-YOLO.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/assets/banner-YOLO.png -------------------------------------------------------------------------------- /assets/image3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/assets/image3.jpg -------------------------------------------------------------------------------- /assets/picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/assets/picture.png -------------------------------------------------------------------------------- /assets/speed_comparision_v2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/assets/speed_comparision_v2.png -------------------------------------------------------------------------------- /assets/speed_comparision_v3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/assets/speed_comparision_v3.png -------------------------------------------------------------------------------- /assets/train_batch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/assets/train_batch.jpg -------------------------------------------------------------------------------- /assets/voc_loss_curve.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/assets/voc_loss_curve.jpg -------------------------------------------------------------------------------- /assets/wechat_qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/assets/wechat_qrcode.png -------------------------------------------------------------------------------- /assets/yolov5s.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/assets/yolov5s.jpg -------------------------------------------------------------------------------- /assets/yolov6lite_l_ncnn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/assets/yolov6lite_l_ncnn.jpg -------------------------------------------------------------------------------- /assets/yolov6s.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/assets/yolov6s.jpg -------------------------------------------------------------------------------- /assets/yoloxs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/assets/yoloxs.jpg -------------------------------------------------------------------------------- /configs/base/README.md: -------------------------------------------------------------------------------- 1 | ## YOLOv6 base model 2 | 3 | English | [简体中文](./README_cn.md) 4 | 5 | ### Features 6 | 7 | - Use only regular convolution and Relu activation functions. 8 | 9 | - Apply CSP (1/2 channel dim) blocks in the network structure, except for Nano base model. 10 | 11 | Advantage: 12 | - Adopt a unified network structure and configuration, and the accuracy loss of the PTQ 8-bit quantization model is negligible. 13 | - Suitable for users who are just getting started or who need to apply, optimize and deploy an 8-bit quantization model quickly and frequently. 14 | 15 | 16 | ### Performance 17 | 18 | | Model | Size | mAPval
0.5:0.95 | SpeedT4
TRT FP16 b1
(FPS) | SpeedT4
TRT FP16 b32
(FPS) | SpeedT4
TRT INT8 b1
(FPS) | SpeedT4
TRT INT8 b32
(FPS) | Params
(M) | FLOPs
(G) | 19 | | :--------------------------------------------------------------------------------------------- | --- | ----------------- | ----- | ---- | ---- | ---- | ----- | ------ | 20 | | [**YOLOv6-N-base**](https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6n_base.pt) | 640 | 36.6distill | 727 | 1302 | 814 | 1805 | 4.65 | 11.46 | 21 | | [**YOLOv6-S-base**](https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6s_base.pt) | 640 | 45.3distill | 346 | 525 | 487 | 908 | 13.14 | 30.6 | 22 | | [**YOLOv6-M-base**](https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6m_base.pt) | 640 | 49.4distill | 179 | 245 | 284 | 439 | 28.33 | 72.30 | 23 | | [**YOLOv6-L-base**](https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6l_base.pt) | 640 | 51.1distill | 116 | 157 | 196 | 288 | 59.61 | 150.89 | 24 | 25 | - Speed is tested with TensorRT 8.2.4.2 on T4. 26 | - The processes of model training, evaluation, and inference are the same as the original ones. For details, please refer to [this README](https://github.com/meituan/YOLOv6#quick-start). 27 | -------------------------------------------------------------------------------- /configs/base/README_cn.md: -------------------------------------------------------------------------------- 1 | ## YOLOv6 基础版模型 2 | 3 | 简体中文 | [English](./README.md) 4 | 5 | ### 模型特点 6 | 7 | - 仅使用常规卷积和Relu激活函数 8 | 9 | - 网络结构均采用CSP (1/2通道) block,Nano网络除外。 10 | 11 | 优势: 12 | - 采用统一的网络结构和配置,且 PTQ 8位量化模型精度损失较小,适合刚入门或有快速迭代部署8位量化模型需求的用户。 13 | 14 | 15 | ### 模型指标 16 | 17 | | 模型 | 尺寸 | mAPval
0.5:0.95 | 速度T4
TRT FP16 b1
(FPS) | 速度T4
TRT FP16 b32
(FPS) | 速度T4
TRT INT8 b1
(FPS) | 速度T4
TRT INT8 b32
(FPS) | Params
(M) | FLOPs
(G) | 18 | | :--------------------------------------------------------------------------------------------- | --- | ----------------- | ----- | ---- | ---- | ---- | ----- | ------ | 19 | | [**YOLOv6-N-base**](https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6n_base.pt) | 640 | 36.6distill | 727 | 1302 | 814 | 1805 | 4.65 | 11.46 | 20 | | [**YOLOv6-S-base**](https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6s_base.pt) | 640 | 45.3distill | 346 | 525 | 487 | 908 | 13.14 | 30.6 | 21 | | [**YOLOv6-M-base**](https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6m_base.pt) | 640 | 49.4distill | 179 | 245 | 284 | 439 | 28.33 | 72.30 | 22 | | [**YOLOv6-L-base**](https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6l_base.pt) | 640 | 51.1distill | 116 | 157 | 196 | 288 | 59.61 | 150.89 | 23 | 24 | - 速度是在 T4 上测试的,TensorRT 版本为 8.4.2.4; 25 | - 模型训练、评估、推理流程与原来保持一致,具体可参考 [首页 README 文档](https://github.com/meituan/YOLOv6/blob/main/README_cn.md#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B)。 26 | -------------------------------------------------------------------------------- /configs/base/yolov6l_base.py: -------------------------------------------------------------------------------- 1 | # YOLOv6l large base model 2 | model = dict( 3 | type='YOLOv6l_base', 4 | pretrained=None, 5 | depth_multiple=1.0, 6 | width_multiple=1.0, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | ), 14 | neck=dict( 15 | type='CSPRepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | csp_e=float(1)/2, 19 | ), 20 | head=dict( 21 | type='EffiDeHead', 22 | in_channels=[128, 256, 512], 23 | num_layers=3, 24 | begin_indices=24, 25 | anchors=3, 26 | anchors_init=[[10,13, 19,19, 33,23], 27 | [30,61, 59,59, 59,119], 28 | [116,90, 185,185, 373,326]], 29 | out_indices=[17, 20, 23], 30 | strides=[8, 16, 32], 31 | atss_warmup_epoch=0, 32 | iou_type='giou', 33 | use_dfl=True, 34 | reg_max=16, #if use_dfl is False, please set reg_max to 0 35 | distill_weight={ 36 | 'class': 2.0, 37 | 'dfl': 1.0, 38 | }, 39 | ) 40 | ) 41 | 42 | solver=dict( 43 | optim='SGD', 44 | lr_scheduler='Cosine', 45 | lr0=0.01, 46 | lrf=0.01, 47 | momentum=0.937, 48 | weight_decay=0.0005, 49 | warmup_epochs=3.0, 50 | warmup_momentum=0.8, 51 | warmup_bias_lr=0.1 52 | ) 53 | 54 | data_aug = dict( 55 | hsv_h=0.015, 56 | hsv_s=0.7, 57 | hsv_v=0.4, 58 | degrees=0.0, 59 | translate=0.1, 60 | scale=0.9, 61 | shear=0.0, 62 | flipud=0.0, 63 | fliplr=0.5, 64 | mosaic=1.0, 65 | mixup=0.1, 66 | ) 67 | training_mode = "conv_relu" 68 | -------------------------------------------------------------------------------- /configs/base/yolov6l_base_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6 large base model 2 | model = dict( 3 | type='YOLOv6l_base', 4 | depth_multiple=1.0, 5 | width_multiple=1.0, 6 | pretrained=None, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | ), 14 | neck=dict( 15 | type='CSPRepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | csp_e=float(1)/2, 19 | ), 20 | head=dict( 21 | type='EffiDeHead', 22 | in_channels=[128, 256, 512], 23 | num_layers=3, 24 | begin_indices=24, 25 | anchors=1, 26 | out_indices=[17, 20, 23], 27 | strides=[8, 16, 32], 28 | iou_type='giou', 29 | use_dfl=True, 30 | reg_max=16, #if use_dfl is False, please set reg_max to 0 31 | distill_weight={ 32 | 'class': 2.0, 33 | 'dfl': 1.0, 34 | }, 35 | ) 36 | ) 37 | 38 | solver = dict( 39 | optim='SGD', 40 | lr_scheduler='Cosine', 41 | lr0=0.0032, 42 | lrf=0.12, 43 | momentum=0.843, 44 | weight_decay=0.00036, 45 | warmup_epochs=2.0, 46 | warmup_momentum=0.5, 47 | warmup_bias_lr=0.05 48 | ) 49 | 50 | data_aug = dict( 51 | hsv_h=0.0138, 52 | hsv_s=0.664, 53 | hsv_v=0.464, 54 | degrees=0.373, 55 | translate=0.245, 56 | scale=0.898, 57 | shear=0.602, 58 | flipud=0.00856, 59 | fliplr=0.5, 60 | mosaic=1.0, 61 | mixup=0.243, 62 | ) 63 | training_mode = "conv_relu" 64 | -------------------------------------------------------------------------------- /configs/base/yolov6m_base.py: -------------------------------------------------------------------------------- 1 | # YOLOv6m medium/large base model 2 | model = dict( 3 | type='YOLOv6m_base', 4 | pretrained=None, 5 | depth_multiple=0.80, 6 | width_multiple=0.75, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | ), 14 | neck=dict( 15 | type='CSPRepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | csp_e=float(1)/2, 19 | ), 20 | head=dict( 21 | type='EffiDeHead', 22 | in_channels=[128, 256, 512], 23 | num_layers=3, 24 | begin_indices=24, 25 | anchors=3, 26 | anchors_init=[[10,13, 19,19, 33,23], 27 | [30,61, 59,59, 59,119], 28 | [116,90, 185,185, 373,326]], 29 | out_indices=[17, 20, 23], 30 | strides=[8, 16, 32], 31 | atss_warmup_epoch=0, 32 | iou_type='giou', 33 | use_dfl=True, 34 | reg_max=16, #if use_dfl is False, please set reg_max to 0 35 | distill_weight={ 36 | 'class': 0.8, 37 | 'dfl': 1.0, 38 | }, 39 | ) 40 | ) 41 | 42 | solver=dict( 43 | optim='SGD', 44 | lr_scheduler='Cosine', 45 | lr0=0.01, 46 | lrf=0.01, 47 | momentum=0.937, 48 | weight_decay=0.0005, 49 | warmup_epochs=3.0, 50 | warmup_momentum=0.8, 51 | warmup_bias_lr=0.1 52 | ) 53 | 54 | data_aug = dict( 55 | hsv_h=0.015, 56 | hsv_s=0.7, 57 | hsv_v=0.4, 58 | degrees=0.0, 59 | translate=0.1, 60 | scale=0.9, 61 | shear=0.0, 62 | flipud=0.0, 63 | fliplr=0.5, 64 | mosaic=1.0, 65 | mixup=0.1, 66 | ) 67 | training_mode = "conv_relu" 68 | -------------------------------------------------------------------------------- /configs/base/yolov6m_base_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6m medium/large base model 2 | model = dict( 3 | type='YOLOv6m_base', 4 | pretrained=None, 5 | depth_multiple=0.80, 6 | width_multiple=0.75, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | ), 14 | neck=dict( 15 | type='CSPRepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | csp_e=float(1)/2, 19 | ), 20 | head=dict( 21 | type='EffiDeHead', 22 | in_channels=[128, 256, 512], 23 | num_layers=3, 24 | begin_indices=24, 25 | anchors=3, 26 | anchors_init=[[10,13, 19,19, 33,23], 27 | [30,61, 59,59, 59,119], 28 | [116,90, 185,185, 373,326]], 29 | out_indices=[17, 20, 23], 30 | strides=[8, 16, 32], 31 | atss_warmup_epoch=0, 32 | iou_type='giou', 33 | use_dfl=True, 34 | reg_max=16, #if use_dfl is False, please set reg_max to 0 35 | distill_weight={ 36 | 'class': 0.8, 37 | 'dfl': 1.0, 38 | }, 39 | ) 40 | ) 41 | 42 | solver = dict( 43 | optim='SGD', 44 | lr_scheduler='Cosine', 45 | lr0=0.0032, 46 | lrf=0.12, 47 | momentum=0.843, 48 | weight_decay=0.00036, 49 | warmup_epochs=2.0, 50 | warmup_momentum=0.5, 51 | warmup_bias_lr=0.05 52 | ) 53 | 54 | data_aug = dict( 55 | hsv_h=0.0138, 56 | hsv_s=0.664, 57 | hsv_v=0.464, 58 | degrees=0.373, 59 | translate=0.245, 60 | scale=0.898, 61 | shear=0.602, 62 | flipud=0.00856, 63 | fliplr=0.5, 64 | mosaic=1.0, 65 | mixup=0.243, 66 | ) 67 | training_mode = "conv_relu" 68 | -------------------------------------------------------------------------------- /configs/base/yolov6n_base.py: -------------------------------------------------------------------------------- 1 | # YOLOv6s nano base model 2 | model = dict( 3 | type='YOLOv6n_base', 4 | pretrained=None, 5 | depth_multiple=0.33, 6 | width_multiple=0.25, 7 | backbone=dict( 8 | type='EfficientRep', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | fuse_P2=True, 12 | cspsppf=True, 13 | ), 14 | neck=dict( 15 | type='RepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | ), 19 | head=dict( 20 | type='EffiDeHead', 21 | in_channels=[128, 256, 512], 22 | num_layers=3, 23 | begin_indices=24, 24 | anchors=3, 25 | anchors_init=[[10,13, 19,19, 33,23], 26 | [30,61, 59,59, 59,119], 27 | [116,90, 185,185, 373,326]], 28 | out_indices=[17, 20, 23], 29 | strides=[8, 16, 32], 30 | atss_warmup_epoch=0, 31 | iou_type='giou', 32 | use_dfl=True, # set to True if you want to further train with distillation 33 | reg_max=16, # set to 16 if you want to further train with distillation 34 | distill_weight={ 35 | 'class': 1.0, 36 | 'dfl': 1.0, 37 | }, 38 | ) 39 | ) 40 | 41 | solver = dict( 42 | optim='SGD', 43 | lr_scheduler='Cosine', 44 | lr0=0.01, 45 | lrf=0.01, 46 | momentum=0.937, 47 | weight_decay=0.0005, 48 | warmup_epochs=3.0, 49 | warmup_momentum=0.8, 50 | warmup_bias_lr=0.1 51 | ) 52 | 53 | data_aug = dict( 54 | hsv_h=0.015, 55 | hsv_s=0.7, 56 | hsv_v=0.4, 57 | degrees=0.0, 58 | translate=0.1, 59 | scale=0.5, 60 | shear=0.0, 61 | flipud=0.0, 62 | fliplr=0.5, 63 | mosaic=1.0, 64 | mixup=0.0, 65 | ) 66 | training_mode = "conv_relu" 67 | -------------------------------------------------------------------------------- /configs/base/yolov6n_base_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6s nanao base model 2 | model = dict( 3 | type='YOLOv6n_base', 4 | pretrained=None, 5 | depth_multiple=0.33, 6 | width_multiple=0.25, 7 | backbone=dict( 8 | type='EfficientRep', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | fuse_P2=True, 12 | cspsppf=True, 13 | ), 14 | neck=dict( 15 | type='RepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | ), 19 | head=dict( 20 | type='EffiDeHead', 21 | in_channels=[128, 256, 512], 22 | num_layers=3, 23 | begin_indices=24, 24 | anchors=3, 25 | anchors_init=[[10,13, 19,19, 33,23], 26 | [30,61, 59,59, 59,119], 27 | [116,90, 185,185, 373,326]], 28 | out_indices=[17, 20, 23], 29 | strides=[8, 16, 32], 30 | atss_warmup_epoch=0, 31 | iou_type='giou', 32 | use_dfl=False, # set to True if you want to further train with distillation 33 | reg_max=0, # set to 16 if you want to further train with distillation 34 | distill_weight={ 35 | 'class': 1.0, 36 | 'dfl': 1.0, 37 | }, 38 | ) 39 | ) 40 | 41 | solver = dict( 42 | optim='SGD', 43 | lr_scheduler='Cosine', 44 | lr0=0.0032, 45 | lrf=0.12, 46 | momentum=0.843, 47 | weight_decay=0.00036, 48 | warmup_epochs=2.0, 49 | warmup_momentum=0.5, 50 | warmup_bias_lr=0.05 51 | ) 52 | 53 | data_aug = dict( 54 | hsv_h=0.0138, 55 | hsv_s=0.664, 56 | hsv_v=0.464, 57 | degrees=0.373, 58 | translate=0.245, 59 | scale=0.898, 60 | shear=0.602, 61 | flipud=0.00856, 62 | fliplr=0.5, 63 | mosaic=1.0, 64 | mixup=0.243, 65 | ) 66 | training_mode = "conv_relu" 67 | -------------------------------------------------------------------------------- /configs/base/yolov6s_base.py: -------------------------------------------------------------------------------- 1 | # YOLOv6s small base model 2 | model = dict( 3 | type='YOLOv6s_base', 4 | pretrained=None, 5 | depth_multiple=0.70, 6 | width_multiple=0.50, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | cspsppf=True, 14 | ), 15 | neck=dict( 16 | type='CSPRepBiFPANNeck',#CSPRepPANNeck 17 | num_repeats=[12, 12, 12, 12], 18 | out_channels=[256, 128, 128, 256, 256, 512], 19 | csp_e=float(1)/2, 20 | ), 21 | head=dict( 22 | type='EffiDeHead', 23 | in_channels=[128, 256, 512], 24 | num_layers=3, 25 | begin_indices=24, 26 | anchors=3, 27 | anchors_init=[[10,13, 19,19, 33,23], 28 | [30,61, 59,59, 59,119], 29 | [116,90, 185,185, 373,326]], 30 | out_indices=[17, 20, 23], 31 | strides=[8, 16, 32], 32 | atss_warmup_epoch=0, 33 | iou_type='giou', 34 | use_dfl=True, # set to True if you want to further train with distillation 35 | reg_max=16, # set to 16 if you want to further train with distillation 36 | distill_weight={ 37 | 'class': 1.0, 38 | 'dfl': 1.0, 39 | }, 40 | ) 41 | ) 42 | 43 | solver = dict( 44 | optim='SGD', 45 | lr_scheduler='Cosine', 46 | lr0=0.01, 47 | lrf=0.01, 48 | momentum=0.937, 49 | weight_decay=0.0005, 50 | warmup_epochs=3.0, 51 | warmup_momentum=0.8, 52 | warmup_bias_lr=0.1 53 | ) 54 | 55 | data_aug = dict( 56 | hsv_h=0.015, 57 | hsv_s=0.7, 58 | hsv_v=0.4, 59 | degrees=0.0, 60 | translate=0.1, 61 | scale=0.5, 62 | shear=0.0, 63 | flipud=0.0, 64 | fliplr=0.5, 65 | mosaic=1.0, 66 | mixup=0.0, 67 | ) 68 | training_mode = "conv_relu" 69 | -------------------------------------------------------------------------------- /configs/base/yolov6s_base_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6s small base model 2 | model = dict( 3 | type='YOLOv6s_base', 4 | pretrained=None, 5 | depth_multiple=0.70, 6 | width_multiple=0.50, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | cspsppf=True, 14 | ), 15 | neck=dict( 16 | type='CSPRepBiFPANNeck', 17 | num_repeats=[12, 12, 12, 12], 18 | out_channels=[256, 128, 128, 256, 256, 512], 19 | csp_e=float(1)/2, 20 | ), 21 | head=dict( 22 | type='EffiDeHead', 23 | in_channels=[128, 256, 512], 24 | num_layers=3, 25 | begin_indices=24, 26 | anchors=3, 27 | anchors_init=[[10,13, 19,19, 33,23], 28 | [30,61, 59,59, 59,119], 29 | [116,90, 185,185, 373,326]], 30 | out_indices=[17, 20, 23], 31 | strides=[8, 16, 32], 32 | atss_warmup_epoch=0, 33 | iou_type='giou', 34 | use_dfl=False, # set to True if you want to further train with distillation 35 | reg_max=0, # set to 16 if you want to further train with distillation 36 | distill_weight={ 37 | 'class': 1.0, 38 | 'dfl': 1.0, 39 | }, 40 | ) 41 | ) 42 | 43 | solver = dict( 44 | optim='SGD', 45 | lr_scheduler='Cosine', 46 | lr0=0.0032, 47 | lrf=0.12, 48 | momentum=0.843, 49 | weight_decay=0.00036, 50 | warmup_epochs=2.0, 51 | warmup_momentum=0.5, 52 | warmup_bias_lr=0.05 53 | ) 54 | 55 | data_aug = dict( 56 | hsv_h=0.0138, 57 | hsv_s=0.664, 58 | hsv_v=0.464, 59 | degrees=0.373, 60 | translate=0.245, 61 | scale=0.898, 62 | shear=0.602, 63 | flipud=0.00856, 64 | fliplr=0.5, 65 | mosaic=1.0, 66 | mixup=0.243, 67 | ) 68 | training_mode = "conv_relu" 69 | -------------------------------------------------------------------------------- /configs/experiment/eval_640_repro.py: -------------------------------------------------------------------------------- 1 | # eval param for different scale 2 | 3 | eval_params = dict( 4 | default = dict( 5 | img_size=640, 6 | shrink_size=2, 7 | infer_on_rect=False, 8 | ), 9 | yolov6n = dict( 10 | img_size=640, 11 | shrink_size=4, 12 | infer_on_rect=False, 13 | ), 14 | yolov6t = dict( 15 | img_size=640, 16 | shrink_size=6, 17 | infer_on_rect=False, 18 | ), 19 | yolov6s = dict( 20 | img_size=640, 21 | shrink_size=6, 22 | infer_on_rect=False, 23 | ), 24 | yolov6m = dict( 25 | img_size=640, 26 | shrink_size=4, 27 | infer_on_rect=False, 28 | ), 29 | yolov6l = dict( 30 | img_size=640, 31 | shrink_size=4, 32 | infer_on_rect=False, 33 | ), 34 | yolov6l_relu = dict( 35 | img_size=640, 36 | shrink_size=2, 37 | infer_on_rect=False, 38 | ), 39 | yolov6n6 = dict( 40 | img_size=1280, 41 | shrink_size=17, 42 | infer_on_rect=False, 43 | ), 44 | yolov6s6 = dict( 45 | img_size=1280, 46 | shrink_size=8, 47 | infer_on_rect=False, 48 | ), 49 | yolov6m6 = dict( 50 | img_size=1280, 51 | shrink_size=64, 52 | infer_on_rect=False, 53 | ), 54 | yolov6l6 = dict( 55 | img_size=1280, 56 | shrink_size=41, 57 | infer_on_rect=False, 58 | ), 59 | yolov6s_mbla = dict( 60 | img_size=640, 61 | shrink_size=7, 62 | infer_on_rect=False, 63 | ), 64 | yolov6m_mbla = dict( 65 | img_size=640, 66 | shrink_size=7, 67 | infer_on_rect=False, 68 | ), 69 | yolov6l_mbla = dict( 70 | img_size=640, 71 | shrink_size=7, 72 | infer_on_rect=False, 73 | ), 74 | yolov6x_mbla = dict( 75 | img_size=640, 76 | shrink_size=3, 77 | infer_on_rect=False, 78 | ) 79 | ) 80 | -------------------------------------------------------------------------------- /configs/experiment/yolov6n_with_eval_params.py: -------------------------------------------------------------------------------- 1 | # YOLOv6n model with eval param(when traing) 2 | model = dict( 3 | type='YOLOv6n', 4 | pretrained=None, 5 | depth_multiple=0.33, 6 | width_multiple=0.25, 7 | backbone=dict( 8 | type='EfficientRep', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | ), 12 | neck=dict( 13 | type='RepPANNeck', 14 | num_repeats=[12, 12, 12, 12], 15 | out_channels=[256, 128, 128, 256, 256, 512], 16 | ), 17 | head=dict( 18 | type='EffiDeHead', 19 | in_channels=[128, 256, 512], 20 | num_layers=3, 21 | begin_indices=24, 22 | anchors=1, 23 | out_indices=[17, 20, 23], 24 | strides=[8, 16, 32], 25 | iou_type='siou', 26 | use_dfl=False, 27 | reg_max=0 #if use_dfl is False, please set reg_max to 0 28 | ) 29 | ) 30 | 31 | solver = dict( 32 | optim='SGD', 33 | lr_scheduler='Cosine', 34 | lr0=0.02, #0.01 # 0.02 35 | lrf=0.01, 36 | momentum=0.937, 37 | weight_decay=0.0005, 38 | warmup_epochs=3.0, 39 | warmup_momentum=0.8, 40 | warmup_bias_lr=0.1 41 | ) 42 | 43 | data_aug = dict( 44 | hsv_h=0.015, 45 | hsv_s=0.7, 46 | hsv_v=0.4, 47 | degrees=0.0, 48 | translate=0.1, 49 | scale=0.5, 50 | shear=0.0, 51 | flipud=0.0, 52 | fliplr=0.5, 53 | mosaic=1.0, 54 | mixup=0.0, 55 | ) 56 | 57 | # Eval params when eval model. 58 | # If eval_params item is list, eg conf_thres=[0.03, 0.03], 59 | # first will be used in train.py and second will be used in eval.py. 60 | eval_params = dict( 61 | batch_size=None, #None mean will be the same as batch on one device * 2 62 | img_size=None, #None mean will be the same as train image size 63 | conf_thres=0.03, 64 | iou_thres=0.65, 65 | 66 | #pading and scale coord 67 | shrink_size=None, # None mean will not shrink the image. 68 | infer_on_rect=True, 69 | 70 | #metric 71 | verbose=False, 72 | do_coco_metric=True, 73 | do_pr_metric=False, 74 | plot_curve=False, 75 | plot_confusion_matrix=False 76 | ) 77 | -------------------------------------------------------------------------------- /configs/experiment/yolov6s_csp_scaled.py: -------------------------------------------------------------------------------- 1 | # YOLOv6m model 2 | model = dict( 3 | type='YOLOv6s_csp', 4 | pretrained=None, 5 | depth_multiple=0.70, 6 | width_multiple=0.50, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | ), 13 | neck=dict( 14 | type='CSPRepPANNeck', 15 | num_repeats=[12, 12, 12, 12], 16 | out_channels=[256, 128, 128, 256, 256, 512], 17 | csp_e=float(1)/2, 18 | ), 19 | head=dict( 20 | type='EffiDeHead', 21 | in_channels=[128, 256, 512], 22 | num_layers=3, 23 | begin_indices=24, 24 | anchors=1, 25 | out_indices=[17, 20, 23], 26 | strides=[8, 16, 32], 27 | iou_type='giou', 28 | use_dfl=False, 29 | reg_max=0 #if use_dfl is False, please set reg_max to 0 30 | ) 31 | ) 32 | 33 | solver=dict( 34 | optim='SGD', 35 | lr_scheduler='Cosine', 36 | lr0=0.01, 37 | lrf=0.01, 38 | momentum=0.937, 39 | weight_decay=0.0005, 40 | warmup_epochs=3.0, 41 | warmup_momentum=0.8, 42 | warmup_bias_lr=0.1 43 | ) 44 | 45 | data_aug = dict( 46 | hsv_h=0.015, 47 | hsv_s=0.7, 48 | hsv_v=0.4, 49 | degrees=0.0, 50 | translate=0.1, 51 | scale=0.9, 52 | shear=0.0, 53 | flipud=0.0, 54 | fliplr=0.5, 55 | mosaic=1.0, 56 | mixup=0.1, 57 | ) 58 | -------------------------------------------------------------------------------- /configs/experiment/yolov6t.py: -------------------------------------------------------------------------------- 1 | # YOLOv6t model 2 | model = dict( 3 | type='YOLOv6t', 4 | pretrained=None, 5 | depth_multiple=0.33, 6 | width_multiple=0.375, 7 | backbone=dict( 8 | type='EfficientRep', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | ), 12 | neck=dict( 13 | type='RepPANNeck', 14 | num_repeats=[12, 12, 12, 12], 15 | out_channels=[256, 128, 128, 256, 256, 512], 16 | ), 17 | head=dict( 18 | type='EffiDeHead', 19 | in_channels=[128, 256, 512], 20 | num_layers=3, 21 | begin_indices=24, 22 | anchors=1, 23 | out_indices=[17, 20, 23], 24 | strides=[8, 16, 32], 25 | iou_type='siou', 26 | use_dfl=False, 27 | reg_max=0 #if use_dfl is False, please set reg_max to 0 28 | ) 29 | ) 30 | 31 | solver = dict( 32 | optim='SGD', 33 | lr_scheduler='Cosine', 34 | lr0=0.01, 35 | lrf=0.01, 36 | momentum=0.937, 37 | weight_decay=0.0005, 38 | warmup_epochs=3.0, 39 | warmup_momentum=0.8, 40 | warmup_bias_lr=0.1 41 | ) 42 | 43 | data_aug = dict( 44 | hsv_h=0.015, 45 | hsv_s=0.7, 46 | hsv_v=0.4, 47 | degrees=0.0, 48 | translate=0.1, 49 | scale=0.5, 50 | shear=0.0, 51 | flipud=0.0, 52 | fliplr=0.5, 53 | mosaic=1.0, 54 | mixup=0.0, 55 | ) 56 | -------------------------------------------------------------------------------- /configs/experiment/yolov6t_csp_scaled.py: -------------------------------------------------------------------------------- 1 | # YOLOv6n model 2 | model = dict( 3 | type='YOLOv6n_csp', 4 | pretrained=None, 5 | depth_multiple=0.60, 6 | width_multiple=0.50, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | ), 13 | neck=dict( 14 | type='CSPRepPANNeck', 15 | num_repeats=[12, 12, 12, 12], 16 | out_channels=[256, 128, 128, 256, 256, 512], 17 | csp_e=float(1)/2, 18 | ), 19 | head=dict( 20 | type='EffiDeHead', 21 | in_channels=[128, 256, 512], 22 | num_layers=3, 23 | begin_indices=24, 24 | anchors=1, 25 | out_indices=[17, 20, 23], 26 | strides=[8, 16, 32], 27 | iou_type='giou', 28 | use_dfl=False, 29 | reg_max=0 #if use_dfl is False, please set reg_max to 0 30 | ) 31 | ) 32 | 33 | solver=dict( 34 | optim='SGD', 35 | lr_scheduler='Cosine', 36 | lr0=0.01, 37 | lrf=0.01, 38 | momentum=0.937, 39 | weight_decay=0.0005, 40 | warmup_epochs=3.0, 41 | warmup_momentum=0.8, 42 | warmup_bias_lr=0.1 43 | ) 44 | 45 | data_aug = dict( 46 | hsv_h=0.015, 47 | hsv_s=0.7, 48 | hsv_v=0.4, 49 | degrees=0.0, 50 | translate=0.1, 51 | scale=0.9, 52 | shear=0.0, 53 | flipud=0.0, 54 | fliplr=0.5, 55 | mosaic=1.0, 56 | mixup=0.1, 57 | ) 58 | -------------------------------------------------------------------------------- /configs/experiment/yolov6t_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6t model 2 | model = dict( 3 | type='YOLOv6t', 4 | pretrained='weights/yolov6t.pt', 5 | depth_multiple=0.33, 6 | width_multiple=0.375, 7 | backbone=dict( 8 | type='EfficientRep', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | ), 12 | neck=dict( 13 | type='RepPANNeck', 14 | num_repeats=[12, 12, 12, 12], 15 | out_channels=[256, 128, 128, 256, 256, 512], 16 | ), 17 | head=dict( 18 | type='EffiDeHead', 19 | in_channels=[128, 256, 512], 20 | num_layers=3, 21 | begin_indices=24, 22 | anchors=1, 23 | out_indices=[17, 20, 23], 24 | strides=[8, 16, 32], 25 | iou_type='siou', 26 | use_dfl=False, 27 | reg_max=0 #if use_dfl is False, please set reg_max to 0 28 | ) 29 | ) 30 | 31 | solver = dict( 32 | optim='SGD', 33 | lr_scheduler='Cosine', 34 | lr0=0.0032, 35 | lrf=0.12, 36 | momentum=0.843, 37 | weight_decay=0.00036, 38 | warmup_epochs=2.0, 39 | warmup_momentum=0.5, 40 | warmup_bias_lr=0.05 41 | ) 42 | 43 | data_aug = dict( 44 | hsv_h=0.0138, 45 | hsv_s=0.664, 46 | hsv_v=0.464, 47 | degrees=0.373, 48 | translate=0.245, 49 | scale=0.898, 50 | shear=0.602, 51 | flipud=0.00856, 52 | fliplr=0.5, 53 | mosaic=1.0, 54 | mixup=0.243, 55 | ) 56 | -------------------------------------------------------------------------------- /configs/mbla/README.md: -------------------------------------------------------------------------------- 1 | ## YOLOv6 mbla model 2 | 3 | English | [简体中文](./README_cn.md) 4 | 5 | ### Features 6 | 7 | - Apply MBLABlock(Multi Branch Layer Aggregation Block) blocks in the network structure. 8 | 9 | Advantage: 10 | - Adopt a unified network structure and configuration. 11 | 12 | - Better performance for Small model comparing to yolov6 3.0 release. 13 | 14 | - Better performance comparing to yolov6 3.0 base. 15 | 16 | 17 | 18 | ### Performance 19 | 20 | | Model | Size | mAPval
0.5:0.95 | SpeedT4
trt fp16 b1
(fps) | SpeedT4
trt fp16 b32
(fps) | Params
(M) | FLOPs
(G) | 21 | | :----------------------------------------------------------- | -------- | :----------------------- | -------------------------------------- | --------------------------------------- | -------------------- | ------------------- | 22 | | [**YOLOv6-S-mbla**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6s_mbla.pt) | 640 | 47.0distill | 300 | 424 | 11.6 | 29.8 | 23 | | [**YOLOv6-M-mbla**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6m_mbla.pt) | 640 | 50.3distill | 168 | 216 | 26.1 | 66.7 | 24 | | [**YOLOv6-L-mbla**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6l_base.pt) | 640 | 52.0distill | 129 | 154 | 46.3 | 118.2 | 25 | | [**YOLOv6-X-base**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6x_base.pt) | 640 | 53.5distill | 78 | 94 | 78.8 | 199.0 | 26 | 27 | - Speed is tested with TensorRT 8.4.2.4 on T4. 28 | - The processes of model training, evaluation, and inference are the same as the original ones. For details, please refer to [this README](https://github.com/meituan/YOLOv6#quick-start). 29 | -------------------------------------------------------------------------------- /configs/mbla/README_cn.md: -------------------------------------------------------------------------------- 1 | ## YOLOv6 MBLA版模型 2 | 3 | 简体中文 | [English](./README.md) 4 | 5 | ### 模型特点 6 | 7 | - 网络主体结构均采用MBLABlock(Multi Branch Layer Aggregation Block) 8 | 9 | 优势: 10 | - 采用统一的网络结构和配置 11 | 12 | - 相比3.0版本在s尺度效果提升,相比3.0base版本各尺度效果提升 13 | 14 | 15 | 16 | ### 模型指标 17 | 18 | | 模型 | 输入尺寸 | mAPval
0.5:0.95 | 速度T4
trt fp16 b1
(fps) | 速度T4
trt fp16 b32
(fps) | Params
(M) | FLOPs
(G) | 19 | | :----------------------------------------------------------- | -------- | :----------------------- | -------------------------------------- | --------------------------------------- | -------------------- | ------------------- | 20 | | [**YOLOv6-S-mbla**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6s_mbla.pt) | 640 | 47.0distill | 300 | 424 | 11.6 | 29.8 | 21 | | [**YOLOv6-M-mbla**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6m_mbla.pt) | 640 | 50.3distill | 168 | 216 | 26.1 | 66.7 | 22 | | [**YOLOv6-L-mbla**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6l_base.pt) | 640 | 52.0distill | 129 | 154 | 46.3 | 118.2 | 23 | | [**YOLOv6-X-base**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6x_base.pt) | 640 | 53.5distill | 78 | 94 | 78.8 | 199.0 | 24 | 25 | - 速度是在 T4 上测试的,TensorRT 版本为 8.4.2.4; 26 | - 模型训练、评估、推理流程与原来保持一致,具体可参考 [首页 README 文档](https://github.com/meituan/YOLOv6/blob/main/README_cn.md#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B)。 27 | -------------------------------------------------------------------------------- /configs/mbla/yolov6l_mbla.py: -------------------------------------------------------------------------------- 1 | # YOLOv6l model 2 | model = dict( 3 | type='YOLOv6l_mbla', 4 | pretrained=None, 5 | depth_multiple=0.5, 6 | width_multiple=1.0, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 4, 8, 8, 4], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | stage_block_type="MBLABlock", 14 | ), 15 | neck=dict( 16 | type='CSPRepBiFPANNeck', 17 | num_repeats=[8, 8, 8, 8], 18 | out_channels=[256, 128, 128, 256, 256, 512], 19 | csp_e=float(1)/2, 20 | stage_block_type="MBLABlock", 21 | ), 22 | head=dict( 23 | type='EffiDeHead', 24 | in_channels=[128, 256, 512], 25 | num_layers=3, 26 | begin_indices=24, 27 | anchors=3, 28 | anchors_init=[[10,13, 19,19, 33,23], 29 | [30,61, 59,59, 59,119], 30 | [116,90, 185,185, 373,326]], 31 | out_indices=[17, 20, 23], 32 | strides=[8, 16, 32], 33 | atss_warmup_epoch=0, 34 | iou_type='giou', 35 | use_dfl=True, 36 | reg_max=16, #if use_dfl is False, please set reg_max to 0 37 | distill_weight={ 38 | 'class': 2.0, 39 | 'dfl': 1.0, 40 | }, 41 | ) 42 | ) 43 | 44 | solver=dict( 45 | optim='SGD', 46 | lr_scheduler='Cosine', 47 | lr0=0.01, 48 | lrf=0.01, 49 | momentum=0.937, 50 | weight_decay=0.0005, 51 | warmup_epochs=3.0, 52 | warmup_momentum=0.8, 53 | warmup_bias_lr=0.1 54 | ) 55 | 56 | data_aug = dict( 57 | hsv_h=0.015, 58 | hsv_s=0.7, 59 | hsv_v=0.4, 60 | degrees=0.0, 61 | translate=0.1, 62 | scale=0.9, 63 | shear=0.0, 64 | flipud=0.0, 65 | fliplr=0.5, 66 | mosaic=1.0, 67 | mixup=0.1, 68 | ) 69 | 70 | training_mode = "conv_silu" 71 | -------------------------------------------------------------------------------- /configs/mbla/yolov6l_mbla_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6l model 2 | model = dict( 3 | type='YOLOv6l_mbla', 4 | pretrained=None, 5 | depth_multiple=0.5, 6 | width_multiple=1.0, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 4, 8, 8, 4], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | stage_block_type="MBLABlock", 14 | ), 15 | neck=dict( 16 | type='CSPRepBiFPANNeck', 17 | num_repeats=[8, 8, 8, 8], 18 | out_channels=[256, 128, 128, 256, 256, 512], 19 | csp_e=float(1)/2, 20 | stage_block_type="MBLABlock", 21 | ), 22 | head=dict( 23 | type='EffiDeHead', 24 | in_channels=[128, 256, 512], 25 | num_layers=3, 26 | begin_indices=24, 27 | anchors=3, 28 | anchors_init=[[10,13, 19,19, 33,23], 29 | [30,61, 59,59, 59,119], 30 | [116,90, 185,185, 373,326]], 31 | out_indices=[17, 20, 23], 32 | strides=[8, 16, 32], 33 | atss_warmup_epoch=0, 34 | iou_type='giou', 35 | use_dfl=True, 36 | reg_max=16, #if use_dfl is False, please set reg_max to 0 37 | distill_weight={ 38 | 'class': 2.0, 39 | 'dfl': 1.0, 40 | }, 41 | ) 42 | ) 43 | 44 | solver=dict( 45 | optim='SGD', 46 | lr_scheduler='Cosine', 47 | lr0=0.0032, 48 | lrf=0.12, 49 | momentum=0.843, 50 | weight_decay=0.00036, 51 | warmup_epochs=2.0, 52 | warmup_momentum=0.5, 53 | warmup_bias_lr=0.05 54 | ) 55 | 56 | data_aug = dict( 57 | hsv_h=0.0138, 58 | hsv_s=0.664, 59 | hsv_v=0.464, 60 | degrees=0.373, 61 | translate=0.245, 62 | scale=0.898, 63 | shear=0.602, 64 | flipud=0.00856, 65 | fliplr=0.5, 66 | mosaic=1.0, 67 | mixup=0.243, 68 | ) 69 | 70 | training_mode = "conv_silu" 71 | -------------------------------------------------------------------------------- /configs/mbla/yolov6m_mbla.py: -------------------------------------------------------------------------------- 1 | # YOLOv6l model 2 | model = dict( 3 | type='YOLOv6m_mbla', 4 | pretrained=None, 5 | depth_multiple=0.5, 6 | width_multiple=0.75, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 4, 8, 8, 4], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | stage_block_type="MBLABlock", 14 | ), 15 | neck=dict( 16 | type='CSPRepBiFPANNeck', 17 | num_repeats=[8, 8, 8, 8], 18 | out_channels=[256, 128, 128, 256, 256, 512], 19 | csp_e=float(1)/2, 20 | stage_block_type="MBLABlock", 21 | ), 22 | head=dict( 23 | type='EffiDeHead', 24 | in_channels=[128, 256, 512], 25 | num_layers=3, 26 | begin_indices=24, 27 | anchors=3, 28 | anchors_init=[[10,13, 19,19, 33,23], 29 | [30,61, 59,59, 59,119], 30 | [116,90, 185,185, 373,326]], 31 | out_indices=[17, 20, 23], 32 | strides=[8, 16, 32], 33 | atss_warmup_epoch=0, 34 | iou_type='giou', 35 | use_dfl=True, 36 | reg_max=16, #if use_dfl is False, please set reg_max to 0 37 | distill_weight={ 38 | 'class': 2.0, 39 | 'dfl': 1.0, 40 | }, 41 | ) 42 | ) 43 | 44 | solver=dict( 45 | optim='SGD', 46 | lr_scheduler='Cosine', 47 | lr0=0.01, 48 | lrf=0.01, 49 | momentum=0.937, 50 | weight_decay=0.0005, 51 | warmup_epochs=3.0, 52 | warmup_momentum=0.8, 53 | warmup_bias_lr=0.1 54 | ) 55 | 56 | data_aug = dict( 57 | hsv_h=0.015, 58 | hsv_s=0.7, 59 | hsv_v=0.4, 60 | degrees=0.0, 61 | translate=0.1, 62 | scale=0.9, 63 | shear=0.0, 64 | flipud=0.0, 65 | fliplr=0.5, 66 | mosaic=1.0, 67 | mixup=0.1, 68 | ) 69 | 70 | training_mode = "conv_silu" 71 | -------------------------------------------------------------------------------- /configs/mbla/yolov6m_mbla_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6l model 2 | model = dict( 3 | type='YOLOv6m_mbla', 4 | pretrained=None, 5 | depth_multiple=0.5, 6 | width_multiple=0.75, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 4, 8, 8, 4], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | stage_block_type="MBLABlock", 14 | ), 15 | neck=dict( 16 | type='CSPRepBiFPANNeck', 17 | num_repeats=[8, 8, 8, 8], 18 | out_channels=[256, 128, 128, 256, 256, 512], 19 | csp_e=float(1)/2, 20 | stage_block_type="MBLABlock", 21 | ), 22 | head=dict( 23 | type='EffiDeHead', 24 | in_channels=[128, 256, 512], 25 | num_layers=3, 26 | begin_indices=24, 27 | anchors=3, 28 | anchors_init=[[10,13, 19,19, 33,23], 29 | [30,61, 59,59, 59,119], 30 | [116,90, 185,185, 373,326]], 31 | out_indices=[17, 20, 23], 32 | strides=[8, 16, 32], 33 | atss_warmup_epoch=0, 34 | iou_type='giou', 35 | use_dfl=True, 36 | reg_max=16, #if use_dfl is False, please set reg_max to 0 37 | distill_weight={ 38 | 'class': 2.0, 39 | 'dfl': 1.0, 40 | }, 41 | ) 42 | ) 43 | 44 | solver=dict( 45 | optim='SGD', 46 | lr_scheduler='Cosine', 47 | lr0=0.0032, 48 | lrf=0.12, 49 | momentum=0.843, 50 | weight_decay=0.00036, 51 | warmup_epochs=2.0, 52 | warmup_momentum=0.5, 53 | warmup_bias_lr=0.05 54 | ) 55 | 56 | data_aug = dict( 57 | hsv_h=0.0138, 58 | hsv_s=0.664, 59 | hsv_v=0.464, 60 | degrees=0.373, 61 | translate=0.245, 62 | scale=0.898, 63 | shear=0.602, 64 | flipud=0.00856, 65 | fliplr=0.5, 66 | mosaic=1.0, 67 | mixup=0.243, 68 | ) 69 | 70 | training_mode = "conv_silu" 71 | -------------------------------------------------------------------------------- /configs/mbla/yolov6s_mbla.py: -------------------------------------------------------------------------------- 1 | # YOLOv6l model 2 | model = dict( 3 | type='YOLOv6s_mbla', 4 | pretrained=None, 5 | depth_multiple=0.5, 6 | width_multiple=0.5, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 4, 8, 8, 4], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | stage_block_type="MBLABlock", 14 | ), 15 | neck=dict( 16 | type='CSPRepBiFPANNeck', 17 | num_repeats=[8, 8, 8, 8], 18 | out_channels=[256, 128, 128, 256, 256, 512], 19 | csp_e=float(1)/2, 20 | stage_block_type="MBLABlock", 21 | ), 22 | head=dict( 23 | type='EffiDeHead', 24 | in_channels=[128, 256, 512], 25 | num_layers=3, 26 | begin_indices=24, 27 | anchors=3, 28 | anchors_init=[[10,13, 19,19, 33,23], 29 | [30,61, 59,59, 59,119], 30 | [116,90, 185,185, 373,326]], 31 | out_indices=[17, 20, 23], 32 | strides=[8, 16, 32], 33 | atss_warmup_epoch=0, 34 | iou_type='giou', 35 | use_dfl=True, 36 | reg_max=16, #if use_dfl is False, please set reg_max to 0 37 | distill_weight={ 38 | 'class': 2.0, 39 | 'dfl': 1.0, 40 | }, 41 | ) 42 | ) 43 | 44 | solver=dict( 45 | optim='SGD', 46 | lr_scheduler='Cosine', 47 | lr0=0.01, 48 | lrf=0.01, 49 | momentum=0.937, 50 | weight_decay=0.0005, 51 | warmup_epochs=3.0, 52 | warmup_momentum=0.8, 53 | warmup_bias_lr=0.1 54 | ) 55 | 56 | data_aug = dict( 57 | hsv_h=0.015, 58 | hsv_s=0.7, 59 | hsv_v=0.4, 60 | degrees=0.0, 61 | translate=0.1, 62 | scale=0.9, 63 | shear=0.0, 64 | flipud=0.0, 65 | fliplr=0.5, 66 | mosaic=1.0, 67 | mixup=0.1, 68 | ) 69 | 70 | training_mode = "conv_silu" 71 | -------------------------------------------------------------------------------- /configs/mbla/yolov6s_mbla_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6l model 2 | model = dict( 3 | type='YOLOv6s_mbla', 4 | pretrained=None, 5 | depth_multiple=0.5, 6 | width_multiple=0.5, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 4, 8, 8, 4], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | stage_block_type="MBLABlock", 14 | ), 15 | neck=dict( 16 | type='CSPRepBiFPANNeck', 17 | num_repeats=[8, 8, 8, 8], 18 | out_channels=[256, 128, 128, 256, 256, 512], 19 | csp_e=float(1)/2, 20 | stage_block_type="MBLABlock", 21 | ), 22 | head=dict( 23 | type='EffiDeHead', 24 | in_channels=[128, 256, 512], 25 | num_layers=3, 26 | begin_indices=24, 27 | anchors=3, 28 | anchors_init=[[10,13, 19,19, 33,23], 29 | [30,61, 59,59, 59,119], 30 | [116,90, 185,185, 373,326]], 31 | out_indices=[17, 20, 23], 32 | strides=[8, 16, 32], 33 | atss_warmup_epoch=0, 34 | iou_type='giou', 35 | use_dfl=True, 36 | reg_max=16, #if use_dfl is False, please set reg_max to 0 37 | distill_weight={ 38 | 'class': 2.0, 39 | 'dfl': 1.0, 40 | }, 41 | ) 42 | ) 43 | 44 | solver=dict( 45 | optim='SGD', 46 | lr_scheduler='Cosine', 47 | lr0=0.0032, 48 | lrf=0.12, 49 | momentum=0.843, 50 | weight_decay=0.00036, 51 | warmup_epochs=2.0, 52 | warmup_momentum=0.5, 53 | warmup_bias_lr=0.05 54 | ) 55 | 56 | data_aug = dict( 57 | hsv_h=0.0138, 58 | hsv_s=0.664, 59 | hsv_v=0.464, 60 | degrees=0.373, 61 | translate=0.245, 62 | scale=0.898, 63 | shear=0.602, 64 | flipud=0.00856, 65 | fliplr=0.5, 66 | mosaic=1.0, 67 | mixup=0.243, 68 | ) 69 | 70 | training_mode = "conv_silu" 71 | -------------------------------------------------------------------------------- /configs/mbla/yolov6x_mbla.py: -------------------------------------------------------------------------------- 1 | # YOLOv6l model 2 | model = dict( 3 | type='YOLOv6x_mbla', 4 | pretrained=None, 5 | depth_multiple=1.0, 6 | width_multiple=1.0, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 4, 8, 8, 4], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | stage_block_type="MBLABlock", 14 | ), 15 | neck=dict( 16 | type='CSPRepBiFPANNeck', 17 | num_repeats=[8, 8, 8, 8], 18 | out_channels=[256, 128, 128, 256, 256, 512], 19 | csp_e=float(1)/2, 20 | stage_block_type="MBLABlock", 21 | ), 22 | head=dict( 23 | type='EffiDeHead', 24 | in_channels=[128, 256, 512], 25 | num_layers=3, 26 | begin_indices=24, 27 | anchors=3, 28 | anchors_init=[[10,13, 19,19, 33,23], 29 | [30,61, 59,59, 59,119], 30 | [116,90, 185,185, 373,326]], 31 | out_indices=[17, 20, 23], 32 | strides=[8, 16, 32], 33 | atss_warmup_epoch=0, 34 | iou_type='giou', 35 | use_dfl=True, 36 | reg_max=16, #if use_dfl is False, please set reg_max to 0 37 | distill_weight={ 38 | 'class': 2.0, 39 | 'dfl': 1.0, 40 | }, 41 | ) 42 | ) 43 | 44 | solver=dict( 45 | optim='SGD', 46 | lr_scheduler='Cosine', 47 | lr0=0.01, 48 | lrf=0.01, 49 | momentum=0.937, 50 | weight_decay=0.0005, 51 | warmup_epochs=3.0, 52 | warmup_momentum=0.8, 53 | warmup_bias_lr=0.1 54 | ) 55 | 56 | data_aug = dict( 57 | hsv_h=0.015, 58 | hsv_s=0.7, 59 | hsv_v=0.4, 60 | degrees=0.0, 61 | translate=0.1, 62 | scale=0.9, 63 | shear=0.0, 64 | flipud=0.0, 65 | fliplr=0.5, 66 | mosaic=1.0, 67 | mixup=0.1, 68 | ) 69 | 70 | training_mode = "conv_silu" 71 | -------------------------------------------------------------------------------- /configs/mbla/yolov6x_mbla_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6l model 2 | model = dict( 3 | type='YOLOv6x_mbla', 4 | pretrained=None, 5 | depth_multiple=1.0, 6 | width_multiple=1.0, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 4, 8, 8, 4], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | stage_block_type="MBLABlock", 14 | ), 15 | neck=dict( 16 | type='CSPRepBiFPANNeck', 17 | num_repeats=[8, 8, 8, 8], 18 | out_channels=[256, 128, 128, 256, 256, 512], 19 | csp_e=float(1)/2, 20 | stage_block_type="MBLABlock", 21 | ), 22 | head=dict( 23 | type='EffiDeHead', 24 | in_channels=[128, 256, 512], 25 | num_layers=3, 26 | begin_indices=24, 27 | anchors=3, 28 | anchors_init=[[10,13, 19,19, 33,23], 29 | [30,61, 59,59, 59,119], 30 | [116,90, 185,185, 373,326]], 31 | out_indices=[17, 20, 23], 32 | strides=[8, 16, 32], 33 | atss_warmup_epoch=0, 34 | iou_type='giou', 35 | use_dfl=True, 36 | reg_max=16, #if use_dfl is False, please set reg_max to 0 37 | distill_weight={ 38 | 'class': 2.0, 39 | 'dfl': 1.0, 40 | }, 41 | ) 42 | ) 43 | 44 | solver=dict( 45 | optim='SGD', 46 | lr_scheduler='Cosine', 47 | lr0=0.0032, 48 | lrf=0.12, 49 | momentum=0.843, 50 | weight_decay=0.00036, 51 | warmup_epochs=2.0, 52 | warmup_momentum=0.5, 53 | warmup_bias_lr=0.05 54 | ) 55 | 56 | data_aug = dict( 57 | hsv_h=0.0138, 58 | hsv_s=0.664, 59 | hsv_v=0.464, 60 | degrees=0.373, 61 | translate=0.245, 62 | scale=0.898, 63 | shear=0.602, 64 | flipud=0.00856, 65 | fliplr=0.5, 66 | mosaic=1.0, 67 | mixup=0.243, 68 | ) 69 | 70 | training_mode = "conv_silu" 71 | -------------------------------------------------------------------------------- /configs/qarepvgg/README.md: -------------------------------------------------------------------------------- 1 | ## YOLOv6 base model 2 | 3 | English | [简体中文](./README_cn.md) 4 | 5 | ### Features 6 | 7 | - This is a RepOpt-version implementation of YOLOv6 according to [QARepVGG](https://arxiv.org/abs/2212.01593). 8 | 9 | - The QARep version models possess slightly lower float accuracy on COCO than the RepVGG version models, but achieve highly improved quantized accuracy. 10 | 11 | - The INT8 accuracies listed were obtained using a simple PTQ process, as implemented in the [`onnx_to_trt.py`](../../deploy/TensorRT/onnx_to_trt.py) script. However, higher accuracies could be achieved using Quantization-Aware Training (QAT) due to the specific architecture design of the QARepVGG model. 12 | 13 | ### Performance 14 | 15 | | Model | Size | Float
mAPval
0.5:0.95 | INT8
mAPval
0.5:0.95 | SpeedT4
trt fp16 b32
(fps) | SpeedT4
trt int8 b32
(fps) | Params
(M) | FLOPs
(G) | 16 | | :----------------------------------------------------------- | -------- | :----------------------- | -------------------------------------- | --------------------------------------- | -------------------- | ------------------- | -------------------- | 17 | | [**YOLOv6-N**](https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6n.pt) | 640 | 37.5 | 34.3 | 1286 | 1773 |4.7 | 11.4 | 18 | | [**YOLOv6-N-qa**](https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6n_qa.pt) | 640 | 37.1 | 36.4 | 1286 | 1773 | 4.7 | 11.4 | 19 | | [**YOLOv6-S**](https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6s.pt) | 640 | 45.0 | 41.3 | 513 | 1117 | 18.5 | 45.3 | 20 | | [**YOLOv6-S-qa**](https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6s_qa.pt) | 640 | 44.7 | 44.0 | 513 | 1117 | 18.5 | 45.3 | 21 | | [**YOLOv6-M**](https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6m.pt) | 640 | 50.0 | 48.1 | 250 | 439 | 34.9 | 85.8 | 22 | | [**YOLOv6-M-qa**](https://github.com/meituan/YOLOv6/releases/download/0.3.0/yolov6m_qa.pt) | 640 | 49.7 | 49.4 | 250 | 439 | 34.9 | 85.8 | 23 | 24 | - Speed is tested with TensorRT 8.4 on T4. 25 | - We have not conducted experiments on the YOLOv6-L model since it does not use the RepVGG architecture. 26 | - The processes of model training, evaluation, and inference are the same as the original ones. For details, please refer to [this README](https://github.com/meituan/YOLOv6#quick-start). 27 | -------------------------------------------------------------------------------- /configs/qarepvgg/yolov6m_qa.py: -------------------------------------------------------------------------------- 1 | # YOLOv6m model 2 | model = dict( 3 | type='YOLOv6m', 4 | pretrained=None, 5 | depth_multiple=0.60, 6 | width_multiple=0.75, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(2)/3, 12 | fuse_P2=True, 13 | ), 14 | neck=dict( 15 | type='CSPRepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | csp_e=float(2)/3, 19 | ), 20 | head=dict( 21 | type='EffiDeHead', 22 | in_channels=[128, 256, 512], 23 | num_layers=3, 24 | begin_indices=24, 25 | anchors=3, 26 | anchors_init=[[10,13, 19,19, 33,23], 27 | [30,61, 59,59, 59,119], 28 | [116,90, 185,185, 373,326]], 29 | out_indices=[17, 20, 23], 30 | strides=[8, 16, 32], 31 | atss_warmup_epoch=0, 32 | iou_type='giou', 33 | use_dfl=True, 34 | reg_max=16, #if use_dfl is False, please set reg_max to 0 35 | distill_weight={ 36 | 'class': 0.8, 37 | 'dfl': 1.0, 38 | }, 39 | ) 40 | ) 41 | 42 | solver=dict( 43 | optim='SGD', 44 | lr_scheduler='Cosine', 45 | lr0=0.01, 46 | lrf=0.01, 47 | momentum=0.937, 48 | weight_decay=0.0005, 49 | warmup_epochs=3.0, 50 | warmup_momentum=0.8, 51 | warmup_bias_lr=0.1 52 | ) 53 | 54 | data_aug = dict( 55 | hsv_h=0.015, 56 | hsv_s=0.7, 57 | hsv_v=0.4, 58 | degrees=0.0, 59 | translate=0.1, 60 | scale=0.9, 61 | shear=0.0, 62 | flipud=0.0, 63 | fliplr=0.5, 64 | mosaic=1.0, 65 | mixup=0.1, 66 | ) 67 | 68 | training_mode='qarepvggv2' 69 | -------------------------------------------------------------------------------- /configs/qarepvgg/yolov6n_qa.py: -------------------------------------------------------------------------------- 1 | # YOLOv6s model 2 | model = dict( 3 | type='YOLOv6n', 4 | pretrained=None, 5 | depth_multiple=0.33, 6 | width_multiple=0.25, 7 | backbone=dict( 8 | type='EfficientRep', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | fuse_P2=True, 12 | cspsppf=True, 13 | ), 14 | neck=dict( 15 | type='RepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | ), 19 | head=dict( 20 | type='EffiDeHead', 21 | in_channels=[128, 256, 512], 22 | num_layers=3, 23 | begin_indices=24, 24 | anchors=3, 25 | anchors_init=[[10,13, 19,19, 33,23], 26 | [30,61, 59,59, 59,119], 27 | [116,90, 185,185, 373,326]], 28 | out_indices=[17, 20, 23], 29 | strides=[8, 16, 32], 30 | atss_warmup_epoch=0, 31 | iou_type='siou', 32 | use_dfl=False, # set to True if you want to further train with distillation 33 | reg_max=0, # set to 16 if you want to further train with distillation 34 | distill_weight={ 35 | 'class': 1.0, 36 | 'dfl': 1.0, 37 | }, 38 | ) 39 | ) 40 | 41 | solver = dict( 42 | optim='SGD', 43 | lr_scheduler='Cosine', 44 | lr0=0.02, 45 | lrf=0.01, 46 | momentum=0.937, 47 | weight_decay=0.0005, 48 | warmup_epochs=3.0, 49 | warmup_momentum=0.8, 50 | warmup_bias_lr=0.1 51 | ) 52 | 53 | data_aug = dict( 54 | hsv_h=0.015, 55 | hsv_s=0.7, 56 | hsv_v=0.4, 57 | degrees=0.0, 58 | translate=0.1, 59 | scale=0.5, 60 | shear=0.0, 61 | flipud=0.0, 62 | fliplr=0.5, 63 | mosaic=1.0, 64 | mixup=0.0, 65 | ) 66 | training_mode='qarepvggv2' 67 | -------------------------------------------------------------------------------- /configs/qarepvgg/yolov6s_qa.py: -------------------------------------------------------------------------------- 1 | # YOLOv6s model 2 | model = dict( 3 | type='YOLOv6s', 4 | pretrained=None, 5 | depth_multiple=0.33, 6 | width_multiple=0.50, 7 | backbone=dict( 8 | type='EfficientRep', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | fuse_P2=True, 12 | cspsppf=True, 13 | ), 14 | neck=dict( 15 | type='RepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | ), 19 | head=dict( 20 | type='EffiDeHead', 21 | in_channels=[128, 256, 512], 22 | num_layers=3, 23 | begin_indices=24, 24 | anchors=3, 25 | anchors_init=[[10,13, 19,19, 33,23], 26 | [30,61, 59,59, 59,119], 27 | [116,90, 185,185, 373,326]], 28 | out_indices=[17, 20, 23], 29 | strides=[8, 16, 32], 30 | atss_warmup_epoch=0, 31 | iou_type='giou', 32 | use_dfl=False, # set to True if you want to further train with distillation 33 | reg_max=0, # set to 16 if you want to further train with distillation 34 | distill_weight={ 35 | 'class': 1.0, 36 | 'dfl': 1.0, 37 | }, 38 | ) 39 | ) 40 | 41 | solver = dict( 42 | optim='SGD', 43 | lr_scheduler='Cosine', 44 | lr0=0.01, 45 | lrf=0.01, 46 | momentum=0.937, 47 | weight_decay=0.0005, 48 | warmup_epochs=3.0, 49 | warmup_momentum=0.8, 50 | warmup_bias_lr=0.1 51 | ) 52 | 53 | data_aug = dict( 54 | hsv_h=0.015, 55 | hsv_s=0.7, 56 | hsv_v=0.4, 57 | degrees=0.0, 58 | translate=0.1, 59 | scale=0.5, 60 | shear=0.0, 61 | flipud=0.0, 62 | fliplr=0.5, 63 | mosaic=1.0, 64 | mixup=0.0, 65 | ) 66 | 67 | training_mode='qarepvggv2' 68 | -------------------------------------------------------------------------------- /configs/repopt/yolov6_tiny_hs.py: -------------------------------------------------------------------------------- 1 | # YOLOv6t model 2 | model = dict( 3 | type='YOLOv6t', 4 | pretrained=None, 5 | depth_multiple=0.33, 6 | width_multiple=0.375, 7 | backbone=dict( 8 | type='EfficientRep', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | ), 12 | neck=dict( 13 | type='RepPANNeck', 14 | num_repeats=[12, 12, 12, 12], 15 | out_channels=[256, 128, 128, 256, 256, 512], 16 | ), 17 | head=dict( 18 | type='EffiDeHead', 19 | in_channels=[128, 256, 512], 20 | num_layers=3, 21 | begin_indices=24, 22 | anchors=1, 23 | out_indices=[17, 20, 23], 24 | strides=[8, 16, 32], 25 | atss_warmup_epoch=0, 26 | iou_type='siou', 27 | use_dfl=False, 28 | reg_max=0 #if use_dfl is False, please set reg_max to 0 29 | ) 30 | ) 31 | 32 | solver = dict( 33 | optim='SGD', 34 | lr_scheduler='Cosine', 35 | lr0=0.01, 36 | lrf=0.01, 37 | momentum=0.937, 38 | weight_decay=0.0005, 39 | warmup_epochs=3.0, 40 | warmup_momentum=0.8, 41 | warmup_bias_lr=0.1 42 | ) 43 | 44 | data_aug = dict( 45 | hsv_h=0.015, 46 | hsv_s=0.7, 47 | hsv_v=0.4, 48 | degrees=0.0, 49 | translate=0.1, 50 | scale=0.5, 51 | shear=0.0, 52 | flipud=0.0, 53 | fliplr=0.5, 54 | mosaic=1.0, 55 | mixup=0.0, 56 | ) 57 | 58 | # Choose Rep-block by the training Mode, choices=["repvgg", "hyper-search", "repopt"] 59 | training_mode='hyper_search' 60 | -------------------------------------------------------------------------------- /configs/repopt/yolov6_tiny_opt.py: -------------------------------------------------------------------------------- 1 | # YOLOv6t model 2 | model = dict( 3 | type='YOLOv6t', 4 | pretrained=None, 5 | scales='../yolov6_assert/v6t_v2_scale_last.pt', 6 | depth_multiple=0.33, 7 | width_multiple=0.375, 8 | backbone=dict( 9 | type='EfficientRep', 10 | num_repeats=[1, 6, 12, 18, 6], 11 | out_channels=[64, 128, 256, 512, 1024], 12 | ), 13 | neck=dict( 14 | type='RepPANNeck', 15 | num_repeats=[12, 12, 12, 12], 16 | out_channels=[256, 128, 128, 256, 256, 512], 17 | ), 18 | head=dict( 19 | type='EffiDeHead', 20 | in_channels=[128, 256, 512], 21 | num_layers=3, 22 | begin_indices=24, 23 | anchors=1, 24 | out_indices=[17, 20, 23], 25 | strides=[8, 16, 32], 26 | atss_warmup_epoch=0, 27 | iou_type='siou', 28 | use_dfl=False, 29 | reg_max=0 #if use_dfl is False, please set reg_max to 0 30 | ) 31 | ) 32 | 33 | solver = dict( 34 | optim='SGD', 35 | lr_scheduler='Cosine', 36 | lr0=0.01, 37 | lrf=0.01, 38 | momentum=0.937, 39 | weight_decay=0.0005, 40 | warmup_epochs=3.0, 41 | warmup_momentum=0.8, 42 | warmup_bias_lr=0.1 43 | ) 44 | 45 | data_aug = dict( 46 | hsv_h=0.015, 47 | hsv_s=0.7, 48 | hsv_v=0.4, 49 | degrees=0.0, 50 | translate=0.1, 51 | scale=0.5, 52 | shear=0.0, 53 | flipud=0.0, 54 | fliplr=0.5, 55 | mosaic=1.0, 56 | mixup=0.0, 57 | ) 58 | # Choose Rep-block by the training Mode, choices=["repvgg", "hyper-search", "repopt"] 59 | training_mode='repopt' 60 | -------------------------------------------------------------------------------- /configs/repopt/yolov6_tiny_opt_qat.py: -------------------------------------------------------------------------------- 1 | # YOLOv6t model 2 | model = dict( 3 | type='YOLOv6t', 4 | pretrained='./assets/v6s_t.pt', 5 | scales='./assets/v6t_v2_scale_last.pt', 6 | depth_multiple=0.33, 7 | width_multiple=0.375, 8 | backbone=dict( 9 | type='EfficientRep', 10 | num_repeats=[1, 6, 12, 18, 6], 11 | out_channels=[64, 128, 256, 512, 1024], 12 | ), 13 | neck=dict( 14 | type='RepPANNeck', 15 | num_repeats=[12, 12, 12, 12], 16 | out_channels=[256, 128, 128, 256, 256, 512], 17 | ), 18 | head=dict( 19 | type='EffiDeHead', 20 | in_channels=[128, 256, 512], 21 | num_layers=3, 22 | begin_indices=24, 23 | anchors=1, 24 | out_indices=[17, 20, 23], 25 | strides=[8, 16, 32], 26 | atss_warmup_epoch=0, 27 | iou_type='siou', 28 | use_dfl=False, 29 | reg_max=0, #if use_dfl is False, please set reg_max to 0 30 | distill_weight={ 31 | 'class': 1.0, 32 | 'dfl': 1.0, 33 | }, 34 | ) 35 | ) 36 | 37 | solver = dict( 38 | optim='SGD', 39 | lr_scheduler='Cosine', 40 | lr0=0.00001, 41 | lrf=0.001, 42 | momentum=0.937, 43 | weight_decay=0.00005, 44 | warmup_epochs=3.0, 45 | warmup_momentum=0.8, 46 | warmup_bias_lr=0.1 47 | ) 48 | 49 | data_aug = dict( 50 | hsv_h=0.015, 51 | hsv_s=0.7, 52 | hsv_v=0.4, 53 | degrees=0.0, 54 | translate=0.1, 55 | scale=0.5, 56 | shear=0.0, 57 | flipud=0.0, 58 | fliplr=0.5, 59 | mosaic=1.0, 60 | mixup=0.0, 61 | ) 62 | 63 | ptq = dict( 64 | num_bits = 8, 65 | calib_batches = 4, 66 | # 'max', 'histogram' 67 | calib_method = 'max', 68 | # 'entropy', 'percentile', 'mse' 69 | histogram_amax_method='entropy', 70 | histogram_amax_percentile=99.99, 71 | calib_output_path='./', 72 | sensitive_layers_skip=False, 73 | sensitive_layers_list=[], 74 | ) 75 | 76 | qat = dict( 77 | calib_pt = './assets/v6s_t_calib_max.pt', 78 | sensitive_layers_skip = False, 79 | sensitive_layers_list=[], 80 | ) 81 | 82 | # Choose Rep-block by the training Mode, choices=["repvgg", "hyper-search", "repopt"] 83 | training_mode='repopt' 84 | -------------------------------------------------------------------------------- /configs/repopt/yolov6n_hs.py: -------------------------------------------------------------------------------- 1 | # YOLOv6n model 2 | model = dict( 3 | type='YOLOv6n', 4 | pretrained=None, 5 | depth_multiple=0.33, 6 | width_multiple=0.25, 7 | backbone=dict( 8 | type='EfficientRep', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | ), 12 | neck=dict( 13 | type='RepPANNeck', 14 | num_repeats=[12, 12, 12, 12], 15 | out_channels=[256, 128, 128, 256, 256, 512], 16 | ), 17 | head=dict( 18 | type='EffiDeHead', 19 | in_channels=[128, 256, 512], 20 | num_layers=3, 21 | begin_indices=24, 22 | anchors=1, 23 | out_indices=[17, 20, 23], 24 | strides=[8, 16, 32], 25 | atss_warmup_epoch=0, 26 | iou_type='siou', 27 | use_dfl=False, 28 | reg_max=0 #if use_dfl is False, please set reg_max to 0 29 | ) 30 | ) 31 | 32 | solver = dict( 33 | optim='SGD', 34 | lr_scheduler='Cosine', 35 | lr0=0.02, #0.01 # 0.02 36 | lrf=0.01, 37 | momentum=0.937, 38 | weight_decay=0.0005, 39 | warmup_epochs=3.0, 40 | warmup_momentum=0.8, 41 | warmup_bias_lr=0.1 42 | ) 43 | 44 | data_aug = dict( 45 | hsv_h=0.015, 46 | hsv_s=0.7, 47 | hsv_v=0.4, 48 | degrees=0.0, 49 | translate=0.1, 50 | scale=0.5, 51 | shear=0.0, 52 | flipud=0.0, 53 | fliplr=0.5, 54 | mosaic=1.0, 55 | mixup=0.0, 56 | ) 57 | 58 | # Choose Rep-block by the training Mode, choices=["repvgg", "hyper-search", "repopt"] 59 | training_mode='hyper_search' 60 | -------------------------------------------------------------------------------- /configs/repopt/yolov6n_opt.py: -------------------------------------------------------------------------------- 1 | # YOLOv6n model 2 | model = dict( 3 | type='YOLOv6n', 4 | pretrained=None, 5 | scales='../yolov6_assert/v6n_v2_scale_last.pt', 6 | depth_multiple=0.33, 7 | width_multiple=0.25, 8 | backbone=dict( 9 | type='EfficientRep', 10 | num_repeats=[1, 6, 12, 18, 6], 11 | out_channels=[64, 128, 256, 512, 1024], 12 | ), 13 | neck=dict( 14 | type='RepPANNeck', 15 | num_repeats=[12, 12, 12, 12], 16 | out_channels=[256, 128, 128, 256, 256, 512], 17 | ), 18 | head=dict( 19 | type='EffiDeHead', 20 | in_channels=[128, 256, 512], 21 | num_layers=3, 22 | begin_indices=24, 23 | anchors=1, 24 | out_indices=[17, 20, 23], 25 | strides=[8, 16, 32], 26 | atss_warmup_epoch=0, 27 | iou_type='siou', 28 | use_dfl=False, 29 | reg_max=0 #if use_dfl is False, please set reg_max to 0 30 | ) 31 | ) 32 | 33 | solver = dict( 34 | optim='SGD', 35 | lr_scheduler='Cosine', 36 | lr0=0.02, #0.01 # 0.02 37 | lrf=0.01, 38 | momentum=0.937, 39 | weight_decay=0.0005, 40 | warmup_epochs=3.0, 41 | warmup_momentum=0.8, 42 | warmup_bias_lr=0.1 43 | ) 44 | 45 | data_aug = dict( 46 | hsv_h=0.015, 47 | hsv_s=0.7, 48 | hsv_v=0.4, 49 | degrees=0.0, 50 | translate=0.1, 51 | scale=0.5, 52 | shear=0.0, 53 | flipud=0.0, 54 | fliplr=0.5, 55 | mosaic=1.0, 56 | mixup=0.0, 57 | ) 58 | # Choose Rep-block by the training Mode, choices=["repvgg", "hyper-search", "repopt"] 59 | training_mode='repopt' 60 | -------------------------------------------------------------------------------- /configs/repopt/yolov6n_opt_qat.py: -------------------------------------------------------------------------------- 1 | # YOLOv6n model 2 | model = dict( 3 | type='YOLOv6n', 4 | pretrained='./assets/v6s_n.pt', 5 | scales='./assets/v6n_v2_scale_last.pt', 6 | depth_multiple=0.33, 7 | width_multiple=0.25, 8 | backbone=dict( 9 | type='EfficientRep', 10 | num_repeats=[1, 6, 12, 18, 6], 11 | out_channels=[64, 128, 256, 512, 1024], 12 | ), 13 | neck=dict( 14 | type='RepPANNeck', 15 | num_repeats=[12, 12, 12, 12], 16 | out_channels=[256, 128, 128, 256, 256, 512], 17 | ), 18 | head=dict( 19 | type='EffiDeHead', 20 | in_channels=[128, 256, 512], 21 | num_layers=3, 22 | begin_indices=24, 23 | anchors=1, 24 | out_indices=[17, 20, 23], 25 | strides=[8, 16, 32], 26 | atss_warmup_epoch=0, 27 | iou_type='siou', 28 | use_dfl=False, 29 | reg_max=0, #if use_dfl is False, please set reg_max to 0 30 | distill_weight={ 31 | 'class': 1.0, 32 | 'dfl': 1.0, 33 | }, 34 | ) 35 | ) 36 | 37 | solver = dict( 38 | optim='SGD', 39 | lr_scheduler='Cosine', 40 | lr0=0.00001, #0.01 # 0.02 41 | lrf=0.001, 42 | momentum=0.937, 43 | weight_decay=0.00005, 44 | warmup_epochs=3.0, 45 | warmup_momentum=0.8, 46 | warmup_bias_lr=0.1 47 | ) 48 | 49 | data_aug = dict( 50 | hsv_h=0.015, 51 | hsv_s=0.7, 52 | hsv_v=0.4, 53 | degrees=0.0, 54 | translate=0.1, 55 | scale=0.5, 56 | shear=0.0, 57 | flipud=0.0, 58 | fliplr=0.5, 59 | mosaic=1.0, 60 | mixup=0.0, 61 | ) 62 | 63 | ptq = dict( 64 | num_bits = 8, 65 | calib_batches = 4, 66 | # 'max', 'histogram' 67 | calib_method = 'max', 68 | # 'entropy', 'percentile', 'mse' 69 | histogram_amax_method='entropy', 70 | histogram_amax_percentile=99.99, 71 | calib_output_path='./', 72 | sensitive_layers_skip=False, 73 | sensitive_layers_list=[], 74 | ) 75 | 76 | qat = dict( 77 | calib_pt = './assets/v6s_n_calib_max.pt', 78 | sensitive_layers_skip = False, 79 | sensitive_layers_list=[], 80 | ) 81 | # Choose Rep-block by the training Mode, choices=["repvgg", "hyper-search", "repopt"] 82 | training_mode='repopt' 83 | -------------------------------------------------------------------------------- /configs/repopt/yolov6s_hs.py: -------------------------------------------------------------------------------- 1 | # YOLOv6s model 2 | model = dict( 3 | type='YOLOv6s', 4 | pretrained=None, 5 | depth_multiple=0.33, 6 | width_multiple=0.50, 7 | backbone=dict( 8 | type='EfficientRep', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | ), 12 | neck=dict( 13 | type='RepPANNeck', 14 | num_repeats=[12, 12, 12, 12], 15 | out_channels=[256, 128, 128, 256, 256, 512], 16 | ), 17 | head=dict( 18 | type='EffiDeHead', 19 | in_channels=[128, 256, 512], 20 | num_layers=3, 21 | begin_indices=24, 22 | anchors=1, 23 | out_indices=[17, 20, 23], 24 | strides=[8, 16, 32], 25 | atss_warmup_epoch=0, 26 | iou_type='giou', 27 | use_dfl=False, 28 | reg_max=0 29 | ) 30 | ) 31 | 32 | solver = dict( 33 | optim='SGD', 34 | lr_scheduler='Cosine', 35 | lr0=0.01, 36 | lrf=0.01, 37 | momentum=0.937, 38 | weight_decay=0.0005, 39 | warmup_epochs=3.0, 40 | warmup_momentum=0.8, 41 | warmup_bias_lr=0.1 42 | ) 43 | 44 | data_aug = dict( 45 | hsv_h=0.015, 46 | hsv_s=0.7, 47 | hsv_v=0.4, 48 | degrees=0.0, 49 | translate=0.1, 50 | scale=0.5, 51 | shear=0.0, 52 | flipud=0.0, 53 | fliplr=0.5, 54 | mosaic=1.0, 55 | mixup=0.0, 56 | ) 57 | 58 | # Choose Rep-block by the training Mode, choices=["repvgg", "hyper-search", "repopt"] 59 | training_mode='hyper_search' 60 | -------------------------------------------------------------------------------- /configs/repopt/yolov6s_opt.py: -------------------------------------------------------------------------------- 1 | # YOLOv6s model 2 | model = dict( 3 | type='YOLOv6s', 4 | pretrained=None, 5 | scales='../yolov6_assert/v6s_v2_scale.pt', 6 | depth_multiple=0.33, 7 | width_multiple=0.50, 8 | backbone=dict( 9 | type='EfficientRep', 10 | num_repeats=[1, 6, 12, 18, 6], 11 | out_channels=[64, 128, 256, 512, 1024], 12 | ), 13 | neck=dict( 14 | type='RepPANNeck', 15 | num_repeats=[12, 12, 12, 12], 16 | out_channels=[256, 128, 128, 256, 256, 512], 17 | ), 18 | head=dict( 19 | type='EffiDeHead', 20 | in_channels=[128, 256, 512], 21 | num_layers=3, 22 | begin_indices=24, 23 | anchors=1, 24 | out_indices=[17, 20, 23], 25 | strides=[8, 16, 32], 26 | atss_warmup_epoch=0, 27 | iou_type='giou', 28 | use_dfl=False, 29 | reg_max=0 30 | ) 31 | ) 32 | 33 | solver = dict( 34 | optim='SGD', 35 | lr_scheduler='Cosine', 36 | lr0=0.01, 37 | lrf=0.01, 38 | momentum=0.937, 39 | weight_decay=0.0005, 40 | warmup_epochs=3.0, 41 | warmup_momentum=0.8, 42 | warmup_bias_lr=0.1 43 | ) 44 | 45 | data_aug = dict( 46 | hsv_h=0.015, 47 | hsv_s=0.7, 48 | hsv_v=0.4, 49 | degrees=0.0, 50 | translate=0.1, 51 | scale=0.5, 52 | shear=0.0, 53 | flipud=0.0, 54 | fliplr=0.5, 55 | mosaic=1.0, 56 | mixup=0.0, 57 | ) 58 | 59 | # Choose Rep-block by the training Mode, choices=["repvgg", "hyper-search", "repopt"] 60 | training_mode='repopt' 61 | -------------------------------------------------------------------------------- /configs/yolov6_lite/README.md: -------------------------------------------------------------------------------- 1 | ## YOLOv6Lite model 2 | 3 | English | [简体中文](./README_cn.md) 4 | 5 | ## Mobile Benchmark 6 | | Model | Size | mAPval
0.5:0.95 | sm8350
(ms) | mt6853
(ms) | sdm660
(ms) |Params
(M) | FLOPs
(G) | 7 | | :----------------------------------------------------------- | ---- | -------------------- | -------------------- | -------------------- | -------------------- | -------------------- | -------------------- | 8 | | [**YOLOv6Lite-S**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6lite_s.pt) | 320*320 | 22.4 | 7.99 | 11.99 | 41.86 | 0.55 | 0.56 | 9 | | [**YOLOv6Lite-M**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6lite_m.pt) | 320*320 | 25.1 | 9.08 | 13.27 | 47.95 | 0.79 | 0.67 | 10 | | [**YOLOv6Lite-L**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6lite_l.pt) | 320*320 | 28.0 | 11.37 | 16.20 | 61.40 | 1.09 | 0.87 | 11 | | [**YOLOv6Lite-L**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6lite_l.pt) | 320*192 | 25.0 | 7.02 | 9.66 | 36.13 | 1.09 | 0.52 | 12 | | [**YOLOv6Lite-L**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6lite_l.pt) | 224*128 | 18.9 | 3.63 | 4.99 | 17.76 | 1.09 | 0.24 | 13 | 14 |
15 | Table Notes 16 | 17 | - From the perspective of model size and input image ratio, we have built a series of models on the mobile terminal to facilitate flexible applications in different scenarios. 18 | - All checkpoints are trained with 400 epochs without distillation. 19 | - Results of the mAP and speed are evaluated on [COCO val2017](https://cocodataset.org/#download) dataset, and the input resolution is the Size in the table. 20 | - Speed is tested on MNN 2.3.0 AArch64 with 2 threads by arm82 acceleration. The inference warm-up is performed 10 times, and the cycle is performed 100 times. 21 | - Qualcomm 888(sm8350), Dimensity 720(mt6853) and Qualcomm 660(sdm660) correspond to chips with different performances at the high, middle and low end respectively, which can be used as a reference for model capabilities under different chips. 22 | - Refer to [Test NCNN Speed](./docs/Test_NCNN_speed.md) tutorial to reproduce the NCNN speed results of YOLOv6Lite. 23 | -------------------------------------------------------------------------------- /configs/yolov6_lite/README_cn.md: -------------------------------------------------------------------------------- 1 | ## YOLOv6 轻量级模型 2 | 3 | 简体中文 | [English](./README.md) 4 | 5 | ## 移动端模型指标 6 | 7 | | 模型 | 输入尺寸 | mAPval
0.5:0.95 | sm8350
(ms) | mt6853
(ms) | sdm660
(ms) |Params
(M) | FLOPs
(G) | 8 | | :----------------------------------------------------------- | ---- | -------------------- | -------------------- | -------------------- | -------------------- | -------------------- | -------------------- | 9 | | [**YOLOv6Lite-S**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6lite_s.pt) | 320*320 | 22.4 | 7.99 | 11.99 | 41.86 | 0.55 | 0.56 | 10 | | [**YOLOv6Lite-M**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6lite_m.pt) | 320*320 | 25.1 | 9.08 | 13.27 | 47.95 | 0.79 | 0.67 | 11 | | [**YOLOv6Lite-L**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6lite_l.pt) | 320*320 | 28.0 | 11.37 | 16.20 | 61.40 | 1.09 | 0.87 | 12 | | [**YOLOv6Lite-L**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6lite_l.pt) | 320*192 | 25.0 | 7.02 | 9.66 | 36.13 | 1.09 | 0.52 | 13 | | [**YOLOv6Lite-L**](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6lite_l.pt) | 224*128 | 18.9 | 3.63 | 4.99 | 17.76 | 1.09 | 0.24 | 14 | 15 |
16 | 表格笔记 17 | 18 | - 从模型尺寸和输入图片比例两种角度,在构建了移动端系列模型,方便不同场景下的灵活应用。 19 | - 所有权重都经过 400 个 epoch 的训练,并且没有使用蒸馏技术。 20 | - mAP 和速度指标是在 COCO val2017 数据集上评估的,输入分辨率为表格中对应展示的。 21 | - 使用 MNN 2.3.0 AArch64 进行速度测试。测速时,采用2个线程,并开启arm82加速,推理预热10次,循环100次。 22 | - 高通888(sm8350)、天玑720(mt6853)和高通660(sdm660)分别对应高中低端不同性能的芯片,可以作为不同芯片下机型能力的参考。 23 | - [NCNN 速度测试](./docs/Test_NCNN_speed.md)教程可以帮助展示及复现 YOLOv6Lite 的 NCNN 速度结果。 24 | -------------------------------------------------------------------------------- /configs/yolov6_lite/yolov6_lite_l.py: -------------------------------------------------------------------------------- 1 | # YOLOv6-lite-l model 2 | model = dict( 3 | type='YOLOv6-lite-l', 4 | pretrained=None, 5 | width_multiple=1.5, 6 | backbone=dict( 7 | type='Lite_EffiBackbone', 8 | num_repeats=[1, 3, 7, 3], 9 | out_channels=[24, 32, 64, 128, 256], 10 | scale_size=0.5, 11 | ), 12 | neck=dict( 13 | type='Lite_EffiNeck', 14 | in_channels=[256, 128, 64], 15 | unified_channels=96 16 | ), 17 | head=dict( 18 | type='Lite_EffideHead', 19 | in_channels=[96, 96, 96, 96], 20 | num_layers=4, 21 | anchors=1, 22 | strides=[8, 16, 32, 64], 23 | atss_warmup_epoch=4, 24 | iou_type='siou', 25 | use_dfl=False, 26 | reg_max=0 #if use_dfl is False, please set reg_max to 0 27 | ) 28 | ) 29 | 30 | solver = dict( 31 | optim='SGD', 32 | lr_scheduler='Cosine', 33 | lr0=0.1 * 4, 34 | lrf=0.01, 35 | momentum=0.9, 36 | weight_decay=0.00004, 37 | warmup_epochs=3.0, 38 | warmup_momentum=0.8, 39 | warmup_bias_lr=0.1 40 | ) 41 | 42 | data_aug = dict( 43 | hsv_h=0.015, 44 | hsv_s=0.7, 45 | hsv_v=0.4, 46 | degrees=0.0, 47 | translate=0.1, 48 | scale=0.5, 49 | shear=0.0, 50 | flipud=0.0, 51 | fliplr=0.5, 52 | mosaic=1.0, 53 | mixup=0.0, 54 | ) 55 | -------------------------------------------------------------------------------- /configs/yolov6_lite/yolov6_lite_l_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6-lite-l model 2 | model = dict( 3 | type='YOLOv6-lite-l', 4 | pretrained='weights/yolov6lite_l.pt', 5 | width_multiple=1.5, 6 | backbone=dict( 7 | type='Lite_EffiBackbone', 8 | num_repeats=[1, 3, 7, 3], 9 | out_channels=[24, 32, 64, 128, 256], 10 | scale_size=0.5, 11 | ), 12 | neck=dict( 13 | type='Lite_EffiNeck', 14 | in_channels=[256, 128, 64], 15 | unified_channels=96 16 | ), 17 | head=dict( 18 | type='Lite_EffideHead', 19 | in_channels=[96, 96, 96, 96], 20 | num_layers=4, 21 | anchors=1, 22 | strides=[8, 16, 32, 64], 23 | atss_warmup_epoch=4, 24 | iou_type='siou', 25 | use_dfl=False, 26 | reg_max=0 #if use_dfl is False, please set reg_max to 0 27 | ) 28 | ) 29 | 30 | solver = dict( 31 | optim='SGD', 32 | lr_scheduler='Cosine', 33 | lr0=0.0032, 34 | lrf=0.12, 35 | momentum=0.843, 36 | weight_decay=0.00036, 37 | warmup_epochs=2.0, 38 | warmup_momentum=0.5, 39 | warmup_bias_lr=0.05 40 | ) 41 | 42 | data_aug = dict( 43 | hsv_h=0.0138, 44 | hsv_s=0.664, 45 | hsv_v=0.464, 46 | degrees=0.373, 47 | translate=0.245, 48 | scale=0.898, 49 | shear=0.602, 50 | flipud=0.00856, 51 | fliplr=0.5, 52 | mosaic=1.0, 53 | mixup=0.243, 54 | ) 55 | -------------------------------------------------------------------------------- /configs/yolov6_lite/yolov6_lite_m.py: -------------------------------------------------------------------------------- 1 | # YOLOv6-lite-m model 2 | model = dict( 3 | type='YOLOv6-lite-m', 4 | pretrained=None, 5 | width_multiple=1.1, 6 | backbone=dict( 7 | type='Lite_EffiBackbone', 8 | num_repeats=[1, 3, 7, 3], 9 | out_channels=[24, 32, 64, 128, 256], 10 | scale_size=0.5, 11 | ), 12 | neck=dict( 13 | type='Lite_EffiNeck', 14 | in_channels=[256, 128, 64], 15 | unified_channels=96 16 | ), 17 | head=dict( 18 | type='Lite_EffideHead', 19 | in_channels=[96, 96, 96, 96], 20 | num_layers=4, 21 | anchors=1, 22 | strides=[8, 16, 32, 64], 23 | atss_warmup_epoch=4, 24 | iou_type='siou', 25 | use_dfl=False, 26 | reg_max=0 #if use_dfl is False, please set reg_max to 0 27 | ) 28 | ) 29 | 30 | solver = dict( 31 | optim='SGD', 32 | lr_scheduler='Cosine', 33 | lr0=0.1 * 4, 34 | lrf=0.01, 35 | momentum=0.9, 36 | weight_decay=0.00004, 37 | warmup_epochs=3.0, 38 | warmup_momentum=0.8, 39 | warmup_bias_lr=0.1 40 | ) 41 | 42 | data_aug = dict( 43 | hsv_h=0.015, 44 | hsv_s=0.7, 45 | hsv_v=0.4, 46 | degrees=0.0, 47 | translate=0.1, 48 | scale=0.5, 49 | shear=0.0, 50 | flipud=0.0, 51 | fliplr=0.5, 52 | mosaic=1.0, 53 | mixup=0.0, 54 | ) 55 | -------------------------------------------------------------------------------- /configs/yolov6_lite/yolov6_lite_m_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6-lite-m model 2 | model = dict( 3 | type='YOLOv6-lite-m', 4 | pretrained='weights/yolov6lite_m.pt', 5 | width_multiple=1.1, 6 | backbone=dict( 7 | type='Lite_EffiBackbone', 8 | num_repeats=[1, 3, 7, 3], 9 | out_channels=[24, 32, 64, 128, 256], 10 | scale_size=0.5, 11 | ), 12 | neck=dict( 13 | type='Lite_EffiNeck', 14 | in_channels=[256, 128, 64], 15 | unified_channels=96 16 | ), 17 | head=dict( 18 | type='Lite_EffideHead', 19 | in_channels=[96, 96, 96, 96], 20 | num_layers=4, 21 | anchors=1, 22 | strides=[8, 16, 32, 64], 23 | atss_warmup_epoch=4, 24 | iou_type='siou', 25 | use_dfl=False, 26 | reg_max=0 #if use_dfl is False, please set reg_max to 0 27 | ) 28 | ) 29 | 30 | solver = dict( 31 | optim='SGD', 32 | lr_scheduler='Cosine', 33 | lr0=0.0032, 34 | lrf=0.12, 35 | momentum=0.843, 36 | weight_decay=0.00036, 37 | warmup_epochs=2.0, 38 | warmup_momentum=0.5, 39 | warmup_bias_lr=0.05 40 | ) 41 | 42 | data_aug = dict( 43 | hsv_h=0.0138, 44 | hsv_s=0.664, 45 | hsv_v=0.464, 46 | degrees=0.373, 47 | translate=0.245, 48 | scale=0.898, 49 | shear=0.602, 50 | flipud=0.00856, 51 | fliplr=0.5, 52 | mosaic=1.0, 53 | mixup=0.243, 54 | ) 55 | -------------------------------------------------------------------------------- /configs/yolov6_lite/yolov6_lite_s.py: -------------------------------------------------------------------------------- 1 | # YOLOv6-lite-s model 2 | model = dict( 3 | type='YOLOv6-lite-s', 4 | pretrained=None, 5 | width_multiple=0.7, 6 | backbone=dict( 7 | type='Lite_EffiBackbone', 8 | num_repeats=[1, 3, 7, 3], 9 | out_channels=[24, 32, 64, 128, 256], 10 | scale_size=0.5, 11 | ), 12 | neck=dict( 13 | type='Lite_EffiNeck', 14 | in_channels=[256, 128, 64], 15 | unified_channels=96 16 | ), 17 | head=dict( 18 | type='Lite_EffideHead', 19 | in_channels=[96, 96, 96, 96], 20 | num_layers=4, 21 | anchors=1, 22 | strides=[8, 16, 32, 64], 23 | atss_warmup_epoch=4, 24 | iou_type='siou', 25 | use_dfl=False, 26 | reg_max=0 #if use_dfl is False, please set reg_max to 0 27 | ) 28 | ) 29 | 30 | solver = dict( 31 | optim='SGD', 32 | lr_scheduler='Cosine', 33 | lr0=0.1 * 4, 34 | lrf=0.01, 35 | momentum=0.9, 36 | weight_decay=0.00004, 37 | warmup_epochs=3.0, 38 | warmup_momentum=0.8, 39 | warmup_bias_lr=0.1 40 | ) 41 | 42 | data_aug = dict( 43 | hsv_h=0.015, 44 | hsv_s=0.7, 45 | hsv_v=0.4, 46 | degrees=0.0, 47 | translate=0.1, 48 | scale=0.5, 49 | shear=0.0, 50 | flipud=0.0, 51 | fliplr=0.5, 52 | mosaic=1.0, 53 | mixup=0.0, 54 | ) 55 | -------------------------------------------------------------------------------- /configs/yolov6_lite/yolov6_lite_s_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6-lite-s model 2 | model = dict( 3 | type='YOLOv6-lite-s', 4 | pretrained='weights/yolov6lite_s.pt', 5 | width_multiple=0.7, 6 | backbone=dict( 7 | type='Lite_EffiBackbone', 8 | num_repeats=[1, 3, 7, 3], 9 | out_channels=[24, 32, 64, 128, 256], 10 | scale_size=0.5, 11 | ), 12 | neck=dict( 13 | type='Lite_EffiNeck', 14 | in_channels=[256, 128, 64], 15 | unified_channels=96 16 | ), 17 | head=dict( 18 | type='Lite_EffideHead', 19 | in_channels=[96, 96, 96, 96], 20 | num_layers=4, 21 | anchors=1, 22 | strides=[8, 16, 32, 64], 23 | atss_warmup_epoch=4, 24 | iou_type='siou', 25 | use_dfl=False, 26 | reg_max=0 #if use_dfl is False, please set reg_max to 0 27 | ) 28 | ) 29 | 30 | solver = dict( 31 | optim='SGD', 32 | lr_scheduler='Cosine', 33 | lr0=0.0032, 34 | lrf=0.12, 35 | momentum=0.843, 36 | weight_decay=0.00036, 37 | warmup_epochs=2.0, 38 | warmup_momentum=0.5, 39 | warmup_bias_lr=0.05 40 | ) 41 | 42 | data_aug = dict( 43 | hsv_h=0.0138, 44 | hsv_s=0.664, 45 | hsv_v=0.464, 46 | degrees=0.373, 47 | translate=0.245, 48 | scale=0.898, 49 | shear=0.602, 50 | flipud=0.00856, 51 | fliplr=0.5, 52 | mosaic=1.0, 53 | mixup=0.243, 54 | ) 55 | -------------------------------------------------------------------------------- /configs/yolov6l.py: -------------------------------------------------------------------------------- 1 | # YOLOv6l model 2 | model = dict( 3 | type='YOLOv6l', 4 | pretrained=None, 5 | depth_multiple=1.0, 6 | width_multiple=1.0, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | ), 14 | neck=dict( 15 | type='CSPRepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | csp_e=float(1)/2, 19 | ), 20 | head=dict( 21 | type='EffiDeHead', 22 | in_channels=[128, 256, 512], 23 | num_layers=3, 24 | begin_indices=24, 25 | anchors=3, 26 | anchors_init=[[10,13, 19,19, 33,23], 27 | [30,61, 59,59, 59,119], 28 | [116,90, 185,185, 373,326]], 29 | out_indices=[17, 20, 23], 30 | strides=[8, 16, 32], 31 | atss_warmup_epoch=0, 32 | iou_type='giou', 33 | use_dfl=True, 34 | reg_max=16, #if use_dfl is False, please set reg_max to 0 35 | distill_weight={ 36 | 'class': 2.0, 37 | 'dfl': 1.0, 38 | }, 39 | ) 40 | ) 41 | 42 | solver=dict( 43 | optim='SGD', 44 | lr_scheduler='Cosine', 45 | lr0=0.01, 46 | lrf=0.01, 47 | momentum=0.937, 48 | weight_decay=0.0005, 49 | warmup_epochs=3.0, 50 | warmup_momentum=0.8, 51 | warmup_bias_lr=0.1 52 | ) 53 | 54 | data_aug = dict( 55 | hsv_h=0.015, 56 | hsv_s=0.7, 57 | hsv_v=0.4, 58 | degrees=0.0, 59 | translate=0.1, 60 | scale=0.9, 61 | shear=0.0, 62 | flipud=0.0, 63 | fliplr=0.5, 64 | mosaic=1.0, 65 | mixup=0.1, 66 | ) 67 | training_mode = "conv_silu" 68 | # use normal conv to speed up training and further improve accuracy. 69 | -------------------------------------------------------------------------------- /configs/yolov6l6.py: -------------------------------------------------------------------------------- 1 | # YOLOv6l6 model 2 | model = dict( 3 | type='YOLOv6l6', 4 | pretrained=None, 5 | depth_multiple=1.0, 6 | width_multiple=1.0, 7 | backbone=dict( 8 | type='CSPBepBackbone_P6', 9 | num_repeats=[1, 6, 12, 18, 6, 6], 10 | out_channels=[64, 128, 256, 512, 768, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | ), 14 | neck=dict( 15 | type='CSPRepBiFPANNeck_P6', 16 | num_repeats=[12, 12, 12, 12, 12, 12], 17 | out_channels=[512, 256, 128, 256, 512, 1024], 18 | csp_e=float(1)/2, 19 | ), 20 | head=dict( 21 | type='EffiDeHead', 22 | in_channels=[128, 256, 512, 1024], 23 | num_layers=4, 24 | anchors=1, 25 | strides=[8, 16, 32, 64], 26 | atss_warmup_epoch=4, 27 | iou_type='giou', 28 | use_dfl=True, 29 | reg_max=16, #if use_dfl is False, please set reg_max to 0 30 | distill_weight={ 31 | 'class': 1.0, 32 | 'dfl': 1.0, 33 | }, 34 | ) 35 | ) 36 | 37 | solver = dict( 38 | optim='SGD', 39 | lr_scheduler='Cosine', 40 | lr0=0.01, 41 | lrf=0.01, 42 | momentum=0.937, 43 | weight_decay=0.0005, 44 | warmup_epochs=3.0, 45 | warmup_momentum=0.8, 46 | warmup_bias_lr=0.1 47 | ) 48 | 49 | data_aug = dict( 50 | hsv_h=0.015, 51 | hsv_s=0.7, 52 | hsv_v=0.4, 53 | degrees=0.0, 54 | translate=0.1, 55 | scale=0.9, 56 | shear=0.0, 57 | flipud=0.0, 58 | fliplr=0.5, 59 | mosaic=1.0, 60 | mixup=0.2, 61 | ) 62 | training_mode = "conv_silu" 63 | -------------------------------------------------------------------------------- /configs/yolov6l6_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6l6 model 2 | model = dict( 3 | type='YOLOv6l6', 4 | pretrained='weights/yolov6l6.pt', 5 | depth_multiple=1.0, 6 | width_multiple=1.0, 7 | backbone=dict( 8 | type='CSPBepBackbone_P6', 9 | num_repeats=[1, 6, 12, 18, 6, 6], 10 | out_channels=[64, 128, 256, 512, 768, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | ), 14 | neck=dict( 15 | type='CSPRepBiFPANNeck_P6', 16 | num_repeats=[12, 12, 12, 12, 12, 12], 17 | out_channels=[512, 256, 128, 256, 512, 1024], 18 | csp_e=float(1)/2, 19 | ), 20 | head=dict( 21 | type='EffiDeHead', 22 | in_channels=[128, 256, 512, 1024], 23 | num_layers=4, 24 | anchors=1, 25 | strides=[8, 16, 32, 64], 26 | atss_warmup_epoch=4, 27 | iou_type='giou', 28 | use_dfl=True, 29 | reg_max=16, #if use_dfl is False, please set reg_max to 0 30 | distill_weight={ 31 | 'class': 1.0, 32 | 'dfl': 1.0, 33 | }, 34 | ) 35 | ) 36 | 37 | solver = dict( 38 | optim='SGD', 39 | lr_scheduler='Cosine', 40 | lr0=0.0032, 41 | lrf=0.12, 42 | momentum=0.843, 43 | weight_decay=0.00036, 44 | warmup_epochs=2.0, 45 | warmup_momentum=0.5, 46 | warmup_bias_lr=0.05 47 | ) 48 | 49 | data_aug = dict( 50 | hsv_h=0.0138, 51 | hsv_s=0.664, 52 | hsv_v=0.464, 53 | degrees=0.373, 54 | translate=0.245, 55 | scale=0.898, 56 | shear=0.602, 57 | flipud=0.00856, 58 | fliplr=0.5, 59 | mosaic=1.0, 60 | mixup=0.243, 61 | ) 62 | training_mode = "conv_silu" 63 | -------------------------------------------------------------------------------- /configs/yolov6l_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6l model 2 | model = dict( 3 | type='YOLOv6l', 4 | pretrained='weights/yolov6l.pt', 5 | depth_multiple=1.0, 6 | width_multiple=1.0, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(1)/2, 12 | fuse_P2=True, 13 | ), 14 | neck=dict( 15 | type='CSPRepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | csp_e=float(1)/2, 19 | ), 20 | head=dict( 21 | type='EffiDeHead', 22 | in_channels=[128, 256, 512], 23 | num_layers=3, 24 | begin_indices=24, 25 | anchors=3, 26 | anchors_init=[[10,13, 19,19, 33,23], 27 | [30,61, 59,59, 59,119], 28 | [116,90, 185,185, 373,326]], 29 | out_indices=[17, 20, 23], 30 | strides=[8, 16, 32], 31 | atss_warmup_epoch=0, 32 | iou_type='giou', 33 | use_dfl=True, 34 | reg_max=16, #if use_dfl is False, please set reg_max to 0 35 | distill_weight={ 36 | 'class': 2.0, 37 | 'dfl': 1.0, 38 | }, 39 | ) 40 | ) 41 | 42 | solver = dict( 43 | optim='SGD', 44 | lr_scheduler='Cosine', 45 | lr0=0.0032, 46 | lrf=0.12, 47 | momentum=0.843, 48 | weight_decay=0.00036, 49 | warmup_epochs=2.0, 50 | warmup_momentum=0.5, 51 | warmup_bias_lr=0.05 52 | ) 53 | 54 | data_aug = dict( 55 | hsv_h=0.0138, 56 | hsv_s=0.664, 57 | hsv_v=0.464, 58 | degrees=0.373, 59 | translate=0.245, 60 | scale=0.898, 61 | shear=0.602, 62 | flipud=0.00856, 63 | fliplr=0.5, 64 | mosaic=1.0, 65 | mixup=0.243, 66 | ) 67 | training_mode = "conv_silu" 68 | # use normal conv to speed up training and further improve accuracy. 69 | -------------------------------------------------------------------------------- /configs/yolov6m.py: -------------------------------------------------------------------------------- 1 | # YOLOv6m model 2 | model = dict( 3 | type='YOLOv6m', 4 | pretrained=None, 5 | depth_multiple=0.60, 6 | width_multiple=0.75, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(2)/3, 12 | fuse_P2=True, 13 | ), 14 | neck=dict( 15 | type='CSPRepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | csp_e=float(2)/3, 19 | ), 20 | head=dict( 21 | type='EffiDeHead', 22 | in_channels=[128, 256, 512], 23 | num_layers=3, 24 | begin_indices=24, 25 | anchors=3, 26 | anchors_init=[[10,13, 19,19, 33,23], 27 | [30,61, 59,59, 59,119], 28 | [116,90, 185,185, 373,326]], 29 | out_indices=[17, 20, 23], 30 | strides=[8, 16, 32], 31 | atss_warmup_epoch=0, 32 | iou_type='giou', 33 | use_dfl=True, 34 | reg_max=16, #if use_dfl is False, please set reg_max to 0 35 | distill_weight={ 36 | 'class': 0.8, 37 | 'dfl': 1.0, 38 | }, 39 | ) 40 | ) 41 | 42 | solver=dict( 43 | optim='SGD', 44 | lr_scheduler='Cosine', 45 | lr0=0.01, 46 | lrf=0.01, 47 | momentum=0.937, 48 | weight_decay=0.0005, 49 | warmup_epochs=3.0, 50 | warmup_momentum=0.8, 51 | warmup_bias_lr=0.1 52 | ) 53 | 54 | data_aug = dict( 55 | hsv_h=0.015, 56 | hsv_s=0.7, 57 | hsv_v=0.4, 58 | degrees=0.0, 59 | translate=0.1, 60 | scale=0.9, 61 | shear=0.0, 62 | flipud=0.0, 63 | fliplr=0.5, 64 | mosaic=1.0, 65 | mixup=0.1, 66 | ) 67 | -------------------------------------------------------------------------------- /configs/yolov6m6.py: -------------------------------------------------------------------------------- 1 | # YOLOv6m6 model 2 | model = dict( 3 | type='YOLOv6m6', 4 | pretrained=None, 5 | depth_multiple=0.60, 6 | width_multiple=0.75, 7 | backbone=dict( 8 | type='CSPBepBackbone_P6', 9 | num_repeats=[1, 6, 12, 18, 6, 6], 10 | out_channels=[64, 128, 256, 512, 768, 1024], 11 | csp_e=float(2)/3, 12 | fuse_P2=True, 13 | ), 14 | neck=dict( 15 | type='CSPRepBiFPANNeck_P6', 16 | num_repeats=[12, 12, 12, 12, 12, 12], 17 | out_channels=[512, 256, 128, 256, 512, 1024], 18 | csp_e=float(2)/3, 19 | ), 20 | head=dict( 21 | type='EffiDeHead', 22 | in_channels=[128, 256, 512, 1024], 23 | num_layers=4, 24 | anchors=1, 25 | strides=[8, 16, 32, 64], 26 | atss_warmup_epoch=4, 27 | iou_type='giou', 28 | use_dfl=True, 29 | reg_max=16, #if use_dfl is False, please set reg_max to 0 30 | distill_weight={ 31 | 'class': 1.0, 32 | 'dfl': 1.0, 33 | }, 34 | ) 35 | ) 36 | 37 | solver = dict( 38 | optim='SGD', 39 | lr_scheduler='Cosine', 40 | lr0=0.01, 41 | lrf=0.01, 42 | momentum=0.937, 43 | weight_decay=0.0005, 44 | warmup_epochs=3.0, 45 | warmup_momentum=0.8, 46 | warmup_bias_lr=0.1 47 | ) 48 | 49 | data_aug = dict( 50 | hsv_h=0.015, 51 | hsv_s=0.7, 52 | hsv_v=0.4, 53 | degrees=0.0, 54 | translate=0.1, 55 | scale=0.9, 56 | shear=0.0, 57 | flipud=0.0, 58 | fliplr=0.5, 59 | mosaic=1.0, 60 | mixup=0.1, 61 | ) 62 | -------------------------------------------------------------------------------- /configs/yolov6m6_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6m6 model 2 | model = dict( 3 | type='YOLOv6m6', 4 | pretrained='weights/yolov6m6.pt', 5 | depth_multiple=0.60, 6 | width_multiple=0.75, 7 | backbone=dict( 8 | type='CSPBepBackbone_P6', 9 | num_repeats=[1, 6, 12, 18, 6, 6], 10 | out_channels=[64, 128, 256, 512, 768, 1024], 11 | csp_e=float(2)/3, 12 | fuse_P2=True, 13 | ), 14 | neck=dict( 15 | type='CSPRepBiFPANNeck_P6', 16 | num_repeats=[12, 12, 12, 12, 12, 12], 17 | out_channels=[512, 256, 128, 256, 512, 1024], 18 | csp_e=float(2)/3, 19 | ), 20 | head=dict( 21 | type='EffiDeHead', 22 | in_channels=[128, 256, 512, 1024], 23 | num_layers=4, 24 | anchors=1, 25 | strides=[8, 16, 32, 64], 26 | atss_warmup_epoch=4, 27 | iou_type='giou', 28 | use_dfl=True, 29 | reg_max=16, #if use_dfl is False, please set reg_max to 0 30 | distill_weight={ 31 | 'class': 1.0, 32 | 'dfl': 1.0, 33 | }, 34 | ) 35 | ) 36 | 37 | solver = dict( 38 | optim='SGD', 39 | lr_scheduler='Cosine', 40 | lr0=0.0032, 41 | lrf=0.12, 42 | momentum=0.843, 43 | weight_decay=0.00036, 44 | warmup_epochs=2.0, 45 | warmup_momentum=0.5, 46 | warmup_bias_lr=0.05 47 | ) 48 | 49 | data_aug = dict( 50 | hsv_h=0.0138, 51 | hsv_s=0.664, 52 | hsv_v=0.464, 53 | degrees=0.373, 54 | translate=0.245, 55 | scale=0.898, 56 | shear=0.602, 57 | flipud=0.00856, 58 | fliplr=0.5, 59 | mosaic=1.0, 60 | mixup=0.243, 61 | ) 62 | -------------------------------------------------------------------------------- /configs/yolov6m_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6m model 2 | model = dict( 3 | type='YOLOv6m', 4 | pretrained='weights/yolov6m.pt', 5 | depth_multiple=0.60, 6 | width_multiple=0.75, 7 | backbone=dict( 8 | type='CSPBepBackbone', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | csp_e=float(2)/3, 12 | fuse_P2=True, 13 | ), 14 | neck=dict( 15 | type='CSPRepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | csp_e=float(2)/3, 19 | ), 20 | head=dict( 21 | type='EffiDeHead', 22 | in_channels=[128, 256, 512], 23 | num_layers=3, 24 | begin_indices=24, 25 | anchors=3, 26 | anchors_init=[[10,13, 19,19, 33,23], 27 | [30,61, 59,59, 59,119], 28 | [116,90, 185,185, 373,326]], 29 | out_indices=[17, 20, 23], 30 | strides=[8, 16, 32], 31 | atss_warmup_epoch=0, 32 | iou_type='giou', 33 | use_dfl=True, 34 | reg_max=16, #if use_dfl is False, please set reg_max to 0 35 | distill_weight={ 36 | 'class': 0.8, 37 | 'dfl': 1.0, 38 | }, 39 | ) 40 | ) 41 | 42 | solver = dict( 43 | optim='SGD', 44 | lr_scheduler='Cosine', 45 | lr0=0.0032, 46 | lrf=0.12, 47 | momentum=0.843, 48 | weight_decay=0.00036, 49 | warmup_epochs=2.0, 50 | warmup_momentum=0.5, 51 | warmup_bias_lr=0.05 52 | ) 53 | 54 | data_aug = dict( 55 | hsv_h=0.0138, 56 | hsv_s=0.664, 57 | hsv_v=0.464, 58 | degrees=0.373, 59 | translate=0.245, 60 | scale=0.898, 61 | shear=0.602, 62 | flipud=0.00856, 63 | fliplr=0.5, 64 | mosaic=1.0, 65 | mixup=0.243, 66 | ) 67 | -------------------------------------------------------------------------------- /configs/yolov6n.py: -------------------------------------------------------------------------------- 1 | # YOLOv6n model 2 | model = dict( 3 | type='YOLOv6n', 4 | pretrained=None, 5 | depth_multiple=0.33, 6 | width_multiple=0.25, 7 | backbone=dict( 8 | type='EfficientRep', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | fuse_P2=True, 12 | cspsppf=True, 13 | ), 14 | neck=dict( 15 | type='RepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | ), 19 | head=dict( 20 | type='EffiDeHead', 21 | in_channels=[128, 256, 512], 22 | num_layers=3, 23 | begin_indices=24, 24 | anchors=3, 25 | anchors_init=[[10,13, 19,19, 33,23], 26 | [30,61, 59,59, 59,119], 27 | [116,90, 185,185, 373,326]], 28 | out_indices=[17, 20, 23], 29 | strides=[8, 16, 32], 30 | atss_warmup_epoch=0, 31 | iou_type='siou', 32 | use_dfl=False, # set to True if you want to further train with distillation 33 | reg_max=0, # set to 16 if you want to further train with distillation 34 | distill_weight={ 35 | 'class': 1.0, 36 | 'dfl': 1.0, 37 | }, 38 | ) 39 | ) 40 | 41 | solver = dict( 42 | optim='SGD', 43 | lr_scheduler='Cosine', 44 | lr0=0.02, 45 | lrf=0.01, 46 | momentum=0.937, 47 | weight_decay=0.0005, 48 | warmup_epochs=3.0, 49 | warmup_momentum=0.8, 50 | warmup_bias_lr=0.1 51 | ) 52 | 53 | data_aug = dict( 54 | hsv_h=0.015, 55 | hsv_s=0.7, 56 | hsv_v=0.4, 57 | degrees=0.0, 58 | translate=0.1, 59 | scale=0.5, 60 | shear=0.0, 61 | flipud=0.0, 62 | fliplr=0.5, 63 | mosaic=1.0, 64 | mixup=0.0, 65 | ) 66 | -------------------------------------------------------------------------------- /configs/yolov6n6.py: -------------------------------------------------------------------------------- 1 | # YOLOv6n model 2 | model = dict( 3 | type='YOLOv6n6', 4 | pretrained=None, 5 | depth_multiple=0.33, 6 | width_multiple=0.25, 7 | backbone=dict( 8 | type='EfficientRep6', 9 | num_repeats=[1, 6, 12, 18, 6, 6], 10 | out_channels=[64, 128, 256, 512, 768, 1024], 11 | fuse_P2=True, # if use RepBiFPANNeck6, please set fuse_P2 to True. 12 | cspsppf=True, 13 | ), 14 | neck=dict( 15 | type='RepBiFPANNeck6', 16 | num_repeats=[12, 12, 12, 12, 12, 12], 17 | out_channels=[512, 256, 128, 256, 512, 1024], 18 | ), 19 | head=dict( 20 | type='EffiDeHead', 21 | in_channels=[128, 256, 512, 1024], 22 | num_layers=4, 23 | anchors=1, 24 | strides=[8, 16, 32, 64], 25 | atss_warmup_epoch=4, 26 | iou_type='siou', 27 | use_dfl=False, 28 | reg_max=0 #if use_dfl is False, please set reg_max to 0 29 | ) 30 | ) 31 | 32 | solver = dict( 33 | optim='SGD', 34 | lr_scheduler='Cosine', 35 | lr0=0.02, 36 | lrf=0.01, 37 | momentum=0.937, 38 | weight_decay=0.0005, 39 | warmup_epochs=3.0, 40 | warmup_momentum=0.8, 41 | warmup_bias_lr=0.1 42 | ) 43 | 44 | data_aug = dict( 45 | hsv_h=0.015, 46 | hsv_s=0.7, 47 | hsv_v=0.4, 48 | degrees=0.0, 49 | translate=0.1, 50 | scale=0.5, 51 | shear=0.0, 52 | flipud=0.0, 53 | fliplr=0.5, 54 | mosaic=1.0, 55 | mixup=0.0, 56 | ) 57 | -------------------------------------------------------------------------------- /configs/yolov6n6_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6n model 2 | model = dict( 3 | type='YOLOv6n6', 4 | pretrained='weights/yolov6n6.pt', 5 | depth_multiple=0.33, 6 | width_multiple=0.25, 7 | backbone=dict( 8 | type='EfficientRep6', 9 | num_repeats=[1, 6, 12, 18, 6, 6], 10 | out_channels=[64, 128, 256, 512, 768, 1024], 11 | fuse_P2=True, # if use RepBiFPANNeck6, please set fuse_P2 to True. 12 | cspsppf=True, 13 | ), 14 | neck=dict( 15 | type='RepBiFPANNeck6', 16 | num_repeats=[12, 12, 12, 12, 12, 12], 17 | out_channels=[512, 256, 128, 256, 512, 1024], 18 | ), 19 | head=dict( 20 | type='EffiDeHead', 21 | in_channels=[128, 256, 512, 1024], 22 | num_layers=4, 23 | anchors=1, 24 | strides=[8, 16, 32, 64], 25 | atss_warmup_epoch=4, 26 | iou_type='siou', 27 | use_dfl=False, 28 | reg_max=0 #if use_dfl is False, please set reg_max to 0 29 | ) 30 | ) 31 | 32 | solver = dict( 33 | optim='SGD', 34 | lr_scheduler='Cosine', 35 | lr0=0.0032, 36 | lrf=0.12, 37 | momentum=0.843, 38 | weight_decay=0.00036, 39 | warmup_epochs=2.0, 40 | warmup_momentum=0.5, 41 | warmup_bias_lr=0.05 42 | ) 43 | 44 | data_aug = dict( 45 | hsv_h=0.0138, 46 | hsv_s=0.664, 47 | hsv_v=0.464, 48 | degrees=0.373, 49 | translate=0.245, 50 | scale=0.898, 51 | shear=0.602, 52 | flipud=0.00856, 53 | fliplr=0.5, 54 | mosaic=1.0, 55 | mixup=0.243, 56 | ) 57 | -------------------------------------------------------------------------------- /configs/yolov6n_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6s model 2 | model = dict( 3 | type='YOLOv6n', 4 | pretrained='weights/yolov6n.pt', 5 | depth_multiple=0.33, 6 | width_multiple=0.25, 7 | backbone=dict( 8 | type='EfficientRep', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | fuse_P2=True, 12 | cspsppf=True, 13 | ), 14 | neck=dict( 15 | type='RepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | ), 19 | head=dict( 20 | type='EffiDeHead', 21 | in_channels=[128, 256, 512], 22 | num_layers=3, 23 | begin_indices=24, 24 | anchors=3, 25 | anchors_init=[[10,13, 19,19, 33,23], 26 | [30,61, 59,59, 59,119], 27 | [116,90, 185,185, 373,326]], 28 | out_indices=[17, 20, 23], 29 | strides=[8, 16, 32], 30 | atss_warmup_epoch=0, 31 | iou_type='siou', 32 | use_dfl=False, # set to True if you want to further train with distillation 33 | reg_max=0, # set to 16 if you want to further train with distillation 34 | distill_weight={ 35 | 'class': 1.0, 36 | 'dfl': 1.0, 37 | }, 38 | ) 39 | ) 40 | 41 | solver = dict( 42 | optim='SGD', 43 | lr_scheduler='Cosine', 44 | lr0=0.0032, 45 | lrf=0.12, 46 | momentum=0.843, 47 | weight_decay=0.00036, 48 | warmup_epochs=2.0, 49 | warmup_momentum=0.5, 50 | warmup_bias_lr=0.05 51 | ) 52 | 53 | data_aug = dict( 54 | hsv_h=0.0138, 55 | hsv_s=0.664, 56 | hsv_v=0.464, 57 | degrees=0.373, 58 | translate=0.245, 59 | scale=0.898, 60 | shear=0.602, 61 | flipud=0.00856, 62 | fliplr=0.5, 63 | mosaic=1.0, 64 | mixup=0.243, 65 | ) 66 | -------------------------------------------------------------------------------- /configs/yolov6s.py: -------------------------------------------------------------------------------- 1 | # YOLOv6s model 2 | model = dict( 3 | type='YOLOv6s', 4 | pretrained=None, 5 | depth_multiple=0.33, 6 | width_multiple=0.50, 7 | backbone=dict( 8 | type='EfficientRep', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | fuse_P2=True, 12 | cspsppf=True, 13 | ), 14 | neck=dict( 15 | type='RepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | ), 19 | head=dict( 20 | type='EffiDeHead', 21 | in_channels=[128, 256, 512], 22 | num_layers=3, 23 | begin_indices=24, 24 | anchors=3, 25 | anchors_init=[[10,13, 19,19, 33,23], 26 | [30,61, 59,59, 59,119], 27 | [116,90, 185,185, 373,326]], 28 | out_indices=[17, 20, 23], 29 | strides=[8, 16, 32], 30 | atss_warmup_epoch=0, 31 | iou_type='giou', 32 | use_dfl=False, # set to True if you want to further train with distillation 33 | reg_max=0, # set to 16 if you want to further train with distillation 34 | distill_weight={ 35 | 'class': 1.0, 36 | 'dfl': 1.0, 37 | }, 38 | ) 39 | ) 40 | 41 | solver = dict( 42 | optim='SGD', 43 | lr_scheduler='Cosine', 44 | lr0=0.01, 45 | lrf=0.01, 46 | momentum=0.937, 47 | weight_decay=0.0005, 48 | warmup_epochs=3.0, 49 | warmup_momentum=0.8, 50 | warmup_bias_lr=0.1 51 | ) 52 | 53 | data_aug = dict( 54 | hsv_h=0.015, 55 | hsv_s=0.7, 56 | hsv_v=0.4, 57 | degrees=0.0, 58 | translate=0.1, 59 | scale=0.5, 60 | shear=0.0, 61 | flipud=0.0, 62 | fliplr=0.5, 63 | mosaic=1.0, 64 | mixup=0.0, 65 | ) 66 | -------------------------------------------------------------------------------- /configs/yolov6s6.py: -------------------------------------------------------------------------------- 1 | # YOLOv6n model 2 | model = dict( 3 | type='YOLOv6s6', 4 | pretrained=None, 5 | depth_multiple=0.33, 6 | width_multiple=0.50, 7 | backbone=dict( 8 | type='EfficientRep6', 9 | num_repeats=[1, 6, 12, 18, 6, 6], 10 | out_channels=[64, 128, 256, 512, 768, 1024], 11 | fuse_P2=True, # if use RepBiFPANNeck6, please set fuse_P2 to True. 12 | cspsppf=True, 13 | ), 14 | neck=dict( 15 | type='RepBiFPANNeck6', 16 | num_repeats=[12, 12, 12, 12, 12, 12], 17 | out_channels=[512, 256, 128, 256, 512, 1024], 18 | ), 19 | head=dict( 20 | type='EffiDeHead', 21 | in_channels=[128, 256, 512, 1024], 22 | num_layers=4, 23 | anchors=1, 24 | strides=[8, 16, 32, 64], 25 | atss_warmup_epoch=4, 26 | iou_type='giou', 27 | use_dfl=False, 28 | reg_max=0 #if use_dfl is False, please set reg_max to 0 29 | ) 30 | ) 31 | 32 | solver = dict( 33 | optim='SGD', 34 | lr_scheduler='Cosine', 35 | lr0=0.01, 36 | lrf=0.01, 37 | momentum=0.937, 38 | weight_decay=0.0005, 39 | warmup_epochs=3.0, 40 | warmup_momentum=0.8, 41 | warmup_bias_lr=0.1 42 | ) 43 | 44 | data_aug = dict( 45 | hsv_h=0.015, 46 | hsv_s=0.7, 47 | hsv_v=0.4, 48 | degrees=0.0, 49 | translate=0.1, 50 | scale=0.5, 51 | shear=0.0, 52 | flipud=0.0, 53 | fliplr=0.5, 54 | mosaic=1.0, 55 | mixup=0.0, 56 | ) 57 | -------------------------------------------------------------------------------- /configs/yolov6s6_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6n model 2 | model = dict( 3 | type='YOLOv6s6', 4 | pretrained='weights/yolov6s6.pt', 5 | depth_multiple=0.33, 6 | width_multiple=0.50, 7 | backbone=dict( 8 | type='EfficientRep6', 9 | num_repeats=[1, 6, 12, 18, 6, 6], 10 | out_channels=[64, 128, 256, 512, 768, 1024], 11 | fuse_P2=True, # if use RepBiFPANNeck6, please set fuse_P2 to True. 12 | cspsppf=True, 13 | ), 14 | neck=dict( 15 | type='RepBiFPANNeck6', 16 | num_repeats=[12, 12, 12, 12, 12, 12], 17 | out_channels=[512, 256, 128, 256, 512, 1024], 18 | ), 19 | head=dict( 20 | type='EffiDeHead', 21 | in_channels=[128, 256, 512, 1024], 22 | num_layers=4, 23 | anchors=1, 24 | strides=[8, 16, 32, 64], 25 | atss_warmup_epoch=4, 26 | iou_type='giou', 27 | use_dfl=False, 28 | reg_max=0 #if use_dfl is False, please set reg_max to 0 29 | ) 30 | ) 31 | 32 | solver = dict( 33 | optim='SGD', 34 | lr_scheduler='Cosine', 35 | lr0=0.0032, 36 | lrf=0.12, 37 | momentum=0.843, 38 | weight_decay=0.00036, 39 | warmup_epochs=2.0, 40 | warmup_momentum=0.5, 41 | warmup_bias_lr=0.05 42 | ) 43 | 44 | data_aug = dict( 45 | hsv_h=0.0138, 46 | hsv_s=0.664, 47 | hsv_v=0.464, 48 | degrees=0.373, 49 | translate=0.245, 50 | scale=0.898, 51 | shear=0.602, 52 | flipud=0.00856, 53 | fliplr=0.5, 54 | mosaic=1.0, 55 | mixup=0.243, 56 | ) 57 | -------------------------------------------------------------------------------- /configs/yolov6s_finetune.py: -------------------------------------------------------------------------------- 1 | # YOLOv6s model 2 | model = dict( 3 | type='YOLOv6s', 4 | pretrained='weights/yolov6s.pt', 5 | depth_multiple=0.33, 6 | width_multiple=0.50, 7 | backbone=dict( 8 | type='EfficientRep', 9 | num_repeats=[1, 6, 12, 18, 6], 10 | out_channels=[64, 128, 256, 512, 1024], 11 | fuse_P2=True, 12 | cspsppf=True, 13 | ), 14 | neck=dict( 15 | type='RepBiFPANNeck', 16 | num_repeats=[12, 12, 12, 12], 17 | out_channels=[256, 128, 128, 256, 256, 512], 18 | ), 19 | head=dict( 20 | type='EffiDeHead', 21 | in_channels=[128, 256, 512], 22 | num_layers=3, 23 | begin_indices=24, 24 | anchors=3, 25 | anchors_init=[[10,13, 19,19, 33,23], 26 | [30,61, 59,59, 59,119], 27 | [116,90, 185,185, 373,326]], 28 | out_indices=[17, 20, 23], 29 | strides=[8, 16, 32], 30 | atss_warmup_epoch=0, 31 | iou_type='giou', 32 | use_dfl=False, # set to True if you want to further train with distillation 33 | reg_max=0, # set to 16 if you want to further train with distillation 34 | distill_weight={ 35 | 'class': 1.0, 36 | 'dfl': 1.0, 37 | }, 38 | ) 39 | ) 40 | 41 | solver = dict( 42 | optim='SGD', 43 | lr_scheduler='Cosine', 44 | lr0=0.0032, 45 | lrf=0.12, 46 | momentum=0.843, 47 | weight_decay=0.00036, 48 | warmup_epochs=2.0, 49 | warmup_momentum=0.5, 50 | warmup_bias_lr=0.05 51 | ) 52 | 53 | data_aug = dict( 54 | hsv_h=0.0138, 55 | hsv_s=0.664, 56 | hsv_v=0.464, 57 | degrees=0.373, 58 | translate=0.245, 59 | scale=0.898, 60 | shear=0.602, 61 | flipud=0.00856, 62 | fliplr=0.5, 63 | mosaic=1.0, 64 | mixup=0.243, 65 | ) 66 | -------------------------------------------------------------------------------- /data/coco.yaml: -------------------------------------------------------------------------------- 1 | # COCO 2017 dataset http://cocodataset.org 2 | 3 | # If you are using Windows system, 4 | # the dataset path should be like this: 5 | # train: d:\dataset\coco\images\train2017 6 | # because windows use "\" as separator, linux use "/" as separator. 7 | 8 | train: ../coco/images/train2017 # 118287 images 9 | val: ../coco/images/val2017 # 5000 images 10 | test: ../coco/images/test2017 11 | anno_path: ../coco/annotations/instances_val2017.json 12 | 13 | # number of classes 14 | nc: 80 15 | # whether it is coco dataset, only coco dataset should be set to True. 16 | is_coco: True 17 | 18 | # class names 19 | names: [ 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 20 | 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 21 | 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 22 | 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 23 | 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 24 | 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 25 | 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 26 | 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 27 | 'hair drier', 'toothbrush' ] 28 | -------------------------------------------------------------------------------- /data/dataset.yaml: -------------------------------------------------------------------------------- 1 | # Please insure that your custom_dataset are put in same parent dir with YOLOv6_DIR 2 | train: ../custom_dataset/images/train # train images 3 | val: ../custom_dataset/images/val # val images 4 | test: ../custom_dataset/images/test # test images (optional) 5 | 6 | # whether it is coco dataset, only coco dataset should be set to True. 7 | is_coco: False 8 | # Classes 9 | nc: 20 # number of classes 10 | names: ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 11 | 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor'] # class names 12 | -------------------------------------------------------------------------------- /data/images/image1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/data/images/image1.jpg -------------------------------------------------------------------------------- /data/images/image2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/data/images/image2.jpg -------------------------------------------------------------------------------- /data/images/image3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/data/images/image3.jpg -------------------------------------------------------------------------------- /data/voc.yaml: -------------------------------------------------------------------------------- 1 | # Please insure that your custom_dataset are put in same parent dir with YOLOv6_DIR 2 | train: VOCdevkit/voc_07_12/images/train # train images 3 | val: VOCdevkit/voc_07_12/images/val # val images 4 | test: VOCdevkit/voc_07_12/images/val # test images (optional) 5 | 6 | # whether it is coco dataset, only coco dataset should be set to True. 7 | is_coco: False 8 | # Classes 9 | nc: 20 # number of classes 10 | names: ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 11 | 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor'] # class names 12 | -------------------------------------------------------------------------------- /deploy/NCNN/Android/README.md: -------------------------------------------------------------------------------- 1 | # ncnn-android-yolov6 2 | 3 | The YOLOv6 object detection demo of `Android`. 4 | You can directly download apk file from [Android Demo here](https://github.com/meituan/YOLOv6/releases/download/0.4.0/yolov6-android-demo.apk), many thanks to [triple Mu](https://github.com/triple-Mu). 5 | 6 | This is a sample ncnn android project, it depends on ncnn library and opencv 7 | 8 | - [ncnn](https://github.com/Tencent/ncnn) 9 | 10 | - [opencv-mobile](https://github.com/nihui/opencv-mobile) 11 | 12 | 13 | ## How to build and run 14 | ### step1 15 | 16 | * Download [ncnn-YYYYMMDD-android-vulkan.zip](https://github.com/Tencent/ncnn/releases) or build ncnn for android yourself 17 | * Extract `ncnn-YYYYMMDD-android-vulkan.zip` into `app/src/main/jni` and change the `ncnn_DIR` path to yours in `app/src/main/jni/CMakeLists.txt` 18 | 19 | ### step2 20 | 21 | * Download [opencv-mobile-XYZ-android.zip](https://github.com/nihui/opencv-mobile) 22 | * Extract `opencv-mobile-XYZ-android.zip` into `app/src/main/jni` and change the `OpenCV_DIR` path to yours in `app/src/main/jni/CMakeLists.txt` 23 | 24 | ### step3 25 | * download [AndroidAssets.zip 26 | ](https://github.com/meituan/YOLOv6/releases/download/0.4.0/AndroidAssets.zip) 27 | * Unzip `AndroidAssets.zip`, you will get a directory named as `assets`, move it 28 | into `app/src/`. 29 | 30 | ### step4 31 | * Open this project with Android Studio, build it and enjoy! 32 | 33 | ## some notes 34 | * Android ndk camera is used for best efficiency 35 | * Crash may happen on very old devices for lacking HAL3 camera interface 36 | * All models are manually modified to accept dynamic input shape 37 | * Most small models run slower on GPU than on CPU, this is common 38 | * FPS may be lower in dark environment because of longer camera exposure time 39 | 40 | ## Reference: 41 | - [ncnn-android-nanodet](https://github.com/nihui/ncnn-android-nanodet) 42 | - [ncnn](https://github.com/Tencent/ncnn) 43 | -------------------------------------------------------------------------------- /deploy/NCNN/Android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 24 5 | 6 | defaultConfig { 7 | applicationId "com.tencent.yolov6ncnn" 8 | archivesBaseName = "$applicationId" 9 | 10 | minSdkVersion 24 11 | } 12 | 13 | externalNativeBuild { 14 | cmake { 15 | version "3.10.2" 16 | path file('src/main/jni/CMakeLists.txt') 17 | } 18 | } 19 | 20 | dependencies { 21 | implementation 'com.android.support:support-v4:24.0.0' 22 | } 23 | ndkVersion '24.0.8215888' 24 | compileOptions { 25 | sourceCompatibility JavaVersion.VERSION_1_8 26 | targetCompatibility JavaVersion.VERSION_1_8 27 | } 28 | namespace 'com.tencent.yolov6ncnn' 29 | } 30 | -------------------------------------------------------------------------------- /deploy/NCNN/Android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /deploy/NCNN/Android/app/src/main/assets/yolov6-lite-l0.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/deploy/NCNN/Android/app/src/main/assets/yolov6-lite-l0.bin -------------------------------------------------------------------------------- /deploy/NCNN/Android/app/src/main/assets/yolov6-lite-l1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/deploy/NCNN/Android/app/src/main/assets/yolov6-lite-l1.bin -------------------------------------------------------------------------------- /deploy/NCNN/Android/app/src/main/assets/yolov6-lite-l2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/deploy/NCNN/Android/app/src/main/assets/yolov6-lite-l2.bin -------------------------------------------------------------------------------- /deploy/NCNN/Android/app/src/main/assets/yolov6-lite-m.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/deploy/NCNN/Android/app/src/main/assets/yolov6-lite-m.bin -------------------------------------------------------------------------------- /deploy/NCNN/Android/app/src/main/assets/yolov6-lite-s.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meituan/YOLOv6/e86a483f3f6bded25d45970b56831345a99744a4/deploy/NCNN/Android/app/src/main/assets/yolov6-lite-s.bin -------------------------------------------------------------------------------- /deploy/NCNN/Android/app/src/main/java/com/tencent/yolov6ncnn/Yolov6Ncnn.java: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making ncnn available. 2 | // 3 | // Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. 4 | // 5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // https://opensource.org/licenses/BSD-3-Clause 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | package com.tencent.yolov6ncnn; 16 | 17 | import android.content.res.AssetManager; 18 | import android.view.Surface; 19 | 20 | public class Yolov6Ncnn 21 | { 22 | public native boolean loadModel(AssetManager mgr, int modelid, int cpugpu); 23 | public native boolean openCamera(int facing); 24 | public native boolean closeCamera(); 25 | public native boolean setOutputWindow(Surface surface); 26 | 27 | static { 28 | System.loadLibrary("yolov6ncnn"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /deploy/NCNN/Android/app/src/main/jni/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(yolov6ncnn) 2 | 3 | cmake_minimum_required(VERSION 3.10) 4 | 5 | set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv-mobile-4.6.0-android/sdk/native/jni) 6 | find_package(OpenCV REQUIRED core imgproc) 7 | 8 | set(ncnn_DIR ${CMAKE_SOURCE_DIR}/ncnn-20230223-android-vulkan/${ANDROID_ABI}/lib/cmake/ncnn) 9 | find_package(ncnn REQUIRED) 10 | 11 | add_library(yolov6ncnn SHARED yolov6ncnn.cpp yolo.cpp ndkcamera.cpp) 12 | 13 | target_link_libraries(yolov6ncnn ncnn ${OpenCV_LIBS} camera2ndk mediandk) 14 | -------------------------------------------------------------------------------- /deploy/NCNN/Android/app/src/main/jni/ndkcamera.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making ncnn available. 2 | // 3 | // Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. 4 | // 5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // https://opensource.org/licenses/BSD-3-Clause 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef NDKCAMERA_H 16 | #define NDKCAMERA_H 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | class NdkCamera 29 | { 30 | public: 31 | NdkCamera(); 32 | virtual ~NdkCamera(); 33 | 34 | // facing 0=front 1=back 35 | int open(int camera_facing = 0); 36 | void close(); 37 | 38 | virtual void on_image(const cv::Mat& rgb) const; 39 | 40 | virtual void on_image(const unsigned char* nv21, int nv21_width, int nv21_height) const; 41 | 42 | public: 43 | int camera_facing; 44 | int camera_orientation; 45 | 46 | private: 47 | ACameraManager* camera_manager; 48 | ACameraDevice* camera_device; 49 | AImageReader* image_reader; 50 | ANativeWindow* image_reader_surface; 51 | ACameraOutputTarget* image_reader_target; 52 | ACaptureRequest* capture_request; 53 | ACaptureSessionOutputContainer* capture_session_output_container; 54 | ACaptureSessionOutput* capture_session_output; 55 | ACameraCaptureSession* capture_session; 56 | }; 57 | 58 | class NdkCameraWindow : public NdkCamera 59 | { 60 | public: 61 | NdkCameraWindow(); 62 | virtual ~NdkCameraWindow(); 63 | 64 | void set_window(ANativeWindow* win); 65 | 66 | virtual void on_image_render(cv::Mat& rgb) const; 67 | 68 | virtual void on_image(const unsigned char* nv21, int nv21_width, int nv21_height) const; 69 | 70 | public: 71 | mutable int accelerometer_orientation; 72 | 73 | private: 74 | ASensorManager* sensor_manager; 75 | mutable ASensorEventQueue* sensor_event_queue; 76 | const ASensor* accelerometer_sensor; 77 | ANativeWindow* win; 78 | }; 79 | 80 | #endif // NDKCAMERA_H 81 | -------------------------------------------------------------------------------- /deploy/NCNN/Android/app/src/main/jni/yolo.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making ncnn available. 2 | // 3 | // Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. 4 | // 5 | // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // https://opensource.org/licenses/BSD-3-Clause 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef YOLO_H 16 | #define YOLO_H 17 | 18 | #include 19 | 20 | #include 21 | 22 | struct Object 23 | { 24 | cv::Rect_ rect; 25 | int label; 26 | float prob; 27 | }; 28 | 29 | class Yolo 30 | { 31 | public: 32 | Yolo(); 33 | 34 | int load(const char* modeltype, const int *target_size, const float* mean_vals, const float* norm_vals, bool use_gpu = false); 35 | 36 | int load(AAssetManager* mgr, const char* modeltype, const int *target_size, const float* mean_vals, const float* norm_vals, bool use_gpu = false); 37 | 38 | int detect(const cv::Mat& rgb, std::vector& objects, float prob_threshold = 0.25f, float nms_threshold = 0.45f); 39 | 40 | int draw(cv::Mat& rgb, const std::vector& objects); 41 | 42 | private: 43 | ncnn::Net yolo; 44 | int net_h; 45 | int net_w; 46 | float mean_vals[3]; 47 | float norm_vals[3]; 48 | ncnn::UnlockedPoolAllocator blob_pool_allocator; 49 | ncnn::PoolAllocator workspace_pool_allocator; 50 | }; 51 | 52 | #endif // NANODET_H 53 | -------------------------------------------------------------------------------- /deploy/NCNN/Android/app/src/main/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 |