Skip to content

Commit

Permalink
🌱 Add MMSeg base configs for trash dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
nanpuhaha committed Jan 4, 2023
1 parent db26109 commit ad689b8
Show file tree
Hide file tree
Showing 63 changed files with 3,639 additions and 0 deletions.
82 changes: 82 additions & 0 deletions mmsegmentation/configs/_trash_/_base_/datasets/trash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# dataset settings
dataset_type = "COCOTrashDataset"
data_root = "/opt/ml/input/mmseg/trash"

classes = (
"Background",
"General trash",
"Paper",
"Paper pack",
"Metal",
"Glass",
"Plastic",
"Styrofoam",
"Plastic bag",
"Battery",
"Clothing",
)

img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True
)
img_scale = (512, 512)
# crop_size = (256, 256)
train_pipeline = [
dict(type="LoadImageFromFile"),
dict(type="LoadAnnotations"),
dict(type="Resize", img_scale=img_scale, ratio_range=(0.5, 2.0)),
# dict(type="RandomCrop", crop_size=crop_size, cat_max_ratio=0.75),
dict(type="RandomFlip", prob=0.5),
dict(type="PhotoMetricDistortion"),
dict(type="Normalize", **img_norm_cfg),
# dict(type="Pad", size=crop_size, pad_val=0, seg_pad_val=255),
dict(type="DefaultFormatBundle"),
dict(type="Collect", keys=["img", "gt_semantic_seg"]),
]
test_pipeline = [
dict(type="LoadImageFromFile"),
dict(
type="MultiScaleFlipAug",
img_scale=img_scale,
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0],
flip=False,
transforms=[
dict(type="Resize", keep_ratio=True),
dict(type="RandomFlip"),
dict(type="Normalize", **img_norm_cfg),
dict(type="ImageToTensor", keys=["img"]),
dict(type="Collect", keys=["img"]),
],
),
]

data = dict(
samples_per_gpu=8,
workers_per_gpu=8,
train=dict(
type="RepeatDataset",
times=40000,
dataset=dict(
type=dataset_type,
data_root=data_root,
img_dir="img_dir/train",
ann_dir="ann_dir/train",
pipeline=train_pipeline,
),
),
val=dict(
type=dataset_type,
data_root=data_root,
img_dir="img_dir/val",
ann_dir="ann_dir/val",
pipeline=test_pipeline,
),
test=dict(
type=dataset_type,
data_root=data_root,
img_dir="img_dir/test",
ann_dir="ann_dir/test",
pipeline=test_pipeline,
test_mode=True,
),
)
32 changes: 32 additions & 0 deletions mmsegmentation/configs/_trash_/_base_/default_runtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# yapf:disable
log_config = dict(
interval=50,
hooks=[
dict(type="TextLoggerHook", by_epoch=False),
# dict(type='MlflowLoggerHook'),
# dict(type='TensorboardLoggerHook'),
dict(
type="MMSegWandbHook", # "WandbLoggerHook",
init_kwargs={
"project": "Semantic Segmentation",
"entity": "boostcamp-ai-tech-4-cv-17",
# "name": "mmseg",
},
interval=10,
log_checkpoint=True,
log_checkpoint_metadata=True,
num_eval_images=100,
),
],
)
# yapf:enable

dist_params = dict(backend="nccl")
log_level = "INFO"
load_from = None
resume_from = None

workflow = [("train", 1)]
# workflow = [("train", 1), ("val", 1)]

cudnn_benchmark = True
48 changes: 48 additions & 0 deletions mmsegmentation/configs/_trash_/_base_/models/ann_r50-d8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# model settings
norm_cfg = dict(type="SyncBN", requires_grad=True)
model = dict(
type="EncoderDecoder",
pretrained="open-mmlab://resnet50_v1c",
backbone=dict(
type="ResNetV1c",
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=(1, 2, 1, 1),
norm_cfg=norm_cfg,
norm_eval=False,
style="pytorch",
contract_dilation=True,
),
decode_head=dict(
type="ANNHead",
in_channels=[1024, 2048],
in_index=[2, 3],
channels=512,
project_channels=256,
query_scales=(1,),
key_pool_scales=(1, 3, 6, 8),
dropout_ratio=0.1,
num_classes=19,
norm_cfg=norm_cfg,
align_corners=False,
loss_decode=dict(type="CrossEntropyLoss", use_sigmoid=False, loss_weight=1.0),
),
auxiliary_head=dict(
type="FCNHead",
in_channels=1024,
in_index=2,
channels=256,
num_convs=1,
concat_input=False,
dropout_ratio=0.1,
num_classes=19,
norm_cfg=norm_cfg,
align_corners=False,
loss_decode=dict(type="CrossEntropyLoss", use_sigmoid=False, loss_weight=0.4),
),
# model training and testing settings
train_cfg=dict(),
test_cfg=dict(mode="whole"),
)
46 changes: 46 additions & 0 deletions mmsegmentation/configs/_trash_/_base_/models/apcnet_r50-d8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# model settings
norm_cfg = dict(type="SyncBN", requires_grad=True)
model = dict(
type="EncoderDecoder",
pretrained="open-mmlab://resnet50_v1c",
backbone=dict(
type="ResNetV1c",
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 2, 4),
strides=(1, 2, 1, 1),
norm_cfg=norm_cfg,
norm_eval=False,
style="pytorch",
contract_dilation=True,
),
decode_head=dict(
type="APCHead",
in_channels=2048,
in_index=3,
channels=512,
pool_scales=(1, 2, 3, 6),
dropout_ratio=0.1,
num_classes=19,
norm_cfg=dict(type="SyncBN", requires_grad=True),
align_corners=False,
loss_decode=dict(type="CrossEntropyLoss", use_sigmoid=False, loss_weight=1.0),
),
auxiliary_head=dict(
type="FCNHead",
in_channels=1024,
in_index=2,
channels=256,
num_convs=1,
concat_input=False,
dropout_ratio=0.1,
num_classes=19,
norm_cfg=norm_cfg,
align_corners=False,
loss_decode=dict(type="CrossEntropyLoss", use_sigmoid=False, loss_weight=0.4),
),
# model training and testing settings
train_cfg=dict(),
test_cfg=dict(mode="whole"),
)
75 changes: 75 additions & 0 deletions mmsegmentation/configs/_trash_/_base_/models/bisenetv1_r18-d32.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# model settings
norm_cfg = dict(type="SyncBN", requires_grad=True)
model = dict(
type="EncoderDecoder",
backbone=dict(
type="BiSeNetV1",
in_channels=3,
context_channels=(128, 256, 512),
spatial_channels=(64, 64, 64, 128),
out_indices=(0, 1, 2),
out_channels=256,
backbone_cfg=dict(
type="ResNet",
in_channels=3,
depth=18,
num_stages=4,
out_indices=(0, 1, 2, 3),
dilations=(1, 1, 1, 1),
strides=(1, 2, 2, 2),
norm_cfg=norm_cfg,
norm_eval=False,
style="pytorch",
contract_dilation=True,
),
norm_cfg=norm_cfg,
align_corners=False,
init_cfg=None,
),
decode_head=dict(
type="FCNHead",
in_channels=256,
in_index=0,
channels=256,
num_convs=1,
concat_input=False,
dropout_ratio=0.1,
num_classes=19,
norm_cfg=norm_cfg,
align_corners=False,
loss_decode=dict(type="CrossEntropyLoss", use_sigmoid=False, loss_weight=1.0),
),
auxiliary_head=[
dict(
type="FCNHead",
in_channels=128,
channels=64,
num_convs=1,
num_classes=19,
in_index=1,
norm_cfg=norm_cfg,
concat_input=False,
align_corners=False,
loss_decode=dict(
type="CrossEntropyLoss", use_sigmoid=False, loss_weight=1.0
),
),
dict(
type="FCNHead",
in_channels=128,
channels=64,
num_convs=1,
num_classes=19,
in_index=2,
norm_cfg=norm_cfg,
concat_input=False,
align_corners=False,
loss_decode=dict(
type="CrossEntropyLoss", use_sigmoid=False, loss_weight=1.0
),
),
],
# model training and testing settings
train_cfg=dict(),
test_cfg=dict(mode="whole"),
)
90 changes: 90 additions & 0 deletions mmsegmentation/configs/_trash_/_base_/models/bisenetv2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# model settings
norm_cfg = dict(type="SyncBN", requires_grad=True)
model = dict(
type="EncoderDecoder",
pretrained=None,
backbone=dict(
type="BiSeNetV2",
detail_channels=(64, 64, 128),
semantic_channels=(16, 32, 64, 128),
semantic_expansion_ratio=6,
bga_channels=128,
out_indices=(0, 1, 2, 3, 4),
init_cfg=None,
align_corners=False,
),
decode_head=dict(
type="FCNHead",
in_channels=128,
in_index=0,
channels=1024,
num_convs=1,
concat_input=False,
dropout_ratio=0.1,
num_classes=19,
norm_cfg=norm_cfg,
align_corners=False,
loss_decode=dict(type="CrossEntropyLoss", use_sigmoid=False, loss_weight=1.0),
),
auxiliary_head=[
dict(
type="FCNHead",
in_channels=16,
channels=16,
num_convs=2,
num_classes=19,
in_index=1,
norm_cfg=norm_cfg,
concat_input=False,
align_corners=False,
loss_decode=dict(
type="CrossEntropyLoss", use_sigmoid=False, loss_weight=1.0
),
),
dict(
type="FCNHead",
in_channels=32,
channels=64,
num_convs=2,
num_classes=19,
in_index=2,
norm_cfg=norm_cfg,
concat_input=False,
align_corners=False,
loss_decode=dict(
type="CrossEntropyLoss", use_sigmoid=False, loss_weight=1.0
),
),
dict(
type="FCNHead",
in_channels=64,
channels=256,
num_convs=2,
num_classes=19,
in_index=3,
norm_cfg=norm_cfg,
concat_input=False,
align_corners=False,
loss_decode=dict(
type="CrossEntropyLoss", use_sigmoid=False, loss_weight=1.0
),
),
dict(
type="FCNHead",
in_channels=128,
channels=1024,
num_convs=2,
num_classes=19,
in_index=4,
norm_cfg=norm_cfg,
concat_input=False,
align_corners=False,
loss_decode=dict(
type="CrossEntropyLoss", use_sigmoid=False, loss_weight=1.0
),
),
],
# model training and testing settings
train_cfg=dict(),
test_cfg=dict(mode="whole"),
)
Loading

0 comments on commit ad689b8

Please sign in to comment.