forked from open-mmlab/mmsegmentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Add GDAL backend and Support LEVIR-CD Dataset (open-mmlab#2903
) ## Motivation For support with reading multiple remote sensing image formats, please refer to https://gdal.org/drivers/raster/index.html. Byte, UInt16, Int16, UInt32, Int32, Float32, Float64, CInt16, CInt32, CFloat32 and CFloat64 are supported for reading and writing. Support input of two images for change detection tasks, and support the LEVIR-CD dataset. ## Modification Add LoadSingleRSImageFromFile in 'mmseg/datasets/transforms/loading.py'. Load a single remote sensing image for object segmentation tasks. Add LoadMultipleRSImageFromFile in 'mmseg/datasets/transforms/loading.py'. Load two remote sensing images for change detection tasks. Add ConcatCDInput in 'mmseg/datasets/transforms/transforms.py'. Combine images that have been separately augmented for data enhancement. Add BaseCDDataset in 'mmseg/datasets/basesegdataset.py' Base class for datasets used in change detection tasks. --------- Co-authored-by: xiexinch <xiexinch@outlook.com>
- Loading branch information
Showing
14 changed files
with
809 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# dataset settings | ||
dataset_type = 'LEVIRCDDataset' | ||
data_root = r'data/LEVIRCD' | ||
|
||
albu_train_transforms = [ | ||
dict(type='RandomBrightnessContrast', p=0.2), | ||
dict(type='HorizontalFlip', p=0.5), | ||
dict(type='VerticalFlip', p=0.5) | ||
] | ||
|
||
train_pipeline = [ | ||
dict(type='LoadMultipleRSImageFromFile'), | ||
dict(type='LoadAnnotations'), | ||
dict(type='Albu', transforms=albu_train_transforms), | ||
dict(type='ConcatCDInput'), | ||
dict(type='PackSegInputs') | ||
] | ||
test_pipeline = [ | ||
dict(type='LoadMultipleRSImageFromFile'), | ||
dict(type='LoadAnnotations'), | ||
dict(type='ConcatCDInput'), | ||
dict(type='PackSegInputs') | ||
] | ||
|
||
tta_pipeline = [ | ||
dict(type='LoadMultipleRSImageFromFile'), | ||
dict( | ||
type='TestTimeAug', | ||
transforms=[[dict(type='LoadAnnotations')], | ||
[dict(type='ConcatCDInput')], | ||
[dict(type='PackSegInputs')]]) | ||
] | ||
train_dataloader = dict( | ||
batch_size=4, | ||
num_workers=4, | ||
persistent_workers=True, | ||
sampler=dict(type='InfiniteSampler', shuffle=True), | ||
dataset=dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
data_prefix=dict( | ||
img_path='train/A', | ||
img_path2='train/B', | ||
seg_map_path='train/label'), | ||
pipeline=train_pipeline)) | ||
val_dataloader = dict( | ||
batch_size=1, | ||
num_workers=4, | ||
persistent_workers=True, | ||
sampler=dict(type='DefaultSampler', shuffle=False), | ||
dataset=dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
data_prefix=dict( | ||
img_path='test/A', img_path2='test/B', seg_map_path='test/label'), | ||
pipeline=test_pipeline)) | ||
test_dataloader = val_dataloader | ||
val_evaluator = dict(type='IoUMetric', iou_metrics=['mIoU']) | ||
test_evaluator = val_evaluator |
56 changes: 56 additions & 0 deletions
56
configs/swin/swin-tiny-patch4-window7_upernet_1xb8-20k_levir-256x256.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
_base_ = [ | ||
'../_base_/models/upernet_swin.py', '../_base_/datasets/levir_256x256.py', | ||
'../_base_/default_runtime.py', '../_base_/schedules/schedule_20k.py' | ||
] | ||
crop_size = (256, 256) | ||
norm_cfg = dict(type='BN', requires_grad=True) | ||
data_preprocessor = dict( | ||
size=crop_size, | ||
type='SegDataPreProcessor', | ||
mean=[123.675, 116.28, 103.53, 123.675, 116.28, 103.53], | ||
std=[58.395, 57.12, 57.375, 58.395, 57.12, 57.375]) | ||
|
||
model = dict( | ||
data_preprocessor=data_preprocessor, | ||
backbone=dict( | ||
in_channels=6, | ||
embed_dims=96, | ||
depths=[2, 2, 6, 2], | ||
num_heads=[3, 6, 12, 24], | ||
window_size=7, | ||
use_abs_pos_embed=False, | ||
drop_path_rate=0.3, | ||
patch_norm=True), | ||
decode_head=dict(in_channels=[96, 192, 384, 768], num_classes=2), | ||
auxiliary_head=dict(in_channels=384, num_classes=2)) | ||
|
||
# AdamW optimizer, no weight decay for position embedding & layer norm | ||
# in backbone | ||
optim_wrapper = dict( | ||
_delete_=True, | ||
type='OptimWrapper', | ||
optimizer=dict( | ||
type='AdamW', lr=0.00006, betas=(0.9, 0.999), weight_decay=0.01), | ||
paramwise_cfg=dict( | ||
custom_keys={ | ||
'absolute_pos_embed': dict(decay_mult=0.), | ||
'relative_position_bias_table': dict(decay_mult=0.), | ||
'norm': dict(decay_mult=0.) | ||
})) | ||
|
||
param_scheduler = [ | ||
dict( | ||
type='LinearLR', start_factor=1e-6, by_epoch=False, begin=0, end=1500), | ||
dict( | ||
type='PolyLR', | ||
eta_min=0.0, | ||
power=1.0, | ||
begin=1500, | ||
end=20000, | ||
by_epoch=False, | ||
) | ||
] | ||
|
||
train_dataloader = dict(batch_size=4) | ||
val_dataloader = dict(batch_size=1) | ||
test_dataloader = val_dataloader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.