|
- _base_ = ['../_base_/schedules/schedule_1x_original.py', '../_base_/default_runtime.py']
-
- # model settings
- model = dict(
- type='YOLOX',
- backbone=dict(type='CSPDarknet', deepen_factor=1.0, widen_factor=1.0),
- neck=dict(
- type='YOLOXPAFPN',
- in_channels=[256, 512, 1024],
- out_channels=256,
- num_csp_blocks=3),
- bbox_head=dict(
- type='YOLOXHead', num_classes=11, in_channels=256, feat_channels=256),
- train_cfg=dict(assigner=dict(type='SimOTAAssigner', center_radius=2.5)),
- # In order to align the source code, the threshold of the val phase is
- # 0.01, and the threshold of the test phase is 0.001.
- test_cfg=dict(score_thr=0.01, nms=dict(type='nms', iou_threshold=0.65)))
-
- # dataset settings
- dataset_type = 'CocoDataset'
- classes = ('yiwei','loujian','celi','libei','fantie','lianxi','duojian','shunjian','shaoxi','jiahan','yiwu')
-
- img_norm_cfg = dict(
- mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
-
- img_scale = (448, 448)
-
- train_pipeline = [
- dict(type='Mosaic', img_scale=img_scale, pad_val=0),
- dict(
- type='MixUp',
- img_scale=img_scale,
- ratio_range=(0.8, 1.6),
- pad_val=114.0),
- dict(
- type='RandomAffine',
- scaling_ratio_range=(0.1, 2),
- border=(-img_scale[0] // 2, -img_scale[1] // 2)),
- dict(
- type='PhotoMetricDistortion',
- brightness_delta=32,
- contrast_range=(0.5, 1.5),
- saturation_range=(0.5, 1.5),
- hue_delta=18),
- dict(type='RandomFlip', flip_ratio=0.5),
- dict(type='Resize', keep_ratio=True),
- dict(type='Pad', size_divisor=32),
- dict(type='Normalize', **img_norm_cfg),
- dict(type='DefaultFormatBundle'),
- dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])
- ]
-
- train_dataset = dict(
- type='MultiImageMixDataset',
- dataset=dict(
- type=dataset_type,
- img_prefix='/home/shanwei-luo/userdata/datasets/dsxw_dataset_v6/dsxw_train/images/',
- classes=classes,
- ann_file='/home/shanwei-luo/userdata/datasets/dsxw_dataset_v6/dsxw_train/annotations/train.json',
- pipeline=[
- dict(type='LoadImageFromFile', to_float32=True),
- dict(type='LoadAnnotations', with_bbox=True)
- ],
- filter_empty_gt=False,
- ),
- pipeline=train_pipeline,
- dynamic_scale=img_scale)
-
- test_pipeline = [
- dict(type='LoadImageFromFile'),
- dict(
- type='MultiScaleFlipAug',
- img_scale=img_scale,
- flip=False,
- transforms=[
- dict(type='Resize', keep_ratio=True),
- dict(type='RandomFlip'),
- dict(type='Pad', size_divisor=32),
- dict(type='Normalize', **img_norm_cfg),
- dict(type='DefaultFormatBundle'),
- dict(type='Collect', keys=['img'])
- ])
- ]
-
- data = dict(
- samples_per_gpu=16,
- workers_per_gpu=8,
- train=train_dataset,
- val=dict(
- type=dataset_type,
- img_prefix='/home/shanwei-luo/userdata/datasets/dsxw_test_0121_0130/images/',
- classes=classes,
- ann_file='/home/shanwei-luo/userdata/datasets/dsxw_test_0121_0130/annotations/test.json',
- pipeline=test_pipeline),
- test=dict(
- type=dataset_type,
- img_prefix='/home/shanwei-luo/userdata/datasets/dsxw_test_0121_0130/images/',
- classes=classes,
- ann_file='/home/shanwei-luo/userdata/datasets/dsxw_test_0121_0130/annotations/test.json',
- pipeline=test_pipeline))
-
- # optimizer
- # default 8 gpu
- optimizer = dict(
- type='SGD',
- lr=0.01,
- momentum=0.9,
- weight_decay=5e-4,
- nesterov=True,
- paramwise_cfg=dict(norm_decay_mult=0., bias_decay_mult=0.))
- optimizer_config = dict(grad_clip=None)
-
- # learning policy
- lr_config = dict(
- _delete_=True,
- policy='YOLOX',
- warmup='exp',
- by_epoch=False,
- warmup_by_epoch=True,
- warmup_ratio=1,
- warmup_iters=5, # 5 epoch
- num_last_epochs=15,
- min_lr_ratio=0.05)
- runner = dict(type='EpochBasedRunner', max_epochs=60)
-
- resume_from = None
- interval = 5
-
- custom_hooks = [
- dict(type='YOLOXModeSwitchHook', num_last_epochs=15, priority=48),
- dict(
- type='SyncRandomSizeHook',
- ratio_range=(11, 17),
- img_scale=img_scale,
- priority=48),
- dict(
- type='SyncNormHook',
- num_last_epochs=15,
- interval=interval,
- priority=48),
- dict(type='ExpMomentumEMAHook', resume_from=resume_from, priority=49)
- ]
- checkpoint_config = dict(interval=interval)
- evaluation = dict(interval=interval, metric='bbox')
- log_config = dict(interval=50)
|