meow2018 commited on
Commit
11ef510
·
verified ·
1 Parent(s): b6465b3

first commit

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. README.md +147 -7
  2. app.py +69 -0
  3. assets/yolo_arch.png +0 -0
  4. assets/yolo_logo.png +0 -0
  5. configs/deploy/detection_onnxruntime-fp16_dynamic.py +18 -0
  6. configs/deploy/detection_onnxruntime-int8_dynamic.py +20 -0
  7. configs/deploy/detection_onnxruntime_static.py +18 -0
  8. configs/deploy/detection_tensorrt-fp16_static-640x640.py +38 -0
  9. configs/deploy/detection_tensorrt-int8_static-640x640.py +30 -0
  10. configs/finetune_coco/yolo_world_l_t2i_bn_2e-4_100e_4x8gpus_coco_finetune.py +183 -0
  11. configs/finetune_coco/yolo_world_m_t2i_bn_2e-4_100e_4x8gpus_coco_finetune.py +183 -0
  12. configs/finetune_coco/yolo_world_s_t2i_bn_2e-4_100e_4x8gpus_coco_finetune.py +183 -0
  13. configs/pretrain/yolo_world_l_dual_3block_l2norm_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py +173 -0
  14. configs/pretrain/yolo_world_l_t2i_bn_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py +182 -0
  15. configs/pretrain/yolo_world_m_dual_3block_l2norm_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py +173 -0
  16. configs/pretrain/yolo_world_m_t2i_bn_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py +171 -0
  17. configs/pretrain/yolo_world_s_dual_l2norm_3block_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py +173 -0
  18. configs/pretrain/yolo_world_s_t2i_bn_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py +172 -0
  19. configs/scaleup/yolo_world_l_t2i_bn_2e-4_20e_4x8gpus_obj365v1_goldg_train_lvis_minival_s1024.py +216 -0
  20. configs/scaleup/yolo_world_l_t2i_bn_2e-4_20e_4x8gpus_obj365v1_goldg_train_lvis_minival_s1280.py +216 -0
  21. configs/scaleup/yolo_world_l_t2i_bn_2e-4_20e_4x8gpus_obj365v1_goldg_train_lvis_minival_s1280_v2.py +216 -0
  22. deploy/__init__.py +1 -0
  23. deploy/models/__init__.py +4 -0
  24. docs/data.md +19 -0
  25. docs/deploy.md +0 -0
  26. docs/install.md +0 -0
  27. docs/training.md +0 -0
  28. requirements.txt +25 -0
  29. setup.py +190 -0
  30. third_party/mmyolo/.circleci/config.yml +34 -0
  31. third_party/mmyolo/.circleci/docker/Dockerfile +11 -0
  32. third_party/mmyolo/.circleci/test.yml +213 -0
  33. third_party/mmyolo/.dev_scripts/gather_models.py +312 -0
  34. third_party/mmyolo/.dev_scripts/print_registers.py +448 -0
  35. third_party/mmyolo/.github/CODE_OF_CONDUCT.md +76 -0
  36. third_party/mmyolo/.github/CONTRIBUTING.md +1 -0
  37. third_party/mmyolo/.github/ISSUE_TEMPLATE/1-bug-report.yml +67 -0
  38. third_party/mmyolo/.github/ISSUE_TEMPLATE/2-feature-request.yml +32 -0
  39. third_party/mmyolo/.github/ISSUE_TEMPLATE/3-new-model.yml +30 -0
  40. third_party/mmyolo/.github/ISSUE_TEMPLATE/4-documentation.yml +22 -0
  41. third_party/mmyolo/.github/ISSUE_TEMPLATE/5-reimplementation.yml +87 -0
  42. third_party/mmyolo/.github/ISSUE_TEMPLATE/config.yml +9 -0
  43. third_party/mmyolo/.github/pull_request_template.md +25 -0
  44. third_party/mmyolo/.github/workflows/deploy.yml +28 -0
  45. third_party/mmyolo/.gitignore +126 -0
  46. third_party/mmyolo/.pre-commit-config-zh-cn.yaml +60 -0
  47. third_party/mmyolo/.pre-commit-config.yaml +60 -0
  48. third_party/mmyolo/.readthedocs.yml +8 -0
  49. third_party/mmyolo/LICENSE +674 -0
  50. third_party/mmyolo/MANIFEST.in +6 -0
README.md CHANGED
@@ -1,13 +1,153 @@
1
  ---
2
- title: My Yolow
3
- emoji: 🚀
4
- colorFrom: yellow
5
  colorTo: blue
6
- sdk: gradio
7
- sdk_version: 4.21.0
8
- app_file: app.py
9
  pinned: false
10
  license: apache-2.0
 
 
 
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: YOLO World
3
+ emoji: 🔥
4
+ colorFrom: pink
5
  colorTo: blue
 
 
 
6
  pinned: false
7
  license: apache-2.0
8
+ app_file: app.py
9
+ sdk: gradio
10
+ sdk_version: 4.16.0
11
  ---
12
 
13
+ <div align="center">
14
+ <center>
15
+ <img width=500px src="./assets/yolo_logo.png">
16
+ </center>
17
+ <br>
18
+ <a href="https://scholar.google.com/citations?hl=zh-CN&user=PH8rJHYAAAAJ">Tianheng Cheng*</a><sup><span>2,3</span></sup>,
19
+ <a href="https://linsong.info/">Lin Song*</a><sup><span>1</span></sup>,
20
+ <a href="">Yixiao Ge</a><sup><span>1,2</span></sup>,
21
+ <a href="">Xinggang Wang</a><sup><span>3</span></sup>,
22
+ <a href="http://eic.hust.edu.cn/professor/liuwenyu/"> Wenyu Liu</a><sup><span>3</span></sup>,
23
+ <a href="">Ying Shan</a><sup><span>1,2</span></sup>
24
+ </br>
25
+
26
+ <sup>1</sup> Tencent AI Lab, <sup>2</sup> ARC Lab, Tencent PCG
27
+ <sup>3</sup> Huazhong University of Science and Technology
28
+ <br>
29
+ <div>
30
+
31
+ [![arxiv paper](https://img.shields.io/badge/arXiv-Paper-red)](https://arxiv.org/abs/)
32
+ [![video](https://img.shields.io/badge/🤗HugginngFace-Spaces-orange)](https://huggingface.co/)
33
+ [![license](https://img.shields.io/badge/License-GPLv3.0-blue)](LICENSE)
34
+
35
+ </div>
36
+ </div>
37
+
38
+
39
+ ## Updates
40
+
41
+ `[2024-1-25]:` We are excited to launch **YOLO-World**, a cutting-edge real-time open-vocabulary object detector.
42
+
43
+ ## Highlights
44
+
45
+ This repo contains the PyTorch implementation, pre-trained weights, and pre-training/fine-tuning code for YOLO-World.
46
+
47
+ * YOLO-World is pre-trained on large-scale datasets, including detection, grounding, and image-text datasets.
48
+
49
+ * YOLO-World is the next-generation YOLO detector, with a strong open-vocabulary detection capability and grounding ability.
50
+
51
+ * YOLO-World presents a *prompt-then-detect* paradigm for efficient user-vocabulary inference, which re-parameterizes vocabulary embeddings as parameters into the model and achieve superior inference speed. You can try to export your own detection model without extra training or fine-tuning in our [online demo]()!
52
+
53
+
54
+ <center>
55
+ <img width=800px src="./assets/yolo_arch.png">
56
+ </center>
57
+
58
+
59
+ ## Abstract
60
+
61
+ The You Only Look Once (YOLO) series of detectors have established themselves as efficient and practical tools. However, their reliance on predefined and trained object categories limits their applicability in open scenarios. Addressing this limitation, we introduce YOLO-World, an innovative approach that enhances YOLO with open-vocabulary detection capabilities through vision-language modeling and pre-training on large-scale datasets. Specifically, we propose a new Re-parameterizable Vision-Language Path Aggregation Network (RepVL-PAN) and region-text contrastive loss to facilitate the interaction between visual and linguistic information. Our method excels in detecting a wide range of objects in a zero-shot manner with high efficiency. On the challenging LVIS dataset, YOLO-World achieves 35.4 AP with 52.0 FPS on V100, which outperforms many state-of-the-art methods in terms of both accuracy and speed. Furthermore, the fine-tuned YOLO-World achieves remarkable performance on several downstream tasks, including object detection and open-vocabulary instance segmentation.
62
+
63
+
64
+ ## Demo
65
+
66
+
67
+ ## Main Results
68
+
69
+ We've pre-trained YOLO-World-S/M/L from scratch and evaluate on the `LVIS val-1.0` and `LVIS minival`. We provide the pre-trained model weights and training logs for applications/research or re-producing the results.
70
+
71
+ ### Zero-shot Inference on LVIS dataset
72
+
73
+ | model | Pre-train Data | AP | AP<sub>r</sub> | AP<sub>c</sub> | AP<sub>f</sub> | FPS(V100) | weights | log |
74
+ | :---- | :------------- | :-:| :------------: |:-------------: | :-------: | :-----: | :---: | :---: |
75
+ | [YOLO-World-S](./configs/pretrain/yolo_world_s_t2i_bn_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py) | O365+GoldG | 17.6 | 11.9 | 14.5 | 23.2 | - | [wecom](https://drive.weixin.qq.com/s?k=AJEAIQdfAAoREsieRl) | [log]() |
76
+ | [YOLO-World-M](./configs/pretrain/yolo_world_m_t2i_bn_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py) | O365+GoldG | 23.5 | 17.2 | 20.4 | 29.6 | - | [wecom](https://drive.weixin.qq.com/s?k=AJEAIQdfAAoj0byBC0) | [log]() |
77
+ | [YOLO-World-L](./configs/pretrain/yolo_world_l_t2i_bn_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py) | O365+GoldG | 25.7 | 18.7 | 22.6 | 32.2 | - | [wecom](https://drive.weixin.qq.com/s?k=AJEAIQdfAAoK06oxO2) | [log]() |
78
+
79
+ **NOTE:**
80
+ 1. The evaluation results are tested on LVIS minival in a zero-shot manner.
81
+
82
+
83
+ ## Getting started
84
+
85
+ ### 1. Installation
86
+
87
+ YOLO-World is developed based on `torch==1.11.0` `mmyolo==0.6.0` and `mmdetection==3.0.0`.
88
+
89
+ ```bash
90
+ # install key dependencies
91
+ pip install mmdetection==3.0.0 mmengine transformers
92
+
93
+ # clone the repo
94
+ git clone https://xxxx.YOLO-World.git
95
+ cd YOLO-World
96
+
97
+ # install mmyolo
98
+ mkdir third_party
99
+ git clone https://github.com/open-mmlab/mmyolo.git
100
+ cd ..
101
+
102
+ ```
103
+
104
+ ### 2. Preparing Data
105
+
106
+ We provide the details about the pre-training data in [docs/data](./docs/data.md).
107
+
108
+
109
+ ## Training & Evaluation
110
+
111
+ We adopt the default [training](./tools/train.py) or [evaluation](./tools/test.py) scripts of [mmyolo](https://github.com/open-mmlab/mmyolo).
112
+ We provide the configs for pre-training and fine-tuning in `configs/pretrain` and `configs/finetune_coco`.
113
+ Training YOLO-World is easy:
114
+
115
+ ```bash
116
+ chmod +x tools/dist_train.sh
117
+ # sample command for pre-training, use AMP for mixed-precision training
118
+ ./tools/dist_train.sh configs/pretrain/yolo_world_l_t2i_bn_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py 8 --amp
119
+ ```
120
+ **NOTE:** YOLO-World is pre-trained on 4 nodes with 8 GPUs per node (32 GPUs in total). For pre-training, the `node_rank` and `nnodes` for multi-node training should be specified.
121
+
122
+ Evalutating YOLO-World is also easy:
123
+
124
+ ```bash
125
+ chmod +x tools/dist_test.sh
126
+ ./tools/dist_test.sh path/to/config path/to/weights 8
127
+ ```
128
+
129
+ **NOTE:** We mainly evaluate the performance on LVIS-minival for pre-training.
130
+
131
+ ## Deployment
132
+
133
+ We provide the details about deployment for downstream applications in [docs/deployment](./docs/deploy.md).
134
+ You can directly download the ONNX model through the online [demo]() in Huggingface Spaces 🤗.
135
+
136
+ ## Acknowledgement
137
+
138
+ We sincerely thank [mmyolo](https://github.com/open-mmlab/mmyolo), [mmdetection](https://github.com/open-mmlab/mmdetection), and [transformers](https://github.com/huggingface/transformers) for providing their wonderful code to the community!
139
+
140
+ ## Citations
141
+ If you find YOLO-World is useful in your research or applications, please consider giving us a star 🌟 and citing it.
142
+
143
+ ```bibtex
144
+ @article{cheng2024yolow,
145
+ title={YOLO-World: Real-Time Open-Vocabulary Object Detection},
146
+ author={Cheng, Tianheng and Song, Lin and Ge, Yixiao and Liu, Wenyu and Wang, Xinggang and Shan, Ying},
147
+ journal={arXiv preprint arXiv:},
148
+ year={2024}
149
+ }
150
+ ```
151
+
152
+ ## Licence
153
+ YOLO-World is under the GPL-v3 Licence and is supported for comercial usage.
app.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ os.system("pip uninstall -y mmcv-full")
3
+ os.system("mim install 'mmengine>=0.6.0'")
4
+ # os.system("pip install mmcv==2.0.1 -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.0/index.html")
5
+ os.system("mim install 'mmcv-lite==2.0.1'")
6
+ os.system("mim install 'mmdet>=3.0.0,<4.0.0'")
7
+ os.system("mim install 'mmyolo'")
8
+ os.system("pip install -e .")
9
+
10
+ import argparse
11
+ import os.path as osp
12
+
13
+ from mmengine.config import Config, DictAction
14
+ from mmengine.runner import Runner
15
+ from mmengine.dataset import Compose
16
+ from mmyolo.registry import RUNNERS
17
+
18
+ from tools.demo import demo
19
+
20
+
21
+ def parse_args():
22
+ parser = argparse.ArgumentParser(
23
+ description='YOLO-World Demo')
24
+ parser.add_argument('--config', default='configs/pretrain/yolo_world_l_t2i_bn_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py')
25
+ parser.add_argument('--checkpoint', default='yolow-v8_l_clipv2_frozen_t2iv2_bn_o365_goldg_pretrain.pth')
26
+ parser.add_argument(
27
+ '--work-dir',
28
+ help='the directory to save the file containing evaluation metrics')
29
+ parser.add_argument(
30
+ '--cfg-options',
31
+ nargs='+',
32
+ action=DictAction,
33
+ help='override some settings in the used config, the key-value pair '
34
+ 'in xxx=yyy format will be merged into config file. If the value to '
35
+ 'be overwritten is a list, it should be like key="[a,b]" or key=a,b '
36
+ 'It also allows nested list/tuple values, e.g. key="[(a,b),(c,d)]" '
37
+ 'Note that the quotation marks are necessary and that no white space '
38
+ 'is allowed.')
39
+ args = parser.parse_args()
40
+ return args
41
+
42
+
43
+ if __name__ == '__main__':
44
+ args = parse_args()
45
+
46
+ # load config
47
+ cfg = Config.fromfile(args.config)
48
+ if args.cfg_options is not None:
49
+ cfg.merge_from_dict(args.cfg_options)
50
+
51
+ if args.work_dir is not None:
52
+ cfg.work_dir = args.work_dir
53
+ elif cfg.get('work_dir', None) is None:
54
+ cfg.work_dir = osp.join('./work_dirs',
55
+ osp.splitext(osp.basename(args.config))[0])
56
+
57
+ cfg.load_from = args.checkpoint
58
+
59
+ if 'runner_type' not in cfg:
60
+ runner = Runner.from_cfg(cfg)
61
+ else:
62
+ runner = RUNNERS.build(cfg)
63
+
64
+ runner.call_hook('before_run')
65
+ runner.load_or_resume()
66
+ pipeline = cfg.test_dataloader.dataset.pipeline
67
+ runner.pipeline = Compose(pipeline)
68
+ runner.model.eval()
69
+ demo(runner, args, cfg)
assets/yolo_arch.png ADDED
assets/yolo_logo.png ADDED
configs/deploy/detection_onnxruntime-fp16_dynamic.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = (
2
+ '../../third_party/mmdeploy/configs/mmdet/detection/'
3
+ 'detection_onnxruntime-fp16_dynamic.py')
4
+ codebase_config = dict(
5
+ type='mmyolo',
6
+ task='ObjectDetection',
7
+ model_type='end2end',
8
+ post_processing=dict(
9
+ score_threshold=0.1,
10
+ confidence_threshold=0.005,
11
+ iou_threshold=0.3,
12
+ max_output_boxes_per_class=100,
13
+ pre_top_k=1000,
14
+ keep_top_k=100,
15
+ background_label_id=-1),
16
+ module=['mmyolo.deploy'])
17
+ backend_config = dict(
18
+ type='onnxruntime')
configs/deploy/detection_onnxruntime-int8_dynamic.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = (
2
+ '../../third_party/mmdeploy/configs/mmdet/detection/'
3
+ 'detection_onnxruntime-fp16_dynamic.py')
4
+ backend_config = dict(
5
+ precision='int8')
6
+ codebase_config = dict(
7
+ type='mmyolo',
8
+ task='ObjectDetection',
9
+ model_type='end2end',
10
+ post_processing=dict(
11
+ score_threshold=0.1,
12
+ confidence_threshold=0.005,
13
+ iou_threshold=0.3,
14
+ max_output_boxes_per_class=100,
15
+ pre_top_k=1000,
16
+ keep_top_k=100,
17
+ background_label_id=-1),
18
+ module=['mmyolo.deploy'])
19
+ backend_config = dict(
20
+ type='onnxruntime')
configs/deploy/detection_onnxruntime_static.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = (
2
+ '../../third_party/mmyolo/configs/deploy/'
3
+ 'detection_onnxruntime_static.py')
4
+ codebase_config = dict(
5
+ type='mmyolo',
6
+ task='ObjectDetection',
7
+ model_type='end2end',
8
+ post_processing=dict(
9
+ score_threshold=0.25,
10
+ confidence_threshold=0.005,
11
+ iou_threshold=0.65,
12
+ max_output_boxes_per_class=200,
13
+ pre_top_k=1000,
14
+ keep_top_k=100,
15
+ background_label_id=-1),
16
+ module=['mmyolo.deploy'])
17
+ backend_config = dict(
18
+ type='onnxruntime')
configs/deploy/detection_tensorrt-fp16_static-640x640.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = (
2
+ '../../third_party/mmyolo/configs/deploy/'
3
+ 'detection_tensorrt-fp16_static-640x640.py')
4
+ onnx_config = dict(
5
+ type='onnx',
6
+ export_params=True,
7
+ keep_initializers_as_inputs=False,
8
+ opset_version=11,
9
+ save_file='end2end.onnx',
10
+ input_names=['input'],
11
+ output_names=['dets', 'labels'],
12
+ input_shape=(640, 640),
13
+ optimize=True)
14
+ backend_config = dict(
15
+ type='tensorrt',
16
+ common_config=dict(fp16_mode=True, max_workspace_size=1 << 34),
17
+ model_inputs=[
18
+ dict(
19
+ input_shapes=dict(
20
+ input=dict(
21
+ min_shape=[1, 3, 640, 640],
22
+ opt_shape=[1, 3, 640, 640],
23
+ max_shape=[1, 3, 640, 640])))
24
+ ])
25
+ use_efficientnms = False # whether to replace TRTBatchedNMS plugin with EfficientNMS plugin # noqa E501
26
+ codebase_config = dict(
27
+ type='mmyolo',
28
+ task='ObjectDetection',
29
+ model_type='end2end',
30
+ post_processing=dict(
31
+ score_threshold=0.25,
32
+ confidence_threshold=0.005,
33
+ iou_threshold=0.65,
34
+ max_output_boxes_per_class=100,
35
+ pre_top_k=1,
36
+ keep_top_k=1,
37
+ background_label_id=-1),
38
+ module=['mmyolo.deploy'])
configs/deploy/detection_tensorrt-int8_static-640x640.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = [
2
+ '../../third_party/mmdeploy/configs/mmdet/_base_/base_static.py',
3
+ '../../third_party/mmdeploy/configs/_base_/backends/tensorrt-int8.py']
4
+
5
+ onnx_config = dict(input_shape=(640, 640))
6
+
7
+ backend_config = dict(
8
+ common_config=dict(max_workspace_size=1 << 30),
9
+ model_inputs=[
10
+ dict(
11
+ input_shapes=dict(
12
+ input=dict(
13
+ min_shape=[1, 3, 640, 640],
14
+ opt_shape=[1, 3, 640, 640],
15
+ max_shape=[1, 3, 640, 640])))
16
+ ])
17
+
18
+ codebase_config = dict(
19
+ type='mmyolo',
20
+ task='ObjectDetection',
21
+ model_type='end2end',
22
+ post_processing=dict(
23
+ score_threshold=0.1,
24
+ confidence_threshold=0.005,
25
+ iou_threshold=0.3,
26
+ max_output_boxes_per_class=100,
27
+ pre_top_k=1000,
28
+ keep_top_k=100,
29
+ background_label_id=-1),
30
+ module=['mmyolo.deploy'])
configs/finetune_coco/yolo_world_l_t2i_bn_2e-4_100e_4x8gpus_coco_finetune.py ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = ('../../third_party/mmyolo/configs/yolov8/'
2
+ 'yolov8_l_mask-refine_syncbn_fast_8xb16-500e_coco.py')
3
+ custom_imports = dict(imports=['yolo_world'],
4
+ allow_failed_imports=False)
5
+
6
+ # hyper-parameters
7
+ num_classes = 80
8
+ num_training_classes = 80
9
+ max_epochs = 80 # Maximum training epochs
10
+ close_mosaic_epochs = 10
11
+ save_epoch_intervals = 5
12
+ text_channels = 512
13
+ neck_embed_channels = [128, 256, _base_.last_stage_out_channels // 2]
14
+ neck_num_heads = [4, 8, _base_.last_stage_out_channels // 2 // 32]
15
+ base_lr = 2e-4
16
+ weight_decay = 0.05
17
+ train_batch_size_per_gpu = 16
18
+ load_from = 'weights/yolow-v8_l_clipv2_frozen_t2iv2_bn_o365_goldg_pretrain.pth'
19
+ persistent_workers = False
20
+
21
+
22
+ # model settings
23
+ model = dict(
24
+ type='YOLOWorldDetector',
25
+ mm_neck=True,
26
+ num_train_classes=num_training_classes,
27
+ num_test_classes=num_classes,
28
+ data_preprocessor=dict(type='YOLOWDetDataPreprocessor'),
29
+ backbone=dict(
30
+ _delete_=True,
31
+ type='MultiModalYOLOBackbone',
32
+ image_model={{_base_.model.backbone}},
33
+ text_model=dict(
34
+ type='HuggingCLIPLanguageBackbone',
35
+ model_name='pretrained_models/clip-vit-base-patch32-projection',
36
+ frozen_modules=['all'])),
37
+ neck=dict(type='YOLOWorldPAFPN',
38
+ guide_channels=text_channels,
39
+ embed_channels=neck_embed_channels,
40
+ num_heads=neck_num_heads,
41
+ block_cfg=dict(type='MaxSigmoidCSPLayerWithTwoConv'),
42
+ num_csp_blocks=2),
43
+ bbox_head=dict(type='YOLOWorldHead',
44
+ head_module=dict(type='YOLOWorldHeadModule',
45
+ embed_dims=text_channels,
46
+ use_bn_head=True,
47
+ num_classes=num_training_classes)),
48
+ train_cfg=dict(assigner=dict(num_classes=num_training_classes)))
49
+
50
+ # dataset settings
51
+ text_transform = [
52
+ dict(type='RandomLoadText',
53
+ num_neg_samples=(num_classes, num_classes),
54
+ max_num_samples=num_training_classes,
55
+ padding_to_max=True,
56
+ padding_value=''),
57
+ dict(type='mmdet.PackDetInputs',
58
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
59
+ 'flip_direction', 'texts'))
60
+ ]
61
+ mosaic_affine_transform = [
62
+ dict(
63
+ type='MultiModalMosaic',
64
+ img_scale=_base_.img_scale,
65
+ pad_val=114.0,
66
+ pre_transform=_base_.pre_transform),
67
+ dict(type='YOLOv5CopyPaste', prob=_base_.copypaste_prob),
68
+ dict(
69
+ type='YOLOv5RandomAffine',
70
+ max_rotate_degree=0.0,
71
+ max_shear_degree=0.0,
72
+ max_aspect_ratio=100.,
73
+ scaling_ratio_range=(1 - _base_.affine_scale,
74
+ 1 + _base_.affine_scale),
75
+ # img_scale is (width, height)
76
+ border=(-_base_.img_scale[0] // 2, -_base_.img_scale[1] // 2),
77
+ border_val=(114, 114, 114),
78
+ min_area_ratio=_base_.min_area_ratio,
79
+ use_mask_refine=_base_.use_mask2refine)
80
+ ]
81
+ train_pipeline = [
82
+ *_base_.pre_transform,
83
+ *mosaic_affine_transform,
84
+ dict(
85
+ type='YOLOv5MultiModalMixUp',
86
+ prob=_base_.mixup_prob,
87
+ pre_transform=[*_base_.pre_transform,
88
+ *mosaic_affine_transform]),
89
+ *_base_.last_transform[:-1],
90
+ *text_transform
91
+ ]
92
+ train_pipeline_stage2 = [
93
+ *_base_.train_pipeline_stage2[:-1],
94
+ *text_transform
95
+ ]
96
+ coco_train_dataset = dict(
97
+ _delete_=True,
98
+ type='MultiModalDataset',
99
+ dataset=dict(
100
+ type='YOLOv5CocoDataset',
101
+ data_root='data/coco',
102
+ ann_file='annotations/instances_train2017.json',
103
+ data_prefix=dict(img='train2017/'),
104
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
105
+ class_text_path='data/captions/coco_class_captions.json',
106
+ pipeline=train_pipeline)
107
+ train_dataloader = dict(
108
+ persistent_workers=persistent_workers,
109
+ batch_size=train_batch_size_per_gpu,
110
+ collate_fn=dict(type='yolow_collate'),
111
+ dataset=coco_train_dataset)
112
+ test_pipeline = [
113
+ *_base_.test_pipeline[:-1],
114
+ dict(type='LoadTextFixed'),
115
+ dict(
116
+ type='mmdet.PackDetInputs',
117
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
118
+ 'scale_factor', 'pad_param', 'texts'))
119
+ ]
120
+ coco_val_dataset = dict(
121
+ _delete_=True,
122
+ type='MultiModalDataset',
123
+ dataset=dict(
124
+ type='YOLOv5CocoDataset',
125
+ data_root='data/coco',
126
+ ann_file='annotations/instances_val2017.json',
127
+ data_prefix=dict(img='val2017/'),
128
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
129
+ class_text_path='data/captions/coco_class_captions.json',
130
+ pipeline=test_pipeline)
131
+ val_dataloader = dict(dataset=coco_val_dataset)
132
+ test_dataloader = val_dataloader
133
+ # training settings
134
+ default_hooks = dict(
135
+ param_scheduler=dict(
136
+ scheduler_type='linear',
137
+ lr_factor=0.01,
138
+ max_epochs=max_epochs),
139
+ checkpoint=dict(
140
+ max_keep_ckpts=-1,
141
+ save_best=None,
142
+ interval=save_epoch_intervals))
143
+ custom_hooks = [
144
+ dict(
145
+ type='EMAHook',
146
+ ema_type='ExpMomentumEMA',
147
+ momentum=0.0001,
148
+ update_buffers=True,
149
+ strict_load=False,
150
+ priority=49),
151
+ dict(
152
+ type='mmdet.PipelineSwitchHook',
153
+ switch_epoch=max_epochs - close_mosaic_epochs,
154
+ switch_pipeline=train_pipeline_stage2)
155
+ ]
156
+ train_cfg = dict(
157
+ max_epochs=max_epochs,
158
+ val_interval=5,
159
+ dynamic_intervals=[((max_epochs - close_mosaic_epochs),
160
+ _base_.val_interval_stage2)])
161
+ optim_wrapper = dict(
162
+ optimizer=dict(
163
+ _delete_=True,
164
+ type='AdamW',
165
+ lr=base_lr,
166
+ weight_decay=weight_decay,
167
+ batch_size_per_gpu=train_batch_size_per_gpu),
168
+ paramwise_cfg=dict(
169
+ bias_decay_mult=0.0,
170
+ norm_decay_mult=0.0,
171
+ custom_keys={'backbone.text_model': dict(lr_mult=0.01),
172
+ 'logit_scale': dict(weight_decay=0.0)}),
173
+ constructor='YOLOWv5OptimizerConstructor')
174
+
175
+ # evaluation settings
176
+ val_evaluator = dict(
177
+ _delete_=True,
178
+ type='mmdet.CocoMetric',
179
+ proposal_nums=(100, 1, 10),
180
+ ann_file='data/coco/annotations/instances_val2017.json',
181
+ metric='bbox')
182
+
183
+ test_evaluator = val_evaluator
configs/finetune_coco/yolo_world_m_t2i_bn_2e-4_100e_4x8gpus_coco_finetune.py ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = ('../../third_party/mmyolo/configs/yolov8/'
2
+ 'yolov8_m_mask-refine_syncbn_fast_8xb16-500e_coco.py')
3
+ custom_imports = dict(imports=['yolo_world'],
4
+ allow_failed_imports=False)
5
+
6
+ # hyper-parameters
7
+ num_classes = 80
8
+ num_training_classes = 80
9
+ max_epochs = 80 # Maximum training epochs
10
+ close_mosaic_epochs = 10
11
+ save_epoch_intervals = 5
12
+ text_channels = 512
13
+ neck_embed_channels = [128, 256, _base_.last_stage_out_channels // 2]
14
+ neck_num_heads = [4, 8, _base_.last_stage_out_channels // 2 // 32]
15
+ base_lr = 2e-4
16
+ weight_decay = 0.05
17
+ train_batch_size_per_gpu = 16
18
+ load_from = 'weights/yolow-v8_m_clipv2_frozen_t2iv2_bn_o365_goldg_pretrain.pth'
19
+ persistent_workers = False
20
+
21
+
22
+ # model settings
23
+ model = dict(
24
+ type='YOLOWorldDetector',
25
+ mm_neck=True,
26
+ num_train_classes=num_training_classes,
27
+ num_test_classes=num_classes,
28
+ data_preprocessor=dict(type='YOLOWDetDataPreprocessor'),
29
+ backbone=dict(
30
+ _delete_=True,
31
+ type='MultiModalYOLOBackbone',
32
+ image_model={{_base_.model.backbone}},
33
+ text_model=dict(
34
+ type='HuggingCLIPLanguageBackbone',
35
+ model_name='pretrained_models/clip-vit-base-patch32-projection',
36
+ frozen_modules=['all'])),
37
+ neck=dict(type='YOLOWorldPAFPN',
38
+ guide_channels=text_channels,
39
+ embed_channels=neck_embed_channels,
40
+ num_heads=neck_num_heads,
41
+ block_cfg=dict(type='MaxSigmoidCSPLayerWithTwoConv'),
42
+ num_csp_blocks=2),
43
+ bbox_head=dict(type='YOLOWorldHead',
44
+ head_module=dict(type='YOLOWorldHeadModule',
45
+ embed_dims=text_channels,
46
+ use_bn_head=True,
47
+ num_classes=num_training_classes)),
48
+ train_cfg=dict(assigner=dict(num_classes=num_training_classes)))
49
+
50
+ # dataset settings
51
+ text_transform = [
52
+ dict(type='RandomLoadText',
53
+ num_neg_samples=(num_classes, num_classes),
54
+ max_num_samples=num_training_classes,
55
+ padding_to_max=True,
56
+ padding_value=''),
57
+ dict(type='mmdet.PackDetInputs',
58
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
59
+ 'flip_direction', 'texts'))
60
+ ]
61
+ mosaic_affine_transform = [
62
+ dict(
63
+ type='MultiModalMosaic',
64
+ img_scale=_base_.img_scale,
65
+ pad_val=114.0,
66
+ pre_transform=_base_.pre_transform),
67
+ dict(type='YOLOv5CopyPaste', prob=_base_.copypaste_prob),
68
+ dict(
69
+ type='YOLOv5RandomAffine',
70
+ max_rotate_degree=0.0,
71
+ max_shear_degree=0.0,
72
+ max_aspect_ratio=100.,
73
+ scaling_ratio_range=(1 - _base_.affine_scale,
74
+ 1 + _base_.affine_scale),
75
+ # img_scale is (width, height)
76
+ border=(-_base_.img_scale[0] // 2, -_base_.img_scale[1] // 2),
77
+ border_val=(114, 114, 114),
78
+ min_area_ratio=_base_.min_area_ratio,
79
+ use_mask_refine=_base_.use_mask2refine)
80
+ ]
81
+ train_pipeline = [
82
+ *_base_.pre_transform,
83
+ *mosaic_affine_transform,
84
+ dict(
85
+ type='YOLOv5MultiModalMixUp',
86
+ prob=_base_.mixup_prob,
87
+ pre_transform=[*_base_.pre_transform,
88
+ *mosaic_affine_transform]),
89
+ *_base_.last_transform[:-1],
90
+ *text_transform
91
+ ]
92
+ train_pipeline_stage2 = [
93
+ *_base_.train_pipeline_stage2[:-1],
94
+ *text_transform
95
+ ]
96
+ coco_train_dataset = dict(
97
+ _delete_=True,
98
+ type='MultiModalDataset',
99
+ dataset=dict(
100
+ type='YOLOv5CocoDataset',
101
+ data_root='data/coco',
102
+ ann_file='annotations/instances_train2017.json',
103
+ data_prefix=dict(img='train2017/'),
104
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
105
+ class_text_path='data/captions/coco_class_captions.json',
106
+ pipeline=train_pipeline)
107
+ train_dataloader = dict(
108
+ persistent_workers=persistent_workers,
109
+ batch_size=train_batch_size_per_gpu,
110
+ collate_fn=dict(type='yolow_collate'),
111
+ dataset=coco_train_dataset)
112
+ test_pipeline = [
113
+ *_base_.test_pipeline[:-1],
114
+ dict(type='LoadTextFixed'),
115
+ dict(
116
+ type='mmdet.PackDetInputs',
117
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
118
+ 'scale_factor', 'pad_param', 'texts'))
119
+ ]
120
+ coco_val_dataset = dict(
121
+ _delete_=True,
122
+ type='MultiModalDataset',
123
+ dataset=dict(
124
+ type='YOLOv5CocoDataset',
125
+ data_root='data/coco',
126
+ ann_file='annotations/instances_val2017.json',
127
+ data_prefix=dict(img='val2017/'),
128
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
129
+ class_text_path='data/captions/coco_class_captions.json',
130
+ pipeline=test_pipeline)
131
+ val_dataloader = dict(dataset=coco_val_dataset)
132
+ test_dataloader = val_dataloader
133
+ # training settings
134
+ default_hooks = dict(
135
+ param_scheduler=dict(
136
+ scheduler_type='linear',
137
+ lr_factor=0.01,
138
+ max_epochs=max_epochs),
139
+ checkpoint=dict(
140
+ max_keep_ckpts=-1,
141
+ save_best=None,
142
+ interval=save_epoch_intervals))
143
+ custom_hooks = [
144
+ dict(
145
+ type='EMAHook',
146
+ ema_type='ExpMomentumEMA',
147
+ momentum=0.0001,
148
+ update_buffers=True,
149
+ strict_load=False,
150
+ priority=49),
151
+ dict(
152
+ type='mmdet.PipelineSwitchHook',
153
+ switch_epoch=max_epochs - close_mosaic_epochs,
154
+ switch_pipeline=train_pipeline_stage2)
155
+ ]
156
+ train_cfg = dict(
157
+ max_epochs=max_epochs,
158
+ val_interval=5,
159
+ dynamic_intervals=[((max_epochs - close_mosaic_epochs),
160
+ _base_.val_interval_stage2)])
161
+ optim_wrapper = dict(
162
+ optimizer=dict(
163
+ _delete_=True,
164
+ type='AdamW',
165
+ lr=base_lr,
166
+ weight_decay=weight_decay,
167
+ batch_size_per_gpu=train_batch_size_per_gpu),
168
+ paramwise_cfg=dict(
169
+ bias_decay_mult=0.0,
170
+ norm_decay_mult=0.0,
171
+ custom_keys={'backbone.text_model': dict(lr_mult=0.01),
172
+ 'logit_scale': dict(weight_decay=0.0)}),
173
+ constructor='YOLOWv5OptimizerConstructor')
174
+
175
+ # evaluation settings
176
+ val_evaluator = dict(
177
+ _delete_=True,
178
+ type='mmdet.CocoMetric',
179
+ proposal_nums=(100, 1, 10),
180
+ ann_file='data/coco/annotations/instances_val2017.json',
181
+ metric='bbox')
182
+
183
+ test_evaluator = val_evaluator
configs/finetune_coco/yolo_world_s_t2i_bn_2e-4_100e_4x8gpus_coco_finetune.py ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = ('../../third_party/mmyolo/configs/yolov8/'
2
+ 'yolov8_s_mask-refine_syncbn_fast_8xb16-500e_coco.py')
3
+ custom_imports = dict(imports=['yolo_world'],
4
+ allow_failed_imports=False)
5
+
6
+ # hyper-parameters
7
+ num_classes = 80
8
+ num_training_classes = 80
9
+ max_epochs = 80 # Maximum training epochs
10
+ close_mosaic_epochs = 10
11
+ save_epoch_intervals = 5
12
+ text_channels = 512
13
+ neck_embed_channels = [128, 256, _base_.last_stage_out_channels // 2]
14
+ neck_num_heads = [4, 8, _base_.last_stage_out_channels // 2 // 32]
15
+ base_lr = 2e-4
16
+ weight_decay = 0.05
17
+ train_batch_size_per_gpu = 16
18
+ load_from = 'weights/yolow-v8_s_clipv2_frozen_t2iv2_bn_o365_goldg_pretrain.pth'
19
+ persistent_workers = False
20
+
21
+
22
+ # model settings
23
+ model = dict(
24
+ type='YOLOWorldDetector',
25
+ mm_neck=True,
26
+ num_train_classes=num_training_classes,
27
+ num_test_classes=num_classes,
28
+ data_preprocessor=dict(type='YOLOWDetDataPreprocessor'),
29
+ backbone=dict(
30
+ _delete_=True,
31
+ type='MultiModalYOLOBackbone',
32
+ image_model={{_base_.model.backbone}},
33
+ text_model=dict(
34
+ type='HuggingCLIPLanguageBackbone',
35
+ model_name='pretrained_models/clip-vit-base-patch32-projection',
36
+ frozen_modules=['all'])),
37
+ neck=dict(type='YOLOWorldPAFPN',
38
+ guide_channels=text_channels,
39
+ embed_channels=neck_embed_channels,
40
+ num_heads=neck_num_heads,
41
+ block_cfg=dict(type='MaxSigmoidCSPLayerWithTwoConv'),
42
+ num_csp_blocks=2),
43
+ bbox_head=dict(type='YOLOWorldHead',
44
+ head_module=dict(type='YOLOWorldHeadModule',
45
+ embed_dims=text_channels,
46
+ use_bn_head=True,
47
+ num_classes=num_training_classes)),
48
+ train_cfg=dict(assigner=dict(num_classes=num_training_classes)))
49
+
50
+ # dataset settings
51
+ text_transform = [
52
+ dict(type='RandomLoadText',
53
+ num_neg_samples=(num_classes, num_classes),
54
+ max_num_samples=num_training_classes,
55
+ padding_to_max=True,
56
+ padding_value=''),
57
+ dict(type='mmdet.PackDetInputs',
58
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
59
+ 'flip_direction', 'texts'))
60
+ ]
61
+ mosaic_affine_transform = [
62
+ dict(
63
+ type='MultiModalMosaic',
64
+ img_scale=_base_.img_scale,
65
+ pad_val=114.0,
66
+ pre_transform=_base_.pre_transform),
67
+ dict(type='YOLOv5CopyPaste', prob=_base_.copypaste_prob),
68
+ dict(
69
+ type='YOLOv5RandomAffine',
70
+ max_rotate_degree=0.0,
71
+ max_shear_degree=0.0,
72
+ max_aspect_ratio=100.,
73
+ scaling_ratio_range=(1 - _base_.affine_scale,
74
+ 1 + _base_.affine_scale),
75
+ # img_scale is (width, height)
76
+ border=(-_base_.img_scale[0] // 2, -_base_.img_scale[1] // 2),
77
+ border_val=(114, 114, 114),
78
+ min_area_ratio=_base_.min_area_ratio,
79
+ use_mask_refine=_base_.use_mask2refine)
80
+ ]
81
+ train_pipeline = [
82
+ *_base_.pre_transform,
83
+ *mosaic_affine_transform,
84
+ dict(
85
+ type='YOLOv5MultiModalMixUp',
86
+ prob=_base_.mixup_prob,
87
+ pre_transform=[*_base_.pre_transform,
88
+ *mosaic_affine_transform]),
89
+ *_base_.last_transform[:-1],
90
+ *text_transform
91
+ ]
92
+ train_pipeline_stage2 = [
93
+ *_base_.train_pipeline_stage2[:-1],
94
+ *text_transform
95
+ ]
96
+ coco_train_dataset = dict(
97
+ _delete_=True,
98
+ type='MultiModalDataset',
99
+ dataset=dict(
100
+ type='YOLOv5CocoDataset',
101
+ data_root='data/coco',
102
+ ann_file='annotations/instances_train2017.json',
103
+ data_prefix=dict(img='train2017/'),
104
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
105
+ class_text_path='data/captions/coco_class_captions.json',
106
+ pipeline=train_pipeline)
107
+ train_dataloader = dict(
108
+ persistent_workers=persistent_workers,
109
+ batch_size=train_batch_size_per_gpu,
110
+ collate_fn=dict(type='yolow_collate'),
111
+ dataset=coco_train_dataset)
112
+ test_pipeline = [
113
+ *_base_.test_pipeline[:-1],
114
+ dict(type='LoadTextFixed'),
115
+ dict(
116
+ type='mmdet.PackDetInputs',
117
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
118
+ 'scale_factor', 'pad_param', 'texts'))
119
+ ]
120
+ coco_val_dataset = dict(
121
+ _delete_=True,
122
+ type='MultiModalDataset',
123
+ dataset=dict(
124
+ type='YOLOv5CocoDataset',
125
+ data_root='data/coco',
126
+ ann_file='annotations/instances_val2017.json',
127
+ data_prefix=dict(img='val2017/'),
128
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
129
+ class_text_path='data/captions/coco_class_captions.json',
130
+ pipeline=test_pipeline)
131
+ val_dataloader = dict(dataset=coco_val_dataset)
132
+ test_dataloader = val_dataloader
133
+ # training settings
134
+ default_hooks = dict(
135
+ param_scheduler=dict(
136
+ scheduler_type='linear',
137
+ lr_factor=0.01,
138
+ max_epochs=max_epochs),
139
+ checkpoint=dict(
140
+ max_keep_ckpts=-1,
141
+ save_best=None,
142
+ interval=save_epoch_intervals))
143
+ custom_hooks = [
144
+ dict(
145
+ type='EMAHook',
146
+ ema_type='ExpMomentumEMA',
147
+ momentum=0.0001,
148
+ update_buffers=True,
149
+ strict_load=False,
150
+ priority=49),
151
+ dict(
152
+ type='mmdet.PipelineSwitchHook',
153
+ switch_epoch=max_epochs - close_mosaic_epochs,
154
+ switch_pipeline=train_pipeline_stage2)
155
+ ]
156
+ train_cfg = dict(
157
+ max_epochs=max_epochs,
158
+ val_interval=5,
159
+ dynamic_intervals=[((max_epochs - close_mosaic_epochs),
160
+ _base_.val_interval_stage2)])
161
+ optim_wrapper = dict(
162
+ optimizer=dict(
163
+ _delete_=True,
164
+ type='AdamW',
165
+ lr=base_lr,
166
+ weight_decay=weight_decay,
167
+ batch_size_per_gpu=train_batch_size_per_gpu),
168
+ paramwise_cfg=dict(
169
+ bias_decay_mult=0.0,
170
+ norm_decay_mult=0.0,
171
+ custom_keys={'backbone.text_model': dict(lr_mult=0.01),
172
+ 'logit_scale': dict(weight_decay=0.0)}),
173
+ constructor='YOLOWv5OptimizerConstructor')
174
+
175
+ # evaluation settings
176
+ val_evaluator = dict(
177
+ _delete_=True,
178
+ type='mmdet.CocoMetric',
179
+ proposal_nums=(100, 1, 10),
180
+ ann_file='data/coco/annotations/instances_val2017.json',
181
+ metric='bbox')
182
+
183
+ test_evaluator = val_evaluator
configs/pretrain/yolo_world_l_dual_3block_l2norm_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = ('../../third_party/mmyolo/configs/yolov8/'
2
+ 'yolov8_l_syncbn_fast_8xb16-500e_coco.py')
3
+ custom_imports = dict(imports=['yolo_world'],
4
+ allow_failed_imports=False)
5
+
6
+ # hyper-parameters
7
+ num_classes = 1203
8
+ num_training_classes = 80
9
+ max_epochs = 100 # Maximum training epochs
10
+ close_mosaic_epochs = 2
11
+ save_epoch_intervals = 2
12
+ text_channels = 512
13
+ neck_embed_channels = [128, 256, _base_.last_stage_out_channels // 2]
14
+ neck_num_heads = [4, 8, _base_.last_stage_out_channels // 2 // 32]
15
+ base_lr = 2e-3
16
+ weight_decay = 0.05 / 2
17
+ train_batch_size_per_gpu = 16
18
+
19
+ # model settings
20
+ model = dict(
21
+ type='YOLOWorldDetector',
22
+ mm_neck=True,
23
+ num_train_classes=num_training_classes,
24
+ num_test_classes=num_classes,
25
+ data_preprocessor=dict(type='YOLOWDetDataPreprocessor'),
26
+ backbone=dict(
27
+ _delete_=True,
28
+ type='MultiModalYOLOBackbone',
29
+ image_model={{_base_.model.backbone}},
30
+ text_model=dict(
31
+ type='HuggingCLIPLanguageBackbone',
32
+ model_name='pretrained_models/clip-vit-base-patch32-projection',
33
+ frozen_modules=['all'])),
34
+ neck=dict(type='YOLOWolrdDualPAFPN',
35
+ guide_channels=text_channels,
36
+ embed_channels=neck_embed_channels,
37
+ num_heads=neck_num_heads,
38
+ block_cfg=dict(type='MaxSigmoidCSPLayerWithTwoConv'),
39
+ text_enhancder=dict(type='ImagePoolingAttentionModule',
40
+ embed_channels=256,
41
+ num_heads=8)),
42
+ bbox_head=dict(type='YOLOWorldHead',
43
+ head_module=dict(type='YOLOWorldHeadModule',
44
+ embed_dims=text_channels,
45
+ num_classes=num_training_classes)),
46
+ train_cfg=dict(assigner=dict(num_classes=num_training_classes)))
47
+
48
+ # dataset settings
49
+ text_transform = [
50
+ dict(type='RandomLoadText',
51
+ num_neg_samples=(num_classes, num_classes),
52
+ max_num_samples=num_training_classes,
53
+ padding_to_max=True,
54
+ padding_value=''),
55
+ dict(type='mmdet.PackDetInputs',
56
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
57
+ 'flip_direction', 'texts'))
58
+ ]
59
+ train_pipeline = [
60
+ *_base_.pre_transform,
61
+ dict(type='MultiModalMosaic',
62
+ img_scale=_base_.img_scale,
63
+ pad_val=114.0,
64
+ pre_transform=_base_.pre_transform),
65
+ dict(
66
+ type='YOLOv5RandomAffine',
67
+ max_rotate_degree=0.0,
68
+ max_shear_degree=0.0,
69
+ scaling_ratio_range=(1 - _base_.affine_scale, 1 + _base_.affine_scale),
70
+ max_aspect_ratio=_base_.max_aspect_ratio,
71
+ border=(-_base_.img_scale[0] // 2, -_base_.img_scale[1] // 2),
72
+ border_val=(114, 114, 114)),
73
+ *_base_.last_transform[:-1],
74
+ *text_transform,
75
+ ]
76
+ train_pipeline_stage2 = [*_base_.train_pipeline_stage2[:-1], *text_transform]
77
+ obj365v1_train_dataset = dict(
78
+ type='MultiModalDataset',
79
+ dataset=dict(
80
+ type='YOLOv5Objects365V1Dataset',
81
+ data_root='data/objects365v1/',
82
+ ann_file='annotations/objects365_train.json',
83
+ data_prefix=dict(img='train/'),
84
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
85
+ class_text_path='data/captions/obj365v1_class_captions.json',
86
+ pipeline=train_pipeline)
87
+
88
+ mg_train_dataset = dict(type='YOLOv5MixedGroundingDataset',
89
+ data_root='data/mixed_grounding/',
90
+ ann_file='annotations/final_mixed_train_no_coco.json',
91
+ data_prefix=dict(img='gqa/images/'),
92
+ filter_cfg=dict(filter_empty_gt=False, min_size=32),
93
+ pipeline=train_pipeline)
94
+
95
+ flickr_train_dataset = dict(
96
+ type='YOLOv5MixedGroundingDataset',
97
+ data_root='data/flickr/',
98
+ ann_file='annotations/final_flickr_separateGT_train.json',
99
+ data_prefix=dict(img='full_images/'),
100
+ filter_cfg=dict(filter_empty_gt=True, min_size=32),
101
+ pipeline=train_pipeline)
102
+
103
+ train_dataloader = dict(batch_size=train_batch_size_per_gpu,
104
+ collate_fn=dict(type='yolow_collate'),
105
+ dataset=dict(_delete_=True,
106
+ type='ConcatDataset',
107
+ datasets=[
108
+ obj365v1_train_dataset,
109
+ flickr_train_dataset, mg_train_dataset
110
+ ],
111
+ ignore_keys=['classes', 'palette']))
112
+
113
+ test_pipeline = [
114
+ *_base_.test_pipeline[:-1],
115
+ dict(type='LoadText'),
116
+ dict(type='mmdet.PackDetInputs',
117
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
118
+ 'scale_factor', 'pad_param', 'texts'))
119
+ ]
120
+ coco_val_dataset = dict(
121
+ _delete_=True,
122
+ type='MultiModalDataset',
123
+ dataset=dict(type='YOLOv5LVISV1Dataset',
124
+ data_root='data/coco/',
125
+ test_mode=True,
126
+ ann_file='lvis/lvis_v1_minival_inserted_image_name.json',
127
+ data_prefix=dict(img=''),
128
+ batch_shapes_cfg=None),
129
+ class_text_path='data/captions/lvis_v1_class_captions.json',
130
+ pipeline=test_pipeline)
131
+ val_dataloader = dict(dataset=coco_val_dataset)
132
+ test_dataloader = val_dataloader
133
+
134
+ val_evaluator = dict(type='mmdet.LVISMetric',
135
+ ann_file='data/coco/lvis/\
136
+ lvis_v1_minival_inserted_image_name.json',
137
+ metric='bbox')
138
+ test_evaluator = val_evaluator
139
+
140
+ # training settings
141
+ default_hooks = dict(param_scheduler=dict(max_epochs=max_epochs),
142
+ checkpoint=dict(interval=save_epoch_intervals,
143
+ rule='greater'))
144
+ custom_hooks = [
145
+ dict(type='EMAHook',
146
+ ema_type='ExpMomentumEMA',
147
+ momentum=0.0001,
148
+ update_buffers=True,
149
+ strict_load=False,
150
+ priority=49),
151
+ dict(type='mmdet.PipelineSwitchHook',
152
+ switch_epoch=max_epochs - close_mosaic_epochs,
153
+ switch_pipeline=train_pipeline_stage2)
154
+ ]
155
+ train_cfg = dict(max_epochs=max_epochs,
156
+ val_interval=10,
157
+ dynamic_intervals=[((max_epochs - close_mosaic_epochs),
158
+ _base_.val_interval_stage2)])
159
+ optim_wrapper = dict(optimizer=dict(
160
+ _delete_=True,
161
+ type='AdamW',
162
+ lr=base_lr,
163
+ weight_decay=weight_decay,
164
+ batch_size_per_gpu=train_batch_size_per_gpu),
165
+ paramwise_cfg=dict(bias_decay_mult=0.0,
166
+ norm_decay_mult=0.0,
167
+ custom_keys={
168
+ 'backbone.text_model':
169
+ dict(lr_mult=0.01),
170
+ 'logit_scale':
171
+ dict(weight_decay=0.0)
172
+ }),
173
+ constructor='YOLOWv5OptimizerConstructor')
configs/pretrain/yolo_world_l_t2i_bn_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = ('../../third_party/mmyolo/configs/yolov8/'
2
+ 'yolov8_l_syncbn_fast_8xb16-500e_coco.py')
3
+ custom_imports = dict(imports=['yolo_world'],
4
+ allow_failed_imports=False)
5
+
6
+ # hyper-parameters
7
+ num_classes = 1203
8
+ num_training_classes = 80
9
+ max_epochs = 100 # Maximum training epochs
10
+ close_mosaic_epochs = 2
11
+ save_epoch_intervals = 2
12
+ text_channels = 512
13
+ neck_embed_channels = [128, 256, _base_.last_stage_out_channels // 2]
14
+ neck_num_heads = [4, 8, _base_.last_stage_out_channels // 2 // 32]
15
+ base_lr = 2e-3
16
+ weight_decay = 0.05 / 2
17
+ train_batch_size_per_gpu = 16
18
+
19
+ # model settings
20
+ model = dict(
21
+ type='YOLOWorldDetector',
22
+ mm_neck=True,
23
+ num_train_classes=num_training_classes,
24
+ num_test_classes=num_classes,
25
+ data_preprocessor=dict(type='YOLOWDetDataPreprocessor'),
26
+ backbone=dict(
27
+ _delete_=True,
28
+ type='MultiModalYOLOBackbone',
29
+ image_model={{_base_.model.backbone}},
30
+ text_model=dict(
31
+ type='HuggingCLIPLanguageBackbone',
32
+ model_name='openai/clip-vit-base-patch32',
33
+ frozen_modules=['all'])),
34
+ neck=dict(type='YOLOWorldPAFPN',
35
+ guide_channels=text_channels,
36
+ embed_channels=neck_embed_channels,
37
+ num_heads=neck_num_heads,
38
+ block_cfg=dict(type='MaxSigmoidCSPLayerWithTwoConv'),
39
+ num_csp_blocks=2),
40
+ bbox_head=dict(type='YOLOWorldHead',
41
+ head_module=dict(type='YOLOWorldHeadModule',
42
+ embed_dims=text_channels,
43
+ use_bn_head=True,
44
+ num_classes=num_training_classes)),
45
+ train_cfg=dict(assigner=dict(num_classes=num_training_classes)))
46
+
47
+ # dataset settings
48
+ text_transform = [
49
+ dict(type='RandomLoadText',
50
+ num_neg_samples=(num_classes, num_classes),
51
+ max_num_samples=num_training_classes,
52
+ padding_to_max=True,
53
+ padding_value=''),
54
+ dict(type='mmdet.PackDetInputs',
55
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
56
+ 'flip_direction', 'texts'))
57
+ ]
58
+ train_pipeline = [
59
+ *_base_.pre_transform,
60
+ dict(type='MultiModalMosaic',
61
+ img_scale=_base_.img_scale,
62
+ pad_val=114.0,
63
+ pre_transform=_base_.pre_transform),
64
+ dict(
65
+ type='YOLOv5RandomAffine',
66
+ max_rotate_degree=0.0,
67
+ max_shear_degree=0.0,
68
+ scaling_ratio_range=(1 - _base_.affine_scale, 1 + _base_.affine_scale),
69
+ max_aspect_ratio=_base_.max_aspect_ratio,
70
+ border=(-_base_.img_scale[0] // 2, -_base_.img_scale[1] // 2),
71
+ border_val=(114, 114, 114)),
72
+ *_base_.last_transform[:-1],
73
+ *text_transform,
74
+ ]
75
+ train_pipeline_stage2 = [*_base_.train_pipeline_stage2[:-1], *text_transform]
76
+ obj365v1_train_dataset = dict(
77
+ type='MultiModalDataset',
78
+ dataset=dict(
79
+ type='YOLOv5Objects365V1Dataset',
80
+ data_root='data/objects365v1/',
81
+ ann_file='annotations/objects365_train.json',
82
+ data_prefix=dict(img='train/'),
83
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
84
+ class_text_path='data/captions/obj365v1_class_captions.json',
85
+ pipeline=train_pipeline)
86
+
87
+ mg_train_dataset = dict(
88
+ type='YOLOv5MixedGroundingDataset',
89
+ data_root='data/mixed_grounding/',
90
+ ann_file='annotations/final_mixed_train_no_coco.json',
91
+ data_prefix=dict(img='gqa/images/'),
92
+ filter_cfg=dict(filter_empty_gt=False, min_size=32),
93
+ pipeline=train_pipeline)
94
+
95
+ flickr_train_dataset = dict(
96
+ type='YOLOv5MixedGroundingDataset',
97
+ data_root='data/flickr/',
98
+ ann_file='annotations/final_flickr_separateGT_train.json',
99
+ data_prefix=dict(img='images/'),
100
+ filter_cfg=dict(filter_empty_gt=True, min_size=32),
101
+ pipeline=train_pipeline)
102
+
103
+ train_dataloader = dict(
104
+ batch_size=train_batch_size_per_gpu,
105
+ collate_fn=dict(type='yolow_collate'),
106
+ dataset=dict(
107
+ _delete_=True,
108
+ type='ConcatDataset',
109
+ datasets=[
110
+ obj365v1_train_dataset,
111
+ flickr_train_dataset,
112
+ mg_train_dataset
113
+ ],
114
+ ignore_keys=['classes', 'palette']))
115
+
116
+ test_pipeline = [
117
+ *_base_.test_pipeline[:-1],
118
+ dict(type='LoadText'),
119
+ dict(type='mmdet.PackDetInputs',
120
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
121
+ 'scale_factor', 'pad_param', 'texts'))
122
+ ]
123
+ coco_val_dataset = dict(
124
+ _delete_=True,
125
+ type='MultiModalDataset',
126
+ dataset=dict(
127
+ type='YOLOv5LVISV1Dataset',
128
+ data_root='data/lvis/',
129
+ test_mode=True,
130
+ ann_file='annotations/'
131
+ 'lvis_v1_minival_inserted_image_name.json',
132
+ data_prefix=dict(img=''),
133
+ batch_shapes_cfg=None),
134
+ class_text_path='data/captions/lvis_v1_class_captions.json',
135
+ pipeline=test_pipeline)
136
+ val_dataloader = dict(dataset=coco_val_dataset)
137
+ test_dataloader = val_dataloader
138
+
139
+ val_evaluator = dict(
140
+ type='mmdet.LVISMetric',
141
+ ann_file='data/lvis/annotations/'
142
+ 'lvis_v1_minival_inserted_image_name.json',
143
+ metric='bbox')
144
+ test_evaluator = val_evaluator
145
+
146
+ # training settings
147
+ default_hooks = dict(
148
+ param_scheduler=dict(max_epochs=max_epochs),
149
+ checkpoint=dict(interval=save_epoch_intervals,
150
+ rule='greater'))
151
+ custom_hooks = [
152
+ dict(type='EMAHook',
153
+ ema_type='ExpMomentumEMA',
154
+ momentum=0.0001,
155
+ update_buffers=True,
156
+ strict_load=False,
157
+ priority=49),
158
+ dict(type='mmdet.PipelineSwitchHook',
159
+ switch_epoch=max_epochs - close_mosaic_epochs,
160
+ switch_pipeline=train_pipeline_stage2)
161
+ ]
162
+ train_cfg = dict(
163
+ max_epochs=max_epochs,
164
+ val_interval=10,
165
+ dynamic_intervals=[((max_epochs - close_mosaic_epochs),
166
+ _base_.val_interval_stage2)])
167
+ optim_wrapper = dict(optimizer=dict(
168
+ _delete_=True,
169
+ type='AdamW',
170
+ lr=base_lr,
171
+ weight_decay=weight_decay,
172
+ batch_size_per_gpu=train_batch_size_per_gpu),
173
+ paramwise_cfg=dict(
174
+ bias_decay_mult=0.0,
175
+ norm_decay_mult=0.0,
176
+ custom_keys={
177
+ 'backbone.text_model':
178
+ dict(lr_mult=0.01),
179
+ 'logit_scale':
180
+ dict(weight_decay=0.0)
181
+ }),
182
+ constructor='YOLOWv5OptimizerConstructor')
configs/pretrain/yolo_world_m_dual_3block_l2norm_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = ('../../third_party/mmyolo/configs/yolov8/'
2
+ 'yolov8_m_syncbn_fast_8xb16-500e_coco.py')
3
+ custom_imports = dict(imports=['yolo_world'],
4
+ allow_failed_imports=False)
5
+
6
+ # hyper-parameters
7
+ num_classes = 1203
8
+ num_training_classes = 80
9
+ max_epochs = 100 # Maximum training epochs
10
+ close_mosaic_epochs = 2
11
+ save_epoch_intervals = 2
12
+ text_channels = 512
13
+ neck_embed_channels = [128, 256, _base_.last_stage_out_channels // 2]
14
+ neck_num_heads = [4, 8, _base_.last_stage_out_channels // 2 // 32]
15
+ base_lr = 2e-3
16
+ weight_decay = 0.05 / 2
17
+ train_batch_size_per_gpu = 16
18
+
19
+ # model settings
20
+ model = dict(
21
+ type='YOLOWorldDetector',
22
+ mm_neck=True,
23
+ num_train_classes=num_training_classes,
24
+ num_test_classes=num_classes,
25
+ data_preprocessor=dict(type='YOLOWDetDataPreprocessor'),
26
+ backbone=dict(
27
+ _delete_=True,
28
+ type='MultiModalYOLOBackbone',
29
+ image_model={{_base_.model.backbone}},
30
+ text_model=dict(
31
+ type='HuggingCLIPLanguageBackbone',
32
+ model_name='pretrained_models/clip-vit-base-patch32-projection',
33
+ frozen_modules=['all'])),
34
+ neck=dict(type='YOLOWolrdDualPAFPN',
35
+ guide_channels=text_channels,
36
+ embed_channels=neck_embed_channels,
37
+ num_heads=neck_num_heads,
38
+ block_cfg=dict(type='MaxSigmoidCSPLayerWithTwoConv'),
39
+ text_enhancder=dict(type='ImagePoolingAttentionModule',
40
+ embed_channels=256,
41
+ num_heads=8)),
42
+ bbox_head=dict(type='YOLOWorldHead',
43
+ head_module=dict(type='YOLOWorldHeadModule',
44
+ embed_dims=text_channels,
45
+ num_classes=num_training_classes)),
46
+ train_cfg=dict(assigner=dict(num_classes=num_training_classes)))
47
+
48
+ # dataset settings
49
+ text_transform = [
50
+ dict(type='RandomLoadText',
51
+ num_neg_samples=(num_classes, num_classes),
52
+ max_num_samples=num_training_classes,
53
+ padding_to_max=True,
54
+ padding_value=''),
55
+ dict(type='mmdet.PackDetInputs',
56
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
57
+ 'flip_direction', 'texts'))
58
+ ]
59
+ train_pipeline = [
60
+ *_base_.pre_transform,
61
+ dict(type='MultiModalMosaic',
62
+ img_scale=_base_.img_scale,
63
+ pad_val=114.0,
64
+ pre_transform=_base_.pre_transform),
65
+ dict(
66
+ type='YOLOv5RandomAffine',
67
+ max_rotate_degree=0.0,
68
+ max_shear_degree=0.0,
69
+ scaling_ratio_range=(1 - _base_.affine_scale, 1 + _base_.affine_scale),
70
+ max_aspect_ratio=_base_.max_aspect_ratio,
71
+ border=(-_base_.img_scale[0] // 2, -_base_.img_scale[1] // 2),
72
+ border_val=(114, 114, 114)),
73
+ *_base_.last_transform[:-1],
74
+ *text_transform,
75
+ ]
76
+ train_pipeline_stage2 = [*_base_.train_pipeline_stage2[:-1], *text_transform]
77
+ obj365v1_train_dataset = dict(
78
+ type='MultiModalDataset',
79
+ dataset=dict(
80
+ type='YOLOv5Objects365V1Dataset',
81
+ data_root='data/objects365v1/',
82
+ ann_file='annotations/objects365_train.json',
83
+ data_prefix=dict(img='train/'),
84
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
85
+ class_text_path='data/captions/obj365v1_class_captions.json',
86
+ pipeline=train_pipeline)
87
+
88
+ mg_train_dataset = dict(type='YOLOv5MixedGroundingDataset',
89
+ data_root='data/mixed_grounding/',
90
+ ann_file='annotations/final_mixed_train_no_coco.json',
91
+ data_prefix=dict(img='gqa/images/'),
92
+ filter_cfg=dict(filter_empty_gt=False, min_size=32),
93
+ pipeline=train_pipeline)
94
+
95
+ flickr_train_dataset = dict(
96
+ type='YOLOv5MixedGroundingDataset',
97
+ data_root='data/flickr/',
98
+ ann_file='annotations/final_flickr_separateGT_train.json',
99
+ data_prefix=dict(img='full_images/'),
100
+ filter_cfg=dict(filter_empty_gt=True, min_size=32),
101
+ pipeline=train_pipeline)
102
+
103
+ train_dataloader = dict(batch_size=train_batch_size_per_gpu,
104
+ collate_fn=dict(type='yolow_collate'),
105
+ dataset=dict(_delete_=True,
106
+ type='ConcatDataset',
107
+ datasets=[
108
+ obj365v1_train_dataset,
109
+ flickr_train_dataset, mg_train_dataset
110
+ ],
111
+ ignore_keys=['classes', 'palette']))
112
+
113
+ test_pipeline = [
114
+ *_base_.test_pipeline[:-1],
115
+ dict(type='LoadText'),
116
+ dict(type='mmdet.PackDetInputs',
117
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
118
+ 'scale_factor', 'pad_param', 'texts'))
119
+ ]
120
+ coco_val_dataset = dict(
121
+ _delete_=True,
122
+ type='MultiModalDataset',
123
+ dataset=dict(type='YOLOv5LVISV1Dataset',
124
+ data_root='data/coco/',
125
+ test_mode=True,
126
+ ann_file='lvis/lvis_v1_minival_inserted_image_name.json',
127
+ data_prefix=dict(img=''),
128
+ batch_shapes_cfg=None),
129
+ class_text_path='data/captions/lvis_v1_class_captions.json',
130
+ pipeline=test_pipeline)
131
+ val_dataloader = dict(dataset=coco_val_dataset)
132
+ test_dataloader = val_dataloader
133
+
134
+ val_evaluator = dict(type='mmdet.LVISMetric',
135
+ ann_file='data/coco/lvis/\
136
+ lvis_v1_minival_inserted_image_name.json',
137
+ metric='bbox')
138
+ test_evaluator = val_evaluator
139
+
140
+ # training settings
141
+ default_hooks = dict(param_scheduler=dict(max_epochs=max_epochs),
142
+ checkpoint=dict(interval=save_epoch_intervals,
143
+ rule='greater'))
144
+ custom_hooks = [
145
+ dict(type='EMAHook',
146
+ ema_type='ExpMomentumEMA',
147
+ momentum=0.0001,
148
+ update_buffers=True,
149
+ strict_load=False,
150
+ priority=49),
151
+ dict(type='mmdet.PipelineSwitchHook',
152
+ switch_epoch=max_epochs - close_mosaic_epochs,
153
+ switch_pipeline=train_pipeline_stage2)
154
+ ]
155
+ train_cfg = dict(max_epochs=max_epochs,
156
+ val_interval=10,
157
+ dynamic_intervals=[((max_epochs - close_mosaic_epochs),
158
+ _base_.val_interval_stage2)])
159
+ optim_wrapper = dict(optimizer=dict(
160
+ _delete_=True,
161
+ type='AdamW',
162
+ lr=base_lr,
163
+ weight_decay=weight_decay,
164
+ batch_size_per_gpu=train_batch_size_per_gpu),
165
+ paramwise_cfg=dict(bias_decay_mult=0.0,
166
+ norm_decay_mult=0.0,
167
+ custom_keys={
168
+ 'backbone.text_model':
169
+ dict(lr_mult=0.01),
170
+ 'logit_scale':
171
+ dict(weight_decay=0.0)
172
+ }),
173
+ constructor='YOLOWv5OptimizerConstructor')
configs/pretrain/yolo_world_m_t2i_bn_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = ('../../third_party/mmyolo/configs/yolov8/'
2
+ 'yolov8_m_syncbn_fast_8xb16-500e_coco.py')
3
+ custom_imports = dict(imports=['yolo_world'],
4
+ allow_failed_imports=False)
5
+
6
+ # hyper-parameters
7
+ num_classes = 1203
8
+ num_training_classes = 80
9
+ max_epochs = 100 # Maximum training epochs
10
+ close_mosaic_epochs = 2
11
+ save_epoch_intervals = 2
12
+ text_channels = 512
13
+ neck_embed_channels = [128, 256, _base_.last_stage_out_channels // 2]
14
+ neck_num_heads = [4, 8, _base_.last_stage_out_channels // 2 // 32]
15
+ base_lr = 2e-3
16
+ weight_decay = 0.05 / 2
17
+ train_batch_size_per_gpu = 16
18
+
19
+ # model settings
20
+ model = dict(
21
+ type='YOLOWorldDetector',
22
+ mm_neck=True,
23
+ num_train_classes=num_training_classes,
24
+ num_test_classes=num_classes,
25
+ data_preprocessor=dict(type='YOLOWDetDataPreprocessor'),
26
+ backbone=dict(
27
+ _delete_=True,
28
+ type='MultiModalYOLOBackbone',
29
+ image_model={{_base_.model.backbone}},
30
+ text_model=dict(
31
+ type='HuggingCLIPLanguageBackbone',
32
+ model_name='pretrained_models/clip-vit-base-patch32-projection',
33
+ frozen_modules=['all'])),
34
+ neck=dict(type='YOLOWorldPAFPN',
35
+ guide_channels=text_channels,
36
+ embed_channels=neck_embed_channels,
37
+ num_heads=neck_num_heads,
38
+ block_cfg=dict(type='MaxSigmoidCSPLayerWithTwoConv'),
39
+ num_csp_blocks=2),
40
+ bbox_head=dict(type='YOLOWorldHead',
41
+ head_module=dict(type='YOLOWorldHeadModule',
42
+ embed_dims=text_channels,
43
+ use_bn_head=True,
44
+ num_classes=num_training_classes)),
45
+ train_cfg=dict(assigner=dict(num_classes=num_training_classes)))
46
+
47
+ # dataset settings
48
+ text_transform = [
49
+ dict(type='RandomLoadText',
50
+ num_neg_samples=(num_classes, num_classes),
51
+ max_num_samples=num_training_classes,
52
+ padding_to_max=True,
53
+ padding_value=''),
54
+ dict(type='mmdet.PackDetInputs',
55
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
56
+ 'flip_direction', 'texts'))
57
+ ]
58
+ train_pipeline = [
59
+ *_base_.pre_transform,
60
+ dict(type='MultiModalMosaic',
61
+ img_scale=_base_.img_scale,
62
+ pad_val=114.0,
63
+ pre_transform=_base_.pre_transform),
64
+ dict(
65
+ type='YOLOv5RandomAffine',
66
+ max_rotate_degree=0.0,
67
+ max_shear_degree=0.0,
68
+ scaling_ratio_range=(1 - _base_.affine_scale, 1 + _base_.affine_scale),
69
+ max_aspect_ratio=_base_.max_aspect_ratio,
70
+ border=(-_base_.img_scale[0] // 2, -_base_.img_scale[1] // 2),
71
+ border_val=(114, 114, 114)),
72
+ *_base_.last_transform[:-1],
73
+ *text_transform,
74
+ ]
75
+ train_pipeline_stage2 = [*_base_.train_pipeline_stage2[:-1], *text_transform]
76
+ obj365v1_train_dataset = dict(
77
+ type='MultiModalDataset',
78
+ dataset=dict(
79
+ type='YOLOv5Objects365V1Dataset',
80
+ data_root='data/objects365v1/',
81
+ ann_file='annotations/objects365_train.json',
82
+ data_prefix=dict(img='train/'),
83
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
84
+ class_text_path='data/captions/obj365v1_class_captions.json',
85
+ pipeline=train_pipeline)
86
+
87
+ mg_train_dataset = dict(type='YOLOv5MixedGroundingDataset',
88
+ data_root='data/mixed_grounding/',
89
+ ann_file='annotations/final_mixed_train_no_coco.json',
90
+ data_prefix=dict(img='gqa/images/'),
91
+ filter_cfg=dict(filter_empty_gt=False, min_size=32),
92
+ pipeline=train_pipeline)
93
+
94
+ flickr_train_dataset = dict(
95
+ type='YOLOv5MixedGroundingDataset',
96
+ data_root='data/flickr/',
97
+ ann_file='annotations/final_flickr_separateGT_train.json',
98
+ data_prefix=dict(img='full_images/'),
99
+ filter_cfg=dict(filter_empty_gt=True, min_size=32),
100
+ pipeline=train_pipeline)
101
+
102
+ train_dataloader = dict(batch_size=train_batch_size_per_gpu,
103
+ collate_fn=dict(type='yolow_collate'),
104
+ dataset=dict(_delete_=True,
105
+ type='ConcatDataset',
106
+ datasets=[
107
+ obj365v1_train_dataset,
108
+ flickr_train_dataset, mg_train_dataset
109
+ ],
110
+ ignore_keys=['classes', 'palette']))
111
+
112
+ test_pipeline = [
113
+ *_base_.test_pipeline[:-1],
114
+ dict(type='LoadText'),
115
+ dict(type='mmdet.PackDetInputs',
116
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
117
+ 'scale_factor', 'pad_param', 'texts'))
118
+ ]
119
+ coco_val_dataset = dict(
120
+ _delete_=True,
121
+ type='MultiModalDataset',
122
+ dataset=dict(type='YOLOv5LVISV1Dataset',
123
+ data_root='data/coco/',
124
+ test_mode=True,
125
+ ann_file='lvis/lvis_v1_minival_inserted_image_name.json',
126
+ data_prefix=dict(img=''),
127
+ batch_shapes_cfg=None),
128
+ class_text_path='data/captions/lvis_v1_class_captions.json',
129
+ pipeline=test_pipeline)
130
+ val_dataloader = dict(dataset=coco_val_dataset)
131
+ test_dataloader = val_dataloader
132
+
133
+ val_evaluator = dict(type='mmdet.LVISMetric',
134
+ ann_file='data/coco/lvis/lvis_v1_minival_inserted_image_name.json',
135
+ metric='bbox')
136
+ test_evaluator = val_evaluator
137
+
138
+ # training settings
139
+ default_hooks = dict(param_scheduler=dict(max_epochs=max_epochs),
140
+ checkpoint=dict(interval=save_epoch_intervals,
141
+ rule='greater'))
142
+ custom_hooks = [
143
+ dict(type='EMAHook',
144
+ ema_type='ExpMomentumEMA',
145
+ momentum=0.0001,
146
+ update_buffers=True,
147
+ strict_load=False,
148
+ priority=49),
149
+ dict(type='mmdet.PipelineSwitchHook',
150
+ switch_epoch=max_epochs - close_mosaic_epochs,
151
+ switch_pipeline=train_pipeline_stage2)
152
+ ]
153
+ train_cfg = dict(max_epochs=max_epochs,
154
+ val_interval=10,
155
+ dynamic_intervals=[((max_epochs - close_mosaic_epochs),
156
+ _base_.val_interval_stage2)])
157
+ optim_wrapper = dict(optimizer=dict(
158
+ _delete_=True,
159
+ type='AdamW',
160
+ lr=base_lr,
161
+ weight_decay=weight_decay,
162
+ batch_size_per_gpu=train_batch_size_per_gpu),
163
+ paramwise_cfg=dict(bias_decay_mult=0.0,
164
+ norm_decay_mult=0.0,
165
+ custom_keys={
166
+ 'backbone.text_model':
167
+ dict(lr_mult=0.01),
168
+ 'logit_scale':
169
+ dict(weight_decay=0.0)
170
+ }),
171
+ constructor='YOLOWv5OptimizerConstructor')
configs/pretrain/yolo_world_s_dual_l2norm_3block_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = ('../../third_party/mmyolo/configs/yolov8/'
2
+ 'yolov8_s_syncbn_fast_8xb16-500e_coco.py')
3
+ custom_imports = dict(imports=['yolo_world'],
4
+ allow_failed_imports=False)
5
+
6
+ # hyper-parameters
7
+ num_classes = 1203
8
+ num_training_classes = 80
9
+ max_epochs = 100 # Maximum training epochs
10
+ close_mosaic_epochs = 2
11
+ save_epoch_intervals = 2
12
+ text_channels = 512
13
+ neck_embed_channels = [128, 256, _base_.last_stage_out_channels // 2]
14
+ neck_num_heads = [4, 8, _base_.last_stage_out_channels // 2 // 32]
15
+ base_lr = 2e-3
16
+ weight_decay = 0.05 / 2
17
+ train_batch_size_per_gpu = 16
18
+
19
+ # model settings
20
+ model = dict(
21
+ type='YOLOWorldDetector',
22
+ mm_neck=True,
23
+ num_train_classes=num_training_classes,
24
+ num_test_classes=num_classes,
25
+ data_preprocessor=dict(type='YOLOWDetDataPreprocessor'),
26
+ backbone=dict(
27
+ _delete_=True,
28
+ type='MultiModalYOLOBackbone',
29
+ image_model={{_base_.model.backbone}},
30
+ text_model=dict(
31
+ type='HuggingCLIPLanguageBackbone',
32
+ model_name='pretrained_models/clip-vit-base-patch32-projection',
33
+ frozen_modules=['all'])),
34
+ neck=dict(type='YOLOWolrdDualPAFPN',
35
+ guide_channels=text_channels,
36
+ embed_channels=neck_embed_channels,
37
+ num_heads=neck_num_heads,
38
+ block_cfg=dict(type='MaxSigmoidCSPLayerWithTwoConv'),
39
+ text_enhancder=dict(type='ImagePoolingAttentionModule',
40
+ embed_channels=256,
41
+ num_heads=8)),
42
+ bbox_head=dict(type='YOLOWorldHead',
43
+ head_module=dict(type='YOLOWorldHeadModule',
44
+ embed_dims=text_channels,
45
+ num_classes=num_training_classes)),
46
+ train_cfg=dict(assigner=dict(num_classes=num_training_classes)))
47
+
48
+ # dataset settings
49
+ text_transform = [
50
+ dict(type='RandomLoadText',
51
+ num_neg_samples=(num_classes, num_classes),
52
+ max_num_samples=num_training_classes,
53
+ padding_to_max=True,
54
+ padding_value=''),
55
+ dict(type='mmdet.PackDetInputs',
56
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
57
+ 'flip_direction', 'texts'))
58
+ ]
59
+ train_pipeline = [
60
+ *_base_.pre_transform,
61
+ dict(type='MultiModalMosaic',
62
+ img_scale=_base_.img_scale,
63
+ pad_val=114.0,
64
+ pre_transform=_base_.pre_transform),
65
+ dict(
66
+ type='YOLOv5RandomAffine',
67
+ max_rotate_degree=0.0,
68
+ max_shear_degree=0.0,
69
+ scaling_ratio_range=(1 - _base_.affine_scale, 1 + _base_.affine_scale),
70
+ max_aspect_ratio=_base_.max_aspect_ratio,
71
+ border=(-_base_.img_scale[0] // 2, -_base_.img_scale[1] // 2),
72
+ border_val=(114, 114, 114)),
73
+ *_base_.last_transform[:-1],
74
+ *text_transform,
75
+ ]
76
+ train_pipeline_stage2 = [*_base_.train_pipeline_stage2[:-1], *text_transform]
77
+ obj365v1_train_dataset = dict(
78
+ type='MultiModalDataset',
79
+ dataset=dict(
80
+ type='YOLOv5Objects365V1Dataset',
81
+ data_root='data/objects365v1/',
82
+ ann_file='annotations/objects365_train.json',
83
+ data_prefix=dict(img='train/'),
84
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
85
+ class_text_path='data/captions/obj365v1_class_captions.json',
86
+ pipeline=train_pipeline)
87
+
88
+ mg_train_dataset = dict(type='YOLOv5MixedGroundingDataset',
89
+ data_root='data/mixed_grounding/',
90
+ ann_file='annotations/final_mixed_train_no_coco.json',
91
+ data_prefix=dict(img='gqa/images/'),
92
+ filter_cfg=dict(filter_empty_gt=False, min_size=32),
93
+ pipeline=train_pipeline)
94
+
95
+ flickr_train_dataset = dict(
96
+ type='YOLOv5MixedGroundingDataset',
97
+ data_root='data/flickr/',
98
+ ann_file='annotations/final_flickr_separateGT_train.json',
99
+ data_prefix=dict(img='full_images/'),
100
+ filter_cfg=dict(filter_empty_gt=True, min_size=32),
101
+ pipeline=train_pipeline)
102
+
103
+ train_dataloader = dict(batch_size=train_batch_size_per_gpu,
104
+ collate_fn=dict(type='yolow_collate'),
105
+ dataset=dict(_delete_=True,
106
+ type='ConcatDataset',
107
+ datasets=[
108
+ obj365v1_train_dataset,
109
+ flickr_train_dataset, mg_train_dataset
110
+ ],
111
+ ignore_keys=['classes', 'palette']))
112
+
113
+ test_pipeline = [
114
+ *_base_.test_pipeline[:-1],
115
+ dict(type='LoadText'),
116
+ dict(type='mmdet.PackDetInputs',
117
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
118
+ 'scale_factor', 'pad_param', 'texts'))
119
+ ]
120
+ coco_val_dataset = dict(
121
+ _delete_=True,
122
+ type='MultiModalDataset',
123
+ dataset=dict(type='YOLOv5LVISV1Dataset',
124
+ data_root='data/coco/',
125
+ test_mode=True,
126
+ ann_file='lvis/lvis_v1_minival_inserted_image_name.json',
127
+ data_prefix=dict(img=''),
128
+ batch_shapes_cfg=None),
129
+ class_text_path='data/captions/lvis_v1_class_captions.json',
130
+ pipeline=test_pipeline)
131
+ val_dataloader = dict(dataset=coco_val_dataset)
132
+ test_dataloader = val_dataloader
133
+
134
+ val_evaluator = dict(type='mmdet.LVISMetric',
135
+ ann_file='data/coco/lvis/\
136
+ lvis_v1_minival_inserted_image_name.json',
137
+ metric='bbox')
138
+ test_evaluator = val_evaluator
139
+
140
+ # training settings
141
+ default_hooks = dict(param_scheduler=dict(max_epochs=max_epochs),
142
+ checkpoint=dict(interval=save_epoch_intervals,
143
+ rule='greater'))
144
+ custom_hooks = [
145
+ dict(type='EMAHook',
146
+ ema_type='ExpMomentumEMA',
147
+ momentum=0.0001,
148
+ update_buffers=True,
149
+ strict_load=False,
150
+ priority=49),
151
+ dict(type='mmdet.PipelineSwitchHook',
152
+ switch_epoch=max_epochs - close_mosaic_epochs,
153
+ switch_pipeline=train_pipeline_stage2)
154
+ ]
155
+ train_cfg = dict(max_epochs=max_epochs,
156
+ val_interval=10,
157
+ dynamic_intervals=[((max_epochs - close_mosaic_epochs),
158
+ _base_.val_interval_stage2)])
159
+ optim_wrapper = dict(optimizer=dict(
160
+ _delete_=True,
161
+ type='AdamW',
162
+ lr=base_lr,
163
+ weight_decay=weight_decay,
164
+ batch_size_per_gpu=train_batch_size_per_gpu),
165
+ paramwise_cfg=dict(bias_decay_mult=0.0,
166
+ norm_decay_mult=0.0,
167
+ custom_keys={
168
+ 'backbone.text_model':
169
+ dict(lr_mult=0.01),
170
+ 'logit_scale':
171
+ dict(weight_decay=0.0)
172
+ }),
173
+ constructor='YOLOWv5OptimizerConstructor')
configs/pretrain/yolo_world_s_t2i_bn_2e-4_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = ('../../third_party/mmyolo/configs/yolov8/'
2
+ 'yolov8_s_syncbn_fast_8xb16-500e_coco.py')
3
+ custom_imports = dict(imports=['yolo_world'],
4
+ allow_failed_imports=False)
5
+
6
+ # hyper-parameters
7
+ num_classes = 1203
8
+ num_training_classes = 80
9
+ max_epochs = 100 # Maximum training epochs
10
+ close_mosaic_epochs = 2
11
+ save_epoch_intervals = 2
12
+ text_channels = 512
13
+ neck_embed_channels = [128, 256, _base_.last_stage_out_channels // 2]
14
+ neck_num_heads = [4, 8, _base_.last_stage_out_channels // 2 // 32]
15
+ base_lr = 2e-3
16
+ # for 4 nodes, 8 gpus per node, 32 total gpus
17
+ weight_decay = 0.05 / 2
18
+ train_batch_size_per_gpu = 16
19
+
20
+ # model settings
21
+ model = dict(
22
+ type='YOLOWorldDetector',
23
+ mm_neck=True,
24
+ num_train_classes=num_training_classes,
25
+ num_test_classes=num_classes,
26
+ data_preprocessor=dict(type='YOLOWDetDataPreprocessor'),
27
+ backbone=dict(
28
+ _delete_=True,
29
+ type='MultiModalYOLOBackbone',
30
+ image_model={{_base_.model.backbone}},
31
+ text_model=dict(
32
+ type='HuggingCLIPLanguageBackbone',
33
+ model_name='pretrained_models/clip-vit-base-patch32-projection',
34
+ frozen_modules=['all'])),
35
+ neck=dict(type='YOLOWorldPAFPN',
36
+ guide_channels=text_channels,
37
+ embed_channels=neck_embed_channels,
38
+ num_heads=neck_num_heads,
39
+ block_cfg=dict(type='MaxSigmoidCSPLayerWithTwoConv'),
40
+ num_csp_blocks=2),
41
+ bbox_head=dict(type='YOLOWorldHead',
42
+ head_module=dict(type='YOLOWorldHeadModule',
43
+ embed_dims=text_channels,
44
+ use_bn_head=True,
45
+ num_classes=num_training_classes)),
46
+ train_cfg=dict(assigner=dict(num_classes=num_training_classes)))
47
+
48
+ # dataset settings
49
+ text_transform = [
50
+ dict(type='RandomLoadText',
51
+ num_neg_samples=(num_classes, num_classes),
52
+ max_num_samples=num_training_classes,
53
+ padding_to_max=True,
54
+ padding_value=''),
55
+ dict(type='mmdet.PackDetInputs',
56
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
57
+ 'flip_direction', 'texts'))
58
+ ]
59
+ train_pipeline = [
60
+ *_base_.pre_transform,
61
+ dict(type='MultiModalMosaic',
62
+ img_scale=_base_.img_scale,
63
+ pad_val=114.0,
64
+ pre_transform=_base_.pre_transform),
65
+ dict(
66
+ type='YOLOv5RandomAffine',
67
+ max_rotate_degree=0.0,
68
+ max_shear_degree=0.0,
69
+ scaling_ratio_range=(1 - _base_.affine_scale, 1 + _base_.affine_scale),
70
+ max_aspect_ratio=_base_.max_aspect_ratio,
71
+ border=(-_base_.img_scale[0] // 2, -_base_.img_scale[1] // 2),
72
+ border_val=(114, 114, 114)),
73
+ *_base_.last_transform[:-1],
74
+ *text_transform,
75
+ ]
76
+ train_pipeline_stage2 = [*_base_.train_pipeline_stage2[:-1], *text_transform]
77
+ obj365v1_train_dataset = dict(
78
+ type='MultiModalDataset',
79
+ dataset=dict(
80
+ type='YOLOv5Objects365V1Dataset',
81
+ data_root='data/objects365v1/',
82
+ ann_file='annotations/objects365_train.json',
83
+ data_prefix=dict(img='train/'),
84
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
85
+ class_text_path='data/captions/obj365v1_class_captions.json',
86
+ pipeline=train_pipeline)
87
+
88
+ mg_train_dataset = dict(type='YOLOv5MixedGroundingDataset',
89
+ data_root='data/mixed_grounding/',
90
+ ann_file='annotations/final_mixed_train_no_coco.json',
91
+ data_prefix=dict(img='gqa/images/'),
92
+ filter_cfg=dict(filter_empty_gt=False, min_size=32),
93
+ pipeline=train_pipeline)
94
+
95
+ flickr_train_dataset = dict(
96
+ type='YOLOv5MixedGroundingDataset',
97
+ data_root='data/flickr/',
98
+ ann_file='annotations/final_flickr_separateGT_train.json',
99
+ data_prefix=dict(img='full_images/'),
100
+ filter_cfg=dict(filter_empty_gt=True, min_size=32),
101
+ pipeline=train_pipeline)
102
+
103
+ train_dataloader = dict(batch_size=train_batch_size_per_gpu,
104
+ collate_fn=dict(type='yolow_collate'),
105
+ dataset=dict(_delete_=True,
106
+ type='ConcatDataset',
107
+ datasets=[
108
+ obj365v1_train_dataset,
109
+ flickr_train_dataset, mg_train_dataset
110
+ ],
111
+ ignore_keys=['classes', 'palette']))
112
+
113
+ test_pipeline = [
114
+ *_base_.test_pipeline[:-1],
115
+ dict(type='LoadText'),
116
+ dict(type='mmdet.PackDetInputs',
117
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
118
+ 'scale_factor', 'pad_param', 'texts'))
119
+ ]
120
+ coco_val_dataset = dict(
121
+ _delete_=True,
122
+ type='MultiModalDataset',
123
+ dataset=dict(type='YOLOv5LVISV1Dataset',
124
+ data_root='data/coco/',
125
+ test_mode=True,
126
+ ann_file='lvis/lvis_v1_minival_inserted_image_name.json',
127
+ data_prefix=dict(img=''),
128
+ batch_shapes_cfg=None),
129
+ class_text_path='data/captions/lvis_v1_class_captions.json',
130
+ pipeline=test_pipeline)
131
+ val_dataloader = dict(dataset=coco_val_dataset)
132
+ test_dataloader = val_dataloader
133
+
134
+ val_evaluator = dict(type='mmdet.LVISMetric',
135
+ ann_file='data/coco/lvis/lvis_v1_minival_inserted_image_name.json',
136
+ metric='bbox')
137
+ test_evaluator = val_evaluator
138
+
139
+ # training settings
140
+ default_hooks = dict(param_scheduler=dict(max_epochs=max_epochs),
141
+ checkpoint=dict(interval=save_epoch_intervals,
142
+ rule='greater'))
143
+ custom_hooks = [
144
+ dict(type='EMAHook',
145
+ ema_type='ExpMomentumEMA',
146
+ momentum=0.0001,
147
+ update_buffers=True,
148
+ strict_load=False,
149
+ priority=49),
150
+ dict(type='mmdet.PipelineSwitchHook',
151
+ switch_epoch=max_epochs - close_mosaic_epochs,
152
+ switch_pipeline=train_pipeline_stage2)
153
+ ]
154
+ train_cfg = dict(max_epochs=max_epochs,
155
+ val_interval=10,
156
+ dynamic_intervals=[((max_epochs - close_mosaic_epochs),
157
+ _base_.val_interval_stage2)])
158
+ optim_wrapper = dict(optimizer=dict(
159
+ _delete_=True,
160
+ type='AdamW',
161
+ lr=base_lr,
162
+ weight_decay=weight_decay,
163
+ batch_size_per_gpu=train_batch_size_per_gpu),
164
+ paramwise_cfg=dict(bias_decay_mult=0.0,
165
+ norm_decay_mult=0.0,
166
+ custom_keys={
167
+ 'backbone.text_model':
168
+ dict(lr_mult=0.01),
169
+ 'logit_scale':
170
+ dict(weight_decay=0.0)
171
+ }),
172
+ constructor='YOLOWv5OptimizerConstructor')
configs/scaleup/yolo_world_l_t2i_bn_2e-4_20e_4x8gpus_obj365v1_goldg_train_lvis_minival_s1024.py ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = ('../../third_party/mmyolo/configs/yolov8/'
2
+ 'yolov8_l_syncbn_fast_8xb16-500e_coco.py')
3
+ custom_imports = dict(imports=['yolo_world'],
4
+ allow_failed_imports=False)
5
+
6
+ # hyper-parameters
7
+ num_classes = 1203
8
+ num_training_classes = 80
9
+ max_epochs = 20 # Maximum training epochs
10
+ close_mosaic_epochs = 2
11
+ save_epoch_intervals = 2
12
+ text_channels = 512
13
+ neck_embed_channels = [128, 256, _base_.last_stage_out_channels // 2]
14
+ neck_num_heads = [4, 8, _base_.last_stage_out_channels // 2 // 32]
15
+ base_lr = 2e-4
16
+ weight_decay = 0.05 / 2
17
+ train_batch_size_per_gpu = 8
18
+ img_scale = (1024, 1024)
19
+ load_from = 'work_dirs/model_zoo/yolow-v8_l_clipv2_frozen_t2iv2_bn_o365_goldg_pretrain.pth' # noqa
20
+
21
+ # model settings
22
+ model = dict(
23
+ type='YOLOWorldDetector',
24
+ mm_neck=True,
25
+ num_train_classes=num_training_classes,
26
+ num_test_classes=num_classes,
27
+ data_preprocessor=dict(type='YOLOWDetDataPreprocessor'),
28
+ backbone=dict(
29
+ _delete_=True,
30
+ type='MultiModalYOLOBackbone',
31
+ image_model={{_base_.model.backbone}},
32
+ text_model=dict(
33
+ type='HuggingCLIPLanguageBackbone',
34
+ model_name='openai/clip-vit-base-patch32',
35
+ frozen_modules=['all'])),
36
+ neck=dict(type='YOLOWorldPAFPN',
37
+ guide_channels=text_channels,
38
+ embed_channels=neck_embed_channels,
39
+ num_heads=neck_num_heads,
40
+ block_cfg=dict(type='MaxSigmoidCSPLayerWithTwoConv'),
41
+ num_csp_blocks=2),
42
+ bbox_head=dict(type='YOLOWorldHead',
43
+ head_module=dict(type='YOLOWorldHeadModule',
44
+ embed_dims=text_channels,
45
+ use_bn_head=True,
46
+ num_classes=num_training_classes)),
47
+ train_cfg=dict(assigner=dict(num_classes=num_training_classes)))
48
+
49
+ # dataset settings
50
+ text_transform = [
51
+ dict(type='RandomLoadText',
52
+ num_neg_samples=(num_classes, num_classes),
53
+ max_num_samples=num_training_classes,
54
+ padding_to_max=True,
55
+ padding_value=''),
56
+ dict(type='mmdet.PackDetInputs',
57
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
58
+ 'flip_direction', 'texts'))
59
+ ]
60
+ mosaic_affine_transform = [
61
+ dict(type='MultiModalMosaic',
62
+ img_scale=img_scale,
63
+ pad_val=114.0,
64
+ pre_transform=_base_.pre_transform),
65
+ dict(
66
+ type='YOLOv5RandomAffine',
67
+ max_rotate_degree=0.0,
68
+ max_shear_degree=0.0,
69
+ scaling_ratio_range=(1 - _base_.affine_scale, 1 + _base_.affine_scale),
70
+ max_aspect_ratio=_base_.max_aspect_ratio,
71
+ border=(-img_scale[0] // 2, -img_scale[1] // 2),
72
+ border_val=(114, 114, 114))
73
+ ]
74
+ train_pipeline = [
75
+ *_base_.pre_transform,
76
+ *mosaic_affine_transform,
77
+ dict(
78
+ type='YOLOv5MultiModalMixUp',
79
+ prob=_base_.mixup_prob,
80
+ pre_transform=[*_base_.pre_transform,
81
+ *mosaic_affine_transform]),
82
+ *_base_.last_transform[:-1],
83
+ *text_transform,
84
+ ]
85
+ train_pipeline_stage2 = [
86
+ *_base_.pre_transform,
87
+ dict(type='YOLOv5KeepRatioResize', scale=img_scale),
88
+ dict(
89
+ type='LetterResize',
90
+ scale=img_scale,
91
+ allow_scale_up=True,
92
+ pad_val=dict(img=114.0)),
93
+ dict(
94
+ type='YOLOv5RandomAffine',
95
+ max_rotate_degree=0.0,
96
+ max_shear_degree=0.0,
97
+ scaling_ratio_range=(1 - _base_.affine_scale, 1 + _base_.affine_scale),
98
+ max_aspect_ratio=_base_.max_aspect_ratio,
99
+ border_val=(114, 114, 114)),
100
+ *_base_.last_transform[:-1],
101
+ *text_transform,
102
+ ]
103
+ obj365v1_train_dataset = dict(
104
+ type='MultiModalDataset',
105
+ dataset=dict(
106
+ type='YOLOv5Objects365V1Dataset',
107
+ data_root='data/objects365v1/',
108
+ ann_file='annotations/objects365_train.json',
109
+ data_prefix=dict(img='train/'),
110
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
111
+ class_text_path='data/captions/obj365v1_class_captions.json',
112
+ pipeline=train_pipeline)
113
+
114
+ mg_train_dataset = dict(
115
+ type='YOLOv5MixedGroundingDataset',
116
+ data_root='data/mixed_grounding/',
117
+ ann_file='annotations/final_mixed_train_no_coco.json',
118
+ data_prefix=dict(img='gqa/images/'),
119
+ filter_cfg=dict(filter_empty_gt=False, min_size=32),
120
+ pipeline=train_pipeline)
121
+
122
+ flickr_train_dataset = dict(
123
+ type='YOLOv5MixedGroundingDataset',
124
+ data_root='data/flickr/',
125
+ ann_file='annotations/final_flickr_separateGT_train.json',
126
+ data_prefix=dict(img='images/'),
127
+ filter_cfg=dict(filter_empty_gt=True, min_size=32),
128
+ pipeline=train_pipeline)
129
+
130
+ train_dataloader = dict(
131
+ batch_size=train_batch_size_per_gpu,
132
+ collate_fn=dict(type='yolow_collate'),
133
+ dataset=dict(
134
+ _delete_=True,
135
+ type='ConcatDataset',
136
+ datasets=[
137
+ obj365v1_train_dataset,
138
+ flickr_train_dataset,
139
+ mg_train_dataset
140
+ ],
141
+ ignore_keys=['classes', 'palette']))
142
+
143
+ test_pipeline = [
144
+ dict(type='LoadImageFromFile', backend_args=_base_.backend_args),
145
+ dict(type='YOLOv5KeepRatioResize', scale=img_scale),
146
+ dict(
147
+ type='LetterResize',
148
+ scale=img_scale,
149
+ allow_scale_up=False,
150
+ pad_val=dict(img=114)),
151
+ dict(type='LoadAnnotations', with_bbox=True, _scope_='mmdet'),
152
+ dict(type='LoadText'),
153
+ dict(type='mmdet.PackDetInputs',
154
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
155
+ 'scale_factor', 'pad_param', 'texts'))
156
+ ]
157
+ coco_val_dataset = dict(
158
+ _delete_=True,
159
+ type='MultiModalDataset',
160
+ dataset=dict(
161
+ type='YOLOv5LVISV1Dataset',
162
+ data_root='data/lvis/',
163
+ test_mode=True,
164
+ ann_file='annotations/'
165
+ 'lvis_v1_minival_inserted_image_name.json',
166
+ data_prefix=dict(img=''),
167
+ batch_shapes_cfg=None),
168
+ class_text_path='data/captions/lvis_v1_class_captions.json',
169
+ pipeline=test_pipeline)
170
+ val_dataloader = dict(dataset=coco_val_dataset)
171
+ test_dataloader = val_dataloader
172
+
173
+ val_evaluator = dict(
174
+ type='mmdet.LVISMetric',
175
+ ann_file='data/lvis/annotations/'
176
+ 'lvis_v1_minival_inserted_image_name.json',
177
+ metric='bbox')
178
+ test_evaluator = val_evaluator
179
+
180
+ # training settings
181
+ default_hooks = dict(
182
+ param_scheduler=dict(max_epochs=max_epochs),
183
+ checkpoint=dict(interval=save_epoch_intervals,
184
+ rule='greater'))
185
+ custom_hooks = [
186
+ dict(type='EMAHook',
187
+ ema_type='ExpMomentumEMA',
188
+ momentum=0.0001,
189
+ update_buffers=True,
190
+ strict_load=False,
191
+ priority=49),
192
+ dict(type='mmdet.PipelineSwitchHook',
193
+ switch_epoch=max_epochs - close_mosaic_epochs,
194
+ switch_pipeline=train_pipeline_stage2)
195
+ ]
196
+ train_cfg = dict(
197
+ max_epochs=max_epochs,
198
+ val_interval=10,
199
+ dynamic_intervals=[((max_epochs - close_mosaic_epochs),
200
+ _base_.val_interval_stage2)])
201
+ optim_wrapper = dict(optimizer=dict(
202
+ _delete_=True,
203
+ type='AdamW',
204
+ lr=base_lr,
205
+ weight_decay=weight_decay,
206
+ batch_size_per_gpu=train_batch_size_per_gpu),
207
+ paramwise_cfg=dict(
208
+ bias_decay_mult=0.0,
209
+ norm_decay_mult=0.0,
210
+ custom_keys={
211
+ 'backbone.text_model':
212
+ dict(lr_mult=0.0),
213
+ 'logit_scale':
214
+ dict(weight_decay=0.0)
215
+ }),
216
+ constructor='YOLOWv5OptimizerConstructor')
configs/scaleup/yolo_world_l_t2i_bn_2e-4_20e_4x8gpus_obj365v1_goldg_train_lvis_minival_s1280.py ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = ('../../third_party/mmyolo/configs/yolov8/'
2
+ 'yolov8_l_syncbn_fast_8xb16-500e_coco.py')
3
+ custom_imports = dict(imports=['yolo_world'],
4
+ allow_failed_imports=False)
5
+
6
+ # hyper-parameters
7
+ num_classes = 1203
8
+ num_training_classes = 80
9
+ max_epochs = 20 # Maximum training epochs
10
+ close_mosaic_epochs = 2
11
+ save_epoch_intervals = 2
12
+ text_channels = 512
13
+ neck_embed_channels = [128, 256, _base_.last_stage_out_channels // 2]
14
+ neck_num_heads = [4, 8, _base_.last_stage_out_channels // 2 // 32]
15
+ base_lr = 2e-4
16
+ weight_decay = 0.05 / 2
17
+ train_batch_size_per_gpu = 4
18
+ img_scale = (1280, 1280)
19
+ load_from = 'work_dirs/model_zoo/yolow-v8_l_clipv2_frozen_t2iv2_bn_o365_goldg_pretrain.pth' # noqa
20
+
21
+ # model settings
22
+ model = dict(
23
+ type='YOLOWorldDetector',
24
+ mm_neck=True,
25
+ num_train_classes=num_training_classes,
26
+ num_test_classes=num_classes,
27
+ data_preprocessor=dict(type='YOLOWDetDataPreprocessor'),
28
+ backbone=dict(
29
+ _delete_=True,
30
+ type='MultiModalYOLOBackbone',
31
+ image_model={{_base_.model.backbone}},
32
+ text_model=dict(
33
+ type='HuggingCLIPLanguageBackbone',
34
+ model_name='openai/clip-vit-base-patch32',
35
+ frozen_modules=['all'])),
36
+ neck=dict(type='YOLOWorldPAFPN',
37
+ guide_channels=text_channels,
38
+ embed_channels=neck_embed_channels,
39
+ num_heads=neck_num_heads,
40
+ block_cfg=dict(type='MaxSigmoidCSPLayerWithTwoConv'),
41
+ num_csp_blocks=2),
42
+ bbox_head=dict(type='YOLOWorldHead',
43
+ head_module=dict(type='YOLOWorldHeadModule',
44
+ embed_dims=text_channels,
45
+ use_bn_head=True,
46
+ num_classes=num_training_classes)),
47
+ train_cfg=dict(assigner=dict(num_classes=num_training_classes)))
48
+
49
+ # dataset settings
50
+ text_transform = [
51
+ dict(type='RandomLoadText',
52
+ num_neg_samples=(num_classes, num_classes),
53
+ max_num_samples=num_training_classes,
54
+ padding_to_max=True,
55
+ padding_value=''),
56
+ dict(type='mmdet.PackDetInputs',
57
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
58
+ 'flip_direction', 'texts'))
59
+ ]
60
+ mosaic_affine_transform = [
61
+ dict(type='MultiModalMosaic',
62
+ img_scale=img_scale,
63
+ pad_val=114.0,
64
+ pre_transform=_base_.pre_transform),
65
+ dict(
66
+ type='YOLOv5RandomAffine',
67
+ max_rotate_degree=0.0,
68
+ max_shear_degree=0.0,
69
+ scaling_ratio_range=(1 - _base_.affine_scale, 1 + _base_.affine_scale),
70
+ max_aspect_ratio=_base_.max_aspect_ratio,
71
+ border=(-img_scale[0] // 2, -img_scale[1] // 2),
72
+ border_val=(114, 114, 114))
73
+ ]
74
+ train_pipeline = [
75
+ *_base_.pre_transform,
76
+ *mosaic_affine_transform,
77
+ dict(
78
+ type='YOLOv5MultiModalMixUp',
79
+ prob=_base_.mixup_prob,
80
+ pre_transform=[*_base_.pre_transform,
81
+ *mosaic_affine_transform]),
82
+ *_base_.last_transform[:-1],
83
+ *text_transform,
84
+ ]
85
+ train_pipeline_stage2 = [
86
+ *_base_.pre_transform,
87
+ dict(type='YOLOv5KeepRatioResize', scale=img_scale),
88
+ dict(
89
+ type='LetterResize',
90
+ scale=img_scale,
91
+ allow_scale_up=True,
92
+ pad_val=dict(img=114.0)),
93
+ dict(
94
+ type='YOLOv5RandomAffine',
95
+ max_rotate_degree=0.0,
96
+ max_shear_degree=0.0,
97
+ scaling_ratio_range=(1 - _base_.affine_scale, 1 + _base_.affine_scale),
98
+ max_aspect_ratio=_base_.max_aspect_ratio,
99
+ border_val=(114, 114, 114)),
100
+ *_base_.last_transform[:-1],
101
+ *text_transform,
102
+ ]
103
+ obj365v1_train_dataset = dict(
104
+ type='MultiModalDataset',
105
+ dataset=dict(
106
+ type='YOLOv5Objects365V1Dataset',
107
+ data_root='data/objects365v1/',
108
+ ann_file='annotations/objects365_train.json',
109
+ data_prefix=dict(img='train/'),
110
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
111
+ class_text_path='data/captions/obj365v1_class_captions.json',
112
+ pipeline=train_pipeline)
113
+
114
+ mg_train_dataset = dict(
115
+ type='YOLOv5MixedGroundingDataset',
116
+ data_root='data/mixed_grounding/',
117
+ ann_file='annotations/final_mixed_train_no_coco.json',
118
+ data_prefix=dict(img='gqa/images/'),
119
+ filter_cfg=dict(filter_empty_gt=False, min_size=32),
120
+ pipeline=train_pipeline)
121
+
122
+ flickr_train_dataset = dict(
123
+ type='YOLOv5MixedGroundingDataset',
124
+ data_root='data/flickr/',
125
+ ann_file='annotations/final_flickr_separateGT_train.json',
126
+ data_prefix=dict(img='images/'),
127
+ filter_cfg=dict(filter_empty_gt=True, min_size=32),
128
+ pipeline=train_pipeline)
129
+
130
+ train_dataloader = dict(
131
+ batch_size=train_batch_size_per_gpu,
132
+ collate_fn=dict(type='yolow_collate'),
133
+ dataset=dict(
134
+ _delete_=True,
135
+ type='ConcatDataset',
136
+ datasets=[
137
+ obj365v1_train_dataset,
138
+ flickr_train_dataset,
139
+ mg_train_dataset
140
+ ],
141
+ ignore_keys=['classes', 'palette']))
142
+
143
+ test_pipeline = [
144
+ dict(type='LoadImageFromFile', backend_args=_base_.backend_args),
145
+ dict(type='YOLOv5KeepRatioResize', scale=img_scale),
146
+ dict(
147
+ type='LetterResize',
148
+ scale=img_scale,
149
+ allow_scale_up=False,
150
+ pad_val=dict(img=114)),
151
+ dict(type='LoadAnnotations', with_bbox=True, _scope_='mmdet'),
152
+ dict(type='LoadText'),
153
+ dict(type='mmdet.PackDetInputs',
154
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
155
+ 'scale_factor', 'pad_param', 'texts'))
156
+ ]
157
+ coco_val_dataset = dict(
158
+ _delete_=True,
159
+ type='MultiModalDataset',
160
+ dataset=dict(
161
+ type='YOLOv5LVISV1Dataset',
162
+ data_root='data/lvis/',
163
+ test_mode=True,
164
+ ann_file='annotations/'
165
+ 'lvis_v1_minival_inserted_image_name.json',
166
+ data_prefix=dict(img=''),
167
+ batch_shapes_cfg=None),
168
+ class_text_path='data/captions/lvis_v1_class_captions.json',
169
+ pipeline=test_pipeline)
170
+ val_dataloader = dict(dataset=coco_val_dataset)
171
+ test_dataloader = val_dataloader
172
+
173
+ val_evaluator = dict(
174
+ type='mmdet.LVISMetric',
175
+ ann_file='data/lvis/annotations/'
176
+ 'lvis_v1_minival_inserted_image_name.json',
177
+ metric='bbox')
178
+ test_evaluator = val_evaluator
179
+
180
+ # training settings
181
+ default_hooks = dict(
182
+ param_scheduler=dict(max_epochs=max_epochs),
183
+ checkpoint=dict(interval=save_epoch_intervals,
184
+ rule='greater'))
185
+ custom_hooks = [
186
+ dict(type='EMAHook',
187
+ ema_type='ExpMomentumEMA',
188
+ momentum=0.0001,
189
+ update_buffers=True,
190
+ strict_load=False,
191
+ priority=49),
192
+ dict(type='mmdet.PipelineSwitchHook',
193
+ switch_epoch=max_epochs - close_mosaic_epochs,
194
+ switch_pipeline=train_pipeline_stage2)
195
+ ]
196
+ train_cfg = dict(
197
+ max_epochs=max_epochs,
198
+ val_interval=10,
199
+ dynamic_intervals=[((max_epochs - close_mosaic_epochs),
200
+ _base_.val_interval_stage2)])
201
+ optim_wrapper = dict(optimizer=dict(
202
+ _delete_=True,
203
+ type='AdamW',
204
+ lr=base_lr,
205
+ weight_decay=weight_decay,
206
+ batch_size_per_gpu=train_batch_size_per_gpu),
207
+ paramwise_cfg=dict(
208
+ bias_decay_mult=0.0,
209
+ norm_decay_mult=0.0,
210
+ custom_keys={
211
+ 'backbone.text_model':
212
+ dict(lr_mult=0.0),
213
+ 'logit_scale':
214
+ dict(weight_decay=0.0)
215
+ }),
216
+ constructor='YOLOWv5OptimizerConstructor')
configs/scaleup/yolo_world_l_t2i_bn_2e-4_20e_4x8gpus_obj365v1_goldg_train_lvis_minival_s1280_v2.py ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _base_ = ('../../third_party/mmyolo/configs/yolov8/'
2
+ 'yolov8_l_syncbn_fast_8xb16-500e_coco.py')
3
+ custom_imports = dict(imports=['yolo_world'],
4
+ allow_failed_imports=False)
5
+
6
+ # hyper-parameters
7
+ num_classes = 1203
8
+ num_training_classes = 80
9
+ max_epochs = 20 # Maximum training epochs
10
+ close_mosaic_epochs = 2
11
+ save_epoch_intervals = 2
12
+ text_channels = 512
13
+ neck_embed_channels = [128, 256, _base_.last_stage_out_channels // 2]
14
+ neck_num_heads = [4, 8, _base_.last_stage_out_channels // 2 // 32]
15
+ base_lr = 2e-4
16
+ weight_decay = 0.05 / 2
17
+ train_batch_size_per_gpu = 6
18
+ img_scale = (1280, 1280)
19
+ load_from = 'work_dirs/yolo_world_l_t2i_bn_2e-4_20e_4x8gpus_obj365v1_goldg_train_lvis_minival_s1280/epoch_20.pth' # noqa
20
+
21
+ # model settings
22
+ model = dict(
23
+ type='YOLOWorldDetector',
24
+ mm_neck=True,
25
+ num_train_classes=num_training_classes,
26
+ num_test_classes=num_classes,
27
+ data_preprocessor=dict(type='YOLOWDetDataPreprocessor'),
28
+ backbone=dict(
29
+ _delete_=True,
30
+ type='MultiModalYOLOBackbone',
31
+ image_model={{_base_.model.backbone}},
32
+ text_model=dict(
33
+ type='HuggingCLIPLanguageBackbone',
34
+ model_name='openai/clip-vit-base-patch32',
35
+ frozen_modules=['all'])),
36
+ neck=dict(type='YOLOWorldPAFPN',
37
+ guide_channels=text_channels,
38
+ embed_channels=neck_embed_channels,
39
+ num_heads=neck_num_heads,
40
+ block_cfg=dict(type='MaxSigmoidCSPLayerWithTwoConv'),
41
+ num_csp_blocks=2),
42
+ bbox_head=dict(type='YOLOWorldHead',
43
+ head_module=dict(type='YOLOWorldHeadModule',
44
+ embed_dims=text_channels,
45
+ use_bn_head=True,
46
+ num_classes=num_training_classes)),
47
+ train_cfg=dict(assigner=dict(num_classes=num_training_classes)))
48
+
49
+ # dataset settings
50
+ text_transform = [
51
+ dict(type='RandomLoadText',
52
+ num_neg_samples=(num_classes, num_classes),
53
+ max_num_samples=num_training_classes,
54
+ padding_to_max=True,
55
+ padding_value=''),
56
+ dict(type='mmdet.PackDetInputs',
57
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
58
+ 'flip_direction', 'texts'))
59
+ ]
60
+ mosaic_affine_transform = [
61
+ dict(type='MultiModalMosaic',
62
+ img_scale=img_scale,
63
+ pad_val=114.0,
64
+ pre_transform=_base_.pre_transform),
65
+ dict(
66
+ type='YOLOv5RandomAffine',
67
+ max_rotate_degree=0.0,
68
+ max_shear_degree=0.0,
69
+ scaling_ratio_range=(1 - _base_.affine_scale, 1 + _base_.affine_scale),
70
+ max_aspect_ratio=_base_.max_aspect_ratio,
71
+ border=(-img_scale[0] // 2, -img_scale[1] // 2),
72
+ border_val=(114, 114, 114))
73
+ ]
74
+ train_pipeline = [
75
+ *_base_.pre_transform,
76
+ *mosaic_affine_transform,
77
+ dict(
78
+ type='YOLOv5MultiModalMixUp',
79
+ prob=_base_.mixup_prob,
80
+ pre_transform=[*_base_.pre_transform,
81
+ *mosaic_affine_transform]),
82
+ *_base_.last_transform[:-1],
83
+ *text_transform,
84
+ ]
85
+ train_pipeline_stage2 = [
86
+ *_base_.pre_transform,
87
+ dict(type='YOLOv5KeepRatioResize', scale=img_scale),
88
+ dict(
89
+ type='LetterResize',
90
+ scale=img_scale,
91
+ allow_scale_up=True,
92
+ pad_val=dict(img=114.0)),
93
+ dict(
94
+ type='YOLOv5RandomAffine',
95
+ max_rotate_degree=0.0,
96
+ max_shear_degree=0.0,
97
+ scaling_ratio_range=(1 - _base_.affine_scale, 1 + _base_.affine_scale),
98
+ max_aspect_ratio=_base_.max_aspect_ratio,
99
+ border_val=(114, 114, 114)),
100
+ *_base_.last_transform[:-1],
101
+ *text_transform,
102
+ ]
103
+ obj365v1_train_dataset = dict(
104
+ type='MultiModalDataset',
105
+ dataset=dict(
106
+ type='YOLOv5Objects365V1Dataset',
107
+ data_root='data/objects365v1/',
108
+ ann_file='annotations/objects365_train.json',
109
+ data_prefix=dict(img='train/'),
110
+ filter_cfg=dict(filter_empty_gt=False, min_size=32)),
111
+ class_text_path='data/captions/obj365v1_class_captions.json',
112
+ pipeline=train_pipeline)
113
+
114
+ mg_train_dataset = dict(
115
+ type='YOLOv5MixedGroundingDataset',
116
+ data_root='data/mixed_grounding/',
117
+ ann_file='annotations/final_mixed_train_no_coco.json',
118
+ data_prefix=dict(img='gqa/images/'),
119
+ filter_cfg=dict(filter_empty_gt=False, min_size=32),
120
+ pipeline=train_pipeline)
121
+
122
+ flickr_train_dataset = dict(
123
+ type='YOLOv5MixedGroundingDataset',
124
+ data_root='data/flickr/',
125
+ ann_file='annotations/final_flickr_separateGT_train.json',
126
+ data_prefix=dict(img='images/'),
127
+ filter_cfg=dict(filter_empty_gt=True, min_size=32),
128
+ pipeline=train_pipeline)
129
+
130
+ train_dataloader = dict(
131
+ batch_size=train_batch_size_per_gpu,
132
+ collate_fn=dict(type='yolow_collate'),
133
+ dataset=dict(
134
+ _delete_=True,
135
+ type='ConcatDataset',
136
+ datasets=[
137
+ obj365v1_train_dataset,
138
+ flickr_train_dataset,
139
+ mg_train_dataset
140
+ ],
141
+ ignore_keys=['classes', 'palette']))
142
+
143
+ test_pipeline = [
144
+ dict(type='LoadImageFromFile', backend_args=_base_.backend_args),
145
+ dict(type='YOLOv5KeepRatioResize', scale=img_scale),
146
+ dict(
147
+ type='LetterResize',
148
+ scale=img_scale,
149
+ allow_scale_up=False,
150
+ pad_val=dict(img=114)),
151
+ dict(type='LoadAnnotations', with_bbox=True, _scope_='mmdet'),
152
+ dict(type='LoadText'),
153
+ dict(type='mmdet.PackDetInputs',
154
+ meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
155
+ 'scale_factor', 'pad_param', 'texts'))
156
+ ]
157
+ coco_val_dataset = dict(
158
+ _delete_=True,
159
+ type='MultiModalDataset',
160
+ dataset=dict(
161
+ type='YOLOv5LVISV1Dataset',
162
+ data_root='data/lvis/',
163
+ test_mode=True,
164
+ ann_file='annotations/'
165
+ 'lvis_v1_minival_inserted_image_name.json',
166
+ data_prefix=dict(img=''),
167
+ batch_shapes_cfg=None),
168
+ class_text_path='data/captions/lvis_v1_class_captions.json',
169
+ pipeline=test_pipeline)
170
+ val_dataloader = dict(dataset=coco_val_dataset)
171
+ test_dataloader = val_dataloader
172
+
173
+ val_evaluator = dict(
174
+ type='mmdet.LVISMetric',
175
+ ann_file='data/lvis/annotations/'
176
+ 'lvis_v1_minival_inserted_image_name.json',
177
+ metric='bbox')
178
+ test_evaluator = val_evaluator
179
+
180
+ # training settings
181
+ default_hooks = dict(
182
+ param_scheduler=dict(max_epochs=max_epochs),
183
+ checkpoint=dict(interval=save_epoch_intervals,
184
+ rule='greater'))
185
+ custom_hooks = [
186
+ dict(type='EMAHook',
187
+ ema_type='ExpMomentumEMA',
188
+ momentum=0.0001,
189
+ update_buffers=True,
190
+ strict_load=False,
191
+ priority=49),
192
+ dict(type='mmdet.PipelineSwitchHook',
193
+ switch_epoch=max_epochs - close_mosaic_epochs,
194
+ switch_pipeline=train_pipeline_stage2)
195
+ ]
196
+ train_cfg = dict(
197
+ max_epochs=max_epochs,
198
+ val_interval=10,
199
+ dynamic_intervals=[((max_epochs - close_mosaic_epochs),
200
+ _base_.val_interval_stage2)])
201
+ optim_wrapper = dict(optimizer=dict(
202
+ _delete_=True,
203
+ type='AdamW',
204
+ lr=base_lr,
205
+ weight_decay=weight_decay,
206
+ batch_size_per_gpu=train_batch_size_per_gpu),
207
+ paramwise_cfg=dict(
208
+ bias_decay_mult=0.0,
209
+ norm_decay_mult=0.0,
210
+ custom_keys={
211
+ 'backbone.text_model':
212
+ dict(lr_mult=0.0),
213
+ 'logit_scale':
214
+ dict(weight_decay=0.0)
215
+ }),
216
+ constructor='YOLOWv5OptimizerConstructor')
deploy/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from .models import * # noqa
deploy/models/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ from .detectors import * # noqa
2
+ from .dense_heads import * # noqa
3
+ from .layers import * # noqa
4
+ from .necks import * # noqa
docs/data.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Preparing Data for YOLO-World
2
+
3
+
4
+ ### Overview
5
+
6
+
7
+
8
+ ### Pre-training Data
9
+
10
+ | Data | Samples | Type | Boxes | Annotations |
11
+ | :-- | :-----: | :---:| :---: | :---------: |
12
+ | Objects365v1 | | detection | | |
13
+ | GQA | | ground | | |
14
+ | Flickr | | ground | | |
15
+
16
+
17
+
18
+
19
+
docs/deploy.md ADDED
File without changes
docs/install.md ADDED
File without changes
docs/training.md ADDED
File without changes
requirements.txt ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ openmim
2
+ mmcv-lite>=2.0.0rc4,<2.1.0
3
+ mmdet>=3.0.0
4
+ mmengine>=0.7.1
5
+ mmyolo
6
+ gradio
7
+ transformers
8
+ addict
9
+ yapf
10
+ numpy
11
+ opencv-python
12
+ supervision==0.18.0
13
+ ftfy
14
+ regex
15
+ pot
16
+ sentencepiece
17
+ tokenizers
18
+ onnx
19
+ onnxruntime
20
+ onnxruntime-gpu
21
+ onnx-simplifier
22
+
23
+ --extra-index-url https://download.pytorch.org/whl/cu118
24
+ torch==2.0.1
25
+ torchvision==0.15.2
setup.py ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Tencent Inc. All rights reserved.
2
+ import os
3
+ import os.path as osp
4
+ import shutil
5
+ import sys
6
+ import warnings
7
+ from setuptools import find_packages, setup
8
+
9
+
10
+ def readme():
11
+ with open('README.md', encoding='utf-8') as f:
12
+ content = f.read()
13
+ return content
14
+
15
+
16
+ def get_version():
17
+ version_file = 'yolo_world/version.py'
18
+ with open(version_file, 'r', encoding='utf-8') as f:
19
+ exec(compile(f.read(), version_file, 'exec'))
20
+ return locals()['__version__']
21
+
22
+
23
+ def parse_requirements(fname='requirements.txt', with_version=True):
24
+ """Parse the package dependencies listed in a requirements file but strips
25
+ specific versioning information.
26
+
27
+ Args:
28
+ fname (str): path to requirements file
29
+ with_version (bool, default=False): if True include version specs
30
+
31
+ Returns:
32
+ List[str]: list of requirements items
33
+
34
+ CommandLine:
35
+ python -c "import setup; print(setup.parse_requirements())"
36
+ """
37
+ import re
38
+ import sys
39
+ from os.path import exists
40
+ require_fpath = fname
41
+
42
+ def parse_line(line):
43
+ """Parse information from a line in a requirements text file."""
44
+ if line.startswith('-r '):
45
+ # Allow specifying requirements in other files
46
+ target = line.split(' ')[1]
47
+ for info in parse_require_file(target):
48
+ yield info
49
+ else:
50
+ info = {'line': line}
51
+ if line.startswith('-e '):
52
+ info['package'] = line.split('#egg=')[1]
53
+ else:
54
+ # Remove versioning from the package
55
+ pat = '(' + '|'.join(['>=', '==', '>']) + ')'
56
+ parts = re.split(pat, line, maxsplit=1)
57
+ parts = [p.strip() for p in parts]
58
+
59
+ info['package'] = parts[0]
60
+ if len(parts) > 1:
61
+ op, rest = parts[1:]
62
+ if ';' in rest:
63
+ # Handle platform specific dependencies
64
+ # http://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-platform-specific-dependencies
65
+ version, platform_deps = map(str.strip,
66
+ rest.split(';'))
67
+ info['platform_deps'] = platform_deps
68
+ else:
69
+ version = rest # NOQA
70
+ if '--' in version:
71
+ # the `extras_require` doesn't accept options.
72
+ version = version.split('--')[0].strip()
73
+ info['version'] = (op, version)
74
+ yield info
75
+
76
+ def parse_require_file(fpath):
77
+ with open(fpath, 'r') as f:
78
+ for line in f.readlines():
79
+ line = line.strip()
80
+ if line and not line.startswith('#'):
81
+ for info in parse_line(line):
82
+ yield info
83
+
84
+ def gen_packages_items():
85
+ if exists(require_fpath):
86
+ for info in parse_require_file(require_fpath):
87
+ parts = [info['package']]
88
+ if with_version and 'version' in info:
89
+ parts.extend(info['version'])
90
+ if not sys.version.startswith('3.4'):
91
+ # apparently package_deps are broken in 3.4
92
+ platform_deps = info.get('platform_deps')
93
+ if platform_deps is not None:
94
+ parts.append(';' + platform_deps)
95
+ item = ''.join(parts)
96
+ yield item
97
+
98
+ packages = list(gen_packages_items())
99
+ return packages
100
+
101
+
102
+ def add_mim_extension():
103
+ """Add extra files that are required to support MIM into the package.
104
+
105
+ These files will be added by creating a symlink to the originals if the
106
+ package is installed in `editable` mode (e.g. pip install -e .), or by
107
+ copying from the originals otherwise.
108
+ """
109
+
110
+ # parse installment mode
111
+ if 'develop' in sys.argv:
112
+ # installed by `pip install -e .`
113
+ mode = 'symlink'
114
+ elif 'sdist' in sys.argv or 'bdist_wheel' in sys.argv:
115
+ # installed by `pip install .`
116
+ # or create source distribution by `python setup.py sdist`
117
+ mode = 'copy'
118
+ else:
119
+ return
120
+
121
+ filenames = ['tools', 'configs', 'model-index.yml', 'dataset-index.yml']
122
+ repo_path = osp.dirname(__file__)
123
+ mim_path = osp.join(repo_path, 'yolo_world', '.mim')
124
+ os.makedirs(mim_path, exist_ok=True)
125
+
126
+ for filename in filenames:
127
+ if osp.exists(filename):
128
+ src_path = osp.join(repo_path, filename)
129
+ tar_path = osp.join(mim_path, filename)
130
+
131
+ if osp.isfile(tar_path) or osp.islink(tar_path):
132
+ os.remove(tar_path)
133
+ elif osp.isdir(tar_path):
134
+ shutil.rmtree(tar_path)
135
+
136
+ if mode == 'symlink':
137
+ src_relpath = osp.relpath(src_path, osp.dirname(tar_path))
138
+ try:
139
+ os.symlink(src_relpath, tar_path)
140
+ except OSError:
141
+ # Creating a symbolic link on windows may raise an
142
+ # `OSError: [WinError 1314]` due to privilege. If
143
+ # the error happens, the src file will be copied
144
+ mode = 'copy'
145
+ warnings.warn(
146
+ f'Failed to create a symbolic link for {src_relpath}, '
147
+ f'and it will be copied to {tar_path}')
148
+ else:
149
+ continue
150
+
151
+ if mode == 'copy':
152
+ if osp.isfile(src_path):
153
+ shutil.copyfile(src_path, tar_path)
154
+ elif osp.isdir(src_path):
155
+ shutil.copytree(src_path, tar_path)
156
+ else:
157
+ warnings.warn(f'Cannot copy file {src_path}.')
158
+ else:
159
+ raise ValueError(f'Invalid mode {mode}')
160
+
161
+
162
+ if __name__ == '__main__':
163
+ setup(
164
+ name='yolo_world',
165
+ version=get_version(),
166
+ description='YOLO-World: Real-time Open Vocabulary Object Detection',
167
+ long_description=readme(),
168
+ long_description_content_type='text/markdown',
169
+ keywords='object detection',
170
+ packages=find_packages(exclude=(
171
+ 'data', 'third_party', 'tools')),
172
+ include_package_data=True,
173
+ python_requires='>=3.7',
174
+ classifiers=[
175
+ 'Development Status :: 4 - Beta',
176
+ 'License :: OSI Approved :: Apache Software License',
177
+ 'Operating System :: OS Independent',
178
+ 'Programming Language :: Python :: 3',
179
+ 'Programming Language :: Python :: 3.7',
180
+ 'Programming Language :: Python :: 3.8',
181
+ 'Programming Language :: Python :: 3.9',
182
+ 'Programming Language :: Python :: 3.10',
183
+ 'Programming Language :: Python :: 3.11',
184
+ 'Topic :: Scientific/Engineering :: Artificial Intelligence',
185
+ ],
186
+ author='Tencent AILab',
187
+ author_email='ronnysong@tencent.com',
188
+ license='Apache License 2.0',
189
+ install_requires=parse_requirements('requirements.txt'),
190
+ zip_safe=False)
third_party/mmyolo/.circleci/config.yml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: 2.1
2
+
3
+ # this allows you to use CircleCI's dynamic configuration feature
4
+ setup: true
5
+
6
+ # the path-filtering orb is required to continue a pipeline based on
7
+ # the path of an updated fileset
8
+ orbs:
9
+ path-filtering: circleci/path-filtering@0.1.2
10
+
11
+ workflows:
12
+ # the always-run workflow is always triggered, regardless of the pipeline parameters.
13
+ always-run:
14
+ jobs:
15
+ # the path-filtering/filter job determines which pipeline
16
+ # parameters to update.
17
+ - path-filtering/filter:
18
+ name: check-updated-files
19
+ # 3-column, whitespace-delimited mapping. One mapping per
20
+ # line:
21
+ # <regex path-to-test> <parameter-to-set> <value-of-pipeline-parameter>
22
+ mapping: |
23
+ mmyolo/.* lint_only false
24
+ requirements/.* lint_only false
25
+ tests/.* lint_only false
26
+ tools/.* lint_only false
27
+ configs/.* lint_only false
28
+ .circleci/.* lint_only false
29
+ base-revision: main
30
+ # this is the path of the configuration we should trigger once
31
+ # path filtering and pipeline parameter value updates are
32
+ # complete. In this case, we are using the parent dynamic
33
+ # configuration itself.
34
+ config-path: .circleci/test.yml
third_party/mmyolo/.circleci/docker/Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ARG PYTORCH="1.8.1"
2
+ ARG CUDA="10.2"
3
+ ARG CUDNN="7"
4
+
5
+ FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel
6
+
7
+ # To fix GPG key error when running apt-get update
8
+ RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
9
+ RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
10
+
11
+ RUN apt-get update && apt-get install -y ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 libgl1-mesa-glx
third_party/mmyolo/.circleci/test.yml ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: 2.1
2
+
3
+ # the default pipeline parameters, which will be updated according to
4
+ # the results of the path-filtering orb
5
+ parameters:
6
+ lint_only:
7
+ type: boolean
8
+ default: true
9
+
10
+ jobs:
11
+ lint:
12
+ docker:
13
+ - image: cimg/python:3.7.4
14
+ steps:
15
+ - checkout
16
+ - run:
17
+ name: Install pre-commit hook
18
+ command: |
19
+ pip install pre-commit
20
+ pre-commit install
21
+ - run:
22
+ name: Linting
23
+ command: pre-commit run --all-files
24
+ - run:
25
+ name: Check docstring coverage
26
+ command: |
27
+ pip install interrogate
28
+ interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-magic --ignore-regex "__repr__" --fail-under 90 mmyolo
29
+ build_cpu:
30
+ parameters:
31
+ # The python version must match available image tags in
32
+ # https://circleci.com/developer/images/image/cimg/python
33
+ python:
34
+ type: string
35
+ torch:
36
+ type: string
37
+ torchvision:
38
+ type: string
39
+ docker:
40
+ - image: cimg/python:<< parameters.python >>
41
+ resource_class: large
42
+ steps:
43
+ - checkout
44
+ - run:
45
+ name: Install Libraries
46
+ command: |
47
+ sudo apt-get update
48
+ sudo apt-get install -y ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 libgl1-mesa-glx libjpeg-dev zlib1g-dev libtinfo-dev libncurses5
49
+ - run:
50
+ name: Configure Python & pip
51
+ command: |
52
+ pip install --upgrade pip
53
+ pip install wheel
54
+ - run:
55
+ name: Install PyTorch
56
+ command: |
57
+ python -V
58
+ pip install torch==<< parameters.torch >>+cpu torchvision==<< parameters.torchvision >>+cpu -f https://download.pytorch.org/whl/torch_stable.html
59
+ - run:
60
+ name: Install ONNXRuntime
61
+ command: |
62
+ pip install onnxruntime==1.8.1
63
+ wget https://github.com/microsoft/onnxruntime/releases/download/v1.8.1/onnxruntime-linux-x64-1.8.1.tgz
64
+ tar xvf onnxruntime-linux-x64-1.8.1.tgz
65
+ - run:
66
+ name: Install mmyolo dependencies
67
+ command: |
68
+ pip install -U openmim
69
+ mim install git+https://github.com/open-mmlab/mmengine.git@main
70
+ mim install 'mmcv >= 2.0.0'
71
+ mim install git+https://github.com/open-mmlab/mmdetection.git@dev-3.x
72
+ pip install -r requirements/albu.txt
73
+ pip install -r requirements/tests.txt
74
+ - run:
75
+ name: Install mmdeploy
76
+ command: |
77
+ pip install setuptools
78
+ git clone -b dev-1.x --depth 1 https://github.com/open-mmlab/mmdeploy.git mmdeploy --recurse-submodules
79
+ wget https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0-linux-x86_64.tar.gz
80
+ tar -xzvf cmake-3.20.0-linux-x86_64.tar.gz
81
+ sudo ln -sf $(pwd)/cmake-3.20.0-linux-x86_64/bin/* /usr/bin/
82
+ cd mmdeploy && mkdir build && cd build && cmake .. -DMMDEPLOY_TARGET_BACKENDS=ort -DONNXRUNTIME_DIR=/home/circleci/project/onnxruntime-linux-x64-1.8.1 && make -j8 && make install
83
+ export LD_LIBRARY_PATH=/home/circleci/project/onnxruntime-linux-x64-1.8.1/lib:${LD_LIBRARY_PATH}
84
+ cd /home/circleci/project/mmdeploy && python -m pip install -v -e .
85
+ - run:
86
+ name: Build and install
87
+ command: |
88
+ pip install -e .
89
+ - run:
90
+ name: Run unittests
91
+ command: |
92
+ export LD_LIBRARY_PATH=/home/circleci/project/onnxruntime-linux-x64-1.8.1/lib:${LD_LIBRARY_PATH}
93
+ pytest tests/
94
+ # coverage run --branch --source mmyolo -m pytest tests/
95
+ # coverage xml
96
+ # coverage report -m
97
+ build_cuda:
98
+ parameters:
99
+ torch:
100
+ type: string
101
+ cuda:
102
+ type: enum
103
+ enum: ["10.1", "10.2", "11.0", "11.7"]
104
+ cudnn:
105
+ type: integer
106
+ default: 7
107
+ machine:
108
+ image: ubuntu-2004-cuda-11.4:202110-01
109
+ # docker_layer_caching: true
110
+ resource_class: gpu.nvidia.small
111
+ steps:
112
+ - checkout
113
+ - run:
114
+ # Cloning repos in VM since Docker doesn't have access to the private key
115
+ name: Clone Repos
116
+ command: |
117
+ git clone -b main --depth 1 https://github.com/open-mmlab/mmengine.git /home/circleci/mmengine
118
+ git clone -b dev-3.x --depth 1 https://github.com/open-mmlab/mmdetection.git /home/circleci/mmdetection
119
+ - run:
120
+ name: Build Docker image
121
+ command: |
122
+ docker build .circleci/docker -t mmyolo:gpu --build-arg PYTORCH=<< parameters.torch >> --build-arg CUDA=<< parameters.cuda >> --build-arg CUDNN=<< parameters.cudnn >>
123
+ docker run --gpus all -t -d -v /home/circleci/project:/mmyolo -v /home/circleci/mmengine:/mmengine -v /home/circleci/mmdetection:/mmdetection -w /mmyolo --name mmyolo mmyolo:gpu
124
+ - run:
125
+ name: Install mmyolo dependencies
126
+ command: |
127
+ docker exec mmyolo pip install -U openmim
128
+ docker exec mmyolo mim install -e /mmengine
129
+ docker exec mmyolo mim install 'mmcv >= 2.0.0'
130
+ docker exec mmyolo pip install -e /mmdetection
131
+ docker exec mmyolo pip install -r requirements/albu.txt
132
+ docker exec mmyolo pip install -r requirements/tests.txt
133
+ - run:
134
+ name: Build and install
135
+ command: |
136
+ docker exec mmyolo pip install -e .
137
+ - run:
138
+ name: Run unittests
139
+ command: |
140
+ docker exec mmyolo pytest tests/
141
+
142
+ workflows:
143
+ pr_stage_lint:
144
+ when: << pipeline.parameters.lint_only >>
145
+ jobs:
146
+ - lint:
147
+ name: lint
148
+ filters:
149
+ branches:
150
+ ignore:
151
+ - main
152
+
153
+ pr_stage_test:
154
+ when:
155
+ not: << pipeline.parameters.lint_only >>
156
+ jobs:
157
+ - lint:
158
+ name: lint
159
+ filters:
160
+ branches:
161
+ ignore:
162
+ - main
163
+ - build_cpu:
164
+ name: minimum_version_cpu
165
+ torch: 1.8.0
166
+ torchvision: 0.9.0
167
+ python: 3.8.0 # The lowest python 3.7.x version available on CircleCI images
168
+ requires:
169
+ - lint
170
+ - build_cpu:
171
+ name: maximum_version_cpu
172
+ # mmdeploy not supported
173
+ # torch: 2.0.0
174
+ # torchvision: 0.15.1
175
+ torch: 1.12.1
176
+ torchvision: 0.13.1
177
+ python: 3.9.0
178
+ requires:
179
+ - minimum_version_cpu
180
+ - hold:
181
+ type: approval
182
+ requires:
183
+ - maximum_version_cpu
184
+ - build_cuda:
185
+ name: mainstream_version_gpu
186
+ torch: 1.8.1
187
+ # Use double quotation mark to explicitly specify its type
188
+ # as string instead of number
189
+ cuda: "10.2"
190
+ requires:
191
+ - hold
192
+ - build_cuda:
193
+ name: maximum_version_gpu
194
+ torch: 2.0.0
195
+ cuda: "11.7"
196
+ cudnn: 8
197
+ requires:
198
+ - hold
199
+ merge_stage_test:
200
+ when:
201
+ not: << pipeline.parameters.lint_only >>
202
+ jobs:
203
+ - build_cuda:
204
+ name: minimum_version_gpu
205
+ torch: 1.7.0
206
+ # Use double quotation mark to explicitly specify its type
207
+ # as string instead of number
208
+ cuda: "11.0"
209
+ cudnn: 8
210
+ filters:
211
+ branches:
212
+ only:
213
+ - main
third_party/mmyolo/.dev_scripts/gather_models.py ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) OpenMMLab. All rights reserved.
2
+ import argparse
3
+ import glob
4
+ import os
5
+ import os.path as osp
6
+ import shutil
7
+ import subprocess
8
+ import time
9
+ from collections import OrderedDict
10
+
11
+ import torch
12
+ import yaml
13
+ from mmengine.config import Config
14
+ from mmengine.fileio import dump
15
+ from mmengine.utils import mkdir_or_exist, scandir
16
+
17
+
18
+ def ordered_yaml_dump(data, stream=None, Dumper=yaml.SafeDumper, **kwds):
19
+
20
+ class OrderedDumper(Dumper):
21
+ pass
22
+
23
+ def _dict_representer(dumper, data):
24
+ return dumper.represent_mapping(
25
+ yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, data.items())
26
+
27
+ OrderedDumper.add_representer(OrderedDict, _dict_representer)
28
+ return yaml.dump(data, stream, OrderedDumper, **kwds)
29
+
30
+
31
+ def process_checkpoint(in_file, out_file):
32
+ checkpoint = torch.load(in_file, map_location='cpu')
33
+ # remove optimizer for smaller file size
34
+ if 'optimizer' in checkpoint:
35
+ del checkpoint['optimizer']
36
+ if 'message_hub' in checkpoint:
37
+ del checkpoint['message_hub']
38
+ if 'ema_state_dict' in checkpoint:
39
+ del checkpoint['ema_state_dict']
40
+
41
+ for key in list(checkpoint['state_dict']):
42
+ if key.startswith('data_preprocessor'):
43
+ checkpoint['state_dict'].pop(key)
44
+ elif 'priors_base_sizes' in key:
45
+ checkpoint['state_dict'].pop(key)
46
+ elif 'grid_offset' in key:
47
+ checkpoint['state_dict'].pop(key)
48
+ elif 'prior_inds' in key:
49
+ checkpoint['state_dict'].pop(key)
50
+
51
+ # if it is necessary to remove some sensitive data in checkpoint['meta'],
52
+ # add the code here.
53
+ if torch.__version__ >= '1.6':
54
+ torch.save(checkpoint, out_file, _use_new_zipfile_serialization=False)
55
+ else:
56
+ torch.save(checkpoint, out_file)
57
+ sha = subprocess.check_output(['sha256sum', out_file]).decode()
58
+ final_file = out_file.rstrip('.pth') + f'-{sha[:8]}.pth'
59
+ subprocess.Popen(['mv', out_file, final_file])
60
+ return final_file
61
+
62
+
63
+ def is_by_epoch(config):
64
+ cfg = Config.fromfile('./configs/' + config)
65
+ return cfg.train_cfg.type == 'EpochBasedTrainLoop'
66
+
67
+
68
+ def get_final_epoch_or_iter(config):
69
+ cfg = Config.fromfile('./configs/' + config)
70
+ if cfg.train_cfg.type == 'EpochBasedTrainLoop':
71
+ return cfg.train_cfg.max_epochs
72
+ else:
73
+ return cfg.train_cfg.max_iters
74
+
75
+
76
+ def get_best_epoch_or_iter(exp_dir):
77
+ best_epoch_iter_full_path = list(
78
+ sorted(glob.glob(osp.join(exp_dir, 'best_*.pth'))))[-1]
79
+ best_epoch_or_iter_model_path = best_epoch_iter_full_path.split('/')[-1]
80
+ best_epoch_or_iter = best_epoch_or_iter_model_path. \
81
+ split('_')[-1].split('.')[0]
82
+ return best_epoch_or_iter_model_path, int(best_epoch_or_iter)
83
+
84
+
85
+ def get_real_epoch_or_iter(config):
86
+ cfg = Config.fromfile('./configs/' + config)
87
+ if cfg.train_cfg.type == 'EpochBasedTrainLoop':
88
+ epoch = cfg.train_cfg.max_epochs
89
+ return epoch
90
+ else:
91
+ return cfg.runner.max_iters
92
+
93
+
94
+ def get_final_results(log_json_path,
95
+ epoch_or_iter,
96
+ results_lut='coco/bbox_mAP',
97
+ by_epoch=True):
98
+ result_dict = dict()
99
+ with open(log_json_path) as f:
100
+ r = f.readlines()[-1]
101
+ last_metric = r.split(',')[0].split(': ')[-1].strip()
102
+ result_dict[results_lut] = last_metric
103
+ return result_dict
104
+
105
+
106
+ def get_dataset_name(config):
107
+ # If there are more dataset, add here.
108
+ name_map = dict(
109
+ CityscapesDataset='Cityscapes',
110
+ CocoDataset='COCO',
111
+ PoseCocoDataset='COCO Person',
112
+ YOLOv5CocoDataset='COCO',
113
+ CocoPanopticDataset='COCO',
114
+ YOLOv5DOTADataset='DOTA 1.0',
115
+ DeepFashionDataset='Deep Fashion',
116
+ LVISV05Dataset='LVIS v0.5',
117
+ LVISV1Dataset='LVIS v1',
118
+ VOCDataset='Pascal VOC',
119
+ YOLOv5VOCDataset='Pascal VOC',
120
+ WIDERFaceDataset='WIDER Face',
121
+ OpenImagesDataset='OpenImagesDataset',
122
+ OpenImagesChallengeDataset='OpenImagesChallengeDataset')
123
+ cfg = Config.fromfile('./configs/' + config)
124
+ return name_map[cfg.dataset_type]
125
+
126
+
127
+ def find_last_dir(model_dir):
128
+ dst_times = []
129
+ for time_stamp in os.scandir(model_dir):
130
+ if osp.isdir(time_stamp):
131
+ dst_time = time.mktime(
132
+ time.strptime(time_stamp.name, '%Y%m%d_%H%M%S'))
133
+ dst_times.append([dst_time, time_stamp.name])
134
+ return max(dst_times, key=lambda x: x[0])[1]
135
+
136
+
137
+ def convert_model_info_to_pwc(model_infos):
138
+ pwc_files = {}
139
+ for model in model_infos:
140
+ cfg_folder_name = osp.split(model['config'])[-2]
141
+ pwc_model_info = OrderedDict()
142
+ pwc_model_info['Name'] = osp.split(model['config'])[-1].split('.')[0]
143
+ pwc_model_info['In Collection'] = 'Please fill in Collection name'
144
+ pwc_model_info['Config'] = osp.join('configs', model['config'])
145
+
146
+ # get metadata
147
+ meta_data = OrderedDict()
148
+ if 'epochs' in model:
149
+ meta_data['Epochs'] = get_real_epoch_or_iter(model['config'])
150
+ else:
151
+ meta_data['Iterations'] = get_real_epoch_or_iter(model['config'])
152
+ pwc_model_info['Metadata'] = meta_data
153
+
154
+ # get dataset name
155
+ dataset_name = get_dataset_name(model['config'])
156
+
157
+ # get results
158
+ results = []
159
+ # if there are more metrics, add here.
160
+ if 'bbox_mAP' in model['results']:
161
+ metric = round(model['results']['bbox_mAP'] * 100, 1)
162
+ results.append(
163
+ OrderedDict(
164
+ Task='Object Detection',
165
+ Dataset=dataset_name,
166
+ Metrics={'box AP': metric}))
167
+ if 'segm_mAP' in model['results']:
168
+ metric = round(model['results']['segm_mAP'] * 100, 1)
169
+ results.append(
170
+ OrderedDict(
171
+ Task='Instance Segmentation',
172
+ Dataset=dataset_name,
173
+ Metrics={'mask AP': metric}))
174
+ if 'PQ' in model['results']:
175
+ metric = round(model['results']['PQ'], 1)
176
+ results.append(
177
+ OrderedDict(
178
+ Task='Panoptic Segmentation',
179
+ Dataset=dataset_name,
180
+ Metrics={'PQ': metric}))
181
+ pwc_model_info['Results'] = results
182
+
183
+ link_string = 'https://download.openmmlab.com/mmyolo/v0/'
184
+ link_string += '{}/{}'.format(model['config'].rstrip('.py'),
185
+ osp.split(model['model_path'])[-1])
186
+ pwc_model_info['Weights'] = link_string
187
+ if cfg_folder_name in pwc_files:
188
+ pwc_files[cfg_folder_name].append(pwc_model_info)
189
+ else:
190
+ pwc_files[cfg_folder_name] = [pwc_model_info]
191
+ return pwc_files
192
+
193
+
194
+ def parse_args():
195
+ parser = argparse.ArgumentParser(description='Gather benchmarked models')
196
+ parser.add_argument(
197
+ 'root',
198
+ type=str,
199
+ help='root path of benchmarked models to be gathered')
200
+ parser.add_argument(
201
+ 'out', type=str, help='output path of gathered models to be stored')
202
+ parser.add_argument(
203
+ '--best',
204
+ action='store_true',
205
+ help='whether to gather the best model.')
206
+
207
+ args = parser.parse_args()
208
+ return args
209
+
210
+
211
+ # TODO: Refine
212
+ def main():
213
+ args = parse_args()
214
+ models_root = args.root
215
+ models_out = args.out
216
+ mkdir_or_exist(models_out)
217
+
218
+ # find all models in the root directory to be gathered
219
+ raw_configs = list(scandir('./configs', '.py', recursive=True))
220
+
221
+ # filter configs that is not trained in the experiments dir
222
+ used_configs = []
223
+ for raw_config in raw_configs:
224
+ if osp.exists(osp.join(models_root, raw_config)):
225
+ used_configs.append(raw_config)
226
+ print(f'Find {len(used_configs)} models to be gathered')
227
+
228
+ # find final_ckpt and log file for trained each config
229
+ # and parse the best performance
230
+ model_infos = []
231
+ for used_config in used_configs:
232
+ exp_dir = osp.join(models_root, used_config)
233
+ by_epoch = is_by_epoch(used_config)
234
+ # check whether the exps is finished
235
+ if args.best is True:
236
+ final_model, final_epoch_or_iter = get_best_epoch_or_iter(exp_dir)
237
+ else:
238
+ final_epoch_or_iter = get_final_epoch_or_iter(used_config)
239
+ final_model = '{}_{}.pth'.format('epoch' if by_epoch else 'iter',
240
+ final_epoch_or_iter)
241
+
242
+ model_path = osp.join(exp_dir, final_model)
243
+ # skip if the model is still training
244
+ if not osp.exists(model_path):
245
+ continue
246
+
247
+ # get the latest logs
248
+ latest_exp_name = find_last_dir(exp_dir)
249
+ latest_exp_json = osp.join(exp_dir, latest_exp_name, 'vis_data',
250
+ latest_exp_name + '.json')
251
+
252
+ model_performance = get_final_results(
253
+ latest_exp_json, final_epoch_or_iter, by_epoch=by_epoch)
254
+
255
+ if model_performance is None:
256
+ continue
257
+
258
+ model_info = dict(
259
+ config=used_config,
260
+ results=model_performance,
261
+ final_model=final_model,
262
+ latest_exp_json=latest_exp_json,
263
+ latest_exp_name=latest_exp_name)
264
+ model_info['epochs' if by_epoch else 'iterations'] = \
265
+ final_epoch_or_iter
266
+ model_infos.append(model_info)
267
+
268
+ # publish model for each checkpoint
269
+ publish_model_infos = []
270
+ for model in model_infos:
271
+ model_publish_dir = osp.join(models_out, model['config'].rstrip('.py'))
272
+ mkdir_or_exist(model_publish_dir)
273
+
274
+ model_name = osp.split(model['config'])[-1].split('.')[0]
275
+
276
+ model_name += '_' + model['latest_exp_name']
277
+ publish_model_path = osp.join(model_publish_dir, model_name)
278
+ trained_model_path = osp.join(models_root, model['config'],
279
+ model['final_model'])
280
+
281
+ # convert model
282
+ final_model_path = process_checkpoint(trained_model_path,
283
+ publish_model_path)
284
+
285
+ # copy log
286
+ shutil.copy(model['latest_exp_json'],
287
+ osp.join(model_publish_dir, f'{model_name}.log.json'))
288
+
289
+ # copy config to guarantee reproducibility
290
+ config_path = model['config']
291
+ config_path = osp.join(
292
+ 'configs',
293
+ config_path) if 'configs' not in config_path else config_path
294
+ target_config_path = osp.split(config_path)[-1]
295
+ shutil.copy(config_path, osp.join(model_publish_dir,
296
+ target_config_path))
297
+
298
+ model['model_path'] = final_model_path
299
+ publish_model_infos.append(model)
300
+
301
+ models = dict(models=publish_model_infos)
302
+ print(f'Totally gathered {len(publish_model_infos)} models')
303
+ dump(models, osp.join(models_out, 'model_info.json'))
304
+
305
+ pwc_files = convert_model_info_to_pwc(publish_model_infos)
306
+ for name in pwc_files:
307
+ with open(osp.join(models_out, name + '_metafile.yml'), 'w') as f:
308
+ ordered_yaml_dump(pwc_files[name], f, encoding='utf-8')
309
+
310
+
311
+ if __name__ == '__main__':
312
+ main()
third_party/mmyolo/.dev_scripts/print_registers.py ADDED
@@ -0,0 +1,448 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) OpenMMLab. All rights reserved.
2
+ import argparse
3
+ import importlib
4
+ import os
5
+ import os.path as osp
6
+ import pkgutil
7
+ import sys
8
+ import tempfile
9
+ from multiprocessing import Pool
10
+ from pathlib import Path
11
+
12
+ import numpy as np
13
+ import pandas as pd
14
+
15
+ # host_addr = 'https://gitee.com/open-mmlab'
16
+ host_addr = 'https://github.com/open-mmlab'
17
+ tools_list = ['tools', '.dev_scripts']
18
+ proxy_names = {
19
+ 'mmdet': 'mmdetection',
20
+ 'mmseg': 'mmsegmentation',
21
+ 'mmcls': 'mmclassification'
22
+ }
23
+ merge_module_keys = {'mmcv': ['mmengine']}
24
+ # exclude_prefix = {'mmcv': ['<class \'mmengine.model.']}
25
+ exclude_prefix = {}
26
+ markdown_title = '# MM 系列开源库注册表\n'
27
+ markdown_title += '(注意:本文档是通过 .dev_scripts/print_registers.py 脚本自动生成)'
28
+
29
+
30
+ def capitalize(repo_name):
31
+ lower = repo_name.lower()
32
+ if lower == 'mmcv':
33
+ return repo_name.upper()
34
+ elif lower.startswith('mm'):
35
+ return 'MM' + repo_name[2:]
36
+ return repo_name.capitalize()
37
+
38
+
39
+ def mkdir_or_exist(dir_name, mode=0o777):
40
+ if dir_name == '':
41
+ return
42
+ dir_name = osp.expanduser(dir_name)
43
+ os.makedirs(dir_name, mode=mode, exist_ok=True)
44
+
45
+
46
+ def parse_repo_name(repo_name):
47
+ proxy_names_rev = dict(zip(proxy_names.values(), proxy_names.keys()))
48
+ repo_name = proxy_names.get(repo_name, repo_name)
49
+ module_name = proxy_names_rev.get(repo_name, repo_name)
50
+ return repo_name, module_name
51
+
52
+
53
+ def git_pull_branch(repo_name, branch_name='', pulldir='.'):
54
+ mkdir_or_exist(pulldir)
55
+ exec_str = f'cd {pulldir};git init;git pull '
56
+ exec_str += f'{host_addr}/{repo_name}.git'
57
+ if branch_name:
58
+ exec_str += f' {branch_name}'
59
+ returncode = os.system(exec_str)
60
+ if returncode:
61
+ raise RuntimeError(
62
+ f'failed to get the remote repo, code: {returncode}')
63
+
64
+
65
+ def load_modules_from_dir(module_name, module_root, throw_error=False):
66
+ print(f'loading the {module_name} modules...')
67
+ # # install the dependencies
68
+ # if osp.exists(osp.join(pkg_dir, 'requirements.txt')):
69
+ # os.system('pip install -r requirements.txt')
70
+ # get all module list
71
+ module_list = []
72
+ error_dict = {}
73
+ module_root = osp.join(module_root, module_name)
74
+ assert osp.exists(module_root), \
75
+ f'cannot find the module root: {module_root}'
76
+ for _root, _dirs, _files in os.walk(module_root):
77
+ if (('__init__.py' not in _files)
78
+ and (osp.split(_root)[1] != '__pycache__')):
79
+ # add __init__.py file to the package
80
+ with open(osp.join(_root, '__init__.py'), 'w') as _:
81
+ pass
82
+
83
+ def _onerror(*args, **kwargs):
84
+ pass
85
+
86
+ for _finder, _name, _ispkg in pkgutil.walk_packages([module_root],
87
+ prefix=module_name +
88
+ '.',
89
+ onerror=_onerror):
90
+ try:
91
+ module = importlib.import_module(_name)
92
+ module_list.append(module)
93
+ except Exception as e:
94
+ if throw_error:
95
+ raise e
96
+ _error_msg = f'{type(e)}: {e}.'
97
+ print(f'cannot import the module: {_name} ({_error_msg})')
98
+ assert (_name not in error_dict), \
99
+ f'duplicate error name was found: {_name}'
100
+ error_dict[_name] = _error_msg
101
+ for module in module_list:
102
+ assert module.__file__.startswith(module_root), \
103
+ f'the importing path of package was wrong: {module.__file__}'
104
+ print('modules were loaded...')
105
+ return module_list, error_dict
106
+
107
+
108
+ def get_registries_from_modules(module_list):
109
+ registries = {}
110
+ objects_set = set()
111
+ # import the Registry class,
112
+ # import at the beginning is not allowed
113
+ # because it is not the temp package
114
+ from mmengine.registry import Registry
115
+
116
+ # only get the specific registries in module list
117
+ for module in module_list:
118
+ for obj_name in dir(module):
119
+ _obj = getattr(module, obj_name)
120
+ if isinstance(_obj, Registry):
121
+ objects_set.add(_obj)
122
+ for _obj in objects_set:
123
+ if _obj.scope not in registries:
124
+ registries[_obj.scope] = {}
125
+ registries_scope = registries[_obj.scope]
126
+ assert _obj.name not in registries_scope, \
127
+ f'multiple definition of {_obj.name} in registries'
128
+ registries_scope[_obj.name] = {
129
+ key: str(val)
130
+ for key, val in _obj.module_dict.items()
131
+ }
132
+ print('registries got...')
133
+ return registries
134
+
135
+
136
+ def merge_registries(src_dict, dst_dict):
137
+ assert type(src_dict) == type(dst_dict), \
138
+ (f'merge type is not supported: '
139
+ f'{type(dst_dict)} and {type(src_dict)}')
140
+ if isinstance(src_dict, str):
141
+ return
142
+ for _k, _v in dst_dict.items():
143
+ if (_k not in src_dict):
144
+ src_dict.update({_k: _v})
145
+ else:
146
+ assert isinstance(_v, (dict, str)) and \
147
+ isinstance(src_dict[_k], (dict, str)), \
148
+ 'merge type is not supported: ' \
149
+ f'{type(_v)} and {type(src_dict[_k])}'
150
+ merge_registries(src_dict[_k], _v)
151
+
152
+
153
+ def exclude_registries(registries, exclude_key):
154
+ for _k in list(registries.keys()):
155
+ _v = registries[_k]
156
+ if isinstance(_v, str) and _v.startswith(exclude_key):
157
+ registries.pop(_k)
158
+ elif isinstance(_v, dict):
159
+ exclude_registries(_v, exclude_key)
160
+
161
+
162
+ def get_scripts_from_dir(root):
163
+
164
+ def _recurse(_dict, _chain):
165
+ if len(_chain) <= 1:
166
+ _dict[_chain[0]] = None
167
+ return
168
+ _key, *_chain = _chain
169
+ if _key not in _dict:
170
+ _dict[_key] = {}
171
+ _recurse(_dict[_key], _chain)
172
+
173
+ # find all scripts in the root directory. (not just ('.py', '.sh'))
174
+ # can not use the scandir function in mmengine to scan the dir,
175
+ # because mmengine import is not allowed before git pull
176
+ scripts = {}
177
+ for _subroot, _dirs, _files in os.walk(root):
178
+ for _file in _files:
179
+ _script = osp.join(osp.relpath(_subroot, root), _file)
180
+ _recurse(scripts, Path(_script).parts)
181
+ return scripts
182
+
183
+
184
+ def get_version_from_module_name(module_name, branch):
185
+ branch_str = str(branch) if branch is not None else ''
186
+ version_str = ''
187
+ try:
188
+ exec(f'import {module_name}')
189
+ _module = eval(f'{module_name}')
190
+ if hasattr(_module, '__version__'):
191
+ version_str = str(_module.__version__)
192
+ else:
193
+ version_str = branch_str
194
+ version_str = f' ({version_str})' if version_str else version_str
195
+ except (ImportError, AttributeError) as e:
196
+ print(f'can not get the version of module {module_name}: {e}')
197
+ return version_str
198
+
199
+
200
+ def print_tree(print_dict):
201
+ # recursive print the dict tree
202
+ def _recurse(_dict, _connector='', n=0):
203
+ assert isinstance(_dict, dict), 'recursive type must be dict'
204
+ tree = ''
205
+ for idx, (_key, _val) in enumerate(_dict.items()):
206
+ sub_tree = ''
207
+ _last = (idx == (len(_dict) - 1))
208
+ if isinstance(_val, str):
209
+ _key += f' ({_val})'
210
+ elif isinstance(_val, dict):
211
+ sub_tree = _recurse(_val,
212
+ _connector + (' ' if _last else '│ '),
213
+ n + 1)
214
+ else:
215
+ assert (_val is None), f'unknown print type {_val}'
216
+ tree += ' ' + _connector + \
217
+ ('└─' if _last else '├─') + f'({n}) {_key}' + '\n'
218
+ tree += sub_tree
219
+ return tree
220
+
221
+ for _pname, _pdict in print_dict.items():
222
+ print('-' * 100)
223
+ print(f'{_pname}\n' + _recurse(_pdict))
224
+
225
+
226
+ def divide_list_into_groups(_array, _maxsize_per_group):
227
+ if not _array:
228
+ return _array
229
+ _groups = np.asarray(len(_array) / _maxsize_per_group)
230
+ if len(_array) % _maxsize_per_group:
231
+ _groups = np.floor(_groups) + 1
232
+ _groups = _groups.astype(int)
233
+ return np.array_split(_array, _groups)
234
+
235
+
236
+ def registries_to_html(registries, title=''):
237
+ max_col_per_row = 5
238
+ max_size_per_cell = 20
239
+ html = ''
240
+ table_data = []
241
+ # save repository registries
242
+ for registry_name, registry_dict in registries.items():
243
+ # filter the empty registries
244
+ if not registry_dict:
245
+ continue
246
+ registry_strings = []
247
+ if isinstance(registry_dict, dict):
248
+ registry_dict = list(registry_dict.keys())
249
+ elif isinstance(registry_dict, list):
250
+ pass
251
+ else:
252
+ raise TypeError(
253
+ f'unknown type of registry_dict {type(registry_dict)}')
254
+ for _k in registry_dict:
255
+ registry_strings.append(f'<li>{_k}</li>')
256
+ table_data.append((registry_name, registry_strings))
257
+
258
+ # sort the data list
259
+ table_data = sorted(table_data, key=lambda x: len(x[1]))
260
+ # split multi parts
261
+ table_data_multi_parts = []
262
+ for (registry_name, registry_strings) in table_data:
263
+ multi_parts = False
264
+ if len(registry_strings) > max_size_per_cell:
265
+ multi_parts = True
266
+ for cell_idx, registry_cell in enumerate(
267
+ divide_list_into_groups(registry_strings, max_size_per_cell)):
268
+ registry_str = ''.join(registry_cell.tolist())
269
+ registry_str = f'<ul>{registry_str}</ul>'
270
+ table_data_multi_parts.append([
271
+ registry_name if not multi_parts else
272
+ f'{registry_name} (part {cell_idx + 1})', registry_str
273
+ ])
274
+
275
+ for table_data in divide_list_into_groups(table_data_multi_parts,
276
+ max_col_per_row):
277
+ table_data = list(zip(*table_data.tolist()))
278
+ html += dataframe_to_html(
279
+ pd.DataFrame([table_data[1]], columns=table_data[0]))
280
+ if html:
281
+ html = f'<div align=\'center\'><b>{title}</b></div>\n{html}'
282
+ html = f'<details open>{html}</details>\n'
283
+ return html
284
+
285
+
286
+ def tools_to_html(tools_dict, repo_name=''):
287
+
288
+ def _recurse(_dict, _connector, _result):
289
+ assert isinstance(_dict, dict), \
290
+ f'unknown recurse type: {_dict} ({type(_dict)})'
291
+ for _k, _v in _dict.items():
292
+ if _v is None:
293
+ if _connector not in _result:
294
+ _result[_connector] = []
295
+ _result[_connector].append(_k)
296
+ else:
297
+ _recurse(_v, osp.join(_connector, _k), _result)
298
+
299
+ table_data = {}
300
+ title = f'{capitalize(repo_name)} Tools'
301
+ _recurse(tools_dict, '', table_data)
302
+ return registries_to_html(table_data, title)
303
+
304
+
305
+ def dataframe_to_html(dataframe):
306
+ styler = dataframe.style
307
+ styler = styler.hide(axis='index')
308
+ styler = styler.format(na_rep='-')
309
+ styler = styler.set_properties(**{
310
+ 'text-align': 'left',
311
+ 'align': 'center',
312
+ 'vertical-align': 'top'
313
+ })
314
+ styler = styler.set_table_styles([{
315
+ 'selector':
316
+ 'thead th',
317
+ 'props':
318
+ 'align:center;text-align:center;vertical-align:bottom'
319
+ }])
320
+ html = styler.to_html()
321
+ html = f'<div align=\'center\'>\n{html}</div>'
322
+ return html
323
+
324
+
325
+ def generate_markdown_by_repository(repo_name,
326
+ module_name,
327
+ branch,
328
+ pulldir,
329
+ throw_error=False):
330
+ # add the pull dir to the system path so that it can be found
331
+ if pulldir not in sys.path:
332
+ sys.path.insert(0, pulldir)
333
+ module_list, error_dict = load_modules_from_dir(
334
+ module_name, pulldir, throw_error=throw_error)
335
+ registries_tree = get_registries_from_modules(module_list)
336
+ if error_dict:
337
+ error_dict_name = 'error_modules'
338
+ assert (error_dict_name not in registries_tree), \
339
+ f'duplicate module name was found: {error_dict_name}'
340
+ registries_tree.update({error_dict_name: error_dict})
341
+ # get the tools files
342
+ for tools_name in tools_list:
343
+ assert (tools_name not in registries_tree), \
344
+ f'duplicate tools name was found: {tools_name}'
345
+ tools_tree = osp.join(pulldir, tools_name)
346
+ tools_tree = get_scripts_from_dir(tools_tree)
347
+ registries_tree.update({tools_name: tools_tree})
348
+ # print_tree(registries_tree)
349
+ # get registries markdown string
350
+ module_registries = registries_tree.get(module_name, {})
351
+ for merge_key in merge_module_keys.get(module_name, []):
352
+ merge_dict = registries_tree.get(merge_key, {})
353
+ merge_registries(module_registries, merge_dict)
354
+ for exclude_key in exclude_prefix.get(module_name, []):
355
+ exclude_registries(module_registries, exclude_key)
356
+ markdown_str = registries_to_html(
357
+ module_registries, title=f'{capitalize(repo_name)} Module Components')
358
+ # get tools markdown string
359
+ tools_registries = {}
360
+ for tools_name in tools_list:
361
+ tools_registries.update(
362
+ {tools_name: registries_tree.get(tools_name, {})})
363
+ markdown_str += tools_to_html(tools_registries, repo_name=repo_name)
364
+ version_str = get_version_from_module_name(module_name, branch)
365
+ title_str = f'\n\n## {capitalize(repo_name)}{version_str}\n'
366
+ # remove the pull dir from system path
367
+ if pulldir in sys.path:
368
+ sys.path.remove(pulldir)
369
+ return f'{title_str}{markdown_str}'
370
+
371
+
372
+ def parse_args():
373
+ parser = argparse.ArgumentParser(
374
+ description='print registries in openmmlab repositories')
375
+ parser.add_argument(
376
+ '-r',
377
+ '--repositories',
378
+ nargs='+',
379
+ default=['mmdet', 'mmcls', 'mmseg', 'mmengine', 'mmcv'],
380
+ type=str,
381
+ help='git repositories name in OpenMMLab')
382
+ parser.add_argument(
383
+ '-b',
384
+ '--branches',
385
+ nargs='+',
386
+ default=['3.x', '1.x', '1.x', 'main', '2.x'],
387
+ type=str,
388
+ help='the branch names of git repositories, the length of branches '
389
+ 'must be same as the length of repositories')
390
+ parser.add_argument(
391
+ '-o', '--out', type=str, default='.', help='output path of the file')
392
+ parser.add_argument(
393
+ '--throw-error',
394
+ action='store_true',
395
+ default=False,
396
+ help='whether to throw error when trying to import modules')
397
+ args = parser.parse_args()
398
+ return args
399
+
400
+
401
+ # TODO: Refine
402
+ def main():
403
+ args = parse_args()
404
+ repositories = args.repositories
405
+ branches = args.branches
406
+ assert isinstance(repositories, list), \
407
+ 'Type of repositories must be list'
408
+ if branches is None:
409
+ branches = [None] * len(repositories)
410
+ assert isinstance(branches, list) and \
411
+ len(branches) == len(repositories), \
412
+ 'The length of branches must be same as ' \
413
+ 'that of repositories'
414
+ assert isinstance(args.out, str), \
415
+ 'The type of output path must be string'
416
+ # save path of file
417
+ mkdir_or_exist(args.out)
418
+ save_path = osp.join(args.out, 'registries_info.md')
419
+ with tempfile.TemporaryDirectory() as tmpdir:
420
+ # multi process init
421
+ pool = Pool(processes=len(repositories))
422
+ multi_proc_input_list = []
423
+ multi_proc_output_list = []
424
+ # get the git repositories
425
+ for branch, repository in zip(branches, repositories):
426
+ repo_name, module_name = parse_repo_name(repository)
427
+ pulldir = osp.join(tmpdir, f'tmp_{repo_name}')
428
+ git_pull_branch(
429
+ repo_name=repo_name, branch_name=branch, pulldir=pulldir)
430
+ multi_proc_input_list.append(
431
+ (repo_name, module_name, branch, pulldir, args.throw_error))
432
+ print('starting the multi process to get the registries')
433
+ for multi_proc_input in multi_proc_input_list:
434
+ multi_proc_output_list.append(
435
+ pool.apply_async(generate_markdown_by_repository,
436
+ multi_proc_input))
437
+ pool.close()
438
+ pool.join()
439
+ with open(save_path, 'w', encoding='utf-8') as fw:
440
+ fw.write(f'{markdown_title}\n')
441
+ for multi_proc_output in multi_proc_output_list:
442
+ markdown_str = multi_proc_output.get()
443
+ fw.write(f'{markdown_str}\n')
444
+ print(f'saved registries to the path: {save_path}')
445
+
446
+
447
+ if __name__ == '__main__':
448
+ main()
third_party/mmyolo/.github/CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ - Using welcoming and inclusive language
18
+ - Being respectful of differing viewpoints and experiences
19
+ - Gracefully accepting constructive criticism
20
+ - Focusing on what is best for the community
21
+ - Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ - The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ - Trolling, insulting/derogatory comments, and personal or political attacks
28
+ - Public or private harassment
29
+ - Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ - Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at chenkaidev@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ For answers to common questions about this code of conduct, see
74
+ https://www.contributor-covenant.org/faq
75
+
76
+ [homepage]: https://www.contributor-covenant.org
third_party/mmyolo/.github/CONTRIBUTING.md ADDED
@@ -0,0 +1 @@
 
 
1
+ We appreciate all contributions to improve MMYOLO. Please refer to [CONTRIBUTING.md](https://github.com/open-mmlab/mmcv/blob/master/CONTRIBUTING.md) in MMCV for more details about the contributing guideline.
third_party/mmyolo/.github/ISSUE_TEMPLATE/1-bug-report.yml ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "🐞 Bug report"
2
+ description: "Create a report to help us reproduce and fix the bug"
3
+
4
+
5
+ body:
6
+ - type: markdown
7
+ attributes:
8
+ value: |
9
+ Thank you for reporting this issue to help us improve!
10
+ If you have already identified the reason, we strongly appreciate you creating a new PR to fix it [here](https://github.com/open-mmlab/mmyolo/pulls)!
11
+ If this issue is about installing MMCV, please file an issue at [MMCV](https://github.com/open-mmlab/mmcv/issues/new/choose).
12
+ If you need our help, please fill in as much of the following form as you're able.
13
+
14
+ - type: checkboxes
15
+ attributes:
16
+ label: Prerequisite
17
+ description: Please check the following items before creating a new issue.
18
+ options:
19
+ - label: I have searched [the existing and past issues](https://github.com/open-mmlab/mmyolo/issues) but cannot get the expected help.
20
+ required: true
21
+ - label: I have read the [FAQ documentation](https://mmyolo.readthedocs.io/en/latest/faq.html) but cannot get the expected help.
22
+ required: true
23
+ - label: The bug has not been fixed in the [latest version](https://github.com/open-mmlab/mmyolo).
24
+ required: true
25
+
26
+ - type: textarea
27
+ attributes:
28
+ label: 🐞 Describe the bug
29
+ description: |
30
+ Please provide a clear and concise description of what the bug is.
31
+ Preferably a simple and minimal code snippet that we can reproduce the error by running the code.
32
+ placeholder: |
33
+ A clear and concise description of what the bug is.
34
+
35
+ ```python
36
+ # Sample code to reproduce the problem
37
+ ```
38
+
39
+ ```shell
40
+ The command or script you run.
41
+ ```
42
+
43
+ ```
44
+ The error message or logs you got, with the full traceback.
45
+ ```
46
+ validations:
47
+ required: true
48
+
49
+ - type: textarea
50
+ attributes:
51
+ label: Environment
52
+ description: |
53
+ Please run `python mmyolo/utils/collect_env.py` to collect necessary environment information and paste it here.
54
+ You may add addition that may be helpful for locating the problem, such as
55
+ - How you installed PyTorch \[e.g., pip, conda, source\]
56
+ - Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.)
57
+ validations:
58
+ required: true
59
+
60
+ - type: textarea
61
+ attributes:
62
+ label: Additional information
63
+ description: Tell us anything else you think we should know.
64
+ placeholder: |
65
+ 1. Did you make any modifications on the code or config? Did you understand what you have modified?
66
+ 2. What dataset did you use?
67
+ 3. What do you think might be the reason?
third_party/mmyolo/.github/ISSUE_TEMPLATE/2-feature-request.yml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 🚀 Feature request
2
+ description: Suggest an idea for this project
3
+ labels: [feature request]
4
+
5
+ body:
6
+ - type: markdown
7
+ attributes:
8
+ value: |
9
+ Thank you for suggesting an idea to make MMYOLO better.
10
+ We strongly appreciate you creating a PR to implete this feature [here](https://github.com/open-mmlab/mmyolo/pulls)!
11
+
12
+ If you need our help, please fill in as much of the following form as you're able.
13
+
14
+ - type: textarea
15
+ attributes:
16
+ label: What is the problem this feature will solve?
17
+ placeholder: |
18
+ E.g., It is inconvenient when \[....\].
19
+ validations:
20
+ required: true
21
+
22
+ - type: textarea
23
+ attributes:
24
+ label: What is the feature you are proposing to solve the problem?
25
+ validations:
26
+ required: true
27
+
28
+ - type: textarea
29
+ attributes:
30
+ label: What alternatives have you considered?
31
+ description: |
32
+ Add any other context or screenshots about the feature request here.
third_party/mmyolo/.github/ISSUE_TEMPLATE/3-new-model.yml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "\U0001F31F New model/dataset addition"
2
+ description: Submit a proposal/request to implement a new model / dataset
3
+ labels: [ "New model/dataset" ]
4
+
5
+ body:
6
+ - type: textarea
7
+ id: description-request
8
+ validations:
9
+ required: true
10
+ attributes:
11
+ label: Model/Dataset description
12
+ description: |
13
+ Put any and all important information relative to the model/dataset
14
+
15
+ - type: checkboxes
16
+ attributes:
17
+ label: Open source status
18
+ description: |
19
+ Please provide the open-source status, which would be very helpful
20
+ options:
21
+ - label: "The model implementation is available"
22
+ - label: "The model weights are available."
23
+
24
+ - type: textarea
25
+ id: additional-info
26
+ attributes:
27
+ label: Provide useful links for the implementation
28
+ description: |
29
+ Please provide information regarding the implementation, the weights, and the authors.
30
+ Please mention the authors by @gh-username if you're aware of their usernames.
third_party/mmyolo/.github/ISSUE_TEMPLATE/4-documentation.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 📚 Documentation
2
+ description: Report an issue related to https://mmyolo.readthedocs.io/en/latest/.
3
+
4
+ body:
5
+ - type: textarea
6
+ attributes:
7
+ label: 📚 The doc issue
8
+ description: >
9
+ A clear and concise description of what content in https://mmyolo.readthedocs.io/en/latest/ is an issue.
10
+ validations:
11
+ required: true
12
+
13
+ - type: textarea
14
+ attributes:
15
+ label: Suggest a potential alternative/fix
16
+ description: >
17
+ Tell us how we could improve the documentation in this regard.
18
+
19
+ - type: markdown
20
+ attributes:
21
+ value: >
22
+ Thanks for contributing 🎉!
third_party/mmyolo/.github/ISSUE_TEMPLATE/5-reimplementation.yml ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "💥 Reimplementation Questions"
2
+ description: "Ask about questions during model reimplementation"
3
+
4
+
5
+ body:
6
+ - type: markdown
7
+ attributes:
8
+ value: |
9
+ If you have already identified the reason, we strongly appreciate you creating a new PR to fix it [here](https://github.com/open-mmlab/mmyolo/pulls)!
10
+
11
+ - type: checkboxes
12
+ attributes:
13
+ label: Prerequisite
14
+ description: Please check the following items before creating a new issue.
15
+ options:
16
+ - label: I have searched [the existing and past issues](https://github.com/open-mmlab/mmyolo/issues) but cannot get the expected help.
17
+ required: true
18
+ - label: I have read the [FAQ documentation](https://mmyolo.readthedocs.io/en/latest/faq.html) but cannot get the expected help.
19
+ required: true
20
+ - label: The bug has not been fixed in the [latest version](https://github.com/open-mmlab/mmyolo).
21
+ required: true
22
+ validations:
23
+ required: true
24
+
25
+ - type: textarea
26
+ attributes:
27
+ label: 💬 Describe the reimplementation questions
28
+ description: |
29
+ A clear and concise description of what the problem you meet and what have you done.
30
+ There are several common situations in the reimplementation issues as below
31
+
32
+ 1. Reimplement a model in the model zoo using the provided configs
33
+ 2. Reimplement a model in the model zoo on other dataset (e.g., custom datasets)
34
+ 3. Reimplement a custom model but all the components are implemented in MMDetection
35
+ 4. Reimplement a custom model with new modules implemented by yourself
36
+
37
+ There are several things to do for different cases as below.
38
+
39
+ - For case 1 & 3, please follow the steps in the following sections thus we could help to quick identify the issue.
40
+ - For case 2 & 4, please understand that we are not able to do much help here because we usually do not know the full code and the users should be responsible to the code they write.
41
+ - One suggestion for case 2 & 4 is that the users should first check whether the bug lies in the self-implemented code or the original code. For example, users can first make sure that the same model runs well on supported datasets. If you still need help, please describe what you have done and what you obtain in the issue, and follow the steps in the following sections and try as clear as possible so that we can better help you.
42
+ placeholder: |
43
+ A clear and concise description of what the bug is.
44
+ What config dir you run?
45
+
46
+ ```none
47
+ A placeholder for the config.
48
+ ```
49
+
50
+ ```shell
51
+ The command or script you run.
52
+ ```
53
+
54
+ ```
55
+ The error message or logs you got, with the full traceback.
56
+ ```
57
+ validations:
58
+ required: true
59
+
60
+ - type: textarea
61
+ attributes:
62
+ label: Environment
63
+ description: |
64
+ Please run `python mmyolo/utils/collect_env.py` to collect necessary environment information and paste it here.
65
+ You may add addition that may be helpful for locating the problem, such as
66
+ - How you installed PyTorch \[e.g., pip, conda, source\]
67
+ - Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.)
68
+ validations:
69
+ required: true
70
+
71
+ - type: textarea
72
+ attributes:
73
+ label: Expected results
74
+ description: If applicable, paste the related results here, e.g., what you expect and what you get.
75
+ placeholder: |
76
+ ```none
77
+ A placeholder for results comparison
78
+ ```
79
+
80
+ - type: textarea
81
+ attributes:
82
+ label: Additional information
83
+ description: Tell us anything else you think we should know.
84
+ placeholder: |
85
+ 1. Did you make any modifications on the code or config? Did you understand what you have modified?
86
+ 2. What dataset did you use?
87
+ 3. What do you think might be the reason?
third_party/mmyolo/.github/ISSUE_TEMPLATE/config.yml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ blank_issues_enabled: true
2
+
3
+ contact_links:
4
+ - name: 💬 Forum
5
+ url: https://github.com/open-mmlab/mmyolo/discussions
6
+ about: Ask general usage questions and discuss with other MMYOLO community members
7
+ - name: 🌐 Explore OpenMMLab
8
+ url: https://openmmlab.com/
9
+ about: Get know more about OpenMMLab
third_party/mmyolo/.github/pull_request_template.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
2
+
3
+ ## Motivation
4
+
5
+ Please describe the motivation for this PR and the goal you want to achieve through this PR.
6
+
7
+ ## Modification
8
+
9
+ Please briefly describe what modification is made in this PR.
10
+
11
+ ## BC-breaking (Optional)
12
+
13
+ Does the modification introduce changes that break the backward compatibility of the downstream repos?
14
+ If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.
15
+
16
+ ## Use cases (Optional)
17
+
18
+ If this PR introduces a new feature, it is better to list some use cases here and update the documentation.
19
+
20
+ ## Checklist
21
+
22
+ 1. Pre-commit or other linting tools are used to fix potential lint issues.
23
+ 2. The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness.
24
+ 3. If the modification has a potential influence on downstream projects, this PR should be tested with downstream projects, like MMDetection or MMClassification.
25
+ 4. The documentation has been modified accordingly, like docstring or example tutorials.
third_party/mmyolo/.github/workflows/deploy.yml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: deploy
2
+
3
+ on: push
4
+
5
+ concurrency:
6
+ group: ${{ github.workflow }}-${{ github.ref }}
7
+ cancel-in-progress: true
8
+
9
+ jobs:
10
+ build-n-publish:
11
+ runs-on: ubuntu-latest
12
+ if: startsWith(github.event.ref, 'refs/tags')
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Python 3.7
16
+ uses: actions/setup-python@v2
17
+ with:
18
+ python-version: 3.7
19
+ - name: Install torch
20
+ run: pip install torch
21
+ - name: Install wheel
22
+ run: pip install wheel
23
+ - name: Build MMYOLO
24
+ run: python setup.py sdist bdist_wheel
25
+ - name: Publish distribution to PyPI
26
+ run: |
27
+ pip install twine
28
+ twine upload dist/* -u __token__ -p ${{ secrets.pypi_password }}
third_party/mmyolo/.gitignore ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+ MANIFEST
27
+
28
+ # PyInstaller
29
+ # Usually these files are written by a python script from a template
30
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
31
+ *.manifest
32
+ *.spec
33
+
34
+ # Installer logs
35
+ pip-log.txt
36
+ pip-delete-this-directory.txt
37
+
38
+ # Unit test / coverage reports
39
+ htmlcov/
40
+ .tox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ .hypothesis/
48
+ .pytest_cache/
49
+
50
+ # Translations
51
+ *.mo
52
+ *.pot
53
+
54
+ # Django stuff:
55
+ *.log
56
+ local_settings.py
57
+ db.sqlite3
58
+
59
+ # Flask stuff:
60
+ instance/
61
+ .webassets-cache
62
+
63
+ # Scrapy stuff:
64
+ .scrapy
65
+
66
+ # Sphinx documentation
67
+ docs/en/_build/
68
+ docs/zh_cn/_build/
69
+
70
+ # PyBuilder
71
+ target/
72
+
73
+ # Jupyter Notebook
74
+ .ipynb_checkpoints
75
+
76
+ # pyenv
77
+ .python-version
78
+
79
+ # celery beat schedule file
80
+ celerybeat-schedule
81
+
82
+ # SageMath parsed files
83
+ *.sage.py
84
+
85
+ # Environments
86
+ .env
87
+ .venv
88
+ env/
89
+ venv/
90
+ ENV/
91
+ env.bak/
92
+ venv.bak/
93
+
94
+ # Spyder project settings
95
+ .spyderproject
96
+ .spyproject
97
+
98
+ # Rope project settings
99
+ .ropeproject
100
+
101
+ # mkdocs documentation
102
+ /site
103
+
104
+ # mypy
105
+ .mypy_cache/
106
+ data/
107
+ data
108
+ .vscode
109
+ .idea
110
+ .DS_Store
111
+
112
+ # custom
113
+ *.pkl
114
+ *.pkl.json
115
+ *.log.json
116
+ docs/modelzoo_statistics.md
117
+ mmyolo/.mim
118
+ output/
119
+ work_dirs
120
+ yolov5-6.1/
121
+
122
+ # Pytorch
123
+ *.pth
124
+ *.pt
125
+ *.py~
126
+ *.sh~
third_party/mmyolo/.pre-commit-config-zh-cn.yaml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ exclude: ^tests/data/
2
+ repos:
3
+ - repo: https://gitee.com/openmmlab/mirrors-flake8
4
+ rev: 5.0.4
5
+ hooks:
6
+ - id: flake8
7
+ - repo: https://gitee.com/openmmlab/mirrors-isort
8
+ rev: 5.11.5
9
+ hooks:
10
+ - id: isort
11
+ - repo: https://gitee.com/openmmlab/mirrors-yapf
12
+ rev: v0.32.0
13
+ hooks:
14
+ - id: yapf
15
+ - repo: https://gitee.com/openmmlab/mirrors-pre-commit-hooks
16
+ rev: v4.3.0
17
+ hooks:
18
+ - id: trailing-whitespace
19
+ - id: check-yaml
20
+ - id: end-of-file-fixer
21
+ - id: requirements-txt-fixer
22
+ - id: double-quote-string-fixer
23
+ - id: check-merge-conflict
24
+ - id: fix-encoding-pragma
25
+ args: ["--remove"]
26
+ - id: mixed-line-ending
27
+ args: ["--fix=lf"]
28
+ - repo: https://gitee.com/openmmlab/mirrors-mdformat
29
+ rev: 0.7.9
30
+ hooks:
31
+ - id: mdformat
32
+ args: ["--number"]
33
+ additional_dependencies:
34
+ - mdformat-openmmlab
35
+ - mdformat_frontmatter
36
+ - linkify-it-py
37
+ - repo: https://gitee.com/openmmlab/mirrors-codespell
38
+ rev: v2.2.1
39
+ hooks:
40
+ - id: codespell
41
+ - repo: https://gitee.com/openmmlab/mirrors-docformatter
42
+ rev: v1.3.1
43
+ hooks:
44
+ - id: docformatter
45
+ args: ["--in-place", "--wrap-descriptions", "79"]
46
+ - repo: https://gitee.com/openmmlab/mirrors-pyupgrade
47
+ rev: v3.0.0
48
+ hooks:
49
+ - id: pyupgrade
50
+ args: ["--py36-plus"]
51
+ - repo: https://github.com/open-mmlab/pre-commit-hooks
52
+ rev: v0.2.0
53
+ hooks:
54
+ - id: check-copyright
55
+ args: ["mmyolo", "tests"]
56
+ # - repo: https://gitee.com/openmmlab/mirrors-mypy
57
+ # rev: v0.812
58
+ # hooks:
59
+ # - id: mypy
60
+ # exclude: "docs"
third_party/mmyolo/.pre-commit-config.yaml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ exclude: ^tests/data/
2
+ repos:
3
+ - repo: https://github.com/PyCQA/flake8
4
+ rev: 5.0.4
5
+ hooks:
6
+ - id: flake8
7
+ - repo: https://github.com/PyCQA/isort
8
+ rev: 5.11.5
9
+ hooks:
10
+ - id: isort
11
+ - repo: https://github.com/pre-commit/mirrors-yapf
12
+ rev: v0.32.0
13
+ hooks:
14
+ - id: yapf
15
+ - repo: https://github.com/pre-commit/pre-commit-hooks
16
+ rev: v4.3.0
17
+ hooks:
18
+ - id: trailing-whitespace
19
+ - id: check-yaml
20
+ - id: end-of-file-fixer
21
+ - id: requirements-txt-fixer
22
+ - id: double-quote-string-fixer
23
+ - id: check-merge-conflict
24
+ - id: fix-encoding-pragma
25
+ args: ["--remove"]
26
+ - id: mixed-line-ending
27
+ args: ["--fix=lf"]
28
+ - repo: https://github.com/executablebooks/mdformat
29
+ rev: 0.7.9
30
+ hooks:
31
+ - id: mdformat
32
+ args: ["--number"]
33
+ additional_dependencies:
34
+ - mdformat-openmmlab
35
+ - mdformat_frontmatter
36
+ - linkify-it-py
37
+ - repo: https://github.com/codespell-project/codespell
38
+ rev: v2.2.1
39
+ hooks:
40
+ - id: codespell
41
+ - repo: https://github.com/myint/docformatter
42
+ rev: v1.3.1
43
+ hooks:
44
+ - id: docformatter
45
+ args: ["--in-place", "--wrap-descriptions", "79"]
46
+ - repo: https://github.com/asottile/pyupgrade
47
+ rev: v3.0.0
48
+ hooks:
49
+ - id: pyupgrade
50
+ args: ["--py36-plus"]
51
+ - repo: https://github.com/open-mmlab/pre-commit-hooks
52
+ rev: v0.2.0
53
+ hooks:
54
+ - id: check-copyright
55
+ args: ["mmyolo", "tests"]
56
+ # - repo: https://github.com/pre-commit/mirrors-mypy
57
+ # rev: v0.812
58
+ # hooks:
59
+ # - id: mypy
60
+ # exclude: "docs"
third_party/mmyolo/.readthedocs.yml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ version: 2
2
+
3
+ formats: all
4
+
5
+ python:
6
+ version: 3.7
7
+ install:
8
+ - requirements: requirements/docs.txt
third_party/mmyolo/LICENSE ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ <one line to give the program's name and a brief idea of what it does.>
635
+ Copyright (C) <year> <name of author>
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ <program> Copyright (C) <year> <name of author>
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <https://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <https://www.gnu.org/licenses/why-not-lgpl.html>.
third_party/mmyolo/MANIFEST.in ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ include requirements/*.txt
2
+ include mmyolo/VERSION
3
+ include mmyolo/.mim/model-index.yml
4
+ include mmyolo/.mim/demo/*/*
5
+ recursive-include mmyolo/.mim/configs *.py *.yml
6
+ recursive-include mmyolo/.mim/tools *.sh *.py