Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Refactor sar dataset #591

Merged
merged 6 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion configs/_base_/datasets/dota.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
test_pipeline = [
dict(type='mmdet.LoadImageFromFile', file_client_args=file_client_args),
dict(type='mmdet.Resize', scale=(1024, 1024), keep_ratio=True),
# avoid bboxes being resized
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
Expand Down
1 change: 0 additions & 1 deletion configs/_base_/datasets/dota_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
test_pipeline = [
dict(type='mmdet.LoadImageFromFile', file_client_args=file_client_args),
dict(type='mmdet.Resize', scale=(1024, 1024), keep_ratio=True),
# avoid bboxes being resized
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
Expand Down
1 change: 0 additions & 1 deletion configs/_base_/datasets/dota_ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
test_pipeline = [
dict(type='mmdet.LoadImageFromFile', file_client_args=file_client_args),
dict(type='mmdet.Resize', scale=(1024, 1024), keep_ratio=True),
# avoid bboxes being resized
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
Expand Down
1 change: 0 additions & 1 deletion configs/_base_/datasets/dota_qbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
test_pipeline = [
dict(type='mmdet.LoadImageFromFile', file_client_args=file_client_args),
dict(type='mmdet.Resize', scale=(1024, 1024), keep_ratio=True),
# avoid bboxes being resized
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
Expand Down
1 change: 0 additions & 1 deletion configs/_base_/datasets/hrsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
test_pipeline = [
dict(type='mmdet.LoadImageFromFile', file_client_args=file_client_args),
dict(type='mmdet.Resize', scale=(800, 512), keep_ratio=True),
# avoid bboxes being resized
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
Expand Down
110 changes: 71 additions & 39 deletions configs/_base_/datasets/hrsid.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,79 @@
# dataset settings
dataset_type = 'SARDataset'
data_root = 'data/hrsid/'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
dataset_type = 'mmdet.CocoDataset'
data_root = 'data/HRSID_JPG/'
file_client_args = dict(backend='disk')

train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True),
dict(type='RResize', img_scale=(800, 800)),
dict(type='RRandomFlip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])
dict(type='mmdet.LoadImageFromFile', file_client_args=file_client_args),
dict(
type='mmdet.LoadAnnotations',
with_bbox=True,
with_mask=True,
poly2mask=False),
dict(type='ConvertMask2BoxType', box_type='rbox'),
dict(type='mmdet.Resize', scale=(800, 800), keep_ratio=True),
dict(
type='mmdet.RandomFlip',
prob=0.75,
direction=['horizontal', 'vertical', 'diagonal']),
dict(type='mmdet.PackDetInputs')
]
val_pipeline = [
dict(type='mmdet.LoadImageFromFile', file_client_args=file_client_args),
dict(type='mmdet.Resize', scale=(800, 800), keep_ratio=True),
# avoid bboxes being resized
dict(
type='mmdet.LoadAnnotations',
with_bbox=True,
with_mask=True,
poly2mask=False),
dict(type='ConvertMask2BoxType', box_type='qbox'),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor', 'instances'))
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='mmdet.LoadImageFromFile', file_client_args=file_client_args),
dict(type='mmdet.Resize', scale=(800, 800), keep_ratio=True),
dict(
type='MultiScaleFlipAug',
img_scale=(800, 800),
flip=False,
transforms=[
dict(type='RResize'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img'])
])
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor'))
]
data = dict(
samples_per_gpu=2,
workers_per_gpu=2,
train=dict(
type=dataset_type,
ann_file=data_root + 'trainsplit/labelTxt/',
img_prefix=data_root + 'trainsplit/images/',
pipeline=train_pipeline),
val=dict(

metainfo = dict(CLASSES=('ship', ))

train_dataloader = dict(
batch_size=2,
num_workers=2,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=True),
batch_sampler=None,
dataset=dict(
type=dataset_type,
ann_file=data_root + 'testsplit/inshore/labelTxt/',
img_prefix=data_root + 'testsplit/inshore/images/',
pipeline=test_pipeline),
test=dict(
metainfo=metainfo,
data_root=data_root,
ann_file='annotations/train2017.json',
data_prefix=dict(img='JPEGImages/'),
filter_cfg=dict(filter_empty_gt=True),
pipeline=train_pipeline))
val_dataloader = dict(
batch_size=1,
num_workers=2,
persistent_workers=True,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type=dataset_type,
ann_file=data_root + 'testsplit/offshore/labelTxt/',
img_prefix=data_root + 'testsplit/offshore/images/',
pipeline=test_pipeline))
metainfo=metainfo,
data_root=data_root,
ann_file='annotations/test2017.json',
data_prefix=dict(img='JPEGImages/'),
test_mode=True,
pipeline=val_pipeline))
test_dataloader = val_dataloader

val_evaluator = dict(type='RotatedCocoMetric', metric='bbox')

test_evaluator = val_evaluator
79 changes: 79 additions & 0 deletions configs/_base_/datasets/rsdd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# dataset settings
dataset_type = 'mmdet.CocoDataset'
data_root = 'data/rsdd/'
file_client_args = dict(backend='disk')

train_pipeline = [
dict(type='mmdet.LoadImageFromFile', file_client_args=file_client_args),
dict(
type='mmdet.LoadAnnotations',
with_bbox=True,
with_mask=True,
poly2mask=False),
dict(type='ConvertMask2BoxType', box_type='rbox'),
dict(type='mmdet.Resize', scale=(512, 512), keep_ratio=True),
dict(
type='mmdet.RandomFlip',
prob=0.75,
direction=['horizontal', 'vertical', 'diagonal']),
dict(type='mmdet.PackDetInputs')
]
val_pipeline = [
dict(type='mmdet.LoadImageFromFile', file_client_args=file_client_args),
dict(type='mmdet.Resize', scale=(512, 512), keep_ratio=True),
# avoid bboxes being resized
dict(
type='mmdet.LoadAnnotations',
with_bbox=True,
with_mask=True,
poly2mask=False),
dict(type='ConvertMask2BoxType', box_type='qbox'),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor', 'instances'))
]
test_pipeline = [
dict(type='mmdet.LoadImageFromFile', file_client_args=file_client_args),
dict(type='mmdet.Resize', scale=(512, 512), keep_ratio=True),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor'))
]

metainfo = dict(CLASSES=('ship', ))

train_dataloader = dict(
batch_size=2,
num_workers=2,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=True),
batch_sampler=None,
dataset=dict(
type=dataset_type,
metainfo=metainfo,
data_root=data_root,
ann_file='ImageSets/train.json',
data_prefix=dict(img='JPEGImages/'),
filter_cfg=dict(filter_empty_gt=True),
pipeline=train_pipeline))
val_dataloader = dict(
batch_size=1,
num_workers=2,
persistent_workers=True,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type=dataset_type,
metainfo=metainfo,
data_root=data_root,
ann_file='ImageSets/test.json',
data_prefix=dict(img='JPEGImages/'),
test_mode=True,
pipeline=val_pipeline))
test_dataloader = val_dataloader

val_evaluator = dict(type='RotatedCocoMetric', metric='bbox')

test_evaluator = val_evaluator
81 changes: 81 additions & 0 deletions configs/_base_/datasets/srsdd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# dataset settings
dataset_type = 'mmdet.CocoDataset'
data_root = 'data/srsdd/'
file_client_args = dict(backend='disk')

train_pipeline = [
dict(type='mmdet.LoadImageFromFile', file_client_args=file_client_args),
dict(
type='mmdet.LoadAnnotations',
with_bbox=True,
with_mask=True,
poly2mask=False),
dict(type='ConvertMask2BoxType', box_type='rbox'),
dict(type='mmdet.Resize', scale=(1024, 1024), keep_ratio=True),
dict(
type='mmdet.RandomFlip',
prob=0.75,
direction=['horizontal', 'vertical', 'diagonal']),
dict(type='mmdet.PackDetInputs')
]
val_pipeline = [
dict(type='mmdet.LoadImageFromFile', file_client_args=file_client_args),
dict(type='mmdet.Resize', scale=(1024, 1024), keep_ratio=True),
# avoid bboxes being resized
dict(
type='mmdet.LoadAnnotations',
with_bbox=True,
with_mask=True,
poly2mask=False),
dict(type='ConvertMask2BoxType', box_type='qbox'),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor', 'instances'))
]
test_pipeline = [
dict(type='mmdet.LoadImageFromFile', file_client_args=file_client_args),
dict(type='mmdet.Resize', scale=(1024, 1024), keep_ratio=True),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor'))
]

metainfo = dict(
CLASSES=('Container', 'Dredger', 'LawEnforce', 'Cell-Container', 'ore-oil',
'Fishing'))

train_dataloader = dict(
batch_size=2,
num_workers=2,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=True),
batch_sampler=None,
dataset=dict(
type=dataset_type,
metainfo=metainfo,
data_root=data_root,
ann_file='train/train.json',
data_prefix=dict(img='train/images/'),
filter_cfg=dict(filter_empty_gt=True),
pipeline=train_pipeline))
val_dataloader = dict(
batch_size=1,
num_workers=2,
persistent_workers=True,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type=dataset_type,
metainfo=metainfo,
data_root=data_root,
ann_file='test/test.json',
data_prefix=dict(img='test/images/'),
test_mode=True,
pipeline=val_pipeline))
test_dataloader = val_dataloader

val_evaluator = dict(type='RotatedCocoMetric', metric='bbox')

test_evaluator = val_evaluator
Loading