Skip to content
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
_base_ = [
'../_base_/datasets/coco_detection.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
'../_base_/datasets/coco_detection.py', '../_base_/default_runtime.py'
]
model = dict(
type='DETR',
Expand All @@ -11,7 +10,7 @@
num_stages=4,
out_indices=(3, ),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_cfg=dict(type='BN', requires_grad=False),
norm_eval=True,
style='pytorch'),
bbox_head=dict(
Expand Down Expand Up @@ -45,8 +44,8 @@
# training and testing settings
train_cfg = dict(
assigner=dict(
type='HungarianMatcher', cls_weight=1., bbox_weight=5., iou_weight=2.),
pos_weight=-1)
type='HungarianAssigner', cls_weight=1., bbox_weight=5.,
iou_weight=2.))
test_cfg = dict(max_per_img=100)
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
Expand All @@ -55,14 +54,39 @@
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='Resize',
img_scale=[(480, 1333), (512, 1333), (544, 1333), (576, 1333),
(608, 1333), (640, 1333), (672, 1333), (704, 1333),
(736, 1333), (768, 1333), (800, 1333)],
multiscale_mode='value',
keep_ratio=True),
dict(type='RandomFlip', flip_ratio=0.5),
dict(
type='AutoAugment',
policies=[[
dict(
type='Resize',
img_scale=[(480, 1333), (512, 1333), (544, 1333), (576, 1333),
(608, 1333), (640, 1333), (672, 1333), (704, 1333),
(736, 1333), (768, 1333), (800, 1333)],
multiscale_mode='value',
keep_ratio=True)
],
[
dict(
type='Resize',
img_scale=[(400, 1333), (500, 1333), (600, 1333)],
multiscale_mode='value',
keep_ratio=True),
dict(
type='RandomCrop',
crop_type='absolute_range',
crop_size=(384, 600),
allow_negative_crop=True),
dict(
type='Resize',
img_scale=[(480, 1333), (512, 1333), (544, 1333),
(576, 1333), (608, 1333), (640, 1333),
(672, 1333), (704, 1333), (736, 1333),
(768, 1333), (800, 1333)],
multiscale_mode='value',
override=True,
keep_ratio=True)
]]),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=1),
dict(type='DefaultFormatBundle'),
Expand All @@ -87,11 +111,20 @@
])
]
data = dict(
samples_per_gpu=4,
workers_per_gpu=4,
samples_per_gpu=2,
workers_per_gpu=2,
train=dict(pipeline=train_pipeline),
val=dict(pipeline=test_pipeline),
test=dict(pipeline=test_pipeline))
# TODO optimizer

# TODO learning policy
# optimizer
optimizer = dict(
type='AdamW',
lr=0.0001,
weight_decay=0.0001,
paramwise_cfg=dict(
custom_keys={'backbone': dict(lr_mult=0.1, decay_mult=1.0)}))
optimizer_config = dict(grad_clip=dict(max_norm=0.1, norm_type=2))
# learning policy
lr_config = dict(policy='step', step=[200])
total_epochs = 300
dist_params = dict(_delete_=True, backend='nccl', port=29504)
18 changes: 15 additions & 3 deletions mmdet/datasets/pipelines/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,19 @@ class Resize(object):
backend (str): Image resize backend, choices are 'cv2' and 'pillow'.
These two backends generates slightly different results. Defaults
to 'cv2'.
override (bool): Whether to override `scale` and `scale_factor` so as
to call resize twice. Default False. If True, after the first
resizing, the existed `scale` and `scale_factor` will be ignored
so the second resizing can be allowed.
"""

def __init__(self,
img_scale=None,
multiscale_mode='range',
ratio_range=None,
keep_ratio=True,
backend='cv2'):
backend='cv2',
override=False):
if img_scale is None:
self.img_scale = None
else:
Expand All @@ -80,6 +85,7 @@ def __init__(self,
self.multiscale_mode = multiscale_mode
self.ratio_range = ratio_range
self.keep_ratio = keep_ratio
self.override = override

@staticmethod
def random_select(img_scales):
Expand Down Expand Up @@ -275,8 +281,14 @@ def __call__(self, results):
else:
self._random_scale(results)
else:
assert 'scale_factor' not in results, (
'scale and scale_factor cannot be both set.')
if not self.override:
assert 'scale_factor' not in results, (
'scale and scale_factor cannot be both set.')
else:
results.pop('scale')
if 'scale_factor' in results:
results.pop('scale_factor')
self._random_scale(results)

self._resize_img(results)
self._resize_bboxes(results)
Expand Down
Loading