Upload folder using huggingface_hub (part 11)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/custom_dataset/yolov5_s-v61_syncbn_fast_1xb32-100e_cat.py +76 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/custom_dataset/yolov6_s_syncbn_fast_1xb32-100e_cat.py +85 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/custom_dataset/yolov7_tiny_syncbn_fast_1xb32-100e_cat.py +78 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/README.md +3 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/rtmdet/rtmdet_l_fast_1xb32-100e_ionogram.py +107 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/rtmdet/rtmdet_s_fast_1xb32-100e_ionogram.py +83 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/rtmdet/rtmdet_tiny_fast_1xb32-100e_ionogram.py +62 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov5/yolov5_m-v61_fast_1xb32-100e_ionogram.py +95 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb32-100e_ionogram_mosaic.py +35 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py +108 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram_aug0.py +21 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram_mosaic_affine.py +29 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram_mosaic_affine_albu_hsv.py +44 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-200e_ionogram_pre0.py +17 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov6/yolov6_l_fast_1xb32-100e_ionogram.py +29 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov6/yolov6_m_fast_1xb32-100e_ionogram.py +63 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov6/yolov6_s_fast_1xb32-100e_ionogram.py +108 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov6/yolov6_s_fast_1xb32-200e_ionogram_pre0.py +17 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov7/yolov7_l_fast_1xb16-100e_ionogram.py +98 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov7/yolov7_tiny_fast_1xb16-100e_ionogram.py +101 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov7/yolov7_x_fast_1xb16-100e_ionogram.py +19 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/pytest.ini +7 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements.txt +3 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/albu.txt +1 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/build.txt +3 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/docs.txt +13 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/mminstall.txt +3 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/mmpose.txt +1 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/mmrotate.txt +1 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/runtime.txt +2 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/sahi.txt +1 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/tests.txt +17 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/resources/mmyolo-logo.png +3 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/resources/qq_group_qrcode.jpg +3 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/resources/zhihu_qrcode.jpg +3 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/setup.cfg +21 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/setup.py +191 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/regression/mmyolo.yml +81 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/__init__.py +1 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/test_transforms/__init__.py +1 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/test_transforms/test_formatting.py +119 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/test_transforms/test_mix_img_transforms.py +416 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/test_transforms/test_transforms.py +493 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/test_utils.py +138 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/test_yolov5_coco.py +71 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/test_yolov5_voc.py +86 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_deploy/conftest.py +13 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_deploy/test_mmyolo_models.py +165 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_deploy/test_object_detection.py +96 -0
- video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_downstream/test_mmrazor.py +21 -0
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/custom_dataset/yolov5_s-v61_syncbn_fast_1xb32-100e_cat.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = '../yolov5/yolov5_s-v61_syncbn_fast_8xb16-300e_coco.py'
|
| 2 |
+
|
| 3 |
+
max_epochs = 100
|
| 4 |
+
data_root = './data/cat/'
|
| 5 |
+
# data_root = '/root/workspace/mmyolo/data/cat/' # Docker
|
| 6 |
+
|
| 7 |
+
work_dir = './work_dirs/yolov5_s-v61_syncbn_fast_1xb32-100e_cat'
|
| 8 |
+
|
| 9 |
+
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov5/yolov5_s-v61_syncbn_fast_8xb16-300e_coco/yolov5_s-v61_syncbn_fast_8xb16-300e_coco_20220918_084700-86e02187.pth' # noqa
|
| 10 |
+
|
| 11 |
+
train_batch_size_per_gpu = 32
|
| 12 |
+
train_num_workers = 4
|
| 13 |
+
|
| 14 |
+
save_epoch_intervals = 2
|
| 15 |
+
|
| 16 |
+
# base_lr_default * (your_bs / default_bs)
|
| 17 |
+
base_lr = _base_.base_lr / 4
|
| 18 |
+
|
| 19 |
+
anchors = [
|
| 20 |
+
[(68, 69), (154, 91), (143, 162)], # P3/8
|
| 21 |
+
[(242, 160), (189, 287), (391, 207)], # P4/16
|
| 22 |
+
[(353, 337), (539, 341), (443, 432)] # P5/32
|
| 23 |
+
]
|
| 24 |
+
|
| 25 |
+
class_name = ('cat', )
|
| 26 |
+
num_classes = len(class_name)
|
| 27 |
+
metainfo = dict(classes=class_name, palette=[(220, 20, 60)])
|
| 28 |
+
|
| 29 |
+
train_cfg = dict(
|
| 30 |
+
max_epochs=max_epochs, val_begin=20, val_interval=save_epoch_intervals)
|
| 31 |
+
|
| 32 |
+
model = dict(
|
| 33 |
+
bbox_head=dict(
|
| 34 |
+
head_module=dict(num_classes=num_classes),
|
| 35 |
+
prior_generator=dict(base_sizes=anchors),
|
| 36 |
+
loss_cls=dict(loss_weight=0.5 *
|
| 37 |
+
(num_classes / 80 * 3 / _base_.num_det_layers))))
|
| 38 |
+
|
| 39 |
+
train_dataloader = dict(
|
| 40 |
+
batch_size=train_batch_size_per_gpu,
|
| 41 |
+
num_workers=train_num_workers,
|
| 42 |
+
dataset=dict(
|
| 43 |
+
_delete_=True,
|
| 44 |
+
type='RepeatDataset',
|
| 45 |
+
times=5,
|
| 46 |
+
dataset=dict(
|
| 47 |
+
type=_base_.dataset_type,
|
| 48 |
+
data_root=data_root,
|
| 49 |
+
metainfo=metainfo,
|
| 50 |
+
ann_file='annotations/trainval.json',
|
| 51 |
+
data_prefix=dict(img='images/'),
|
| 52 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
| 53 |
+
pipeline=_base_.train_pipeline)))
|
| 54 |
+
|
| 55 |
+
val_dataloader = dict(
|
| 56 |
+
dataset=dict(
|
| 57 |
+
metainfo=metainfo,
|
| 58 |
+
data_root=data_root,
|
| 59 |
+
ann_file='annotations/trainval.json',
|
| 60 |
+
data_prefix=dict(img='images/')))
|
| 61 |
+
|
| 62 |
+
test_dataloader = val_dataloader
|
| 63 |
+
|
| 64 |
+
val_evaluator = dict(ann_file=data_root + 'annotations/trainval.json')
|
| 65 |
+
test_evaluator = val_evaluator
|
| 66 |
+
|
| 67 |
+
optim_wrapper = dict(optimizer=dict(lr=base_lr))
|
| 68 |
+
|
| 69 |
+
default_hooks = dict(
|
| 70 |
+
checkpoint=dict(
|
| 71 |
+
type='CheckpointHook',
|
| 72 |
+
interval=save_epoch_intervals,
|
| 73 |
+
max_keep_ckpts=5,
|
| 74 |
+
save_best='auto'),
|
| 75 |
+
param_scheduler=dict(max_epochs=max_epochs),
|
| 76 |
+
logger=dict(type='LoggerHook', interval=10))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/custom_dataset/yolov6_s_syncbn_fast_1xb32-100e_cat.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = '../yolov6/yolov6_s_syncbn_fast_8xb32-400e_coco.py'
|
| 2 |
+
|
| 3 |
+
max_epochs = 100
|
| 4 |
+
data_root = './data/cat/'
|
| 5 |
+
|
| 6 |
+
work_dir = './work_dirs/yolov6_s_syncbn_fast_1xb32-100e_cat'
|
| 7 |
+
|
| 8 |
+
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov6/yolov6_s_syncbn_fast_8xb32-400e_coco/yolov6_s_syncbn_fast_8xb32-400e_coco_20221102_203035-932e1d91.pth' # noqa
|
| 9 |
+
|
| 10 |
+
train_batch_size_per_gpu = 32
|
| 11 |
+
train_num_workers = 4 # train_num_workers = nGPU x 4
|
| 12 |
+
|
| 13 |
+
save_epoch_intervals = 2
|
| 14 |
+
|
| 15 |
+
# base_lr_default * (your_bs / default_bs)
|
| 16 |
+
base_lr = _base_.base_lr / 8
|
| 17 |
+
|
| 18 |
+
class_name = ('cat', )
|
| 19 |
+
num_classes = len(class_name)
|
| 20 |
+
metainfo = dict(classes=class_name, palette=[(220, 20, 60)])
|
| 21 |
+
|
| 22 |
+
train_cfg = dict(
|
| 23 |
+
max_epochs=max_epochs,
|
| 24 |
+
val_begin=20,
|
| 25 |
+
val_interval=save_epoch_intervals,
|
| 26 |
+
dynamic_intervals=[(max_epochs - _base_.num_last_epochs, 1)])
|
| 27 |
+
|
| 28 |
+
model = dict(
|
| 29 |
+
bbox_head=dict(head_module=dict(num_classes=num_classes)),
|
| 30 |
+
train_cfg=dict(
|
| 31 |
+
initial_assigner=dict(num_classes=num_classes),
|
| 32 |
+
assigner=dict(num_classes=num_classes)))
|
| 33 |
+
|
| 34 |
+
train_dataloader = dict(
|
| 35 |
+
batch_size=train_batch_size_per_gpu,
|
| 36 |
+
num_workers=train_num_workers,
|
| 37 |
+
dataset=dict(
|
| 38 |
+
_delete_=True,
|
| 39 |
+
type='RepeatDataset',
|
| 40 |
+
times=5,
|
| 41 |
+
dataset=dict(
|
| 42 |
+
type=_base_.dataset_type,
|
| 43 |
+
data_root=data_root,
|
| 44 |
+
metainfo=metainfo,
|
| 45 |
+
ann_file='annotations/trainval.json',
|
| 46 |
+
data_prefix=dict(img='images/'),
|
| 47 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
| 48 |
+
pipeline=_base_.train_pipeline)))
|
| 49 |
+
|
| 50 |
+
val_dataloader = dict(
|
| 51 |
+
dataset=dict(
|
| 52 |
+
metainfo=metainfo,
|
| 53 |
+
data_root=data_root,
|
| 54 |
+
ann_file='annotations/trainval.json',
|
| 55 |
+
data_prefix=dict(img='images/')))
|
| 56 |
+
|
| 57 |
+
test_dataloader = val_dataloader
|
| 58 |
+
|
| 59 |
+
val_evaluator = dict(ann_file=data_root + 'annotations/trainval.json')
|
| 60 |
+
test_evaluator = val_evaluator
|
| 61 |
+
|
| 62 |
+
optim_wrapper = dict(optimizer=dict(lr=base_lr))
|
| 63 |
+
|
| 64 |
+
default_hooks = dict(
|
| 65 |
+
checkpoint=dict(
|
| 66 |
+
type='CheckpointHook',
|
| 67 |
+
interval=save_epoch_intervals,
|
| 68 |
+
max_keep_ckpts=5,
|
| 69 |
+
save_best='auto'),
|
| 70 |
+
param_scheduler=dict(max_epochs=max_epochs),
|
| 71 |
+
logger=dict(type='LoggerHook', interval=10))
|
| 72 |
+
|
| 73 |
+
custom_hooks = [
|
| 74 |
+
dict(
|
| 75 |
+
type='EMAHook',
|
| 76 |
+
ema_type='ExpMomentumEMA',
|
| 77 |
+
momentum=0.0001,
|
| 78 |
+
update_buffers=True,
|
| 79 |
+
strict_load=False,
|
| 80 |
+
priority=49),
|
| 81 |
+
dict(
|
| 82 |
+
type='mmdet.PipelineSwitchHook',
|
| 83 |
+
switch_epoch=max_epochs - _base_.num_last_epochs,
|
| 84 |
+
switch_pipeline=_base_.train_pipeline_stage2)
|
| 85 |
+
]
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/custom_dataset/yolov7_tiny_syncbn_fast_1xb32-100e_cat.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = '../yolov7/yolov7_tiny_syncbn_fast_8x16b-300e_coco.py'
|
| 2 |
+
|
| 3 |
+
max_epochs = 100
|
| 4 |
+
data_root = './data/cat/'
|
| 5 |
+
|
| 6 |
+
work_dir = './work_dirs/yolov7_tiny_syncbn_fast_1xb32-100e_cat'
|
| 7 |
+
|
| 8 |
+
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov7/yolov7_tiny_syncbn_fast_8x16b-300e_coco/yolov7_tiny_syncbn_fast_8x16b-300e_coco_20221126_102719-0ee5bbdf.pth' # noqa
|
| 9 |
+
|
| 10 |
+
train_batch_size_per_gpu = 32
|
| 11 |
+
train_num_workers = 4 # train_num_workers = nGPU x 4
|
| 12 |
+
|
| 13 |
+
save_epoch_intervals = 2
|
| 14 |
+
|
| 15 |
+
# base_lr_default * (your_bs / default_bs)
|
| 16 |
+
base_lr = 0.01 / 4
|
| 17 |
+
|
| 18 |
+
anchors = [
|
| 19 |
+
[(68, 69), (154, 91), (143, 162)], # P3/8
|
| 20 |
+
[(242, 160), (189, 287), (391, 207)], # P4/16
|
| 21 |
+
[(353, 337), (539, 341), (443, 432)] # P5/32
|
| 22 |
+
]
|
| 23 |
+
|
| 24 |
+
class_name = ('cat', )
|
| 25 |
+
num_classes = len(class_name)
|
| 26 |
+
metainfo = dict(classes=class_name, palette=[(220, 20, 60)])
|
| 27 |
+
|
| 28 |
+
train_cfg = dict(
|
| 29 |
+
max_epochs=max_epochs,
|
| 30 |
+
val_begin=20,
|
| 31 |
+
val_interval=save_epoch_intervals,
|
| 32 |
+
dynamic_intervals=[(max_epochs - 10, 1)])
|
| 33 |
+
|
| 34 |
+
model = dict(
|
| 35 |
+
bbox_head=dict(
|
| 36 |
+
head_module=dict(num_classes=num_classes),
|
| 37 |
+
prior_generator=dict(base_sizes=anchors),
|
| 38 |
+
loss_cls=dict(loss_weight=0.5 *
|
| 39 |
+
(num_classes / 80 * 3 / _base_.num_det_layers))))
|
| 40 |
+
|
| 41 |
+
train_dataloader = dict(
|
| 42 |
+
batch_size=train_batch_size_per_gpu,
|
| 43 |
+
num_workers=train_num_workers,
|
| 44 |
+
dataset=dict(
|
| 45 |
+
_delete_=True,
|
| 46 |
+
type='RepeatDataset',
|
| 47 |
+
times=5,
|
| 48 |
+
dataset=dict(
|
| 49 |
+
type=_base_.dataset_type,
|
| 50 |
+
data_root=data_root,
|
| 51 |
+
metainfo=metainfo,
|
| 52 |
+
ann_file='annotations/trainval.json',
|
| 53 |
+
data_prefix=dict(img='images/'),
|
| 54 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
| 55 |
+
pipeline=_base_.train_pipeline)))
|
| 56 |
+
|
| 57 |
+
val_dataloader = dict(
|
| 58 |
+
dataset=dict(
|
| 59 |
+
metainfo=metainfo,
|
| 60 |
+
data_root=data_root,
|
| 61 |
+
ann_file='annotations/trainval.json',
|
| 62 |
+
data_prefix=dict(img='images/')))
|
| 63 |
+
|
| 64 |
+
test_dataloader = val_dataloader
|
| 65 |
+
|
| 66 |
+
val_evaluator = dict(ann_file=data_root + 'annotations/trainval.json')
|
| 67 |
+
test_evaluator = val_evaluator
|
| 68 |
+
|
| 69 |
+
optim_wrapper = dict(optimizer=dict(lr=base_lr))
|
| 70 |
+
|
| 71 |
+
default_hooks = dict(
|
| 72 |
+
checkpoint=dict(
|
| 73 |
+
type='CheckpointHook',
|
| 74 |
+
interval=save_epoch_intervals,
|
| 75 |
+
max_keep_ckpts=2,
|
| 76 |
+
save_best='auto'),
|
| 77 |
+
param_scheduler=dict(max_epochs=max_epochs),
|
| 78 |
+
logger=dict(type='LoggerHook', interval=10))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Tips: 这是 MMYOLO 应用范例的配置文件,请结合 [基于 MMYOLO 的频高图实时目标检测 benchmark](/docs/zh_cn/recommended_topics/application_examples/ionogram_detection.md) 来使用。
|
| 2 |
+
|
| 3 |
+
Tips: This is the config file of the MMYOLO application examples. Please use it in combination with [A Benchmark for Ionogram Detection Based on MMYOLO](/docs/en/recommended_topics/application_examples/ionogram_detection.md).
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/rtmdet/rtmdet_l_fast_1xb32-100e_ionogram.py
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = 'mmyolo::rtmdet/rtmdet_l_syncbn_fast_8xb32-300e_coco.py'
|
| 2 |
+
|
| 3 |
+
# ======================== Modified parameters ======================
|
| 4 |
+
# -----data related-----
|
| 5 |
+
data_root = './Iono4311/'
|
| 6 |
+
train_ann_file = 'annotations/train.json'
|
| 7 |
+
train_data_prefix = 'train_images/'
|
| 8 |
+
val_ann_file = 'annotations/val.json'
|
| 9 |
+
val_data_prefix = 'val_images/'
|
| 10 |
+
test_ann_file = 'annotations/test.json'
|
| 11 |
+
test_data_prefix = 'test_images/'
|
| 12 |
+
|
| 13 |
+
class_name = ('E', 'Es-l', 'Es-c', 'F1', 'F2', 'Spread-F')
|
| 14 |
+
num_classes = len(class_name)
|
| 15 |
+
metainfo = dict(
|
| 16 |
+
classes=class_name,
|
| 17 |
+
palette=[(250, 165, 30), (120, 69, 125), (53, 125, 34), (0, 11, 123),
|
| 18 |
+
(130, 20, 12), (120, 121, 80)])
|
| 19 |
+
|
| 20 |
+
train_batch_size_per_gpu = 32
|
| 21 |
+
train_num_workers = 8
|
| 22 |
+
val_batch_size_per_gpu = train_batch_size_per_gpu
|
| 23 |
+
|
| 24 |
+
# Config of batch shapes. Only on val.
|
| 25 |
+
batch_shapes_cfg = dict(batch_size=val_batch_size_per_gpu)
|
| 26 |
+
|
| 27 |
+
# -----train val related-----
|
| 28 |
+
load_from = 'https://download.openmmlab.com/mmyolo/v0/rtmdet/rtmdet_l_syncbn_fast_8xb32-300e_coco/rtmdet_l_syncbn_fast_8xb32-300e_coco_20230102_135928-ee3abdc4.pth' # noqa
|
| 29 |
+
|
| 30 |
+
# default hooks
|
| 31 |
+
save_epoch_intervals = 10
|
| 32 |
+
max_epochs = 100
|
| 33 |
+
max_keep_ckpts = 1
|
| 34 |
+
|
| 35 |
+
# learning rate
|
| 36 |
+
param_scheduler = [
|
| 37 |
+
dict(
|
| 38 |
+
type='LinearLR', start_factor=1.0e-5, by_epoch=False, begin=0,
|
| 39 |
+
end=300),
|
| 40 |
+
dict(
|
| 41 |
+
# use cosine lr from 20 to 100 epoch
|
| 42 |
+
type='CosineAnnealingLR',
|
| 43 |
+
eta_min=_base_.base_lr * 0.05,
|
| 44 |
+
begin=max_epochs // 5,
|
| 45 |
+
end=max_epochs,
|
| 46 |
+
T_max=max_epochs * 4 // 5,
|
| 47 |
+
by_epoch=True,
|
| 48 |
+
convert_to_iter_based=True),
|
| 49 |
+
]
|
| 50 |
+
|
| 51 |
+
# train_cfg
|
| 52 |
+
val_interval = 2
|
| 53 |
+
val_begin = 20
|
| 54 |
+
|
| 55 |
+
tta_model = None
|
| 56 |
+
tta_pipeline = None
|
| 57 |
+
|
| 58 |
+
visualizer = dict(
|
| 59 |
+
vis_backends=[dict(type='LocalVisBackend'),
|
| 60 |
+
dict(type='WandbVisBackend')])
|
| 61 |
+
|
| 62 |
+
# ===================== Unmodified in most cases ==================
|
| 63 |
+
model = dict(
|
| 64 |
+
bbox_head=dict(head_module=dict(num_classes=num_classes)),
|
| 65 |
+
train_cfg=dict(assigner=dict(num_classes=num_classes)))
|
| 66 |
+
|
| 67 |
+
train_dataloader = dict(
|
| 68 |
+
batch_size=train_batch_size_per_gpu,
|
| 69 |
+
num_workers=train_num_workers,
|
| 70 |
+
dataset=dict(
|
| 71 |
+
metainfo=metainfo,
|
| 72 |
+
data_root=data_root,
|
| 73 |
+
ann_file=train_ann_file,
|
| 74 |
+
data_prefix=dict(img=train_data_prefix)))
|
| 75 |
+
|
| 76 |
+
val_dataloader = dict(
|
| 77 |
+
batch_size=val_batch_size_per_gpu,
|
| 78 |
+
num_workers=train_num_workers,
|
| 79 |
+
dataset=dict(
|
| 80 |
+
metainfo=metainfo,
|
| 81 |
+
data_root=data_root,
|
| 82 |
+
data_prefix=dict(img=val_data_prefix),
|
| 83 |
+
ann_file=val_ann_file))
|
| 84 |
+
|
| 85 |
+
test_dataloader = dict(
|
| 86 |
+
batch_size=val_batch_size_per_gpu,
|
| 87 |
+
num_workers=train_num_workers,
|
| 88 |
+
dataset=dict(
|
| 89 |
+
metainfo=metainfo,
|
| 90 |
+
data_root=data_root,
|
| 91 |
+
data_prefix=dict(img=test_data_prefix),
|
| 92 |
+
ann_file=test_ann_file))
|
| 93 |
+
|
| 94 |
+
default_hooks = dict(
|
| 95 |
+
checkpoint=dict(
|
| 96 |
+
interval=save_epoch_intervals,
|
| 97 |
+
max_keep_ckpts=max_keep_ckpts,
|
| 98 |
+
save_best='auto'))
|
| 99 |
+
|
| 100 |
+
val_evaluator = dict(ann_file=data_root + val_ann_file)
|
| 101 |
+
test_evaluator = dict(ann_file=data_root + test_ann_file)
|
| 102 |
+
|
| 103 |
+
train_cfg = dict(
|
| 104 |
+
type='EpochBasedTrainLoop',
|
| 105 |
+
max_epochs=max_epochs,
|
| 106 |
+
val_begin=val_begin,
|
| 107 |
+
val_interval=val_interval)
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/rtmdet/rtmdet_s_fast_1xb32-100e_ionogram.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = './rtmdet_l_fast_1xb32-100e_ionogram.py'
|
| 2 |
+
|
| 3 |
+
load_from = 'https://download.openmmlab.com/mmyolo/v0/rtmdet/rtmdet_s_syncbn_fast_8xb32-300e_coco/rtmdet_s_syncbn_fast_8xb32-300e_coco_20221230_182329-0a8c901a.pth' # noqa
|
| 4 |
+
|
| 5 |
+
# ======================= Modified parameters =====================
|
| 6 |
+
deepen_factor = 0.33
|
| 7 |
+
widen_factor = 0.5
|
| 8 |
+
img_scale = _base_.img_scale
|
| 9 |
+
|
| 10 |
+
# ratio range for random resize
|
| 11 |
+
random_resize_ratio_range = (0.5, 2.0)
|
| 12 |
+
# Number of cached images in mosaic
|
| 13 |
+
mosaic_max_cached_images = 40
|
| 14 |
+
# Number of cached images in mixup
|
| 15 |
+
mixup_max_cached_images = 20
|
| 16 |
+
|
| 17 |
+
# ===================== Unmodified in most cases ==================
|
| 18 |
+
model = dict(
|
| 19 |
+
backbone=dict(deepen_factor=deepen_factor, widen_factor=widen_factor),
|
| 20 |
+
neck=dict(
|
| 21 |
+
deepen_factor=deepen_factor,
|
| 22 |
+
widen_factor=widen_factor,
|
| 23 |
+
),
|
| 24 |
+
bbox_head=dict(head_module=dict(widen_factor=widen_factor)))
|
| 25 |
+
|
| 26 |
+
train_pipeline = [
|
| 27 |
+
dict(type='LoadImageFromFile', backend_args=_base_.backend_args),
|
| 28 |
+
dict(type='LoadAnnotations', with_bbox=True),
|
| 29 |
+
dict(
|
| 30 |
+
type='Mosaic',
|
| 31 |
+
img_scale=img_scale,
|
| 32 |
+
use_cached=True,
|
| 33 |
+
max_cached_images=mosaic_max_cached_images,
|
| 34 |
+
pad_val=114.0),
|
| 35 |
+
dict(
|
| 36 |
+
type='mmdet.RandomResize',
|
| 37 |
+
# img_scale is (width, height)
|
| 38 |
+
scale=(img_scale[0] * 2, img_scale[1] * 2),
|
| 39 |
+
ratio_range=random_resize_ratio_range, # note
|
| 40 |
+
resize_type='mmdet.Resize',
|
| 41 |
+
keep_ratio=True),
|
| 42 |
+
dict(type='mmdet.RandomCrop', crop_size=img_scale),
|
| 43 |
+
dict(type='mmdet.YOLOXHSVRandomAug'),
|
| 44 |
+
dict(type='mmdet.RandomFlip', prob=0.5),
|
| 45 |
+
dict(type='mmdet.Pad', size=img_scale, pad_val=dict(img=(114, 114, 114))),
|
| 46 |
+
dict(
|
| 47 |
+
type='YOLOv5MixUp',
|
| 48 |
+
use_cached=True,
|
| 49 |
+
max_cached_images=mixup_max_cached_images),
|
| 50 |
+
dict(type='mmdet.PackDetInputs')
|
| 51 |
+
]
|
| 52 |
+
|
| 53 |
+
train_pipeline_stage2 = [
|
| 54 |
+
dict(type='LoadImageFromFile', backend_args=_base_.backend_args),
|
| 55 |
+
dict(type='LoadAnnotations', with_bbox=True),
|
| 56 |
+
dict(
|
| 57 |
+
type='mmdet.RandomResize',
|
| 58 |
+
scale=img_scale,
|
| 59 |
+
ratio_range=random_resize_ratio_range, # note
|
| 60 |
+
resize_type='mmdet.Resize',
|
| 61 |
+
keep_ratio=True),
|
| 62 |
+
dict(type='mmdet.RandomCrop', crop_size=img_scale),
|
| 63 |
+
dict(type='mmdet.YOLOXHSVRandomAug'),
|
| 64 |
+
dict(type='mmdet.RandomFlip', prob=0.5),
|
| 65 |
+
dict(type='mmdet.Pad', size=img_scale, pad_val=dict(img=(114, 114, 114))),
|
| 66 |
+
dict(type='mmdet.PackDetInputs')
|
| 67 |
+
]
|
| 68 |
+
|
| 69 |
+
train_dataloader = dict(dataset=dict(pipeline=train_pipeline))
|
| 70 |
+
|
| 71 |
+
custom_hooks = [
|
| 72 |
+
dict(
|
| 73 |
+
type='EMAHook',
|
| 74 |
+
ema_type='ExpMomentumEMA',
|
| 75 |
+
momentum=0.0002,
|
| 76 |
+
update_buffers=True,
|
| 77 |
+
strict_load=False,
|
| 78 |
+
priority=49),
|
| 79 |
+
dict(
|
| 80 |
+
type='mmdet.PipelineSwitchHook',
|
| 81 |
+
switch_epoch=_base_.max_epochs - _base_.num_epochs_stage2,
|
| 82 |
+
switch_pipeline=train_pipeline_stage2)
|
| 83 |
+
]
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/rtmdet/rtmdet_tiny_fast_1xb32-100e_ionogram.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = './rtmdet_s_fast_1xb32-100e_ionogram.py'
|
| 2 |
+
|
| 3 |
+
# ======================= Modified parameters ======================
|
| 4 |
+
deepen_factor = 0.167
|
| 5 |
+
widen_factor = 0.375
|
| 6 |
+
img_scale = _base_.img_scale
|
| 7 |
+
|
| 8 |
+
load_from = 'https://download.openmmlab.com/mmyolo/v0/rtmdet/rtmdet_tiny_syncbn_fast_8xb32-300e_coco/rtmdet_tiny_syncbn_fast_8xb32-300e_coco_20230102_140117-dbb1dc83.pth' # noqa
|
| 9 |
+
|
| 10 |
+
# learning rate
|
| 11 |
+
param_scheduler = [
|
| 12 |
+
dict(
|
| 13 |
+
type='LinearLR', start_factor=1.0e-5, by_epoch=False, begin=0,
|
| 14 |
+
end=300),
|
| 15 |
+
dict(
|
| 16 |
+
# use cosine lr from 50 to 100 epoch
|
| 17 |
+
type='CosineAnnealingLR',
|
| 18 |
+
eta_min=_base_.base_lr * 0.05,
|
| 19 |
+
begin=_base_.max_epochs // 2,
|
| 20 |
+
end=_base_.max_epochs,
|
| 21 |
+
T_max=_base_.max_epochs // 2,
|
| 22 |
+
by_epoch=True,
|
| 23 |
+
convert_to_iter_based=True),
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
# =======================Unmodified in most cases==================
|
| 27 |
+
model = dict(
|
| 28 |
+
backbone=dict(deepen_factor=deepen_factor, widen_factor=widen_factor),
|
| 29 |
+
neck=dict(deepen_factor=deepen_factor, widen_factor=widen_factor),
|
| 30 |
+
bbox_head=dict(head_module=dict(widen_factor=widen_factor)))
|
| 31 |
+
|
| 32 |
+
train_pipeline = [
|
| 33 |
+
dict(type='LoadImageFromFile', backend_args=_base_.backend_args),
|
| 34 |
+
dict(type='LoadAnnotations', with_bbox=True),
|
| 35 |
+
dict(
|
| 36 |
+
type='Mosaic',
|
| 37 |
+
img_scale=img_scale,
|
| 38 |
+
use_cached=True,
|
| 39 |
+
max_cached_images=20, # note
|
| 40 |
+
random_pop=False, # note
|
| 41 |
+
pad_val=114.0),
|
| 42 |
+
dict(
|
| 43 |
+
type='mmdet.RandomResize',
|
| 44 |
+
# img_scale is (width, height)
|
| 45 |
+
scale=(img_scale[0] * 2, img_scale[1] * 2),
|
| 46 |
+
ratio_range=(0.5, 2.0),
|
| 47 |
+
resize_type='mmdet.Resize',
|
| 48 |
+
keep_ratio=True),
|
| 49 |
+
dict(type='mmdet.RandomCrop', crop_size=img_scale),
|
| 50 |
+
dict(type='mmdet.YOLOXHSVRandomAug'),
|
| 51 |
+
dict(type='mmdet.RandomFlip', prob=0.5),
|
| 52 |
+
dict(type='mmdet.Pad', size=img_scale, pad_val=dict(img=(114, 114, 114))),
|
| 53 |
+
dict(
|
| 54 |
+
type='YOLOv5MixUp',
|
| 55 |
+
use_cached=True,
|
| 56 |
+
random_pop=False,
|
| 57 |
+
max_cached_images=10,
|
| 58 |
+
prob=0.5),
|
| 59 |
+
dict(type='mmdet.PackDetInputs')
|
| 60 |
+
]
|
| 61 |
+
|
| 62 |
+
train_dataloader = dict(dataset=dict(pipeline=train_pipeline))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov5/yolov5_m-v61_fast_1xb32-100e_ionogram.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = './yolov5_s-v61_fast_1xb96-100e_ionogram.py'
|
| 2 |
+
|
| 3 |
+
# ======================= Modified parameters =====================
|
| 4 |
+
# Copied from '../../yolov5/yolov5_m-v61_syncbn_fast_8xb16-300e_coco.py'
|
| 5 |
+
deepen_factor = 0.67
|
| 6 |
+
widen_factor = 0.75
|
| 7 |
+
lr_factor = 0.1
|
| 8 |
+
affine_scale = 0.9
|
| 9 |
+
loss_cls_weight = 0.3
|
| 10 |
+
loss_obj_weight = 0.7
|
| 11 |
+
mixup_prob = 0.1
|
| 12 |
+
|
| 13 |
+
# -----data related-----
|
| 14 |
+
train_batch_size_per_gpu = 32
|
| 15 |
+
|
| 16 |
+
# -----train val related-----
|
| 17 |
+
# Scale lr for SGD
|
| 18 |
+
base_lr = _base_.base_lr * train_batch_size_per_gpu \
|
| 19 |
+
/ _base_.train_batch_size_per_gpu
|
| 20 |
+
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov5/yolov5_m-v61_syncbn_fast_8xb16-300e_coco/yolov5_m-v61_syncbn_fast_8xb16-300e_coco_20220917_204944-516a710f.pth' # noqa
|
| 21 |
+
|
| 22 |
+
# ===================== Unmodified in most cases ==================
|
| 23 |
+
num_classes = _base_.num_classes
|
| 24 |
+
num_det_layers = _base_.num_det_layers
|
| 25 |
+
img_scale = _base_.img_scale
|
| 26 |
+
|
| 27 |
+
model = dict(
|
| 28 |
+
backbone=dict(
|
| 29 |
+
deepen_factor=deepen_factor,
|
| 30 |
+
widen_factor=widen_factor,
|
| 31 |
+
),
|
| 32 |
+
neck=dict(
|
| 33 |
+
deepen_factor=deepen_factor,
|
| 34 |
+
widen_factor=widen_factor,
|
| 35 |
+
),
|
| 36 |
+
bbox_head=dict(
|
| 37 |
+
head_module=dict(widen_factor=widen_factor),
|
| 38 |
+
loss_cls=dict(loss_weight=loss_cls_weight *
|
| 39 |
+
(num_classes / 80 * 3 / num_det_layers)),
|
| 40 |
+
loss_obj=dict(loss_weight=loss_obj_weight *
|
| 41 |
+
((img_scale[0] / 640)**2 * 3 / num_det_layers))))
|
| 42 |
+
|
| 43 |
+
pre_transform = _base_.pre_transform
|
| 44 |
+
albu_train_transforms = _base_.albu_train_transforms
|
| 45 |
+
|
| 46 |
+
mosaic_affine_pipeline = [
|
| 47 |
+
dict(
|
| 48 |
+
type='Mosaic',
|
| 49 |
+
img_scale=img_scale,
|
| 50 |
+
pad_val=114.0,
|
| 51 |
+
pre_transform=pre_transform),
|
| 52 |
+
dict(
|
| 53 |
+
type='YOLOv5RandomAffine',
|
| 54 |
+
max_rotate_degree=0.0,
|
| 55 |
+
max_shear_degree=0.0,
|
| 56 |
+
scaling_ratio_range=(1 - affine_scale, 1 + affine_scale),
|
| 57 |
+
# img_scale is (width, height)
|
| 58 |
+
border=(-img_scale[0] // 2, -img_scale[1] // 2),
|
| 59 |
+
border_val=(114, 114, 114))
|
| 60 |
+
]
|
| 61 |
+
|
| 62 |
+
# enable mixup
|
| 63 |
+
train_pipeline = [
|
| 64 |
+
*pre_transform, *mosaic_affine_pipeline,
|
| 65 |
+
dict(
|
| 66 |
+
type='YOLOv5MixUp',
|
| 67 |
+
prob=mixup_prob,
|
| 68 |
+
pre_transform=[*pre_transform, *mosaic_affine_pipeline]),
|
| 69 |
+
dict(
|
| 70 |
+
type='mmdet.Albu',
|
| 71 |
+
transforms=albu_train_transforms,
|
| 72 |
+
bbox_params=dict(
|
| 73 |
+
type='BboxParams',
|
| 74 |
+
format='pascal_voc',
|
| 75 |
+
label_fields=['gt_bboxes_labels', 'gt_ignore_flags']),
|
| 76 |
+
keymap={
|
| 77 |
+
'img': 'image',
|
| 78 |
+
'gt_bboxes': 'bboxes'
|
| 79 |
+
}),
|
| 80 |
+
dict(type='YOLOv5HSVRandomAug'),
|
| 81 |
+
dict(type='mmdet.RandomFlip', prob=0.5),
|
| 82 |
+
dict(
|
| 83 |
+
type='mmdet.PackDetInputs',
|
| 84 |
+
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
|
| 85 |
+
'flip_direction'))
|
| 86 |
+
]
|
| 87 |
+
|
| 88 |
+
train_dataloader = dict(
|
| 89 |
+
batch_size=train_batch_size_per_gpu,
|
| 90 |
+
dataset=dict(dataset=dict(pipeline=train_pipeline)))
|
| 91 |
+
|
| 92 |
+
val_dataloader = dict(batch_size=train_batch_size_per_gpu)
|
| 93 |
+
test_dataloader = dict(batch_size=train_batch_size_per_gpu)
|
| 94 |
+
optim_wrapper = dict(optimizer=dict(lr=base_lr))
|
| 95 |
+
default_hooks = dict(param_scheduler=dict(lr_factor=lr_factor))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb32-100e_ionogram_mosaic.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = './yolov5_s-v61_fast_1xb96-100e_ionogram.py'
|
| 2 |
+
|
| 3 |
+
# ======================= Modified parameters =====================
|
| 4 |
+
# -----data related-----
|
| 5 |
+
train_batch_size_per_gpu = 32
|
| 6 |
+
|
| 7 |
+
# -----train val related-----
|
| 8 |
+
base_lr = _base_.base_lr * train_batch_size_per_gpu \
|
| 9 |
+
/ _base_.train_batch_size_per_gpu / 2
|
| 10 |
+
train_pipeline = [
|
| 11 |
+
dict(type='LoadImageFromFile'),
|
| 12 |
+
dict(type='LoadAnnotations', with_bbox=True),
|
| 13 |
+
dict(
|
| 14 |
+
type='Mosaic',
|
| 15 |
+
img_scale=(640, 640),
|
| 16 |
+
pad_val=114.0,
|
| 17 |
+
pre_transform=[
|
| 18 |
+
dict(type='LoadImageFromFile'),
|
| 19 |
+
dict(type='LoadAnnotations', with_bbox=True)
|
| 20 |
+
]),
|
| 21 |
+
dict(
|
| 22 |
+
type='mmdet.PackDetInputs',
|
| 23 |
+
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape'))
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
# ===================== Unmodified in most cases ==================
|
| 27 |
+
train_dataloader = dict(
|
| 28 |
+
batch_size=train_batch_size_per_gpu,
|
| 29 |
+
dataset=dict(dataset=dict(pipeline=train_pipeline)))
|
| 30 |
+
|
| 31 |
+
val_dataloader = dict(batch_size=train_batch_size_per_gpu)
|
| 32 |
+
|
| 33 |
+
test_dataloader = dict(batch_size=train_batch_size_per_gpu)
|
| 34 |
+
|
| 35 |
+
optim_wrapper = dict(optimizer=dict(lr=base_lr))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = 'mmyolo::yolov5/yolov5_s-v61_syncbn_fast_8xb16-300e_coco.py'
|
| 2 |
+
|
| 3 |
+
# ======================= Modified parameters =====================
|
| 4 |
+
# -----data related-----
|
| 5 |
+
data_root = './Iono4311/'
|
| 6 |
+
train_ann_file = 'annotations/train.json'
|
| 7 |
+
train_data_prefix = 'train_images/'
|
| 8 |
+
val_ann_file = 'annotations/val.json'
|
| 9 |
+
val_data_prefix = 'val_images/'
|
| 10 |
+
test_ann_file = 'annotations/test.json'
|
| 11 |
+
test_data_prefix = 'test_images/'
|
| 12 |
+
class_name = ('E', 'Es-l', 'Es-c', 'F1', 'F2', 'Spread-F')
|
| 13 |
+
num_classes = len(class_name)
|
| 14 |
+
metainfo = dict(
|
| 15 |
+
classes=class_name,
|
| 16 |
+
palette=[(250, 165, 30), (120, 69, 125), (53, 125, 34), (0, 11, 123),
|
| 17 |
+
(130, 20, 12), (120, 121, 80)])
|
| 18 |
+
# Batch size of a single GPU during training
|
| 19 |
+
train_batch_size_per_gpu = 96
|
| 20 |
+
# Worker to pre-fetch data for each single GPU during training
|
| 21 |
+
train_num_workers = 8
|
| 22 |
+
|
| 23 |
+
# -----model related-----
|
| 24 |
+
# Basic size of multi-scale prior box
|
| 25 |
+
anchors = [[[8, 6], [24, 4], [19, 9]], [[22, 19], [17, 49], [29, 45]],
|
| 26 |
+
[[44, 66], [96, 76], [126, 59]]]
|
| 27 |
+
|
| 28 |
+
# -----train val related-----
|
| 29 |
+
# base_lr_default * (your_bs / default_bs (8x16)) for SGD
|
| 30 |
+
base_lr = _base_.base_lr * train_batch_size_per_gpu / (8 * 16)
|
| 31 |
+
max_epochs = 100
|
| 32 |
+
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov5/yolov5_s-v61_syncbn_fast_8xb16-300e_coco/yolov5_s-v61_syncbn_fast_8xb16-300e_coco_20220918_084700-86e02187.pth' # noqa
|
| 33 |
+
|
| 34 |
+
# default_hooks
|
| 35 |
+
save_epoch_intervals = 10
|
| 36 |
+
logger_interval = 20
|
| 37 |
+
max_keep_ckpts = 1
|
| 38 |
+
|
| 39 |
+
# train_cfg
|
| 40 |
+
val_interval = 2
|
| 41 |
+
val_begin = 20
|
| 42 |
+
|
| 43 |
+
tta_model = None
|
| 44 |
+
tta_pipeline = None
|
| 45 |
+
|
| 46 |
+
visualizer = dict(
|
| 47 |
+
vis_backends=[dict(type='LocalVisBackend'),
|
| 48 |
+
dict(type='WandbVisBackend')])
|
| 49 |
+
|
| 50 |
+
# ===================== Unmodified in most cases ==================
|
| 51 |
+
model = dict(
|
| 52 |
+
bbox_head=dict(
|
| 53 |
+
head_module=dict(num_classes=num_classes),
|
| 54 |
+
prior_generator=dict(base_sizes=anchors),
|
| 55 |
+
loss_cls=dict(loss_weight=0.5 *
|
| 56 |
+
(num_classes / 80 * 3 / _base_.num_det_layers))))
|
| 57 |
+
|
| 58 |
+
train_dataloader = dict(
|
| 59 |
+
batch_size=train_batch_size_per_gpu,
|
| 60 |
+
num_workers=train_num_workers,
|
| 61 |
+
dataset=dict(
|
| 62 |
+
_delete_=True,
|
| 63 |
+
type='RepeatDataset',
|
| 64 |
+
times=1,
|
| 65 |
+
dataset=dict(
|
| 66 |
+
type=_base_.dataset_type,
|
| 67 |
+
data_root=data_root,
|
| 68 |
+
metainfo=metainfo,
|
| 69 |
+
ann_file=train_ann_file,
|
| 70 |
+
data_prefix=dict(img=train_data_prefix),
|
| 71 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
| 72 |
+
pipeline=_base_.train_pipeline)))
|
| 73 |
+
|
| 74 |
+
val_dataloader = dict(
|
| 75 |
+
batch_size=train_batch_size_per_gpu,
|
| 76 |
+
num_workers=train_num_workers,
|
| 77 |
+
dataset=dict(
|
| 78 |
+
metainfo=metainfo,
|
| 79 |
+
data_root=data_root,
|
| 80 |
+
ann_file=val_ann_file,
|
| 81 |
+
data_prefix=dict(img=val_data_prefix)))
|
| 82 |
+
|
| 83 |
+
test_dataloader = dict(
|
| 84 |
+
batch_size=train_batch_size_per_gpu,
|
| 85 |
+
num_workers=train_num_workers,
|
| 86 |
+
dataset=dict(
|
| 87 |
+
metainfo=metainfo,
|
| 88 |
+
data_root=data_root,
|
| 89 |
+
ann_file=test_ann_file,
|
| 90 |
+
data_prefix=dict(img=test_data_prefix)))
|
| 91 |
+
|
| 92 |
+
optim_wrapper = dict(optimizer=dict(lr=base_lr))
|
| 93 |
+
|
| 94 |
+
default_hooks = dict(
|
| 95 |
+
checkpoint=dict(
|
| 96 |
+
type='CheckpointHook',
|
| 97 |
+
save_param_scheduler=None, # for yolov5
|
| 98 |
+
interval=save_epoch_intervals,
|
| 99 |
+
max_keep_ckpts=max_keep_ckpts,
|
| 100 |
+
save_best='auto'),
|
| 101 |
+
param_scheduler=dict(max_epochs=max_epochs),
|
| 102 |
+
logger=dict(type='LoggerHook', interval=logger_interval))
|
| 103 |
+
|
| 104 |
+
val_evaluator = dict(ann_file=data_root + val_ann_file)
|
| 105 |
+
test_evaluator = dict(ann_file=data_root + test_ann_file)
|
| 106 |
+
|
| 107 |
+
train_cfg = dict(
|
| 108 |
+
max_epochs=max_epochs, val_begin=val_begin, val_interval=val_interval)
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram_aug0.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = './yolov5_s-v61_fast_1xb96-100e_ionogram.py'
|
| 2 |
+
|
| 3 |
+
# ======================= Modified parameters =====================
|
| 4 |
+
# -----train val related-----
|
| 5 |
+
train_pipeline = [
|
| 6 |
+
dict(type='LoadImageFromFile'),
|
| 7 |
+
dict(type='LoadAnnotations', with_bbox=True),
|
| 8 |
+
dict(type='YOLOv5KeepRatioResize', scale=(640, 640)),
|
| 9 |
+
dict(
|
| 10 |
+
type='LetterResize',
|
| 11 |
+
scale=(640, 640),
|
| 12 |
+
allow_scale_up=False,
|
| 13 |
+
pad_val=dict(img=114)),
|
| 14 |
+
dict(
|
| 15 |
+
type='mmdet.PackDetInputs',
|
| 16 |
+
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
|
| 17 |
+
'scale_factor', 'pad_param'))
|
| 18 |
+
]
|
| 19 |
+
|
| 20 |
+
# ===================== Unmodified in most cases ==================
|
| 21 |
+
train_dataloader = dict(dataset=dict(dataset=dict(pipeline=train_pipeline)))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram_mosaic_affine.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = './yolov5_s-v61_fast_1xb96-100e_ionogram.py'
|
| 2 |
+
|
| 3 |
+
# ======================= Modified parameters =====================
|
| 4 |
+
# -----train val related-----
|
| 5 |
+
train_pipeline = [
|
| 6 |
+
dict(type='LoadImageFromFile'),
|
| 7 |
+
dict(type='LoadAnnotations', with_bbox=True),
|
| 8 |
+
dict(
|
| 9 |
+
type='Mosaic',
|
| 10 |
+
img_scale=(640, 640),
|
| 11 |
+
pad_val=114.0,
|
| 12 |
+
pre_transform=[
|
| 13 |
+
dict(type='LoadImageFromFile'),
|
| 14 |
+
dict(type='LoadAnnotations', with_bbox=True)
|
| 15 |
+
]),
|
| 16 |
+
dict(
|
| 17 |
+
type='YOLOv5RandomAffine',
|
| 18 |
+
max_rotate_degree=0.0,
|
| 19 |
+
max_shear_degree=0.0,
|
| 20 |
+
scaling_ratio_range=(0.5, 1.5),
|
| 21 |
+
border=(-320, -320),
|
| 22 |
+
border_val=(114, 114, 114)),
|
| 23 |
+
dict(
|
| 24 |
+
type='mmdet.PackDetInputs',
|
| 25 |
+
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape'))
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
# ===================== Unmodified in most cases ==================
|
| 29 |
+
train_dataloader = dict(dataset=dict(dataset=dict(pipeline=train_pipeline)))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram_mosaic_affine_albu_hsv.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = './yolov5_s-v61_fast_1xb96-100e_ionogram.py'
|
| 2 |
+
|
| 3 |
+
# ======================= Modified parameters =====================
|
| 4 |
+
# -----train val related-----
|
| 5 |
+
train_pipeline = [
|
| 6 |
+
dict(type='LoadImageFromFile'),
|
| 7 |
+
dict(type='LoadAnnotations', with_bbox=True),
|
| 8 |
+
dict(
|
| 9 |
+
type='Mosaic',
|
| 10 |
+
img_scale=(640, 640),
|
| 11 |
+
pad_val=114.0,
|
| 12 |
+
pre_transform=[
|
| 13 |
+
dict(type='LoadImageFromFile'),
|
| 14 |
+
dict(type='LoadAnnotations', with_bbox=True)
|
| 15 |
+
]),
|
| 16 |
+
dict(
|
| 17 |
+
type='YOLOv5RandomAffine',
|
| 18 |
+
max_rotate_degree=0.0,
|
| 19 |
+
max_shear_degree=0.0,
|
| 20 |
+
scaling_ratio_range=(0.5, 1.5),
|
| 21 |
+
border=(-320, -320),
|
| 22 |
+
border_val=(114, 114, 114)),
|
| 23 |
+
dict(
|
| 24 |
+
type='mmdet.Albu',
|
| 25 |
+
transforms=[
|
| 26 |
+
dict(type='Blur', p=0.01),
|
| 27 |
+
dict(type='MedianBlur', p=0.01),
|
| 28 |
+
dict(type='ToGray', p=0.01),
|
| 29 |
+
dict(type='CLAHE', p=0.01)
|
| 30 |
+
],
|
| 31 |
+
bbox_params=dict(
|
| 32 |
+
type='BboxParams',
|
| 33 |
+
format='pascal_voc',
|
| 34 |
+
label_fields=['gt_bboxes_labels', 'gt_ignore_flags']),
|
| 35 |
+
keymap=dict(img='image', gt_bboxes='bboxes')),
|
| 36 |
+
dict(type='YOLOv5HSVRandomAug'),
|
| 37 |
+
# dict(type='mmdet.RandomFlip', prob=0.5),
|
| 38 |
+
dict(
|
| 39 |
+
type='mmdet.PackDetInputs',
|
| 40 |
+
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape'))
|
| 41 |
+
]
|
| 42 |
+
|
| 43 |
+
# ===================== Unmodified in most cases ==================
|
| 44 |
+
train_dataloader = dict(dataset=dict(dataset=dict(pipeline=train_pipeline)))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-200e_ionogram_pre0.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = './yolov5_s-v61_fast_1xb96-100e_ionogram.py'
|
| 2 |
+
|
| 3 |
+
# ======================= Modified parameters =====================
|
| 4 |
+
# -----train val related-----
|
| 5 |
+
base_lr = _base_.base_lr * 4
|
| 6 |
+
max_epochs = 200
|
| 7 |
+
load_from = None
|
| 8 |
+
logger_interval = 50
|
| 9 |
+
|
| 10 |
+
train_cfg = dict(max_epochs=max_epochs, )
|
| 11 |
+
|
| 12 |
+
# ===================== Unmodified in most cases ==================
|
| 13 |
+
optim_wrapper = dict(optimizer=dict(lr=base_lr))
|
| 14 |
+
|
| 15 |
+
default_hooks = dict(
|
| 16 |
+
param_scheduler=dict(max_epochs=max_epochs),
|
| 17 |
+
logger=dict(type='LoggerHook', interval=logger_interval))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov6/yolov6_l_fast_1xb32-100e_ionogram.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = './yolov6_m_fast_1xb32-100e_ionogram.py'
|
| 2 |
+
|
| 3 |
+
# ======================= Modified parameters =======================
|
| 4 |
+
# -----model related-----
|
| 5 |
+
deepen_factor = 1
|
| 6 |
+
widen_factor = 1
|
| 7 |
+
|
| 8 |
+
# -----train val related-----
|
| 9 |
+
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov6/yolov6_l_syncbn_fast_8xb32-300e_coco/yolov6_l_syncbn_fast_8xb32-300e_coco_20221109_183156-91e3c447.pth' # noqa
|
| 10 |
+
|
| 11 |
+
# ====================== Unmodified in most cases ===================
|
| 12 |
+
model = dict(
|
| 13 |
+
backbone=dict(
|
| 14 |
+
deepen_factor=deepen_factor,
|
| 15 |
+
widen_factor=widen_factor,
|
| 16 |
+
hidden_ratio=1. / 2,
|
| 17 |
+
block_cfg=dict(
|
| 18 |
+
type='ConvWrapper',
|
| 19 |
+
norm_cfg=dict(type='BN', momentum=0.03, eps=0.001)),
|
| 20 |
+
act_cfg=dict(type='SiLU', inplace=True)),
|
| 21 |
+
neck=dict(
|
| 22 |
+
deepen_factor=deepen_factor,
|
| 23 |
+
widen_factor=widen_factor,
|
| 24 |
+
hidden_ratio=1. / 2,
|
| 25 |
+
block_cfg=dict(
|
| 26 |
+
type='ConvWrapper',
|
| 27 |
+
norm_cfg=dict(type='BN', momentum=0.03, eps=0.001)),
|
| 28 |
+
block_act_cfg=dict(type='SiLU', inplace=True)),
|
| 29 |
+
bbox_head=dict(head_module=dict(widen_factor=widen_factor)))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov6/yolov6_m_fast_1xb32-100e_ionogram.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = './yolov6_s_fast_1xb32-100e_ionogram.py'
|
| 2 |
+
|
| 3 |
+
# ======================= Modified parameters =======================
|
| 4 |
+
# -----model related-----
|
| 5 |
+
# The scaling factor that controls the depth of the network structure
|
| 6 |
+
deepen_factor = 0.6
|
| 7 |
+
# The scaling factor that controls the width of the network structure
|
| 8 |
+
widen_factor = 0.75
|
| 9 |
+
|
| 10 |
+
# -----train val related-----
|
| 11 |
+
affine_scale = 0.9 # YOLOv5RandomAffine scaling ratio
|
| 12 |
+
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov6/yolov6_m_syncbn_fast_8xb32-300e_coco/yolov6_m_syncbn_fast_8xb32-300e_coco_20221109_182658-85bda3f4.pth' # noqa
|
| 13 |
+
|
| 14 |
+
# ====================== Unmodified in most cases ===================
|
| 15 |
+
model = dict(
|
| 16 |
+
backbone=dict(
|
| 17 |
+
type='YOLOv6CSPBep',
|
| 18 |
+
deepen_factor=deepen_factor,
|
| 19 |
+
widen_factor=widen_factor,
|
| 20 |
+
hidden_ratio=2. / 3,
|
| 21 |
+
block_cfg=dict(type='RepVGGBlock'),
|
| 22 |
+
act_cfg=dict(type='ReLU', inplace=True)),
|
| 23 |
+
neck=dict(
|
| 24 |
+
type='YOLOv6CSPRepPAFPN',
|
| 25 |
+
deepen_factor=deepen_factor,
|
| 26 |
+
widen_factor=widen_factor,
|
| 27 |
+
block_cfg=dict(type='RepVGGBlock'),
|
| 28 |
+
hidden_ratio=2. / 3,
|
| 29 |
+
block_act_cfg=dict(type='ReLU', inplace=True)),
|
| 30 |
+
bbox_head=dict(
|
| 31 |
+
type='YOLOv6Head', head_module=dict(widen_factor=widen_factor)))
|
| 32 |
+
|
| 33 |
+
mosaic_affine_pipeline = [
|
| 34 |
+
dict(
|
| 35 |
+
type='Mosaic',
|
| 36 |
+
img_scale=_base_.img_scale,
|
| 37 |
+
pad_val=114.0,
|
| 38 |
+
pre_transform=_base_.pre_transform),
|
| 39 |
+
dict(
|
| 40 |
+
type='YOLOv5RandomAffine',
|
| 41 |
+
max_rotate_degree=0.0,
|
| 42 |
+
max_shear_degree=0.0,
|
| 43 |
+
scaling_ratio_range=(1 - affine_scale, 1 + affine_scale),
|
| 44 |
+
# img_scale is (width, height)
|
| 45 |
+
border=(-_base_.img_scale[0] // 2, -_base_.img_scale[1] // 2),
|
| 46 |
+
border_val=(114, 114, 114))
|
| 47 |
+
]
|
| 48 |
+
|
| 49 |
+
train_pipeline = [
|
| 50 |
+
*_base_.pre_transform, *mosaic_affine_pipeline,
|
| 51 |
+
dict(
|
| 52 |
+
type='YOLOv5MixUp',
|
| 53 |
+
prob=0.1,
|
| 54 |
+
pre_transform=[*_base_.pre_transform, *mosaic_affine_pipeline]),
|
| 55 |
+
dict(type='YOLOv5HSVRandomAug'),
|
| 56 |
+
dict(type='mmdet.RandomFlip', prob=0.5),
|
| 57 |
+
dict(
|
| 58 |
+
type='mmdet.PackDetInputs',
|
| 59 |
+
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
|
| 60 |
+
'flip_direction'))
|
| 61 |
+
]
|
| 62 |
+
|
| 63 |
+
train_dataloader = dict(dataset=dict(dataset=dict(pipeline=train_pipeline)))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov6/yolov6_s_fast_1xb32-100e_ionogram.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = 'mmyolo::yolov6/yolov6_s_syncbn_fast_8xb32-400e_coco.py'
|
| 2 |
+
|
| 3 |
+
# ======================= Modified parameters =====================
|
| 4 |
+
# -----data related-----
|
| 5 |
+
data_root = './Iono4311/'
|
| 6 |
+
train_ann_file = 'annotations/train.json'
|
| 7 |
+
train_data_prefix = 'train_images/'
|
| 8 |
+
val_ann_file = 'annotations/val.json'
|
| 9 |
+
val_data_prefix = 'val_images/'
|
| 10 |
+
test_ann_file = 'annotations/test.json'
|
| 11 |
+
test_data_prefix = 'test_images/'
|
| 12 |
+
|
| 13 |
+
class_name = ('E', 'Es-l', 'Es-c', 'F1', 'F2', 'Spread-F')
|
| 14 |
+
num_classes = len(class_name)
|
| 15 |
+
metainfo = dict(
|
| 16 |
+
classes=class_name,
|
| 17 |
+
palette=[(250, 165, 30), (120, 69, 125), (53, 125, 34), (0, 11, 123),
|
| 18 |
+
(130, 20, 12), (120, 121, 80)])
|
| 19 |
+
|
| 20 |
+
train_batch_size_per_gpu = 32
|
| 21 |
+
train_num_workers = 8
|
| 22 |
+
|
| 23 |
+
tta_model = None
|
| 24 |
+
tta_pipeline = None
|
| 25 |
+
|
| 26 |
+
# -----train val related-----
|
| 27 |
+
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov6/yolov6_s_syncbn_fast_8xb32-400e_coco/yolov6_s_syncbn_fast_8xb32-400e_coco_20221102_203035-932e1d91.pth' # noqa
|
| 28 |
+
# base_lr_default * (your_bs 32 / default_bs (8 x 32))
|
| 29 |
+
base_lr = _base_.base_lr * train_batch_size_per_gpu / (8 * 32)
|
| 30 |
+
max_epochs = 100
|
| 31 |
+
save_epoch_intervals = 10
|
| 32 |
+
val_begin = 20
|
| 33 |
+
max_keep_ckpts = 1
|
| 34 |
+
log_interval = 50
|
| 35 |
+
visualizer = dict(
|
| 36 |
+
vis_backends=[dict(type='LocalVisBackend'),
|
| 37 |
+
dict(type='WandbVisBackend')])
|
| 38 |
+
|
| 39 |
+
# ==================== Unmodified in most cases ===================
|
| 40 |
+
train_cfg = dict(
|
| 41 |
+
max_epochs=max_epochs,
|
| 42 |
+
val_begin=val_begin,
|
| 43 |
+
val_interval=save_epoch_intervals,
|
| 44 |
+
dynamic_intervals=None)
|
| 45 |
+
|
| 46 |
+
model = dict(
|
| 47 |
+
bbox_head=dict(head_module=dict(num_classes=num_classes)),
|
| 48 |
+
train_cfg=dict(
|
| 49 |
+
initial_assigner=dict(num_classes=num_classes),
|
| 50 |
+
assigner=dict(num_classes=num_classes)))
|
| 51 |
+
|
| 52 |
+
train_dataloader = dict(
|
| 53 |
+
batch_size=train_batch_size_per_gpu,
|
| 54 |
+
num_workers=train_num_workers,
|
| 55 |
+
dataset=dict(
|
| 56 |
+
_delete_=True,
|
| 57 |
+
type='RepeatDataset',
|
| 58 |
+
times=1,
|
| 59 |
+
dataset=dict(
|
| 60 |
+
type=_base_.dataset_type,
|
| 61 |
+
data_root=data_root,
|
| 62 |
+
metainfo=metainfo,
|
| 63 |
+
ann_file=train_ann_file,
|
| 64 |
+
data_prefix=dict(img=train_data_prefix),
|
| 65 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
| 66 |
+
pipeline=_base_.train_pipeline)))
|
| 67 |
+
|
| 68 |
+
val_dataloader = dict(
|
| 69 |
+
dataset=dict(
|
| 70 |
+
metainfo=metainfo,
|
| 71 |
+
data_root=data_root,
|
| 72 |
+
ann_file=val_ann_file,
|
| 73 |
+
data_prefix=dict(img=val_data_prefix)))
|
| 74 |
+
|
| 75 |
+
test_dataloader = dict(
|
| 76 |
+
dataset=dict(
|
| 77 |
+
metainfo=metainfo,
|
| 78 |
+
data_root=data_root,
|
| 79 |
+
ann_file=test_ann_file,
|
| 80 |
+
data_prefix=dict(img=test_data_prefix)))
|
| 81 |
+
|
| 82 |
+
val_evaluator = dict(ann_file=data_root + val_data_prefix)
|
| 83 |
+
test_evaluator = dict(ann_file=data_root + test_data_prefix)
|
| 84 |
+
|
| 85 |
+
optim_wrapper = dict(optimizer=dict(lr=base_lr))
|
| 86 |
+
|
| 87 |
+
default_hooks = dict(
|
| 88 |
+
checkpoint=dict(
|
| 89 |
+
type='CheckpointHook',
|
| 90 |
+
interval=save_epoch_intervals,
|
| 91 |
+
max_keep_ckpts=max_keep_ckpts,
|
| 92 |
+
save_best='auto'),
|
| 93 |
+
param_scheduler=dict(max_epochs=max_epochs),
|
| 94 |
+
logger=dict(type='LoggerHook', interval=log_interval))
|
| 95 |
+
|
| 96 |
+
custom_hooks = [
|
| 97 |
+
dict(
|
| 98 |
+
type='EMAHook',
|
| 99 |
+
ema_type='ExpMomentumEMA',
|
| 100 |
+
momentum=0.0001,
|
| 101 |
+
update_buffers=True,
|
| 102 |
+
strict_load=False,
|
| 103 |
+
priority=49),
|
| 104 |
+
dict(
|
| 105 |
+
type='mmdet.PipelineSwitchHook',
|
| 106 |
+
switch_epoch=max_epochs - _base_.num_last_epochs,
|
| 107 |
+
switch_pipeline=_base_.train_pipeline_stage2)
|
| 108 |
+
]
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov6/yolov6_s_fast_1xb32-200e_ionogram_pre0.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = './yolov6_s_fast_1xb32-100e_ionogram.py'
|
| 2 |
+
|
| 3 |
+
# ======================= Modified parameters =====================
|
| 4 |
+
base_lr = _base_.base_lr * 4
|
| 5 |
+
optim_wrapper = dict(optimizer=dict(lr=base_lr))
|
| 6 |
+
max_epochs = 200
|
| 7 |
+
load_from = None
|
| 8 |
+
|
| 9 |
+
# ==================== Unmodified in most cases ===================
|
| 10 |
+
train_cfg = dict(
|
| 11 |
+
max_epochs=max_epochs,
|
| 12 |
+
val_begin=20,
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
default_hooks = dict(
|
| 16 |
+
param_scheduler=dict(max_epochs=max_epochs),
|
| 17 |
+
logger=dict(type='LoggerHook', interval=50))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov7/yolov7_l_fast_1xb16-100e_ionogram.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = 'mmyolo::yolov7/yolov7_l_syncbn_fast_8x16b-300e_coco.py'
|
| 2 |
+
|
| 3 |
+
# ======================== Modified parameters ======================
|
| 4 |
+
# -----data related-----
|
| 5 |
+
data_root = './Iono4311/'
|
| 6 |
+
train_ann_file = 'annotations/train.json'
|
| 7 |
+
train_data_prefix = 'train_images/'
|
| 8 |
+
val_ann_file = 'annotations/val.json'
|
| 9 |
+
val_data_prefix = 'val_images/'
|
| 10 |
+
test_ann_file = 'annotations/test.json'
|
| 11 |
+
test_data_prefix = 'test_images/'
|
| 12 |
+
|
| 13 |
+
class_name = ('E', 'Es-l', 'Es-c', 'F1', 'F2', 'Spread-F')
|
| 14 |
+
num_classes = len(class_name)
|
| 15 |
+
metainfo = dict(
|
| 16 |
+
classes=class_name,
|
| 17 |
+
palette=[(250, 165, 30), (120, 69, 125), (53, 125, 34), (0, 11, 123),
|
| 18 |
+
(130, 20, 12), (120, 121, 80)])
|
| 19 |
+
|
| 20 |
+
train_batch_size_per_gpu = 16
|
| 21 |
+
train_num_workers = 8
|
| 22 |
+
|
| 23 |
+
# -----model related-----
|
| 24 |
+
anchors = [[[14, 14], [35, 6], [32, 18]], [[32, 45], [28, 97], [52, 80]],
|
| 25 |
+
[[71, 122], [185, 94], [164, 134]]]
|
| 26 |
+
|
| 27 |
+
# -----train val related-----
|
| 28 |
+
# base_lr_default * (your_bs 32 / default_bs (8 x 16))
|
| 29 |
+
base_lr = _base_.base_lr * train_batch_size_per_gpu / (8 * 16)
|
| 30 |
+
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov7/yolov7_l_syncbn_fast_8x16b-300e_coco/yolov7_l_syncbn_fast_8x16b-300e_coco_20221123_023601-8113c0eb.pth' # noqa
|
| 31 |
+
|
| 32 |
+
# default hooks
|
| 33 |
+
save_epoch_intervals = 10
|
| 34 |
+
max_epochs = 100
|
| 35 |
+
max_keep_ckpts = 1
|
| 36 |
+
|
| 37 |
+
# train_cfg
|
| 38 |
+
val_interval = 2
|
| 39 |
+
val_begin = 20
|
| 40 |
+
|
| 41 |
+
tta_model = None
|
| 42 |
+
tta_pipeline = None
|
| 43 |
+
|
| 44 |
+
visualizer = dict(
|
| 45 |
+
vis_backends=[dict(type='LocalVisBackend'),
|
| 46 |
+
dict(type='WandbVisBackend')])
|
| 47 |
+
|
| 48 |
+
# ===================== Unmodified in most cases ==================
|
| 49 |
+
model = dict(
|
| 50 |
+
bbox_head=dict(
|
| 51 |
+
head_module=dict(num_classes=num_classes),
|
| 52 |
+
prior_generator=dict(base_sizes=anchors),
|
| 53 |
+
loss_cls=dict(loss_weight=_base_.loss_cls_weight *
|
| 54 |
+
(num_classes / 80 * 3 / _base_.num_det_layers))))
|
| 55 |
+
|
| 56 |
+
train_dataloader = dict(
|
| 57 |
+
batch_size=train_batch_size_per_gpu,
|
| 58 |
+
num_workers=train_num_workers,
|
| 59 |
+
dataset=dict(
|
| 60 |
+
metainfo=metainfo,
|
| 61 |
+
data_root=data_root,
|
| 62 |
+
ann_file=train_ann_file,
|
| 63 |
+
data_prefix=dict(img=train_data_prefix)))
|
| 64 |
+
|
| 65 |
+
val_dataloader = dict(
|
| 66 |
+
batch_size=train_batch_size_per_gpu,
|
| 67 |
+
num_workers=train_num_workers,
|
| 68 |
+
dataset=dict(
|
| 69 |
+
metainfo=metainfo,
|
| 70 |
+
data_root=data_root,
|
| 71 |
+
data_prefix=dict(img=val_data_prefix),
|
| 72 |
+
ann_file=val_ann_file))
|
| 73 |
+
|
| 74 |
+
test_dataloader = dict(
|
| 75 |
+
batch_size=train_batch_size_per_gpu,
|
| 76 |
+
num_workers=train_num_workers,
|
| 77 |
+
dataset=dict(
|
| 78 |
+
metainfo=metainfo,
|
| 79 |
+
data_root=data_root,
|
| 80 |
+
data_prefix=dict(img=test_data_prefix),
|
| 81 |
+
ann_file=test_ann_file))
|
| 82 |
+
|
| 83 |
+
optim_wrapper = dict(
|
| 84 |
+
optimizer=dict(lr=base_lr, batch_size_per_gpu=train_batch_size_per_gpu))
|
| 85 |
+
|
| 86 |
+
default_hooks = dict(
|
| 87 |
+
param_scheduler=dict(max_epochs=max_epochs),
|
| 88 |
+
checkpoint=dict(
|
| 89 |
+
interval=save_epoch_intervals, max_keep_ckpts=max_keep_ckpts))
|
| 90 |
+
|
| 91 |
+
val_evaluator = dict(ann_file=data_root + val_ann_file)
|
| 92 |
+
test_evaluator = dict(ann_file=data_root + test_ann_file)
|
| 93 |
+
|
| 94 |
+
train_cfg = dict(
|
| 95 |
+
type='EpochBasedTrainLoop',
|
| 96 |
+
max_epochs=max_epochs,
|
| 97 |
+
val_begin=val_begin,
|
| 98 |
+
val_interval=val_interval)
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov7/yolov7_tiny_fast_1xb16-100e_ionogram.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = './yolov7_l_fast_1xb16-100e_ionogram.py'
|
| 2 |
+
|
| 3 |
+
# ======================== Modified parameters =======================
|
| 4 |
+
# pre-train
|
| 5 |
+
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov7/yolov7_tiny_syncbn_fast_8x16b-300e_coco/yolov7_tiny_syncbn_fast_8x16b-300e_coco_20221126_102719-0ee5bbdf.pth' # noqa
|
| 6 |
+
|
| 7 |
+
# -----model related-----
|
| 8 |
+
# Data augmentation
|
| 9 |
+
max_translate_ratio = 0.1 # YOLOv5RandomAffine
|
| 10 |
+
scaling_ratio_range = (0.5, 1.6) # YOLOv5RandomAffine
|
| 11 |
+
mixup_prob = 0.05 # YOLOv5MixUp
|
| 12 |
+
randchoice_mosaic_prob = [0.8, 0.2]
|
| 13 |
+
mixup_alpha = 8.0 # YOLOv5MixUp
|
| 14 |
+
mixup_beta = 8.0 # YOLOv5MixUp
|
| 15 |
+
|
| 16 |
+
# -----train val related-----
|
| 17 |
+
loss_cls_weight = 0.5
|
| 18 |
+
loss_obj_weight = 1.0
|
| 19 |
+
|
| 20 |
+
lr_factor = 0.01 # Learning rate scaling factor
|
| 21 |
+
|
| 22 |
+
# ====================== Unmodified in most cases ====================
|
| 23 |
+
num_classes = _base_.num_classes
|
| 24 |
+
num_det_layers = _base_.num_det_layers
|
| 25 |
+
img_scale = _base_.img_scale
|
| 26 |
+
pre_transform = _base_.pre_transform
|
| 27 |
+
model = dict(
|
| 28 |
+
backbone=dict(
|
| 29 |
+
arch='Tiny', act_cfg=dict(type='LeakyReLU', negative_slope=0.1)),
|
| 30 |
+
neck=dict(
|
| 31 |
+
is_tiny_version=True,
|
| 32 |
+
in_channels=[128, 256, 512],
|
| 33 |
+
out_channels=[64, 128, 256],
|
| 34 |
+
block_cfg=dict(
|
| 35 |
+
_delete_=True, type='TinyDownSampleBlock', middle_ratio=0.25),
|
| 36 |
+
act_cfg=dict(type='LeakyReLU', negative_slope=0.1),
|
| 37 |
+
use_repconv_outs=False),
|
| 38 |
+
bbox_head=dict(
|
| 39 |
+
head_module=dict(in_channels=[128, 256, 512]),
|
| 40 |
+
loss_cls=dict(loss_weight=loss_cls_weight *
|
| 41 |
+
(num_classes / 80 * 3 / num_det_layers)),
|
| 42 |
+
loss_obj=dict(loss_weight=loss_obj_weight *
|
| 43 |
+
((img_scale[0] / 640)**2 * 3 / num_det_layers))))
|
| 44 |
+
|
| 45 |
+
mosiac4_pipeline = [
|
| 46 |
+
dict(
|
| 47 |
+
type='Mosaic',
|
| 48 |
+
img_scale=img_scale,
|
| 49 |
+
pad_val=114.0,
|
| 50 |
+
pre_transform=pre_transform),
|
| 51 |
+
dict(
|
| 52 |
+
type='YOLOv5RandomAffine',
|
| 53 |
+
max_rotate_degree=0.0,
|
| 54 |
+
max_shear_degree=0.0,
|
| 55 |
+
max_translate_ratio=max_translate_ratio, # change
|
| 56 |
+
scaling_ratio_range=scaling_ratio_range, # change
|
| 57 |
+
# img_scale is (width, height)
|
| 58 |
+
border=(-img_scale[0] // 2, -img_scale[1] // 2),
|
| 59 |
+
border_val=(114, 114, 114)),
|
| 60 |
+
]
|
| 61 |
+
|
| 62 |
+
mosiac9_pipeline = [
|
| 63 |
+
dict(
|
| 64 |
+
type='Mosaic9',
|
| 65 |
+
img_scale=img_scale,
|
| 66 |
+
pad_val=114.0,
|
| 67 |
+
pre_transform=pre_transform),
|
| 68 |
+
dict(
|
| 69 |
+
type='YOLOv5RandomAffine',
|
| 70 |
+
max_rotate_degree=0.0,
|
| 71 |
+
max_shear_degree=0.0,
|
| 72 |
+
max_translate_ratio=max_translate_ratio, # change
|
| 73 |
+
scaling_ratio_range=scaling_ratio_range, # change
|
| 74 |
+
border=(-img_scale[0] // 2, -img_scale[1] // 2),
|
| 75 |
+
border_val=(114, 114, 114)),
|
| 76 |
+
]
|
| 77 |
+
|
| 78 |
+
randchoice_mosaic_pipeline = dict(
|
| 79 |
+
type='RandomChoice',
|
| 80 |
+
transforms=[mosiac4_pipeline, mosiac9_pipeline],
|
| 81 |
+
prob=randchoice_mosaic_prob)
|
| 82 |
+
|
| 83 |
+
train_pipeline = [
|
| 84 |
+
*pre_transform,
|
| 85 |
+
randchoice_mosaic_pipeline,
|
| 86 |
+
dict(
|
| 87 |
+
type='YOLOv5MixUp',
|
| 88 |
+
alpha=mixup_alpha,
|
| 89 |
+
beta=mixup_beta,
|
| 90 |
+
prob=mixup_prob, # change
|
| 91 |
+
pre_transform=[*pre_transform, randchoice_mosaic_pipeline]),
|
| 92 |
+
dict(type='YOLOv5HSVRandomAug'),
|
| 93 |
+
dict(type='mmdet.RandomFlip', prob=0.5),
|
| 94 |
+
dict(
|
| 95 |
+
type='mmdet.PackDetInputs',
|
| 96 |
+
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
|
| 97 |
+
'flip_direction'))
|
| 98 |
+
]
|
| 99 |
+
|
| 100 |
+
train_dataloader = dict(dataset=dict(pipeline=train_pipeline))
|
| 101 |
+
default_hooks = dict(param_scheduler=dict(lr_factor=lr_factor))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/projects/misc/ionogram_detection/yolov7/yolov7_x_fast_1xb16-100e_ionogram.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_base_ = './yolov7_l_fast_1xb16-100e_ionogram.py'
|
| 2 |
+
|
| 3 |
+
# ======================== Modified parameters =======================
|
| 4 |
+
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov7/yolov7_x_syncbn_fast_8x16b-300e_coco/yolov7_x_syncbn_fast_8x16b-300e_coco_20221124_215331-ef949a68.pth' # noqa
|
| 5 |
+
|
| 6 |
+
# ===================== Unmodified in most cases ==================
|
| 7 |
+
model = dict(
|
| 8 |
+
backbone=dict(arch='X'),
|
| 9 |
+
neck=dict(
|
| 10 |
+
in_channels=[640, 1280, 1280],
|
| 11 |
+
out_channels=[160, 320, 640],
|
| 12 |
+
block_cfg=dict(
|
| 13 |
+
type='ELANBlock',
|
| 14 |
+
middle_ratio=0.4,
|
| 15 |
+
block_ratio=0.4,
|
| 16 |
+
num_blocks=3,
|
| 17 |
+
num_convs_in_block=2),
|
| 18 |
+
use_repconv_outs=False),
|
| 19 |
+
bbox_head=dict(head_module=dict(in_channels=[320, 640, 1280])))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/pytest.ini
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[pytest]
|
| 2 |
+
addopts = --xdoctest --xdoctest-style=auto
|
| 3 |
+
norecursedirs = .git ignore build __pycache__ data docker docs .eggs
|
| 4 |
+
|
| 5 |
+
filterwarnings= default
|
| 6 |
+
ignore:.*No cfgstr given in Cacher constructor or call.*:Warning
|
| 7 |
+
ignore:.*Define the __nice__ method for.*:Warning
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-r requirements/build.txt
|
| 2 |
+
-r requirements/runtime.txt
|
| 3 |
+
-r requirements/tests.txt
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/albu.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
albumentations --no-binary qudida,albumentations
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/build.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# These must be installed before building mmyolo
|
| 2 |
+
cython
|
| 3 |
+
numpy
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/docs.txt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
docutils==0.16.0
|
| 2 |
+
mmcv>=2.0.0rc4,<=2.1.0
|
| 3 |
+
mmdet>=3.0.0
|
| 4 |
+
mmengine>=0.7.1
|
| 5 |
+
myst-parser
|
| 6 |
+
-e git+https://github.com/open-mmlab/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
|
| 7 |
+
sphinx==4.0.2
|
| 8 |
+
sphinx-copybutton
|
| 9 |
+
sphinx_markdown_tables
|
| 10 |
+
sphinx_rtd_theme==0.5.2
|
| 11 |
+
torch
|
| 12 |
+
torchvision
|
| 13 |
+
urllib3<2.0.0
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/mminstall.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
mmcv>=2.0.0rc4,<=2.1.0
|
| 2 |
+
mmdet>=3.0.0
|
| 3 |
+
mmengine>=0.7.1
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/mmpose.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
mmpose>=1.0.0
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/mmrotate.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
mmrotate>=1.0.0rc1
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/runtime.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
numpy
|
| 2 |
+
prettytable
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/sahi.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
sahi>=0.11.4
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/requirements/tests.txt
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
flake8
|
| 2 |
+
interrogate
|
| 3 |
+
isort==4.3.21
|
| 4 |
+
# Note: used for kwarray.group_items, this may be ported to mmcv in the future.
|
| 5 |
+
kwarray
|
| 6 |
+
memory_profiler
|
| 7 |
+
mmcls>=1.0.0rc4
|
| 8 |
+
mmpose>=1.0.0
|
| 9 |
+
mmrazor>=1.0.0rc2
|
| 10 |
+
mmrotate>=1.0.0rc1
|
| 11 |
+
parameterized
|
| 12 |
+
protobuf<=3.20.1
|
| 13 |
+
psutil
|
| 14 |
+
pytest
|
| 15 |
+
ubelt
|
| 16 |
+
xdoctest>=0.10.0
|
| 17 |
+
yapf
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/resources/mmyolo-logo.png
ADDED
|
Git LFS Details
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/resources/qq_group_qrcode.jpg
ADDED
|
Git LFS Details
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/resources/zhihu_qrcode.jpg
ADDED
|
Git LFS Details
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/setup.cfg
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[isort]
|
| 2 |
+
line_length = 79
|
| 3 |
+
multi_line_output = 0
|
| 4 |
+
extra_standard_library = setuptools
|
| 5 |
+
known_first_party = mmyolo
|
| 6 |
+
known_third_party = PIL,asynctest,cityscapesscripts,cv2,gather_models,matplotlib,mmcv,numpy,onnx,onnxruntime,pycocotools,pytest,parameterized,pytorch_sphinx_theme,requests,scipy,seaborn,six,terminaltables,torch,ts,yaml,mmengine,mmdet,mmdeploy
|
| 7 |
+
no_lines_before = STDLIB,LOCALFOLDER
|
| 8 |
+
default_section = THIRDPARTY
|
| 9 |
+
|
| 10 |
+
[yapf]
|
| 11 |
+
BASED_ON_STYLE = pep8
|
| 12 |
+
BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF = true
|
| 13 |
+
SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN = true
|
| 14 |
+
|
| 15 |
+
# ignore-words-list needs to be lowercase format. For example, if we want to
|
| 16 |
+
# ignore word "BA", then we need to append "ba" to ignore-words-list rather
|
| 17 |
+
# than "BA"
|
| 18 |
+
[codespell]
|
| 19 |
+
skip = *.ipynb
|
| 20 |
+
quiet-level = 3
|
| 21 |
+
ignore-words-list = patten,nd,ty,mot,hist,formating,winn,gool,datas,wan,confids,tood,ba,warmup,elease,dota
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/setup.py
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# Copyright (c) OpenMMLab. All rights reserved.
|
| 3 |
+
import os
|
| 4 |
+
import os.path as osp
|
| 5 |
+
import platform
|
| 6 |
+
import shutil
|
| 7 |
+
import sys
|
| 8 |
+
import warnings
|
| 9 |
+
from setuptools import find_packages, setup
|
| 10 |
+
|
| 11 |
+
from torch.utils.cpp_extension import BuildExtension
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def readme():
|
| 15 |
+
with open('README.md', encoding='utf-8') as f:
|
| 16 |
+
content = f.read()
|
| 17 |
+
return content
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
version_file = 'mmyolo/version.py'
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def get_version():
|
| 24 |
+
with open(version_file) as f:
|
| 25 |
+
exec(compile(f.read(), version_file, 'exec'))
|
| 26 |
+
return locals()['__version__']
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def parse_requirements(fname='requirements.txt', with_version=True):
|
| 30 |
+
"""Parse the package dependencies listed in a requirements file but strips
|
| 31 |
+
specific versioning information.
|
| 32 |
+
|
| 33 |
+
Args:
|
| 34 |
+
fname (str): path to requirements file
|
| 35 |
+
with_version (bool, default=False): if True include version specs
|
| 36 |
+
|
| 37 |
+
Returns:
|
| 38 |
+
List[str]: list of requirements items
|
| 39 |
+
|
| 40 |
+
CommandLine:
|
| 41 |
+
python -c "import setup; print(setup.parse_requirements())"
|
| 42 |
+
"""
|
| 43 |
+
import re
|
| 44 |
+
import sys
|
| 45 |
+
from os.path import exists
|
| 46 |
+
require_fpath = fname
|
| 47 |
+
|
| 48 |
+
def parse_line(line):
|
| 49 |
+
"""Parse information from a line in a requirements text file."""
|
| 50 |
+
if line.startswith('-r '):
|
| 51 |
+
# Allow specifying requirements in other files
|
| 52 |
+
target = line.split(' ')[1]
|
| 53 |
+
for info in parse_require_file(target):
|
| 54 |
+
yield info
|
| 55 |
+
else:
|
| 56 |
+
info = {'line': line}
|
| 57 |
+
if line.startswith('-e '):
|
| 58 |
+
info['package'] = line.split('#egg=')[1]
|
| 59 |
+
elif '@git+' in line:
|
| 60 |
+
info['package'] = line
|
| 61 |
+
else:
|
| 62 |
+
# Remove versioning from the package
|
| 63 |
+
pat = '(' + '|'.join(['>=', '==', '>']) + ')'
|
| 64 |
+
parts = re.split(pat, line, maxsplit=1)
|
| 65 |
+
parts = [p.strip() for p in parts]
|
| 66 |
+
|
| 67 |
+
info['package'] = parts[0]
|
| 68 |
+
if len(parts) > 1:
|
| 69 |
+
op, rest = parts[1:]
|
| 70 |
+
if ';' in rest:
|
| 71 |
+
# Handle platform specific dependencies
|
| 72 |
+
# http://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-platform-specific-dependencies
|
| 73 |
+
version, platform_deps = map(str.strip,
|
| 74 |
+
rest.split(';'))
|
| 75 |
+
info['platform_deps'] = platform_deps
|
| 76 |
+
else:
|
| 77 |
+
version = rest # NOQA
|
| 78 |
+
info['version'] = (op, version)
|
| 79 |
+
yield info
|
| 80 |
+
|
| 81 |
+
def parse_require_file(fpath):
|
| 82 |
+
with open(fpath) as f:
|
| 83 |
+
for line in f.readlines():
|
| 84 |
+
line = line.strip()
|
| 85 |
+
if line and not line.startswith('#'):
|
| 86 |
+
yield from parse_line(line)
|
| 87 |
+
|
| 88 |
+
def gen_packages_items():
|
| 89 |
+
if exists(require_fpath):
|
| 90 |
+
for info in parse_require_file(require_fpath):
|
| 91 |
+
parts = [info['package']]
|
| 92 |
+
if with_version and 'version' in info:
|
| 93 |
+
parts.extend(info['version'])
|
| 94 |
+
if not sys.version.startswith('3.4'):
|
| 95 |
+
# apparently package_deps are broken in 3.4
|
| 96 |
+
platform_deps = info.get('platform_deps')
|
| 97 |
+
if platform_deps is not None:
|
| 98 |
+
parts.append(';' + platform_deps)
|
| 99 |
+
item = ''.join(parts)
|
| 100 |
+
yield item
|
| 101 |
+
|
| 102 |
+
packages = list(gen_packages_items())
|
| 103 |
+
return packages
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def add_mim_extension():
|
| 107 |
+
"""Add extra files that are required to support MIM into the package.
|
| 108 |
+
|
| 109 |
+
These files will be added by creating a symlink to the originals if the
|
| 110 |
+
package is installed in `editable` mode (e.g. pip install -e .), or by
|
| 111 |
+
copying from the originals otherwise.
|
| 112 |
+
"""
|
| 113 |
+
|
| 114 |
+
# parse installment mode
|
| 115 |
+
if 'develop' in sys.argv:
|
| 116 |
+
# installed by `pip install -e .`
|
| 117 |
+
if platform.system() == 'Windows':
|
| 118 |
+
# set `copy` mode here since symlink fails on Windows.
|
| 119 |
+
mode = 'copy'
|
| 120 |
+
else:
|
| 121 |
+
mode = 'symlink'
|
| 122 |
+
elif 'sdist' in sys.argv or 'bdist_wheel' in sys.argv:
|
| 123 |
+
# installed by `pip install .`
|
| 124 |
+
# or create source distribution by `python setup.py sdist`
|
| 125 |
+
mode = 'copy'
|
| 126 |
+
else:
|
| 127 |
+
return
|
| 128 |
+
|
| 129 |
+
filenames = ['tools', 'configs', 'demo', 'model-index.yml']
|
| 130 |
+
repo_path = osp.dirname(__file__)
|
| 131 |
+
mim_path = osp.join(repo_path, 'mmyolo', '.mim')
|
| 132 |
+
os.makedirs(mim_path, exist_ok=True)
|
| 133 |
+
|
| 134 |
+
for filename in filenames:
|
| 135 |
+
if osp.exists(filename):
|
| 136 |
+
src_path = osp.join(repo_path, filename)
|
| 137 |
+
tar_path = osp.join(mim_path, filename)
|
| 138 |
+
|
| 139 |
+
if osp.isfile(tar_path) or osp.islink(tar_path):
|
| 140 |
+
os.remove(tar_path)
|
| 141 |
+
elif osp.isdir(tar_path):
|
| 142 |
+
shutil.rmtree(tar_path)
|
| 143 |
+
|
| 144 |
+
if mode == 'symlink':
|
| 145 |
+
src_relpath = osp.relpath(src_path, osp.dirname(tar_path))
|
| 146 |
+
os.symlink(src_relpath, tar_path)
|
| 147 |
+
elif mode == 'copy':
|
| 148 |
+
if osp.isfile(src_path):
|
| 149 |
+
shutil.copyfile(src_path, tar_path)
|
| 150 |
+
elif osp.isdir(src_path):
|
| 151 |
+
shutil.copytree(src_path, tar_path)
|
| 152 |
+
else:
|
| 153 |
+
warnings.warn(f'Cannot copy file {src_path}.')
|
| 154 |
+
else:
|
| 155 |
+
raise ValueError(f'Invalid mode {mode}')
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
if __name__ == '__main__':
|
| 159 |
+
add_mim_extension()
|
| 160 |
+
setup(
|
| 161 |
+
name='mmyolo',
|
| 162 |
+
version=get_version(),
|
| 163 |
+
description='OpenMMLab Toolbox of YOLO',
|
| 164 |
+
long_description=readme(),
|
| 165 |
+
long_description_content_type='text/markdown',
|
| 166 |
+
author='MMYOLO Contributors',
|
| 167 |
+
author_email='openmmlab@gmail.com',
|
| 168 |
+
keywords='computer vision, object detection',
|
| 169 |
+
url='https://github.com/open-mmlab/mmyolo',
|
| 170 |
+
packages=find_packages(exclude=('configs', 'tools', 'demo')),
|
| 171 |
+
include_package_data=True,
|
| 172 |
+
classifiers=[
|
| 173 |
+
'Development Status :: 5 - Production/Stable',
|
| 174 |
+
'License :: OSI Approved :: Apache Software License',
|
| 175 |
+
'Operating System :: OS Independent',
|
| 176 |
+
'Programming Language :: Python :: 3',
|
| 177 |
+
'Programming Language :: Python :: 3.7',
|
| 178 |
+
'Programming Language :: Python :: 3.8',
|
| 179 |
+
'Programming Language :: Python :: 3.9',
|
| 180 |
+
],
|
| 181 |
+
license='GPL License 3.0',
|
| 182 |
+
install_requires=parse_requirements('requirements/runtime.txt'),
|
| 183 |
+
extras_require={
|
| 184 |
+
'all': parse_requirements('requirements.txt'),
|
| 185 |
+
'tests': parse_requirements('requirements/tests.txt'),
|
| 186 |
+
'build': parse_requirements('requirements/build.txt'),
|
| 187 |
+
'mim': parse_requirements('requirements/mminstall.txt'),
|
| 188 |
+
},
|
| 189 |
+
ext_modules=[],
|
| 190 |
+
cmdclass={'build_ext': BuildExtension},
|
| 191 |
+
zip_safe=False)
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/regression/mmyolo.yml
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
globals:
|
| 2 |
+
codebase_dir: ../mmyolo
|
| 3 |
+
checkpoint_force_download: False
|
| 4 |
+
images:
|
| 5 |
+
input_img: &input_img ../mmyolo/demo/demo.jpg
|
| 6 |
+
test_img: &test_img ./tests/data/tiger.jpeg
|
| 7 |
+
metric_info: &metric_info
|
| 8 |
+
box AP: # named after metafile.Results.Metrics
|
| 9 |
+
metric_key: coco/bbox_mAP # eval OrderedDict key name
|
| 10 |
+
tolerance: 1 # metric ±n%
|
| 11 |
+
multi_value: 100
|
| 12 |
+
convert_image: &convert_image
|
| 13 |
+
input_img: *input_img
|
| 14 |
+
test_img: *test_img
|
| 15 |
+
backend_test: &default_backend_test True
|
| 16 |
+
|
| 17 |
+
onnxruntime:
|
| 18 |
+
pipeline_ort_static_fp32: &pipeline_ort_static_fp32
|
| 19 |
+
convert_image: *convert_image
|
| 20 |
+
backend_test: False
|
| 21 |
+
deploy_config: configs/mmyolo/detection_onnxruntime_static.py
|
| 22 |
+
|
| 23 |
+
pipeline_ort_dynamic_fp32: &pipeline_ort_dynamic_fp32
|
| 24 |
+
convert_image: *convert_image
|
| 25 |
+
backend_test: False
|
| 26 |
+
deploy_config: configs/mmyolo/detection_onnxruntime_dynamic.py
|
| 27 |
+
|
| 28 |
+
tensorrt:
|
| 29 |
+
pipeline_trt_static_fp32: &pipeline_trt_static_fp32_640x640
|
| 30 |
+
convert_image: *convert_image
|
| 31 |
+
backend_test: False
|
| 32 |
+
deploy_config: configs/mmyolo/detection_tensorrt_static-640x640.py
|
| 33 |
+
|
| 34 |
+
pipeline_trt_static_fp16: &pipeline_trt_static_fp16_640x640
|
| 35 |
+
convert_image: *convert_image
|
| 36 |
+
backend_test: False
|
| 37 |
+
deploy_config: configs/mmyolo/detection_tensorrt-fp16_static-640x640.py
|
| 38 |
+
|
| 39 |
+
pipeline_trt_dynamic_fp32: &pipeline_trt_dynamic_fp32
|
| 40 |
+
convert_image: *convert_image
|
| 41 |
+
backend_test: *default_backend_test
|
| 42 |
+
deploy_config: configs/mmyolo/detection_tensorrt_dynamic-192x192-960x960.py
|
| 43 |
+
|
| 44 |
+
pipeline_trt_dynamic_fp16: &pipeline_trt_dynamic_fp16
|
| 45 |
+
convert_image: *convert_image
|
| 46 |
+
backend_test: *default_backend_test
|
| 47 |
+
deploy_config: configs/mmyolo/detection_tensorrt-fp16_dynamic-64x64-1344x1344.py
|
| 48 |
+
|
| 49 |
+
models:
|
| 50 |
+
- name: YOLOv5
|
| 51 |
+
metafile: configs/yolov5/metafile.yml
|
| 52 |
+
model_configs:
|
| 53 |
+
- configs/yolov5/yolov5_s-p6-v62_syncbn_fast_8xb16-300e_coco.py
|
| 54 |
+
pipelines:
|
| 55 |
+
- *pipeline_ort_dynamic_fp32
|
| 56 |
+
- *pipeline_trt_dynamic_fp16
|
| 57 |
+
|
| 58 |
+
- name: YOLOv6
|
| 59 |
+
metafile: configs/yolov6/metafile.yml
|
| 60 |
+
model_configs:
|
| 61 |
+
- configs/yolov6/yolov6_s_syncbn_fast_8xb32-400e_coco.py
|
| 62 |
+
pipelines:
|
| 63 |
+
- *pipeline_ort_dynamic_fp32
|
| 64 |
+
- *pipeline_trt_dynamic_fp16
|
| 65 |
+
|
| 66 |
+
- name: YOLOX
|
| 67 |
+
metafile: configs/yolox/metafile.yml
|
| 68 |
+
model_configs:
|
| 69 |
+
- configs/yolox/yolox_s_8xb8-300e_coco.py
|
| 70 |
+
pipelines:
|
| 71 |
+
- *pipeline_ort_dynamic_fp32
|
| 72 |
+
- *pipeline_trt_dynamic_fp16
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
- name: RTMDet
|
| 76 |
+
metafile: configs/rtmdet/metafile.yml
|
| 77 |
+
model_configs:
|
| 78 |
+
- configs/rtmdet/rtmdet_s_syncbn_8xb32-300e_coco.py
|
| 79 |
+
pipelines:
|
| 80 |
+
- *pipeline_ort_dynamic_fp32
|
| 81 |
+
- *pipeline_trt_dynamic_fp16
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) OpenMMLab. All rights reserved.
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/test_transforms/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) OpenMMLab. All rights reserved.
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/test_transforms/test_formatting.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) OpenMMLab. All rights reserved.
|
| 2 |
+
import copy
|
| 3 |
+
import os.path as osp
|
| 4 |
+
import unittest
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
from mmdet.structures import DetDataSample
|
| 8 |
+
from mmdet.structures.mask import BitmapMasks
|
| 9 |
+
from mmengine.structures import InstanceData, PixelData
|
| 10 |
+
|
| 11 |
+
from mmyolo.datasets.transforms import PackDetInputs
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class TestPackDetInputs(unittest.TestCase):
|
| 15 |
+
|
| 16 |
+
def setUp(self):
|
| 17 |
+
"""Setup the model and optimizer which are used in every test method.
|
| 18 |
+
|
| 19 |
+
TestCase calls functions in this order: setUp() -> testMethod() ->
|
| 20 |
+
tearDown() -> cleanUp()
|
| 21 |
+
"""
|
| 22 |
+
data_prefix = osp.join(osp.dirname(__file__), '../../data')
|
| 23 |
+
img_path = osp.join(data_prefix, 'color.jpg')
|
| 24 |
+
rng = np.random.RandomState(0)
|
| 25 |
+
self.results1 = {
|
| 26 |
+
'img_id': 1,
|
| 27 |
+
'img_path': img_path,
|
| 28 |
+
'ori_shape': (300, 400),
|
| 29 |
+
'img_shape': (600, 800),
|
| 30 |
+
'scale_factor': 2.0,
|
| 31 |
+
'flip': False,
|
| 32 |
+
'img': rng.rand(300, 400),
|
| 33 |
+
'gt_seg_map': rng.rand(300, 400),
|
| 34 |
+
'gt_masks':
|
| 35 |
+
BitmapMasks(rng.rand(3, 300, 400), height=300, width=400),
|
| 36 |
+
'gt_bboxes_labels': rng.rand(3, ),
|
| 37 |
+
'gt_ignore_flags': np.array([0, 0, 1], dtype=bool),
|
| 38 |
+
'proposals': rng.rand(2, 4),
|
| 39 |
+
'proposals_scores': rng.rand(2, )
|
| 40 |
+
}
|
| 41 |
+
self.results2 = {
|
| 42 |
+
'img_id': 1,
|
| 43 |
+
'img_path': img_path,
|
| 44 |
+
'ori_shape': (300, 400),
|
| 45 |
+
'img_shape': (600, 800),
|
| 46 |
+
'scale_factor': 2.0,
|
| 47 |
+
'flip': False,
|
| 48 |
+
'img': rng.rand(300, 400),
|
| 49 |
+
'gt_seg_map': rng.rand(300, 400),
|
| 50 |
+
'gt_masks':
|
| 51 |
+
BitmapMasks(rng.rand(3, 300, 400), height=300, width=400),
|
| 52 |
+
'gt_bboxes_labels': rng.rand(3, ),
|
| 53 |
+
'proposals': rng.rand(2, 4),
|
| 54 |
+
'proposals_scores': rng.rand(2, )
|
| 55 |
+
}
|
| 56 |
+
self.results3 = {
|
| 57 |
+
'img_id': 1,
|
| 58 |
+
'img_path': img_path,
|
| 59 |
+
'ori_shape': (300, 400),
|
| 60 |
+
'img_shape': (600, 800),
|
| 61 |
+
'scale_factor': 2.0,
|
| 62 |
+
'flip': False,
|
| 63 |
+
'img': rng.rand(300, 400),
|
| 64 |
+
'gt_seg_map': rng.rand(300, 400),
|
| 65 |
+
'gt_masks':
|
| 66 |
+
BitmapMasks(rng.rand(3, 300, 400), height=300, width=400),
|
| 67 |
+
'gt_panoptic_seg': rng.rand(1, 300, 400),
|
| 68 |
+
'gt_bboxes_labels': rng.rand(3, ),
|
| 69 |
+
'proposals': rng.rand(2, 4),
|
| 70 |
+
'proposals_scores': rng.rand(2, )
|
| 71 |
+
}
|
| 72 |
+
self.meta_keys = ('img_id', 'img_path', 'ori_shape', 'scale_factor',
|
| 73 |
+
'flip')
|
| 74 |
+
|
| 75 |
+
def test_transform(self):
|
| 76 |
+
transform = PackDetInputs(meta_keys=self.meta_keys)
|
| 77 |
+
results = transform(copy.deepcopy(self.results1))
|
| 78 |
+
self.assertIn('data_samples', results)
|
| 79 |
+
self.assertIsInstance(results['data_samples'], DetDataSample)
|
| 80 |
+
self.assertIsInstance(results['data_samples'].gt_instances,
|
| 81 |
+
InstanceData)
|
| 82 |
+
self.assertIsInstance(results['data_samples'].ignored_instances,
|
| 83 |
+
InstanceData)
|
| 84 |
+
self.assertEqual(len(results['data_samples'].gt_instances), 2)
|
| 85 |
+
self.assertEqual(len(results['data_samples'].ignored_instances), 1)
|
| 86 |
+
self.assertIsInstance(results['data_samples'].gt_sem_seg, PixelData)
|
| 87 |
+
|
| 88 |
+
def test_transform_without_ignore(self):
|
| 89 |
+
transform = PackDetInputs(meta_keys=self.meta_keys)
|
| 90 |
+
results = transform(copy.deepcopy(self.results2))
|
| 91 |
+
self.assertIn('data_samples', results)
|
| 92 |
+
self.assertIsInstance(results['data_samples'], DetDataSample)
|
| 93 |
+
self.assertIsInstance(results['data_samples'].gt_instances,
|
| 94 |
+
InstanceData)
|
| 95 |
+
self.assertIsInstance(results['data_samples'].ignored_instances,
|
| 96 |
+
InstanceData)
|
| 97 |
+
self.assertEqual(len(results['data_samples'].gt_instances), 3)
|
| 98 |
+
self.assertEqual(len(results['data_samples'].ignored_instances), 0)
|
| 99 |
+
self.assertIsInstance(results['data_samples'].gt_sem_seg, PixelData)
|
| 100 |
+
|
| 101 |
+
def test_transform_with_panoptic_seg(self):
|
| 102 |
+
transform = PackDetInputs(meta_keys=self.meta_keys)
|
| 103 |
+
results = transform(copy.deepcopy(self.results3))
|
| 104 |
+
self.assertIn('data_samples', results)
|
| 105 |
+
self.assertIsInstance(results['data_samples'], DetDataSample)
|
| 106 |
+
self.assertIsInstance(results['data_samples'].gt_instances,
|
| 107 |
+
InstanceData)
|
| 108 |
+
self.assertIsInstance(results['data_samples'].ignored_instances,
|
| 109 |
+
InstanceData)
|
| 110 |
+
self.assertEqual(len(results['data_samples'].gt_instances), 3)
|
| 111 |
+
self.assertEqual(len(results['data_samples'].ignored_instances), 0)
|
| 112 |
+
self.assertIsInstance(results['data_samples'].gt_sem_seg, PixelData)
|
| 113 |
+
self.assertIsInstance(results['data_samples'].gt_panoptic_seg,
|
| 114 |
+
PixelData)
|
| 115 |
+
|
| 116 |
+
def test_repr(self):
|
| 117 |
+
transform = PackDetInputs(meta_keys=self.meta_keys)
|
| 118 |
+
self.assertEqual(
|
| 119 |
+
repr(transform), f'PackDetInputs(meta_keys={self.meta_keys})')
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/test_transforms/test_mix_img_transforms.py
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) OpenMMLab. All rights reserved.
|
| 2 |
+
import copy
|
| 3 |
+
import os.path as osp
|
| 4 |
+
import unittest
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
import torch
|
| 8 |
+
from mmdet.structures.bbox import HorizontalBoxes
|
| 9 |
+
from mmdet.structures.mask import BitmapMasks, PolygonMasks
|
| 10 |
+
|
| 11 |
+
from mmyolo.datasets import YOLOv5CocoDataset
|
| 12 |
+
from mmyolo.datasets.transforms import Mosaic, Mosaic9, YOLOv5MixUp, YOLOXMixUp
|
| 13 |
+
from mmyolo.utils import register_all_modules
|
| 14 |
+
|
| 15 |
+
register_all_modules()
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class TestMosaic(unittest.TestCase):
|
| 19 |
+
|
| 20 |
+
def setUp(self):
|
| 21 |
+
"""Setup the data info which are used in every test method.
|
| 22 |
+
|
| 23 |
+
TestCase calls functions in this order: setUp() -> testMethod() ->
|
| 24 |
+
tearDown() -> cleanUp()
|
| 25 |
+
"""
|
| 26 |
+
self.pre_transform = [
|
| 27 |
+
dict(type='LoadImageFromFile'),
|
| 28 |
+
dict(type='LoadAnnotations', with_bbox=True)
|
| 29 |
+
]
|
| 30 |
+
|
| 31 |
+
self.dataset = YOLOv5CocoDataset(
|
| 32 |
+
data_prefix=dict(
|
| 33 |
+
img=osp.join(osp.dirname(__file__), '../../data')),
|
| 34 |
+
ann_file=osp.join(
|
| 35 |
+
osp.dirname(__file__), '../../data/coco_sample_color.json'),
|
| 36 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
| 37 |
+
pipeline=[])
|
| 38 |
+
self.results = {
|
| 39 |
+
'img':
|
| 40 |
+
np.random.random((224, 224, 3)),
|
| 41 |
+
'img_shape': (224, 224),
|
| 42 |
+
'gt_bboxes_labels':
|
| 43 |
+
np.array([1, 2, 3], dtype=np.int64),
|
| 44 |
+
'gt_bboxes':
|
| 45 |
+
np.array([[10, 10, 20, 20], [20, 20, 40, 40], [40, 40, 80, 80]],
|
| 46 |
+
dtype=np.float32),
|
| 47 |
+
'gt_ignore_flags':
|
| 48 |
+
np.array([0, 0, 1], dtype=bool),
|
| 49 |
+
'dataset':
|
| 50 |
+
self.dataset
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
def test_transform(self):
|
| 54 |
+
# test assertion for invalid img_scale
|
| 55 |
+
with self.assertRaises(AssertionError):
|
| 56 |
+
transform = Mosaic(img_scale=640)
|
| 57 |
+
|
| 58 |
+
# test assertion for invalid probability
|
| 59 |
+
with self.assertRaises(AssertionError):
|
| 60 |
+
transform = Mosaic(prob=1.5)
|
| 61 |
+
|
| 62 |
+
# test assertion for invalid max_cached_images
|
| 63 |
+
with self.assertRaises(AssertionError):
|
| 64 |
+
transform = Mosaic(use_cached=True, max_cached_images=1)
|
| 65 |
+
|
| 66 |
+
transform = Mosaic(
|
| 67 |
+
img_scale=(12, 10), pre_transform=self.pre_transform)
|
| 68 |
+
results = transform(copy.deepcopy(self.results))
|
| 69 |
+
self.assertTrue(results['img'].shape[:2] == (20, 24))
|
| 70 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 71 |
+
results['gt_bboxes'].shape[0])
|
| 72 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 73 |
+
self.assertTrue(results['gt_bboxes'].dtype == np.float32)
|
| 74 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 75 |
+
|
| 76 |
+
def test_transform_with_no_gt(self):
|
| 77 |
+
self.results['gt_bboxes'] = np.empty((0, 4), dtype=np.float32)
|
| 78 |
+
self.results['gt_bboxes_labels'] = np.empty((0, ), dtype=np.int64)
|
| 79 |
+
self.results['gt_ignore_flags'] = np.empty((0, ), dtype=bool)
|
| 80 |
+
transform = Mosaic(
|
| 81 |
+
img_scale=(12, 10), pre_transform=self.pre_transform)
|
| 82 |
+
results = transform(copy.deepcopy(self.results))
|
| 83 |
+
self.assertIsInstance(results, dict)
|
| 84 |
+
self.assertTrue(results['img'].shape[:2] == (20, 24))
|
| 85 |
+
self.assertTrue(
|
| 86 |
+
results['gt_bboxes_labels'].shape[0] == results['gt_bboxes'].
|
| 87 |
+
shape[0] == results['gt_ignore_flags'].shape[0])
|
| 88 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 89 |
+
self.assertTrue(results['gt_bboxes'].dtype == np.float32)
|
| 90 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 91 |
+
|
| 92 |
+
def test_transform_with_box_list(self):
|
| 93 |
+
transform = Mosaic(
|
| 94 |
+
img_scale=(12, 10), pre_transform=self.pre_transform)
|
| 95 |
+
results = copy.deepcopy(self.results)
|
| 96 |
+
results['gt_bboxes'] = HorizontalBoxes(results['gt_bboxes'])
|
| 97 |
+
results = transform(results)
|
| 98 |
+
self.assertTrue(results['img'].shape[:2] == (20, 24))
|
| 99 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 100 |
+
results['gt_bboxes'].shape[0])
|
| 101 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 102 |
+
self.assertTrue(results['gt_bboxes'].dtype == torch.float32)
|
| 103 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 104 |
+
|
| 105 |
+
def test_transform_with_mask(self):
|
| 106 |
+
rng = np.random.RandomState(0)
|
| 107 |
+
pre_transform = [
|
| 108 |
+
dict(type='LoadImageFromFile'),
|
| 109 |
+
dict(type='LoadAnnotations', with_bbox=True, with_mask=True)
|
| 110 |
+
]
|
| 111 |
+
|
| 112 |
+
dataset = YOLOv5CocoDataset(
|
| 113 |
+
data_prefix=dict(
|
| 114 |
+
img=osp.join(osp.dirname(__file__), '../../data')),
|
| 115 |
+
ann_file=osp.join(
|
| 116 |
+
osp.dirname(__file__), '../../data/coco_sample_color.json'),
|
| 117 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
| 118 |
+
pipeline=[])
|
| 119 |
+
results = {
|
| 120 |
+
'img':
|
| 121 |
+
np.random.random((224, 224, 3)),
|
| 122 |
+
'img_shape': (224, 224),
|
| 123 |
+
'gt_bboxes_labels':
|
| 124 |
+
np.array([1, 2, 3], dtype=np.int64),
|
| 125 |
+
'gt_bboxes':
|
| 126 |
+
np.array([[10, 10, 20, 20], [20, 20, 40, 40], [40, 40, 80, 80]],
|
| 127 |
+
dtype=np.float32),
|
| 128 |
+
'gt_ignore_flags':
|
| 129 |
+
np.array([0, 0, 1], dtype=bool),
|
| 130 |
+
'gt_masks':
|
| 131 |
+
PolygonMasks.random(num_masks=3, height=224, width=224, rng=rng),
|
| 132 |
+
'dataset':
|
| 133 |
+
dataset
|
| 134 |
+
}
|
| 135 |
+
transform = Mosaic(img_scale=(12, 10), pre_transform=pre_transform)
|
| 136 |
+
results['gt_bboxes'] = HorizontalBoxes(results['gt_bboxes'])
|
| 137 |
+
results = transform(results)
|
| 138 |
+
self.assertTrue(results['img'].shape[:2] == (20, 24))
|
| 139 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 140 |
+
results['gt_bboxes'].shape[0])
|
| 141 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 142 |
+
self.assertTrue(results['gt_bboxes'].dtype == torch.float32)
|
| 143 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
class TestMosaic9(unittest.TestCase):
|
| 147 |
+
|
| 148 |
+
def setUp(self):
|
| 149 |
+
"""Setup the data info which are used in every test method.
|
| 150 |
+
|
| 151 |
+
TestCase calls functions in this order: setUp() -> testMethod() ->
|
| 152 |
+
tearDown() -> cleanUp()
|
| 153 |
+
"""
|
| 154 |
+
rng = np.random.RandomState(0)
|
| 155 |
+
self.pre_transform = [
|
| 156 |
+
dict(type='LoadImageFromFile'),
|
| 157 |
+
dict(type='LoadAnnotations', with_bbox=True)
|
| 158 |
+
]
|
| 159 |
+
|
| 160 |
+
self.dataset = YOLOv5CocoDataset(
|
| 161 |
+
data_prefix=dict(
|
| 162 |
+
img=osp.join(osp.dirname(__file__), '../../data')),
|
| 163 |
+
ann_file=osp.join(
|
| 164 |
+
osp.dirname(__file__), '../../data/coco_sample_color.json'),
|
| 165 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
| 166 |
+
pipeline=[])
|
| 167 |
+
self.results = {
|
| 168 |
+
'img':
|
| 169 |
+
np.random.random((224, 224, 3)),
|
| 170 |
+
'img_shape': (224, 224),
|
| 171 |
+
'gt_bboxes_labels':
|
| 172 |
+
np.array([1, 2, 3], dtype=np.int64),
|
| 173 |
+
'gt_bboxes':
|
| 174 |
+
np.array([[10, 10, 20, 20], [20, 20, 40, 40], [40, 40, 80, 80]],
|
| 175 |
+
dtype=np.float32),
|
| 176 |
+
'gt_ignore_flags':
|
| 177 |
+
np.array([0, 0, 1], dtype=bool),
|
| 178 |
+
'gt_masks':
|
| 179 |
+
BitmapMasks(rng.rand(3, 224, 224), height=224, width=224),
|
| 180 |
+
'dataset':
|
| 181 |
+
self.dataset
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
def test_transform(self):
|
| 185 |
+
# test assertion for invalid img_scale
|
| 186 |
+
with self.assertRaises(AssertionError):
|
| 187 |
+
transform = Mosaic9(img_scale=640)
|
| 188 |
+
|
| 189 |
+
# test assertion for invalid probability
|
| 190 |
+
with self.assertRaises(AssertionError):
|
| 191 |
+
transform = Mosaic9(prob=1.5)
|
| 192 |
+
|
| 193 |
+
# test assertion for invalid max_cached_images
|
| 194 |
+
with self.assertRaises(AssertionError):
|
| 195 |
+
transform = Mosaic9(use_cached=True, max_cached_images=1)
|
| 196 |
+
|
| 197 |
+
transform = Mosaic9(
|
| 198 |
+
img_scale=(12, 10), pre_transform=self.pre_transform)
|
| 199 |
+
results = transform(copy.deepcopy(self.results))
|
| 200 |
+
self.assertTrue(results['img'].shape[:2] == (20, 24))
|
| 201 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 202 |
+
results['gt_bboxes'].shape[0])
|
| 203 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 204 |
+
self.assertTrue(results['gt_bboxes'].dtype == np.float32)
|
| 205 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 206 |
+
|
| 207 |
+
def test_transform_with_no_gt(self):
|
| 208 |
+
self.results['gt_bboxes'] = np.empty((0, 4), dtype=np.float32)
|
| 209 |
+
self.results['gt_bboxes_labels'] = np.empty((0, ), dtype=np.int64)
|
| 210 |
+
self.results['gt_ignore_flags'] = np.empty((0, ), dtype=bool)
|
| 211 |
+
transform = Mosaic9(
|
| 212 |
+
img_scale=(12, 10), pre_transform=self.pre_transform)
|
| 213 |
+
results = transform(copy.deepcopy(self.results))
|
| 214 |
+
self.assertIsInstance(results, dict)
|
| 215 |
+
self.assertTrue(results['img'].shape[:2] == (20, 24))
|
| 216 |
+
self.assertTrue(
|
| 217 |
+
results['gt_bboxes_labels'].shape[0] == results['gt_bboxes'].
|
| 218 |
+
shape[0] == results['gt_ignore_flags'].shape[0])
|
| 219 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 220 |
+
self.assertTrue(results['gt_bboxes'].dtype == np.float32)
|
| 221 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 222 |
+
|
| 223 |
+
def test_transform_with_box_list(self):
|
| 224 |
+
transform = Mosaic9(
|
| 225 |
+
img_scale=(12, 10), pre_transform=self.pre_transform)
|
| 226 |
+
results = copy.deepcopy(self.results)
|
| 227 |
+
results['gt_bboxes'] = HorizontalBoxes(results['gt_bboxes'])
|
| 228 |
+
results = transform(results)
|
| 229 |
+
self.assertTrue(results['img'].shape[:2] == (20, 24))
|
| 230 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 231 |
+
results['gt_bboxes'].shape[0])
|
| 232 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 233 |
+
self.assertTrue(results['gt_bboxes'].dtype == torch.float32)
|
| 234 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
class TestYOLOv5MixUp(unittest.TestCase):
|
| 238 |
+
|
| 239 |
+
def setUp(self):
|
| 240 |
+
"""Setup the data info which are used in every test method.
|
| 241 |
+
|
| 242 |
+
TestCase calls functions in this order: setUp() -> testMethod() ->
|
| 243 |
+
tearDown() -> cleanUp()
|
| 244 |
+
"""
|
| 245 |
+
self.pre_transform = [
|
| 246 |
+
dict(type='LoadImageFromFile'),
|
| 247 |
+
dict(type='LoadAnnotations', with_bbox=True)
|
| 248 |
+
]
|
| 249 |
+
self.dataset = YOLOv5CocoDataset(
|
| 250 |
+
data_prefix=dict(
|
| 251 |
+
img=osp.join(osp.dirname(__file__), '../../data')),
|
| 252 |
+
ann_file=osp.join(
|
| 253 |
+
osp.dirname(__file__), '../../data/coco_sample_color.json'),
|
| 254 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
| 255 |
+
pipeline=[])
|
| 256 |
+
|
| 257 |
+
self.results = {
|
| 258 |
+
'img':
|
| 259 |
+
np.random.random((288, 512, 3)),
|
| 260 |
+
'img_shape': (288, 512),
|
| 261 |
+
'gt_bboxes_labels':
|
| 262 |
+
np.array([1, 2, 3], dtype=np.int64),
|
| 263 |
+
'gt_bboxes':
|
| 264 |
+
np.array([[10, 10, 20, 20], [20, 20, 40, 40], [40, 40, 80, 80]],
|
| 265 |
+
dtype=np.float32),
|
| 266 |
+
'gt_ignore_flags':
|
| 267 |
+
np.array([0, 0, 1], dtype=bool),
|
| 268 |
+
'dataset':
|
| 269 |
+
self.dataset
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
def test_transform(self):
|
| 273 |
+
transform = YOLOv5MixUp(pre_transform=self.pre_transform)
|
| 274 |
+
results = transform(copy.deepcopy(self.results))
|
| 275 |
+
self.assertTrue(results['img'].shape[:2] == (288, 512))
|
| 276 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 277 |
+
results['gt_bboxes'].shape[0])
|
| 278 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 279 |
+
self.assertTrue(results['gt_bboxes'].dtype == np.float32)
|
| 280 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 281 |
+
|
| 282 |
+
# test assertion for invalid max_cached_images
|
| 283 |
+
with self.assertRaises(AssertionError):
|
| 284 |
+
transform = YOLOv5MixUp(use_cached=True, max_cached_images=1)
|
| 285 |
+
|
| 286 |
+
def test_transform_with_box_list(self):
|
| 287 |
+
results = copy.deepcopy(self.results)
|
| 288 |
+
results['gt_bboxes'] = HorizontalBoxes(results['gt_bboxes'])
|
| 289 |
+
|
| 290 |
+
transform = YOLOv5MixUp(pre_transform=self.pre_transform)
|
| 291 |
+
results = transform(results)
|
| 292 |
+
self.assertTrue(results['img'].shape[:2] == (288, 512))
|
| 293 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 294 |
+
results['gt_bboxes'].shape[0])
|
| 295 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 296 |
+
self.assertTrue(results['gt_bboxes'].dtype == torch.float32)
|
| 297 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 298 |
+
|
| 299 |
+
def test_transform_with_mask(self):
|
| 300 |
+
rng = np.random.RandomState(0)
|
| 301 |
+
pre_transform = [
|
| 302 |
+
dict(type='LoadImageFromFile'),
|
| 303 |
+
dict(type='LoadAnnotations', with_bbox=True, with_mask=True)
|
| 304 |
+
]
|
| 305 |
+
dataset = YOLOv5CocoDataset(
|
| 306 |
+
data_prefix=dict(
|
| 307 |
+
img=osp.join(osp.dirname(__file__), '../../data')),
|
| 308 |
+
ann_file=osp.join(
|
| 309 |
+
osp.dirname(__file__), '../../data/coco_sample_color.json'),
|
| 310 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
| 311 |
+
pipeline=[])
|
| 312 |
+
|
| 313 |
+
results = {
|
| 314 |
+
'img':
|
| 315 |
+
np.random.random((288, 512, 3)),
|
| 316 |
+
'img_shape': (288, 512),
|
| 317 |
+
'gt_bboxes_labels':
|
| 318 |
+
np.array([1, 2, 3], dtype=np.int64),
|
| 319 |
+
'gt_bboxes':
|
| 320 |
+
np.array([[10, 10, 20, 20], [20, 20, 40, 40], [40, 40, 80, 80]],
|
| 321 |
+
dtype=np.float32),
|
| 322 |
+
'gt_ignore_flags':
|
| 323 |
+
np.array([0, 0, 1], dtype=bool),
|
| 324 |
+
'gt_masks':
|
| 325 |
+
PolygonMasks.random(num_masks=3, height=288, width=512, rng=rng),
|
| 326 |
+
'dataset':
|
| 327 |
+
dataset
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
transform = YOLOv5MixUp(pre_transform=pre_transform)
|
| 331 |
+
results = transform(copy.deepcopy(results))
|
| 332 |
+
self.assertTrue(results['img'].shape[:2] == (288, 512))
|
| 333 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 334 |
+
results['gt_bboxes'].shape[0])
|
| 335 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 336 |
+
self.assertTrue(results['gt_bboxes'].dtype == np.float32)
|
| 337 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
class TestYOLOXMixUp(unittest.TestCase):
|
| 341 |
+
|
| 342 |
+
def setUp(self):
|
| 343 |
+
"""Setup the data info which are used in every test method.
|
| 344 |
+
|
| 345 |
+
TestCase calls functions in this order: setUp() -> testMethod() ->
|
| 346 |
+
tearDown() -> cleanUp()
|
| 347 |
+
"""
|
| 348 |
+
rng = np.random.RandomState(0)
|
| 349 |
+
self.pre_transform = [
|
| 350 |
+
dict(type='LoadImageFromFile'),
|
| 351 |
+
dict(type='LoadAnnotations', with_bbox=True)
|
| 352 |
+
]
|
| 353 |
+
self.dataset = YOLOv5CocoDataset(
|
| 354 |
+
data_prefix=dict(
|
| 355 |
+
img=osp.join(osp.dirname(__file__), '../../data')),
|
| 356 |
+
ann_file=osp.join(
|
| 357 |
+
osp.dirname(__file__), '../../data/coco_sample_color.json'),
|
| 358 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
| 359 |
+
pipeline=[])
|
| 360 |
+
self.results = {
|
| 361 |
+
'img':
|
| 362 |
+
np.random.random((224, 224, 3)),
|
| 363 |
+
'img_shape': (224, 224),
|
| 364 |
+
'gt_bboxes_labels':
|
| 365 |
+
np.array([1, 2, 3], dtype=np.int64),
|
| 366 |
+
'gt_bboxes':
|
| 367 |
+
np.array([[10, 10, 20, 20], [20, 20, 40, 40], [40, 40, 80, 80]],
|
| 368 |
+
dtype=np.float32),
|
| 369 |
+
'gt_ignore_flags':
|
| 370 |
+
np.array([0, 0, 1], dtype=bool),
|
| 371 |
+
'gt_masks':
|
| 372 |
+
BitmapMasks(rng.rand(3, 224, 224), height=224, width=224),
|
| 373 |
+
'dataset':
|
| 374 |
+
self.dataset
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
def test_transform(self):
|
| 378 |
+
# test assertion for invalid img_scale
|
| 379 |
+
with self.assertRaises(AssertionError):
|
| 380 |
+
transform = YOLOXMixUp(img_scale=640)
|
| 381 |
+
|
| 382 |
+
# test assertion for invalid max_cached_images
|
| 383 |
+
with self.assertRaises(AssertionError):
|
| 384 |
+
transform = YOLOXMixUp(use_cached=True, max_cached_images=1)
|
| 385 |
+
|
| 386 |
+
transform = YOLOXMixUp(
|
| 387 |
+
img_scale=(10, 12),
|
| 388 |
+
ratio_range=(0.8, 1.6),
|
| 389 |
+
pad_val=114.0,
|
| 390 |
+
pre_transform=self.pre_transform)
|
| 391 |
+
|
| 392 |
+
# self.results['mix_results'] = [copy.deepcopy(self.results)]
|
| 393 |
+
results = transform(copy.deepcopy(self.results))
|
| 394 |
+
self.assertTrue(results['img'].shape[:2] == (224, 224))
|
| 395 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 396 |
+
results['gt_bboxes'].shape[0])
|
| 397 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 398 |
+
self.assertTrue(results['gt_bboxes'].dtype == np.float32)
|
| 399 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 400 |
+
|
| 401 |
+
def test_transform_with_boxlist(self):
|
| 402 |
+
results = copy.deepcopy(self.results)
|
| 403 |
+
results['gt_bboxes'] = HorizontalBoxes(results['gt_bboxes'])
|
| 404 |
+
|
| 405 |
+
transform = YOLOXMixUp(
|
| 406 |
+
img_scale=(10, 12),
|
| 407 |
+
ratio_range=(0.8, 1.6),
|
| 408 |
+
pad_val=114.0,
|
| 409 |
+
pre_transform=self.pre_transform)
|
| 410 |
+
results = transform(results)
|
| 411 |
+
self.assertTrue(results['img'].shape[:2] == (224, 224))
|
| 412 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 413 |
+
results['gt_bboxes'].shape[0])
|
| 414 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 415 |
+
self.assertTrue(results['gt_bboxes'].dtype == torch.float32)
|
| 416 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/test_transforms/test_transforms.py
ADDED
|
@@ -0,0 +1,493 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) OpenMMLab. All rights reserved.
|
| 2 |
+
import copy
|
| 3 |
+
import os.path as osp
|
| 4 |
+
import unittest
|
| 5 |
+
|
| 6 |
+
import mmcv
|
| 7 |
+
import numpy as np
|
| 8 |
+
import torch
|
| 9 |
+
from mmdet.structures.bbox import HorizontalBoxes
|
| 10 |
+
from mmdet.structures.mask import BitmapMasks, PolygonMasks
|
| 11 |
+
|
| 12 |
+
from mmyolo.datasets.transforms import (LetterResize, LoadAnnotations,
|
| 13 |
+
YOLOv5HSVRandomAug,
|
| 14 |
+
YOLOv5KeepRatioResize,
|
| 15 |
+
YOLOv5RandomAffine)
|
| 16 |
+
from mmyolo.datasets.transforms.transforms import (PPYOLOERandomCrop,
|
| 17 |
+
PPYOLOERandomDistort,
|
| 18 |
+
YOLOv5CopyPaste)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class TestLetterResize(unittest.TestCase):
|
| 22 |
+
|
| 23 |
+
def setUp(self):
|
| 24 |
+
"""Set up the data info which are used in every test method.
|
| 25 |
+
|
| 26 |
+
TestCase calls functions in this order: setUp() -> testMethod() ->
|
| 27 |
+
tearDown() -> cleanUp()
|
| 28 |
+
"""
|
| 29 |
+
rng = np.random.RandomState(0)
|
| 30 |
+
self.data_info1 = dict(
|
| 31 |
+
img=np.random.random((300, 400, 3)),
|
| 32 |
+
gt_bboxes=np.array([[0, 0, 150, 150]], dtype=np.float32),
|
| 33 |
+
batch_shape=np.array([192, 672], dtype=np.int64),
|
| 34 |
+
gt_masks=PolygonMasks.random(1, height=300, width=400, rng=rng))
|
| 35 |
+
self.data_info2 = dict(
|
| 36 |
+
img=np.random.random((300, 400, 3)),
|
| 37 |
+
gt_bboxes=np.array([[0, 0, 150, 150]], dtype=np.float32))
|
| 38 |
+
self.data_info3 = dict(
|
| 39 |
+
img=np.random.random((300, 400, 3)),
|
| 40 |
+
batch_shape=np.array([192, 672], dtype=np.int64))
|
| 41 |
+
self.data_info4 = dict(img=np.random.random((300, 400, 3)))
|
| 42 |
+
|
| 43 |
+
def test_letter_resize(self):
|
| 44 |
+
# Test allow_scale_up
|
| 45 |
+
transform = LetterResize(scale=(640, 640), allow_scale_up=False)
|
| 46 |
+
results = transform(copy.deepcopy(self.data_info1))
|
| 47 |
+
self.assertEqual(results['img_shape'], (192, 672, 3))
|
| 48 |
+
self.assertTrue(
|
| 49 |
+
(results['gt_bboxes'] == np.array([[208., 0., 304., 96.]])).all())
|
| 50 |
+
self.assertTrue((results['batch_shape'] == np.array([192, 672])).all())
|
| 51 |
+
self.assertTrue((results['pad_param'] == np.array([0., 0., 208.,
|
| 52 |
+
208.])).all())
|
| 53 |
+
self.assertTrue(
|
| 54 |
+
(np.array(results['scale_factor'], dtype=np.float32) <= 1.).all())
|
| 55 |
+
|
| 56 |
+
# Test pad_val
|
| 57 |
+
transform = LetterResize(scale=(640, 640), pad_val=dict(img=144))
|
| 58 |
+
results = transform(copy.deepcopy(self.data_info1))
|
| 59 |
+
self.assertEqual(results['img_shape'], (192, 672, 3))
|
| 60 |
+
self.assertTrue(
|
| 61 |
+
(results['gt_bboxes'] == np.array([[208., 0., 304., 96.]])).all())
|
| 62 |
+
self.assertTrue((results['batch_shape'] == np.array([192, 672])).all())
|
| 63 |
+
self.assertTrue((results['pad_param'] == np.array([0., 0., 208.,
|
| 64 |
+
208.])).all())
|
| 65 |
+
self.assertTrue(
|
| 66 |
+
(np.array(results['scale_factor'], dtype=np.float32) <= 1.).all())
|
| 67 |
+
|
| 68 |
+
# Test use_mini_pad
|
| 69 |
+
transform = LetterResize(scale=(640, 640), use_mini_pad=True)
|
| 70 |
+
results = transform(copy.deepcopy(self.data_info1))
|
| 71 |
+
self.assertEqual(results['img_shape'], (192, 256, 3))
|
| 72 |
+
self.assertTrue((results['gt_bboxes'] == np.array([[0., 0., 96.,
|
| 73 |
+
96.]])).all())
|
| 74 |
+
self.assertTrue((results['batch_shape'] == np.array([192, 672])).all())
|
| 75 |
+
self.assertTrue((results['pad_param'] == np.array([0., 0., 0.,
|
| 76 |
+
0.])).all())
|
| 77 |
+
self.assertTrue(
|
| 78 |
+
(np.array(results['scale_factor'], dtype=np.float32) <= 1.).all())
|
| 79 |
+
|
| 80 |
+
# Test stretch_only
|
| 81 |
+
transform = LetterResize(scale=(640, 640), stretch_only=True)
|
| 82 |
+
results = transform(copy.deepcopy(self.data_info1))
|
| 83 |
+
self.assertEqual(results['img_shape'], (192, 672, 3))
|
| 84 |
+
self.assertTrue((results['gt_bboxes'] == np.array(
|
| 85 |
+
[[0., 0., 251.99998474121094, 96.]])).all())
|
| 86 |
+
self.assertTrue((results['batch_shape'] == np.array([192, 672])).all())
|
| 87 |
+
self.assertTrue((results['pad_param'] == np.array([0., 0., 0.,
|
| 88 |
+
0.])).all())
|
| 89 |
+
|
| 90 |
+
# Test
|
| 91 |
+
transform = LetterResize(scale=(640, 640), pad_val=dict(img=144))
|
| 92 |
+
for _ in range(5):
|
| 93 |
+
input_h, input_w = np.random.randint(100, 700), np.random.randint(
|
| 94 |
+
100, 700)
|
| 95 |
+
output_h, output_w = np.random.randint(100,
|
| 96 |
+
700), np.random.randint(
|
| 97 |
+
100, 700)
|
| 98 |
+
data_info = dict(
|
| 99 |
+
img=np.random.random((input_h, input_w, 3)),
|
| 100 |
+
gt_bboxes=np.array([[0, 0, 10, 10]], dtype=np.float32),
|
| 101 |
+
batch_shape=np.array([output_h, output_w], dtype=np.int64),
|
| 102 |
+
gt_masks=PolygonMasks(
|
| 103 |
+
[[np.array([0., 0., 0., 10., 10., 10., 10., 0.])]],
|
| 104 |
+
height=input_h,
|
| 105 |
+
width=input_w))
|
| 106 |
+
results = transform(data_info)
|
| 107 |
+
self.assertEqual(results['img_shape'], (output_h, output_w, 3))
|
| 108 |
+
self.assertTrue(
|
| 109 |
+
(results['batch_shape'] == np.array([output_h,
|
| 110 |
+
output_w])).all())
|
| 111 |
+
|
| 112 |
+
# Test without batchshape
|
| 113 |
+
transform = LetterResize(scale=(640, 640), pad_val=dict(img=144))
|
| 114 |
+
for _ in range(5):
|
| 115 |
+
input_h, input_w = np.random.randint(100, 700), np.random.randint(
|
| 116 |
+
100, 700)
|
| 117 |
+
data_info = dict(
|
| 118 |
+
img=np.random.random((input_h, input_w, 3)),
|
| 119 |
+
gt_bboxes=np.array([[0, 0, 10, 10]], dtype=np.float32),
|
| 120 |
+
gt_masks=PolygonMasks(
|
| 121 |
+
[[np.array([0., 0., 0., 10., 10., 10., 10., 0.])]],
|
| 122 |
+
height=input_h,
|
| 123 |
+
width=input_w))
|
| 124 |
+
results = transform(data_info)
|
| 125 |
+
self.assertEqual(results['img_shape'], (640, 640, 3))
|
| 126 |
+
|
| 127 |
+
# TODO: Testing the existence of multiple scale_factor and pad_param
|
| 128 |
+
transform = [
|
| 129 |
+
YOLOv5KeepRatioResize(scale=(32, 32)),
|
| 130 |
+
LetterResize(scale=(64, 68), pad_val=dict(img=144))
|
| 131 |
+
]
|
| 132 |
+
for _ in range(5):
|
| 133 |
+
input_h, input_w = np.random.randint(100, 700), np.random.randint(
|
| 134 |
+
100, 700)
|
| 135 |
+
output_h, output_w = np.random.randint(100,
|
| 136 |
+
700), np.random.randint(
|
| 137 |
+
100, 700)
|
| 138 |
+
data_info = dict(
|
| 139 |
+
img=np.random.random((input_h, input_w, 3)),
|
| 140 |
+
gt_bboxes=np.array([[0, 0, 5, 5]], dtype=np.float32),
|
| 141 |
+
batch_shape=np.array([output_h, output_w], dtype=np.int64))
|
| 142 |
+
for t in transform:
|
| 143 |
+
data_info = t(data_info)
|
| 144 |
+
# because of the "math.round" operation,
|
| 145 |
+
# it is unable to strictly restore the original input shape
|
| 146 |
+
# we just validate the correctness of scale_factor and pad_param
|
| 147 |
+
self.assertIn('scale_factor', data_info)
|
| 148 |
+
self.assertIn('pad_param', data_info)
|
| 149 |
+
pad_param = data_info['pad_param'].reshape(-1, 2).sum(
|
| 150 |
+
1) # (top, b, l, r) -> (h, w)
|
| 151 |
+
scale_factor = np.asarray(data_info['scale_factor']) # (w, h)
|
| 152 |
+
|
| 153 |
+
max_long_edge = max((32, 32))
|
| 154 |
+
max_short_edge = min((32, 32))
|
| 155 |
+
scale_factor_keepratio = min(
|
| 156 |
+
max_long_edge / max(input_h, input_w),
|
| 157 |
+
max_short_edge / min(input_h, input_w))
|
| 158 |
+
validate_shape = np.asarray(
|
| 159 |
+
(int(input_h * scale_factor_keepratio),
|
| 160 |
+
int(input_w * scale_factor_keepratio)))
|
| 161 |
+
scale_factor_keepratio = np.asarray(
|
| 162 |
+
(validate_shape[1] / input_w, validate_shape[0] / input_h))
|
| 163 |
+
|
| 164 |
+
scale_factor_letter = ((np.asarray(
|
| 165 |
+
(output_h, output_w)) - pad_param) / validate_shape)[::-1]
|
| 166 |
+
self.assertTrue(data_info['img_shape'][:2] == (output_h, output_w))
|
| 167 |
+
self.assertTrue((scale_factor == (scale_factor_keepratio *
|
| 168 |
+
scale_factor_letter)).all())
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
class TestYOLOv5KeepRatioResize(unittest.TestCase):
|
| 172 |
+
|
| 173 |
+
def setUp(self):
|
| 174 |
+
"""Set up the data info which are used in every test method.
|
| 175 |
+
|
| 176 |
+
TestCase calls functions in this order: setUp() -> testMethod() ->
|
| 177 |
+
tearDown() -> cleanUp()
|
| 178 |
+
"""
|
| 179 |
+
rng = np.random.RandomState(0)
|
| 180 |
+
self.data_info1 = dict(
|
| 181 |
+
img=np.random.random((300, 400, 3)),
|
| 182 |
+
gt_bboxes=np.array([[0, 0, 150, 150]], dtype=np.float32),
|
| 183 |
+
gt_masks=PolygonMasks.random(
|
| 184 |
+
num_masks=1, height=300, width=400, rng=rng))
|
| 185 |
+
self.data_info2 = dict(img=np.random.random((300, 400, 3)))
|
| 186 |
+
|
| 187 |
+
def test_yolov5_keep_ratio_resize(self):
|
| 188 |
+
# test assertion for invalid keep_ratio
|
| 189 |
+
with self.assertRaises(AssertionError):
|
| 190 |
+
transform = YOLOv5KeepRatioResize(scale=(640, 640))
|
| 191 |
+
transform.keep_ratio = False
|
| 192 |
+
results = transform(copy.deepcopy(self.data_info1))
|
| 193 |
+
|
| 194 |
+
# Test with gt_bboxes
|
| 195 |
+
transform = YOLOv5KeepRatioResize(scale=(640, 640))
|
| 196 |
+
results = transform(copy.deepcopy(self.data_info1))
|
| 197 |
+
self.assertTrue(transform.keep_ratio, True)
|
| 198 |
+
self.assertEqual(results['img_shape'], (480, 640))
|
| 199 |
+
self.assertTrue(
|
| 200 |
+
(results['gt_bboxes'] == np.array([[0., 0., 240., 240.]])).all())
|
| 201 |
+
self.assertTrue((np.array(results['scale_factor'],
|
| 202 |
+
dtype=np.float32) == 1.6).all())
|
| 203 |
+
|
| 204 |
+
# Test only img
|
| 205 |
+
transform = YOLOv5KeepRatioResize(scale=(640, 640))
|
| 206 |
+
results = transform(copy.deepcopy(self.data_info2))
|
| 207 |
+
self.assertEqual(results['img_shape'], (480, 640))
|
| 208 |
+
self.assertTrue((np.array(results['scale_factor'],
|
| 209 |
+
dtype=np.float32) == 1.6).all())
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
class TestYOLOv5HSVRandomAug(unittest.TestCase):
|
| 213 |
+
|
| 214 |
+
def setUp(self):
|
| 215 |
+
"""Set up the data info which are used in every test method.
|
| 216 |
+
|
| 217 |
+
TestCase calls functions in this order: setUp() -> testMethod() ->
|
| 218 |
+
tearDown() -> cleanUp()
|
| 219 |
+
"""
|
| 220 |
+
self.data_info = dict(
|
| 221 |
+
img=mmcv.imread(
|
| 222 |
+
osp.join(osp.dirname(__file__), '../../data/color.jpg'),
|
| 223 |
+
'color'))
|
| 224 |
+
|
| 225 |
+
def test_yolov5_hsv_random_aug(self):
|
| 226 |
+
# Test with gt_bboxes
|
| 227 |
+
transform = YOLOv5HSVRandomAug(
|
| 228 |
+
hue_delta=0.015, saturation_delta=0.7, value_delta=0.4)
|
| 229 |
+
results = transform(copy.deepcopy(self.data_info))
|
| 230 |
+
self.assertTrue(
|
| 231 |
+
results['img'].shape[:2] == self.data_info['img'].shape[:2])
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
class TestLoadAnnotations(unittest.TestCase):
|
| 235 |
+
|
| 236 |
+
def setUp(self):
|
| 237 |
+
"""Set up the data info which are used in every test method.
|
| 238 |
+
|
| 239 |
+
TestCase calls functions in this order: setUp() -> testMethod() ->
|
| 240 |
+
tearDown() -> cleanUp()
|
| 241 |
+
"""
|
| 242 |
+
data_prefix = osp.join(osp.dirname(__file__), '../../data')
|
| 243 |
+
seg_map = osp.join(data_prefix, 'gray.jpg')
|
| 244 |
+
self.results = {
|
| 245 |
+
'ori_shape': (300, 400),
|
| 246 |
+
'seg_map_path':
|
| 247 |
+
seg_map,
|
| 248 |
+
'instances': [{
|
| 249 |
+
'bbox': [0, 0, 10, 20],
|
| 250 |
+
'bbox_label': 1,
|
| 251 |
+
'mask': [[0, 0, 0, 20, 10, 20, 10, 0]],
|
| 252 |
+
'ignore_flag': 0
|
| 253 |
+
}, {
|
| 254 |
+
'bbox': [10, 10, 110, 120],
|
| 255 |
+
'bbox_label': 2,
|
| 256 |
+
'mask': [[10, 10, 110, 10, 110, 120, 110, 10]],
|
| 257 |
+
'ignore_flag': 0
|
| 258 |
+
}, {
|
| 259 |
+
'bbox': [50, 50, 60, 80],
|
| 260 |
+
'bbox_label': 2,
|
| 261 |
+
'mask': [[50, 50, 60, 50, 60, 80, 50, 80]],
|
| 262 |
+
'ignore_flag': 1
|
| 263 |
+
}]
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
def test_load_bboxes(self):
|
| 267 |
+
transform = LoadAnnotations(
|
| 268 |
+
with_bbox=True,
|
| 269 |
+
with_label=False,
|
| 270 |
+
with_seg=False,
|
| 271 |
+
with_mask=False,
|
| 272 |
+
box_type=None)
|
| 273 |
+
results = transform(copy.deepcopy(self.results))
|
| 274 |
+
self.assertIn('gt_bboxes', results)
|
| 275 |
+
self.assertTrue((results['gt_bboxes'] == np.array([[0, 0, 10, 20],
|
| 276 |
+
[10, 10, 110,
|
| 277 |
+
120]])).all())
|
| 278 |
+
self.assertEqual(results['gt_bboxes'].dtype, np.float32)
|
| 279 |
+
self.assertTrue(
|
| 280 |
+
(results['gt_ignore_flags'] == np.array([False, False])).all())
|
| 281 |
+
self.assertEqual(results['gt_ignore_flags'].dtype, bool)
|
| 282 |
+
|
| 283 |
+
# test empty instance
|
| 284 |
+
results = transform({})
|
| 285 |
+
self.assertIn('gt_bboxes', results)
|
| 286 |
+
self.assertTrue(results['gt_bboxes'].shape == (0, 4))
|
| 287 |
+
self.assertIn('gt_ignore_flags', results)
|
| 288 |
+
self.assertTrue(results['gt_ignore_flags'].shape == (0, ))
|
| 289 |
+
|
| 290 |
+
def test_load_labels(self):
|
| 291 |
+
transform = LoadAnnotations(
|
| 292 |
+
with_bbox=False,
|
| 293 |
+
with_label=True,
|
| 294 |
+
with_seg=False,
|
| 295 |
+
with_mask=False,
|
| 296 |
+
)
|
| 297 |
+
results = transform(copy.deepcopy(self.results))
|
| 298 |
+
self.assertIn('gt_bboxes_labels', results)
|
| 299 |
+
self.assertTrue((results['gt_bboxes_labels'] == np.array([1,
|
| 300 |
+
2])).all())
|
| 301 |
+
self.assertEqual(results['gt_bboxes_labels'].dtype, np.int64)
|
| 302 |
+
|
| 303 |
+
# test empty instance
|
| 304 |
+
results = transform({})
|
| 305 |
+
self.assertIn('gt_bboxes_labels', results)
|
| 306 |
+
self.assertTrue(results['gt_bboxes_labels'].shape == (0, ))
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
class TestYOLOv5RandomAffine(unittest.TestCase):
|
| 310 |
+
|
| 311 |
+
def setUp(self):
|
| 312 |
+
"""Setup the data info which are used in every test method.
|
| 313 |
+
|
| 314 |
+
TestCase calls functions in this order: setUp() -> testMethod() ->
|
| 315 |
+
tearDown() -> cleanUp()
|
| 316 |
+
"""
|
| 317 |
+
self.results = {
|
| 318 |
+
'img':
|
| 319 |
+
np.random.random((224, 224, 3)),
|
| 320 |
+
'img_shape': (224, 224),
|
| 321 |
+
'gt_bboxes_labels':
|
| 322 |
+
np.array([1, 2, 3], dtype=np.int64),
|
| 323 |
+
'gt_bboxes':
|
| 324 |
+
np.array([[10, 10, 20, 20], [20, 20, 40, 40], [40, 40, 80, 80]],
|
| 325 |
+
dtype=np.float32),
|
| 326 |
+
'gt_ignore_flags':
|
| 327 |
+
np.array([0, 0, 1], dtype=bool),
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
def test_transform(self):
|
| 331 |
+
# test assertion for invalid translate_ratio
|
| 332 |
+
with self.assertRaises(AssertionError):
|
| 333 |
+
transform = YOLOv5RandomAffine(max_translate_ratio=1.5)
|
| 334 |
+
|
| 335 |
+
# test assertion for invalid scaling_ratio_range
|
| 336 |
+
with self.assertRaises(AssertionError):
|
| 337 |
+
transform = YOLOv5RandomAffine(scaling_ratio_range=(1.5, 0.5))
|
| 338 |
+
|
| 339 |
+
with self.assertRaises(AssertionError):
|
| 340 |
+
transform = YOLOv5RandomAffine(scaling_ratio_range=(0, 0.5))
|
| 341 |
+
|
| 342 |
+
transform = YOLOv5RandomAffine()
|
| 343 |
+
results = transform(copy.deepcopy(self.results))
|
| 344 |
+
self.assertTrue(results['img'].shape[:2] == (224, 224))
|
| 345 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 346 |
+
results['gt_bboxes'].shape[0])
|
| 347 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 348 |
+
self.assertTrue(results['gt_bboxes'].dtype == np.float32)
|
| 349 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 350 |
+
|
| 351 |
+
def test_transform_with_boxlist(self):
|
| 352 |
+
results = copy.deepcopy(self.results)
|
| 353 |
+
results['gt_bboxes'] = HorizontalBoxes(results['gt_bboxes'])
|
| 354 |
+
|
| 355 |
+
transform = YOLOv5RandomAffine()
|
| 356 |
+
results = transform(copy.deepcopy(results))
|
| 357 |
+
self.assertTrue(results['img'].shape[:2] == (224, 224))
|
| 358 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 359 |
+
results['gt_bboxes'].shape[0])
|
| 360 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 361 |
+
self.assertTrue(results['gt_bboxes'].dtype == torch.float32)
|
| 362 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
class TestPPYOLOERandomCrop(unittest.TestCase):
|
| 366 |
+
|
| 367 |
+
def setUp(self):
|
| 368 |
+
"""Setup the data info which are used in every test method.
|
| 369 |
+
|
| 370 |
+
TestCase calls functions in this order: setUp() -> testMethod() ->
|
| 371 |
+
tearDown() -> cleanUp()
|
| 372 |
+
"""
|
| 373 |
+
self.results = {
|
| 374 |
+
'img':
|
| 375 |
+
np.random.random((224, 224, 3)),
|
| 376 |
+
'img_shape': (224, 224),
|
| 377 |
+
'gt_bboxes_labels':
|
| 378 |
+
np.array([1, 2, 3], dtype=np.int64),
|
| 379 |
+
'gt_bboxes':
|
| 380 |
+
np.array([[10, 10, 20, 20], [20, 20, 40, 40], [40, 40, 80, 80]],
|
| 381 |
+
dtype=np.float32),
|
| 382 |
+
'gt_ignore_flags':
|
| 383 |
+
np.array([0, 0, 1], dtype=bool),
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
def test_transform(self):
|
| 387 |
+
transform = PPYOLOERandomCrop()
|
| 388 |
+
results = transform(copy.deepcopy(self.results))
|
| 389 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 390 |
+
results['gt_bboxes'].shape[0])
|
| 391 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 392 |
+
self.assertTrue(results['gt_bboxes'].dtype == np.float32)
|
| 393 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 394 |
+
|
| 395 |
+
def test_transform_with_boxlist(self):
|
| 396 |
+
results = copy.deepcopy(self.results)
|
| 397 |
+
results['gt_bboxes'] = HorizontalBoxes(results['gt_bboxes'])
|
| 398 |
+
|
| 399 |
+
transform = PPYOLOERandomCrop()
|
| 400 |
+
results = transform(copy.deepcopy(results))
|
| 401 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 402 |
+
results['gt_bboxes'].shape[0])
|
| 403 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 404 |
+
self.assertTrue(results['gt_bboxes'].dtype == torch.float32)
|
| 405 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 406 |
+
|
| 407 |
+
|
| 408 |
+
class TestPPYOLOERandomDistort(unittest.TestCase):
|
| 409 |
+
|
| 410 |
+
def setUp(self):
|
| 411 |
+
"""Setup the data info which are used in every test method.
|
| 412 |
+
|
| 413 |
+
TestCase calls functions in this order: setUp() -> testMethod() ->
|
| 414 |
+
tearDown() -> cleanUp()
|
| 415 |
+
"""
|
| 416 |
+
self.results = {
|
| 417 |
+
'img':
|
| 418 |
+
np.random.random((224, 224, 3)),
|
| 419 |
+
'img_shape': (224, 224),
|
| 420 |
+
'gt_bboxes_labels':
|
| 421 |
+
np.array([1, 2, 3], dtype=np.int64),
|
| 422 |
+
'gt_bboxes':
|
| 423 |
+
np.array([[10, 10, 20, 20], [20, 20, 40, 40], [40, 40, 80, 80]],
|
| 424 |
+
dtype=np.float32),
|
| 425 |
+
'gt_ignore_flags':
|
| 426 |
+
np.array([0, 0, 1], dtype=bool),
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
def test_transform(self):
|
| 430 |
+
# test assertion for invalid prob
|
| 431 |
+
with self.assertRaises(AssertionError):
|
| 432 |
+
transform = PPYOLOERandomDistort(
|
| 433 |
+
hue_cfg=dict(min=-18, max=18, prob=1.5))
|
| 434 |
+
|
| 435 |
+
# test assertion for invalid num_distort_func
|
| 436 |
+
with self.assertRaises(AssertionError):
|
| 437 |
+
transform = PPYOLOERandomDistort(num_distort_func=5)
|
| 438 |
+
|
| 439 |
+
transform = PPYOLOERandomDistort()
|
| 440 |
+
results = transform(copy.deepcopy(self.results))
|
| 441 |
+
self.assertTrue(results['img'].shape[:2] == (224, 224))
|
| 442 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 443 |
+
results['gt_bboxes'].shape[0])
|
| 444 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 445 |
+
self.assertTrue(results['gt_bboxes'].dtype == np.float32)
|
| 446 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 447 |
+
|
| 448 |
+
def test_transform_with_boxlist(self):
|
| 449 |
+
results = copy.deepcopy(self.results)
|
| 450 |
+
results['gt_bboxes'] = HorizontalBoxes(results['gt_bboxes'])
|
| 451 |
+
|
| 452 |
+
transform = PPYOLOERandomDistort()
|
| 453 |
+
results = transform(copy.deepcopy(results))
|
| 454 |
+
self.assertTrue(results['img'].shape[:2] == (224, 224))
|
| 455 |
+
self.assertTrue(results['gt_bboxes_labels'].shape[0] ==
|
| 456 |
+
results['gt_bboxes'].shape[0])
|
| 457 |
+
self.assertTrue(results['gt_bboxes_labels'].dtype == np.int64)
|
| 458 |
+
self.assertTrue(results['gt_bboxes'].dtype == torch.float32)
|
| 459 |
+
self.assertTrue(results['gt_ignore_flags'].dtype == bool)
|
| 460 |
+
|
| 461 |
+
|
| 462 |
+
class TestYOLOv5CopyPaste(unittest.TestCase):
|
| 463 |
+
|
| 464 |
+
def setUp(self):
|
| 465 |
+
"""Set up the data info which are used in every test method.
|
| 466 |
+
|
| 467 |
+
TestCase calls functions in this order: setUp() -> testMethod() ->
|
| 468 |
+
tearDown() -> cleanUp()
|
| 469 |
+
"""
|
| 470 |
+
self.data_info = dict(
|
| 471 |
+
img=np.random.random((300, 400, 3)),
|
| 472 |
+
gt_bboxes=np.array([[0, 0, 10, 10]], dtype=np.float32),
|
| 473 |
+
gt_masks=PolygonMasks(
|
| 474 |
+
[[np.array([0., 0., 0., 10., 10., 10., 10., 0.])]],
|
| 475 |
+
height=300,
|
| 476 |
+
width=400))
|
| 477 |
+
|
| 478 |
+
def test_transform(self):
|
| 479 |
+
# test transform
|
| 480 |
+
transform = YOLOv5CopyPaste(prob=1.0)
|
| 481 |
+
results = transform(copy.deepcopy(self.data_info))
|
| 482 |
+
self.assertTrue(len(results['gt_bboxes']) == 2)
|
| 483 |
+
self.assertTrue(len(results['gt_masks']) == 2)
|
| 484 |
+
|
| 485 |
+
rng = np.random.RandomState(0)
|
| 486 |
+
# test with bitmap
|
| 487 |
+
with self.assertRaises(AssertionError):
|
| 488 |
+
results = transform(
|
| 489 |
+
dict(
|
| 490 |
+
img=np.random.random((300, 400, 3)),
|
| 491 |
+
gt_bboxes=np.array([[0, 0, 10, 10]], dtype=np.float32),
|
| 492 |
+
gt_masks=BitmapMasks(
|
| 493 |
+
rng.rand(1, 300, 400), height=300, width=400)))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/test_utils.py
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) OpenMMLab. All rights reserved.
|
| 2 |
+
import unittest
|
| 3 |
+
|
| 4 |
+
import numpy as np
|
| 5 |
+
import torch
|
| 6 |
+
from mmdet.structures import DetDataSample
|
| 7 |
+
from mmdet.structures.bbox import HorizontalBoxes
|
| 8 |
+
from mmengine.structures import InstanceData
|
| 9 |
+
|
| 10 |
+
from mmyolo.datasets import BatchShapePolicy, yolov5_collate
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def _rand_bboxes(rng, num_boxes, w, h):
|
| 14 |
+
cx, cy, bw, bh = rng.rand(num_boxes, 4).T
|
| 15 |
+
|
| 16 |
+
tl_x = ((cx * w) - (w * bw / 2)).clip(0, w)
|
| 17 |
+
tl_y = ((cy * h) - (h * bh / 2)).clip(0, h)
|
| 18 |
+
br_x = ((cx * w) + (w * bw / 2)).clip(0, w)
|
| 19 |
+
br_y = ((cy * h) + (h * bh / 2)).clip(0, h)
|
| 20 |
+
|
| 21 |
+
bboxes = np.vstack([tl_x, tl_y, br_x, br_y]).T
|
| 22 |
+
return bboxes
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class TestYOLOv5Collate(unittest.TestCase):
|
| 26 |
+
|
| 27 |
+
def test_yolov5_collate(self):
|
| 28 |
+
rng = np.random.RandomState(0)
|
| 29 |
+
|
| 30 |
+
inputs = torch.randn((3, 10, 10))
|
| 31 |
+
data_samples = DetDataSample()
|
| 32 |
+
gt_instances = InstanceData()
|
| 33 |
+
bboxes = _rand_bboxes(rng, 4, 6, 8)
|
| 34 |
+
gt_instances.bboxes = HorizontalBoxes(bboxes, dtype=torch.float32)
|
| 35 |
+
labels = rng.randint(1, 2, size=len(bboxes))
|
| 36 |
+
gt_instances.labels = torch.LongTensor(labels)
|
| 37 |
+
data_samples.gt_instances = gt_instances
|
| 38 |
+
|
| 39 |
+
out = yolov5_collate([dict(inputs=inputs, data_samples=data_samples)])
|
| 40 |
+
self.assertIsInstance(out, dict)
|
| 41 |
+
self.assertTrue(out['inputs'].shape == (1, 3, 10, 10))
|
| 42 |
+
self.assertTrue(out['data_samples'], dict)
|
| 43 |
+
self.assertTrue(out['data_samples']['bboxes_labels'].shape == (4, 6))
|
| 44 |
+
|
| 45 |
+
out = yolov5_collate([dict(inputs=inputs, data_samples=data_samples)] *
|
| 46 |
+
2)
|
| 47 |
+
self.assertIsInstance(out, dict)
|
| 48 |
+
self.assertTrue(out['inputs'].shape == (2, 3, 10, 10))
|
| 49 |
+
self.assertTrue(out['data_samples'], dict)
|
| 50 |
+
self.assertTrue(out['data_samples']['bboxes_labels'].shape == (8, 6))
|
| 51 |
+
|
| 52 |
+
def test_yolov5_collate_with_multi_scale(self):
|
| 53 |
+
rng = np.random.RandomState(0)
|
| 54 |
+
|
| 55 |
+
inputs = torch.randn((3, 10, 10))
|
| 56 |
+
data_samples = DetDataSample()
|
| 57 |
+
gt_instances = InstanceData()
|
| 58 |
+
bboxes = _rand_bboxes(rng, 4, 6, 8)
|
| 59 |
+
gt_instances.bboxes = HorizontalBoxes(bboxes, dtype=torch.float32)
|
| 60 |
+
labels = rng.randint(1, 2, size=len(bboxes))
|
| 61 |
+
gt_instances.labels = torch.LongTensor(labels)
|
| 62 |
+
data_samples.gt_instances = gt_instances
|
| 63 |
+
|
| 64 |
+
out = yolov5_collate([dict(inputs=inputs, data_samples=data_samples)],
|
| 65 |
+
use_ms_training=True)
|
| 66 |
+
self.assertIsInstance(out, dict)
|
| 67 |
+
self.assertTrue(out['inputs'][0].shape == (3, 10, 10))
|
| 68 |
+
self.assertTrue(out['data_samples'], dict)
|
| 69 |
+
self.assertTrue(out['data_samples']['bboxes_labels'].shape == (4, 6))
|
| 70 |
+
self.assertIsInstance(out['inputs'], list)
|
| 71 |
+
self.assertIsInstance(out['data_samples']['bboxes_labels'],
|
| 72 |
+
torch.Tensor)
|
| 73 |
+
|
| 74 |
+
out = yolov5_collate(
|
| 75 |
+
[dict(inputs=inputs, data_samples=data_samples)] * 2,
|
| 76 |
+
use_ms_training=True)
|
| 77 |
+
self.assertIsInstance(out, dict)
|
| 78 |
+
self.assertTrue(out['inputs'][0].shape == (3, 10, 10))
|
| 79 |
+
self.assertTrue(out['data_samples'], dict)
|
| 80 |
+
self.assertTrue(out['data_samples']['bboxes_labels'].shape == (8, 6))
|
| 81 |
+
self.assertIsInstance(out['inputs'], list)
|
| 82 |
+
self.assertIsInstance(out['data_samples']['bboxes_labels'],
|
| 83 |
+
torch.Tensor)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
class TestBatchShapePolicy(unittest.TestCase):
|
| 87 |
+
|
| 88 |
+
def test_batch_shape_policy(self):
|
| 89 |
+
src_data_infos = [{
|
| 90 |
+
'height': 20,
|
| 91 |
+
'width': 100,
|
| 92 |
+
}, {
|
| 93 |
+
'height': 11,
|
| 94 |
+
'width': 100,
|
| 95 |
+
}, {
|
| 96 |
+
'height': 21,
|
| 97 |
+
'width': 100,
|
| 98 |
+
}, {
|
| 99 |
+
'height': 30,
|
| 100 |
+
'width': 100,
|
| 101 |
+
}, {
|
| 102 |
+
'height': 10,
|
| 103 |
+
'width': 100,
|
| 104 |
+
}]
|
| 105 |
+
|
| 106 |
+
expected_data_infos = [{
|
| 107 |
+
'height': 10,
|
| 108 |
+
'width': 100,
|
| 109 |
+
'batch_shape': np.array([96, 672])
|
| 110 |
+
}, {
|
| 111 |
+
'height': 11,
|
| 112 |
+
'width': 100,
|
| 113 |
+
'batch_shape': np.array([96, 672])
|
| 114 |
+
}, {
|
| 115 |
+
'height': 20,
|
| 116 |
+
'width': 100,
|
| 117 |
+
'batch_shape': np.array([160, 672])
|
| 118 |
+
}, {
|
| 119 |
+
'height': 21,
|
| 120 |
+
'width': 100,
|
| 121 |
+
'batch_shape': np.array([160, 672])
|
| 122 |
+
}, {
|
| 123 |
+
'height': 30,
|
| 124 |
+
'width': 100,
|
| 125 |
+
'batch_shape': np.array([224, 672])
|
| 126 |
+
}]
|
| 127 |
+
|
| 128 |
+
batch_shapes_policy = BatchShapePolicy(batch_size=2)
|
| 129 |
+
out_data_infos = batch_shapes_policy(src_data_infos)
|
| 130 |
+
|
| 131 |
+
for i in range(5):
|
| 132 |
+
self.assertEqual(
|
| 133 |
+
(expected_data_infos[i]['height'],
|
| 134 |
+
expected_data_infos[i]['width']),
|
| 135 |
+
(out_data_infos[i]['height'], out_data_infos[i]['width']))
|
| 136 |
+
self.assertTrue(
|
| 137 |
+
np.allclose(expected_data_infos[i]['batch_shape'],
|
| 138 |
+
out_data_infos[i]['batch_shape']))
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/test_yolov5_coco.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) OpenMMLab. All rights reserved.
|
| 2 |
+
import unittest
|
| 3 |
+
|
| 4 |
+
from mmyolo.datasets import YOLOv5CocoDataset
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class TestYOLOv5CocoDataset(unittest.TestCase):
|
| 8 |
+
|
| 9 |
+
def test_batch_shapes_cfg(self):
|
| 10 |
+
batch_shapes_cfg = dict(
|
| 11 |
+
type='BatchShapePolicy',
|
| 12 |
+
batch_size=2,
|
| 13 |
+
img_size=640,
|
| 14 |
+
size_divisor=32,
|
| 15 |
+
extra_pad_ratio=0.5)
|
| 16 |
+
|
| 17 |
+
# test serialize_data=True
|
| 18 |
+
dataset = YOLOv5CocoDataset(
|
| 19 |
+
data_prefix=dict(img='imgs'),
|
| 20 |
+
ann_file='tests/data/coco_sample.json',
|
| 21 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=0),
|
| 22 |
+
pipeline=[],
|
| 23 |
+
serialize_data=True,
|
| 24 |
+
batch_shapes_cfg=batch_shapes_cfg,
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
expected_img_ids = [3, 0, 2, 1]
|
| 28 |
+
expected_batch_shapes = [[512, 672], [512, 672], [672, 672],
|
| 29 |
+
[672, 672]]
|
| 30 |
+
for i, data in enumerate(dataset):
|
| 31 |
+
assert data['img_id'] == expected_img_ids[i]
|
| 32 |
+
assert data['batch_shape'].tolist() == expected_batch_shapes[i]
|
| 33 |
+
|
| 34 |
+
# test serialize_data=True
|
| 35 |
+
dataset = YOLOv5CocoDataset(
|
| 36 |
+
data_prefix=dict(img='imgs'),
|
| 37 |
+
ann_file='tests/data/coco_sample.json',
|
| 38 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=0),
|
| 39 |
+
pipeline=[],
|
| 40 |
+
serialize_data=False,
|
| 41 |
+
batch_shapes_cfg=batch_shapes_cfg,
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
expected_img_ids = [3, 0, 2, 1]
|
| 45 |
+
expected_batch_shapes = [[512, 672], [512, 672], [672, 672],
|
| 46 |
+
[672, 672]]
|
| 47 |
+
for i, data in enumerate(dataset):
|
| 48 |
+
assert data['img_id'] == expected_img_ids[i]
|
| 49 |
+
assert data['batch_shape'].tolist() == expected_batch_shapes[i]
|
| 50 |
+
|
| 51 |
+
def test_prepare_data(self):
|
| 52 |
+
dataset = YOLOv5CocoDataset(
|
| 53 |
+
data_prefix=dict(img='imgs'),
|
| 54 |
+
ann_file='tests/data/coco_sample.json',
|
| 55 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=0),
|
| 56 |
+
pipeline=[],
|
| 57 |
+
serialize_data=True,
|
| 58 |
+
batch_shapes_cfg=None,
|
| 59 |
+
)
|
| 60 |
+
for data in dataset:
|
| 61 |
+
assert 'dataset' in data
|
| 62 |
+
|
| 63 |
+
# test with test_mode = True
|
| 64 |
+
dataset = YOLOv5CocoDataset(
|
| 65 |
+
data_prefix=dict(img='imgs'),
|
| 66 |
+
ann_file='tests/data/coco_sample.json',
|
| 67 |
+
test_mode=True,
|
| 68 |
+
pipeline=[])
|
| 69 |
+
|
| 70 |
+
for data in dataset:
|
| 71 |
+
assert 'dataset' not in data
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_datasets/test_yolov5_voc.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) OpenMMLab. All rights reserved.
|
| 2 |
+
import unittest
|
| 3 |
+
|
| 4 |
+
from mmengine.dataset import ConcatDataset
|
| 5 |
+
|
| 6 |
+
from mmyolo.datasets import YOLOv5VOCDataset
|
| 7 |
+
from mmyolo.utils import register_all_modules
|
| 8 |
+
|
| 9 |
+
register_all_modules()
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class TestYOLOv5VocDataset(unittest.TestCase):
|
| 13 |
+
|
| 14 |
+
def test_batch_shapes_cfg(self):
|
| 15 |
+
batch_shapes_cfg = dict(
|
| 16 |
+
type='BatchShapePolicy',
|
| 17 |
+
batch_size=2,
|
| 18 |
+
img_size=640,
|
| 19 |
+
size_divisor=32,
|
| 20 |
+
extra_pad_ratio=0.5)
|
| 21 |
+
|
| 22 |
+
# test serialize_data=True
|
| 23 |
+
dataset = YOLOv5VOCDataset(
|
| 24 |
+
data_root='tests/data/VOCdevkit/',
|
| 25 |
+
ann_file='VOC2007/ImageSets/Main/trainval.txt',
|
| 26 |
+
data_prefix=dict(sub_data_root='VOC2007/'),
|
| 27 |
+
test_mode=True,
|
| 28 |
+
pipeline=[],
|
| 29 |
+
batch_shapes_cfg=batch_shapes_cfg,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
expected_img_ids = ['000001']
|
| 33 |
+
expected_batch_shapes = [[672, 480]]
|
| 34 |
+
for i, data in enumerate(dataset):
|
| 35 |
+
assert data['img_id'] == expected_img_ids[i]
|
| 36 |
+
assert data['batch_shape'].tolist() == expected_batch_shapes[i]
|
| 37 |
+
|
| 38 |
+
def test_prepare_data(self):
|
| 39 |
+
dataset = YOLOv5VOCDataset(
|
| 40 |
+
data_root='tests/data/VOCdevkit/',
|
| 41 |
+
ann_file='VOC2007/ImageSets/Main/trainval.txt',
|
| 42 |
+
data_prefix=dict(sub_data_root='VOC2007/'),
|
| 43 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=0),
|
| 44 |
+
pipeline=[],
|
| 45 |
+
serialize_data=True,
|
| 46 |
+
batch_shapes_cfg=None,
|
| 47 |
+
)
|
| 48 |
+
for data in dataset:
|
| 49 |
+
assert 'dataset' in data
|
| 50 |
+
|
| 51 |
+
# test with test_mode = True
|
| 52 |
+
dataset = YOLOv5VOCDataset(
|
| 53 |
+
data_root='tests/data/VOCdevkit/',
|
| 54 |
+
ann_file='VOC2007/ImageSets/Main/trainval.txt',
|
| 55 |
+
data_prefix=dict(sub_data_root='VOC2007/'),
|
| 56 |
+
filter_cfg=dict(
|
| 57 |
+
filter_empty_gt=True, min_size=32, bbox_min_size=None),
|
| 58 |
+
pipeline=[],
|
| 59 |
+
test_mode=True,
|
| 60 |
+
batch_shapes_cfg=None)
|
| 61 |
+
|
| 62 |
+
for data in dataset:
|
| 63 |
+
assert 'dataset' not in data
|
| 64 |
+
|
| 65 |
+
def test_concat_dataset(self):
|
| 66 |
+
dataset = ConcatDataset(
|
| 67 |
+
datasets=[
|
| 68 |
+
dict(
|
| 69 |
+
type='YOLOv5VOCDataset',
|
| 70 |
+
data_root='tests/data/VOCdevkit/',
|
| 71 |
+
ann_file='VOC2007/ImageSets/Main/trainval.txt',
|
| 72 |
+
data_prefix=dict(sub_data_root='VOC2007/'),
|
| 73 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
| 74 |
+
pipeline=[]),
|
| 75 |
+
dict(
|
| 76 |
+
type='YOLOv5VOCDataset',
|
| 77 |
+
data_root='tests/data/VOCdevkit/',
|
| 78 |
+
ann_file='VOC2012/ImageSets/Main/trainval.txt',
|
| 79 |
+
data_prefix=dict(sub_data_root='VOC2012/'),
|
| 80 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
| 81 |
+
pipeline=[])
|
| 82 |
+
],
|
| 83 |
+
ignore_keys='dataset_type')
|
| 84 |
+
|
| 85 |
+
dataset.full_init()
|
| 86 |
+
self.assertEqual(len(dataset), 2)
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_deploy/conftest.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) OpenMMLab. All rights reserved.
|
| 2 |
+
import pytest
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
@pytest.fixture(autouse=True)
|
| 6 |
+
def init_test():
|
| 7 |
+
# init default scope
|
| 8 |
+
from mmdet.utils import register_all_modules as register_det
|
| 9 |
+
|
| 10 |
+
from mmyolo.utils import register_all_modules as register_yolo
|
| 11 |
+
|
| 12 |
+
register_yolo(True)
|
| 13 |
+
register_det(False)
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_deploy/test_mmyolo_models.py
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) OpenMMLab. All rights reserved.
|
| 2 |
+
import os
|
| 3 |
+
import random
|
| 4 |
+
|
| 5 |
+
import numpy as np
|
| 6 |
+
import pytest
|
| 7 |
+
import torch
|
| 8 |
+
from mmengine import Config
|
| 9 |
+
|
| 10 |
+
try:
|
| 11 |
+
import importlib
|
| 12 |
+
importlib.import_module('mmdeploy')
|
| 13 |
+
except ImportError:
|
| 14 |
+
pytest.skip('mmdeploy is not installed.', allow_module_level=True)
|
| 15 |
+
|
| 16 |
+
from mmdeploy.codebase import import_codebase
|
| 17 |
+
from mmdeploy.utils import Backend
|
| 18 |
+
from mmdeploy.utils.config_utils import register_codebase
|
| 19 |
+
from mmdeploy.utils.test import (WrapModel, check_backend, get_model_outputs,
|
| 20 |
+
get_rewrite_outputs)
|
| 21 |
+
|
| 22 |
+
try:
|
| 23 |
+
codebase = register_codebase('mmyolo')
|
| 24 |
+
import_codebase(codebase, ['mmyolo.deploy'])
|
| 25 |
+
except ImportError:
|
| 26 |
+
pytest.skip('mmyolo is not installed.', allow_module_level=True)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def seed_everything(seed=1029):
|
| 30 |
+
random.seed(seed)
|
| 31 |
+
os.environ['PYTHONHASHSEED'] = str(seed)
|
| 32 |
+
np.random.seed(seed)
|
| 33 |
+
torch.manual_seed(seed)
|
| 34 |
+
if torch.cuda.is_available():
|
| 35 |
+
torch.cuda.manual_seed(seed)
|
| 36 |
+
torch.cuda.manual_seed_all(seed) # if you are using multi-GPU.
|
| 37 |
+
torch.backends.cudnn.benchmark = False
|
| 38 |
+
torch.backends.cudnn.deterministic = True
|
| 39 |
+
torch.backends.cudnn.enabled = False
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def get_yolov5_head_model():
|
| 43 |
+
"""YOLOv5 Head Config."""
|
| 44 |
+
test_cfg = Config(
|
| 45 |
+
dict(
|
| 46 |
+
multi_label=True,
|
| 47 |
+
nms_pre=30000,
|
| 48 |
+
score_thr=0.001,
|
| 49 |
+
nms=dict(type='nms', iou_threshold=0.65),
|
| 50 |
+
max_per_img=300))
|
| 51 |
+
|
| 52 |
+
from mmyolo.models.dense_heads import YOLOv5Head
|
| 53 |
+
head_module = dict(
|
| 54 |
+
type='YOLOv5HeadModule',
|
| 55 |
+
num_classes=4,
|
| 56 |
+
in_channels=[2, 4, 8],
|
| 57 |
+
featmap_strides=[8, 16, 32],
|
| 58 |
+
num_base_priors=1)
|
| 59 |
+
|
| 60 |
+
model = YOLOv5Head(head_module, test_cfg=test_cfg)
|
| 61 |
+
|
| 62 |
+
model.requires_grad_(False)
|
| 63 |
+
return model
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
@pytest.mark.parametrize('backend_type', [Backend.ONNXRUNTIME])
|
| 67 |
+
def test_yolov5_head_predict_by_feat(backend_type: Backend):
|
| 68 |
+
"""Test predict_by_feat rewrite of YOLOXHead."""
|
| 69 |
+
check_backend(backend_type)
|
| 70 |
+
yolov5_head = get_yolov5_head_model()
|
| 71 |
+
yolov5_head.cpu().eval()
|
| 72 |
+
s = 256
|
| 73 |
+
batch_img_metas = [{
|
| 74 |
+
'scale_factor': (1.0, 1.0),
|
| 75 |
+
'pad_shape': (s, s, 3),
|
| 76 |
+
'img_shape': (s, s, 3),
|
| 77 |
+
'ori_shape': (s, s, 3)
|
| 78 |
+
}]
|
| 79 |
+
output_names = ['dets', 'labels']
|
| 80 |
+
deploy_cfg = Config(
|
| 81 |
+
dict(
|
| 82 |
+
backend_config=dict(type=backend_type.value),
|
| 83 |
+
onnx_config=dict(output_names=output_names, input_shape=None),
|
| 84 |
+
codebase_config=dict(
|
| 85 |
+
type='mmyolo',
|
| 86 |
+
task='ObjectDetection',
|
| 87 |
+
post_processing=dict(
|
| 88 |
+
score_threshold=0.05,
|
| 89 |
+
iou_threshold=0.5,
|
| 90 |
+
max_output_boxes_per_class=20,
|
| 91 |
+
pre_top_k=-1,
|
| 92 |
+
keep_top_k=10,
|
| 93 |
+
background_label_id=-1,
|
| 94 |
+
),
|
| 95 |
+
module=['mmyolo.deploy'])))
|
| 96 |
+
seed_everything(1234)
|
| 97 |
+
cls_scores = [
|
| 98 |
+
torch.rand(1, yolov5_head.num_classes * yolov5_head.num_base_priors,
|
| 99 |
+
4 * pow(2, i), 4 * pow(2, i)) for i in range(3, 0, -1)
|
| 100 |
+
]
|
| 101 |
+
seed_everything(5678)
|
| 102 |
+
bbox_preds = [
|
| 103 |
+
torch.rand(1, 4 * yolov5_head.num_base_priors, 4 * pow(2, i),
|
| 104 |
+
4 * pow(2, i)) for i in range(3, 0, -1)
|
| 105 |
+
]
|
| 106 |
+
seed_everything(9101)
|
| 107 |
+
objectnesses = [
|
| 108 |
+
torch.rand(1, 1 * yolov5_head.num_base_priors, 4 * pow(2, i),
|
| 109 |
+
4 * pow(2, i)) for i in range(3, 0, -1)
|
| 110 |
+
]
|
| 111 |
+
|
| 112 |
+
# to get outputs of pytorch model
|
| 113 |
+
model_inputs = {
|
| 114 |
+
'cls_scores': cls_scores,
|
| 115 |
+
'bbox_preds': bbox_preds,
|
| 116 |
+
'objectnesses': objectnesses,
|
| 117 |
+
'batch_img_metas': batch_img_metas,
|
| 118 |
+
'with_nms': True
|
| 119 |
+
}
|
| 120 |
+
model_outputs = get_model_outputs(yolov5_head, 'predict_by_feat',
|
| 121 |
+
model_inputs)
|
| 122 |
+
|
| 123 |
+
# to get outputs of onnx model after rewrite
|
| 124 |
+
wrapped_model = WrapModel(
|
| 125 |
+
yolov5_head,
|
| 126 |
+
'predict_by_feat',
|
| 127 |
+
batch_img_metas=batch_img_metas,
|
| 128 |
+
with_nms=True)
|
| 129 |
+
rewrite_inputs = {
|
| 130 |
+
'cls_scores': cls_scores,
|
| 131 |
+
'bbox_preds': bbox_preds,
|
| 132 |
+
'objectnesses': objectnesses,
|
| 133 |
+
}
|
| 134 |
+
rewrite_outputs, is_backend_output = get_rewrite_outputs(
|
| 135 |
+
wrapped_model=wrapped_model,
|
| 136 |
+
model_inputs=rewrite_inputs,
|
| 137 |
+
deploy_cfg=deploy_cfg)
|
| 138 |
+
|
| 139 |
+
if is_backend_output:
|
| 140 |
+
# hard code to make two tensors with the same shape
|
| 141 |
+
# rewrite and original codes applied different nms strategy
|
| 142 |
+
min_shape = min(model_outputs[0].bboxes.shape[0],
|
| 143 |
+
rewrite_outputs[0].shape[1], 5)
|
| 144 |
+
for i in range(len(model_outputs)):
|
| 145 |
+
rewrite_outputs[0][i, :min_shape, 0::2] = \
|
| 146 |
+
rewrite_outputs[0][i, :min_shape, 0::2].clamp_(0, s)
|
| 147 |
+
rewrite_outputs[0][i, :min_shape, 1::2] = \
|
| 148 |
+
rewrite_outputs[0][i, :min_shape, 1::2].clamp_(0, s)
|
| 149 |
+
assert np.allclose(
|
| 150 |
+
model_outputs[i].bboxes[:min_shape],
|
| 151 |
+
rewrite_outputs[0][i, :min_shape, :4],
|
| 152 |
+
rtol=1e-03,
|
| 153 |
+
atol=1e-05)
|
| 154 |
+
assert np.allclose(
|
| 155 |
+
model_outputs[i].scores[:min_shape],
|
| 156 |
+
rewrite_outputs[0][i, :min_shape, 4],
|
| 157 |
+
rtol=1e-03,
|
| 158 |
+
atol=1e-05)
|
| 159 |
+
assert np.allclose(
|
| 160 |
+
model_outputs[i].labels[:min_shape],
|
| 161 |
+
rewrite_outputs[1][i, :min_shape],
|
| 162 |
+
rtol=1e-03,
|
| 163 |
+
atol=1e-05)
|
| 164 |
+
else:
|
| 165 |
+
assert rewrite_outputs is not None
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_deploy/test_object_detection.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) OpenMMLab. All rights reserved.
|
| 2 |
+
import os
|
| 3 |
+
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
| 4 |
+
|
| 5 |
+
import numpy as np
|
| 6 |
+
import pytest
|
| 7 |
+
import torch
|
| 8 |
+
from mmengine import Config
|
| 9 |
+
|
| 10 |
+
try:
|
| 11 |
+
import importlib
|
| 12 |
+
importlib.import_module('mmdeploy')
|
| 13 |
+
except ImportError:
|
| 14 |
+
pytest.skip('mmdeploy is not installed.', allow_module_level=True)
|
| 15 |
+
|
| 16 |
+
import mmdeploy.backend.onnxruntime as ort_apis
|
| 17 |
+
from mmdeploy.apis import build_task_processor
|
| 18 |
+
from mmdeploy.codebase import import_codebase
|
| 19 |
+
from mmdeploy.utils import load_config
|
| 20 |
+
from mmdeploy.utils.config_utils import register_codebase
|
| 21 |
+
from mmdeploy.utils.test import SwitchBackendWrapper
|
| 22 |
+
|
| 23 |
+
try:
|
| 24 |
+
codebase = register_codebase('mmyolo')
|
| 25 |
+
import_codebase(codebase, ['mmyolo.deploy'])
|
| 26 |
+
except ImportError:
|
| 27 |
+
pytest.skip('mmyolo is not installed.', allow_module_level=True)
|
| 28 |
+
|
| 29 |
+
model_cfg_path = 'tests/test_deploy/data/model.py'
|
| 30 |
+
model_cfg = load_config(model_cfg_path)[0]
|
| 31 |
+
model_cfg.test_dataloader.dataset.data_root = \
|
| 32 |
+
'tests/data'
|
| 33 |
+
model_cfg.test_dataloader.dataset.ann_file = 'coco_sample.json'
|
| 34 |
+
model_cfg.test_evaluator.ann_file = \
|
| 35 |
+
'tests/coco_sample.json'
|
| 36 |
+
deploy_cfg = Config(
|
| 37 |
+
dict(
|
| 38 |
+
backend_config=dict(type='onnxruntime'),
|
| 39 |
+
codebase_config=dict(
|
| 40 |
+
type='mmyolo',
|
| 41 |
+
task='ObjectDetection',
|
| 42 |
+
post_processing=dict(
|
| 43 |
+
score_threshold=0.05,
|
| 44 |
+
confidence_threshold=0.005, # for YOLOv3
|
| 45 |
+
iou_threshold=0.5,
|
| 46 |
+
max_output_boxes_per_class=200,
|
| 47 |
+
pre_top_k=5000,
|
| 48 |
+
keep_top_k=100,
|
| 49 |
+
background_label_id=-1,
|
| 50 |
+
),
|
| 51 |
+
module=['mmyolo.deploy']),
|
| 52 |
+
onnx_config=dict(
|
| 53 |
+
type='onnx',
|
| 54 |
+
export_params=True,
|
| 55 |
+
keep_initializers_as_inputs=False,
|
| 56 |
+
opset_version=11,
|
| 57 |
+
input_shape=None,
|
| 58 |
+
input_names=['input'],
|
| 59 |
+
output_names=['dets', 'labels'])))
|
| 60 |
+
onnx_file = NamedTemporaryFile(suffix='.onnx').name
|
| 61 |
+
task_processor = None
|
| 62 |
+
img_shape = (32, 32)
|
| 63 |
+
img = np.random.rand(*img_shape, 3)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
@pytest.fixture(autouse=True)
|
| 67 |
+
def init_task_processor():
|
| 68 |
+
global task_processor
|
| 69 |
+
task_processor = build_task_processor(model_cfg, deploy_cfg, 'cpu')
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
@pytest.fixture
|
| 73 |
+
def backend_model():
|
| 74 |
+
from mmdeploy.backend.onnxruntime import ORTWrapper
|
| 75 |
+
ort_apis.__dict__.update({'ORTWrapper': ORTWrapper})
|
| 76 |
+
wrapper = SwitchBackendWrapper(ORTWrapper)
|
| 77 |
+
wrapper.set(
|
| 78 |
+
outputs={
|
| 79 |
+
'dets': torch.rand(1, 10, 5).sort(2).values,
|
| 80 |
+
'labels': torch.randint(0, 10, (1, 10))
|
| 81 |
+
})
|
| 82 |
+
|
| 83 |
+
yield task_processor.build_backend_model([''])
|
| 84 |
+
|
| 85 |
+
wrapper.recover()
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def test_visualize(backend_model):
|
| 89 |
+
img_path = 'tests/data/color.jpg'
|
| 90 |
+
input_dict, _ = task_processor.create_input(
|
| 91 |
+
img_path, input_shape=img_shape)
|
| 92 |
+
results = backend_model.test_step(input_dict)[0]
|
| 93 |
+
with TemporaryDirectory() as dir:
|
| 94 |
+
filename = dir + 'tmp.jpg'
|
| 95 |
+
task_processor.visualize(img, results, filename, 'window')
|
| 96 |
+
assert os.path.exists(filename)
|
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/YOLO-World/mmyolo/tests/test_downstream/test_mmrazor.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) OpenMMLab. All rights reserved.
|
| 2 |
+
import copy
|
| 3 |
+
|
| 4 |
+
import pytest
|
| 5 |
+
from mmcls.models.backbones.base_backbone import BaseBackbone
|
| 6 |
+
|
| 7 |
+
from mmyolo.testing import get_detector_cfg
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
@pytest.mark.parametrize('cfg_file', [
|
| 11 |
+
'razor/subnets/'
|
| 12 |
+
'yolov5_s_spos_shufflenetv2_syncbn_8xb16-300e_coco.py', 'razor/subnets/'
|
| 13 |
+
'rtmdet_tiny_ofa_lat31_syncbn_16xb16-300e_coco.py', 'razor/subnets/'
|
| 14 |
+
'yolov6_l_attentivenas_a6_d12_syncbn_fast_8xb32-300e_coco.py'
|
| 15 |
+
])
|
| 16 |
+
def test_razor_backbone_init(cfg_file):
|
| 17 |
+
model = get_detector_cfg(cfg_file)
|
| 18 |
+
model_cfg = copy.deepcopy(model.backbone)
|
| 19 |
+
from mmrazor.registry import MODELS
|
| 20 |
+
model = MODELS.build(model_cfg)
|
| 21 |
+
assert isinstance(model, BaseBackbone)
|