Skip to content

Commit

Permalink
chore: update configs
Browse files Browse the repository at this point in the history
  • Loading branch information
nullptr committed May 31, 2024
1 parent 957eaa9 commit 5a0a105
Showing 1 changed file with 58 additions and 20 deletions.
78 changes: 58 additions & 20 deletions configs/swift_yolo/swift_yolo_1xb16_300e_coco_mbnv4s.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@

# dataset link: https://universe.roboflow.com/team-roboflow/coco-128
data_root = 'https://universe.roboflow.com/ds/z5UOcgxZzD?key=bwx9LQUT0t'
height = 192
width = 192
height = 224
width = 224
epochs = 300
batch = 16
workers = 2
workers = 16
use_cached = True
max_cached_images = 4096
val_batch = batch
val_workers = workers
val_interval = 5
imgsz = (width, height)
max_keep_ckpts = 15
lr_factor = 0.01

# TRAIN
persistent_workers = True
Expand Down Expand Up @@ -87,33 +93,58 @@

pre_transform = [
dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')),
dict(type='LoadAnnotations', with_bbox=True, _scope_='sscma'),
dict(type='sscma.YOLOLoadAnnotations', with_bbox=True),
]

last_transform = [
dict(
type='mmdet.Albu',
transforms=albu_train_transforms,
bbox_params=dict(type='BboxParams', format='pascal_voc', label_fields=['gt_bboxes_labels', 'gt_ignore_flags']),
keymap={'img': 'image', 'gt_bboxes': 'bboxes'},
),
dict(type='sscma.YOLOv5HSVRandomAug'),
dict(type='mmdet.RandomFlip', prob=0.5),
dict(
type='mmdet.PackDetInputs', meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip', 'flip_direction')
),
]

train_pipeline = [
*pre_transform,
dict(type='Mosaic', img_scale=imgsz, pad_val=114.0, pre_transform=pre_transform, _scope_='sscma'),
dict(
type='YOLOv5RandomAffine',
type='sscma.Mosaic',
img_scale=imgsz,
pad_val=114.0,
use_cached=use_cached,
max_cached_images=max_cached_images,
),
dict(
type='sscma.YOLOv5RandomAffine',
max_rotate_degree=0.0,
max_shear_degree=0.0,
scaling_ratio_range=(1 - affine_scale, 1 + affine_scale),
# imgsz is (width, height)
border=(-imgsz[0] // 2, -imgsz[1] // 2),
border_val=(114, 114, 114),
_scope_='sscma'
),
*last_transform,
]

train_pipeline_stage2 = [
*pre_transform,
dict(type='sscma.YOLOv5KeepRatioResize', scale=imgsz),
dict(type='sscma.LetterResize', scale=imgsz, allow_scale_up=True, pad_val=dict(img=114.0)),
dict(
type='mmdet.Albu',
transforms=albu_train_transforms,
bbox_params=dict(type='BboxParams', format='pascal_voc', label_fields=['gt_bboxes_labels', 'gt_ignore_flags']),
keymap={'img': 'image', 'gt_bboxes': 'bboxes'},
),
dict(type='YOLOv5HSVRandomAug', _scope_='sscma'),
dict(type='mmdet.RandomFlip', prob=0.5),
dict(
type='mmdet.PackDetInputs', meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip', 'flip_direction')
type='sscma.YOLOv5RandomAffine',
max_rotate_degree=0.0,
max_shear_degree=0.0,
scaling_ratio_range=(1 - affine_scale, 1 + affine_scale),
# imgsz is (width, height)
border=(-imgsz[0] // 2, -imgsz[1] // 2),
border_val=(114, 114, 114),
),
*last_transform,
]

train_dataloader = dict(
Expand All @@ -133,10 +164,10 @@
)

test_pipeline = [
dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')),
dict(type='YOLOv5KeepRatioResize', scale=imgsz, _scope_='sscma'),
dict(type='sscma.LetterResize', scale=imgsz, allow_scale_up=False, pad_val=dict(img=114), _scope_='sscma'),
dict(type='LoadAnnotations', with_bbox=True, _scope_='sscma'),
dict(type='sscma.LoadImageFromFile', file_client_args=dict(backend='disk')),
dict(type='sscma.YOLOv5KeepRatioResize', scale=imgsz),
dict(type='sscma.LetterResize', scale=imgsz, allow_scale_up=False, pad_val=dict(img=114)),
dict(type='sscma.LoadAnnotations', with_bbox=True, _scope_='mmdet'),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor', 'pad_param'),
Expand All @@ -162,3 +193,10 @@
)

test_dataloader = val_dataloader

default_hooks = dict(
param_scheduler=dict(
type='sscma.YOLOv5ParamSchedulerHook', scheduler_type='cosin', lr_factor=lr_factor, max_epochs=epochs
),
checkpoint=dict(type='CheckpointHook', interval=val_interval, save_best='auto', max_keep_ckpts=max_keep_ckpts),
)

0 comments on commit 5a0a105

Please sign in to comment.