-
Notifications
You must be signed in to change notification settings - Fork 112
/
dota.py
83 lines (81 loc) · 2.84 KB
/
dota.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
dataset_type = 'DOTADataset'
data_root = 'data/ss_dota_split/'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadOBBAnnotations', with_bbox=True,
with_label=True, obb_as_mask=True),
dict(type='LoadDOTASpecialInfo'),
dict(type='Resize', img_scale=(1024, 1024), keep_ratio=True),
dict(type='OBBRandomFlip', h_flip_ratio=0.5, v_flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='RandomOBBRotate', rotate_after_flip=True,
angles=(0, 0), vert_rate=0.5, vert_cls=['roundabout', 'storage-tank']),
dict(type='Pad', size_divisor=32),
dict(type='DOTASpecialIgnore', ignore_size=2),
dict(type='FliterEmpty'),
dict(type='Mask2OBB', obb_type='obb'),
dict(type='OBBDefaultFormatBundle'),
dict(type='OBBCollect', keys=['img', 'gt_bboxes', 'gt_obboxes', 'gt_labels'])
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipRotateAug',
img_scale=[(1024, 1024)],
h_flip=False,
v_flip=False,
rotate=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='OBBRandomFlip'),
dict(type='Normalize', **img_norm_cfg),
dict(type='RandomOBBRotate', rotate_after_flip=True),
dict(type='Pad', size_divisor=32),
dict(type='ImageToTensor', keys=['img']),
dict(type='OBBCollect', keys=['img']),
])
]
# does evaluation while training
# uncomments it when you need evaluate every epoch
# data = dict(
# samples_per_gpu=2,
# workers_per_gpu=4,
# train=dict(
# type=dataset_type,
# task='Task1',
# ann_file=data_root + 'train/annfiles/',
# img_prefix=data_root + 'train/images/',
# pipeline=train_pipeline),
# val=dict(
# type=dataset_type,
# task='Task1',
# ann_file=data_root + 'val/annfiles/',
# img_prefix=data_root + 'val/images/',
# pipeline=test_pipeline),
# test=dict(
# type=dataset_type,
# task='Task1',
# ann_file=data_root + 'val/annfiles/',
# img_prefix=data_root + 'val/images/',
# pipeline=test_pipeline))
# evaluation = dict(metric='mAP')
# disable evluation, only need train and test
# uncomments it when use trainval as train
data = dict(
samples_per_gpu=2,
workers_per_gpu=4,
train=dict(
type=dataset_type,
task='Task1',
ann_file=data_root + 'trainval/annfiles/',
img_prefix=data_root + 'trainval/images/',
pipeline=train_pipeline),
test=dict(
type=dataset_type,
task='Task1',
ann_file=data_root + 'test/annfiles/',
img_prefix=data_root + 'test/images/',
pipeline=test_pipeline))
evaluation = None