Skip to content

Commit

Permalink
Merge branch 'develop' into feature/shh_train
Browse files Browse the repository at this point in the history
  • Loading branch information
vhehduatks authored May 4, 2022
2 parents 1bba5ea + 51c831a commit d2f5f9f
Show file tree
Hide file tree
Showing 22 changed files with 611 additions and 84 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ __pycache__/
mmsegmentation/work_dirs
mmsegmentation/out
mmsegmentation/wandb
*.jpg
*.jpg
mmsegmentation/output
mmsegmentation/nohup.out

2 changes: 1 addition & 1 deletion mmsegmentation/configs/_ljh_/_base_/default_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
log_level = 'INFO'
load_from = None
resume_from = None
workflow = [('train', 1)]
workflow = [('train', 1),('val',1)]
cudnn_benchmark = True
49 changes: 49 additions & 0 deletions mmsegmentation/configs/_ljh_/_base_/models/psanet_r50-d8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 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='PSAHead',
in_channels=2048,
in_index=3,
channels=512,
mask_size=(97, 97),
psa_type='bi-direction',
compact=False,
shrink_factor=2,
normalization_factor=1.0,
psa_softmax=True,
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'))
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005)
optimizer = dict(type='SGD', lr=0.001, momentum=0.9, weight_decay=0.0005)
# optimizer = dict(type='AdamW', lr=0.001, betas=(0.9, 0.999), weight_decay=0.0005)
optimizer_config = dict()

# learning policy
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False)
lr_config = dict(policy='poly', power=0.9, min_lr=1e-5, by_epoch=False)

# runtime settings
runner = dict(type='IterBasedRunner', max_iters=160000)
checkpoint_config = dict(by_epoch=False, interval=16000)
Expand Down
2 changes: 2 additions & 0 deletions mmsegmentation/configs/_ljh_/psanet_r101-d8_160k_pascal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_base_ = './psanet_r50-d8_160k_pascal.py'
model = dict(pretrained='open-mmlab://resnet101_v1c', backbone=dict(depth=101))
9 changes: 9 additions & 0 deletions mmsegmentation/configs/_ljh_/psanet_r50-d8_160k_pascal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
_base_ = [
'./_base_/models/psanet_r50-d8.py',
'./_base_/datasets/pascal_context.py', './_base_/default_runtime.py',
'./_base_/schedules/schedule_160k.py'
]
model = dict(
decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True),
test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))
60 changes: 60 additions & 0 deletions mmsegmentation/configs/_owj_/_base_/datasets/pascal_context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# dataset settings
dataset_type = 'PascalContextDataset'
data_root = '../data/mmseg'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)

img_scale = (520, 520)
crop_size = (480, 480)

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],
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=4,
workers_per_gpu=4,
train=dict(
type=dataset_type,
data_root=data_root,
img_dir='images',
ann_dir='labels',
split='splits/train.txt',
pipeline=train_pipeline),
val=dict(
type=dataset_type,
data_root=data_root,
img_dir='images',
ann_dir='labels',
split='splits/val.txt',
pipeline=test_pipeline),
test=dict(
type=dataset_type,
data_root=data_root,
img_dir='images',
ann_dir='labels',
split='splits/test.txt',
pipeline=test_pipeline))
16 changes: 16 additions & 0 deletions mmsegmentation/configs/_owj_/_base_/default_runtime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# yapf:disable
log_config = dict(
interval=50,
hooks=[
dict(type="TextLoggerHook", by_epoch=False),
dict(type="WandbLoggerHook", init_kwargs=dict(entity='cv04',project="Semantic Segmentation", name="ccnet_test")),
],
)

# yapf:enable
dist_params = dict(backend='nccl')
log_level = 'INFO'
load_from = None
resume_from = None
workflow = [('train', 1)]
cudnn_benchmark = True
44 changes: 44 additions & 0 deletions mmsegmentation/configs/_owj_/_base_/models/ccnet_r50-d8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 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='CCHead',
in_channels=2048,
in_index=3,
channels=512,
recurrence=2,
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'))
68 changes: 68 additions & 0 deletions mmsegmentation/configs/_owj_/_base_/models/ocrnet_hr18.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='CascadeEncoderDecoder',
num_stages=2,
pretrained='open-mmlab://msra/hrnetv2_w18',
backbone=dict(
type='HRNet',
norm_cfg=norm_cfg,
norm_eval=False,
extra=dict(
stage1=dict(
num_modules=1,
num_branches=1,
block='BOTTLENECK',
num_blocks=(4, ),
num_channels=(64, )),
stage2=dict(
num_modules=1,
num_branches=2,
block='BASIC',
num_blocks=(4, 4),
num_channels=(18, 36)),
stage3=dict(
num_modules=4,
num_branches=3,
block='BASIC',
num_blocks=(4, 4, 4),
num_channels=(18, 36, 72)),
stage4=dict(
num_modules=3,
num_branches=4,
block='BASIC',
num_blocks=(4, 4, 4, 4),
num_channels=(18, 36, 72, 144)))),
decode_head=[
dict(
type='FCNHead',
in_channels=[18, 36, 72, 144],
channels=sum([18, 36, 72, 144]),
in_index=(0, 1, 2, 3),
input_transform='resize_concat',
kernel_size=1,
num_convs=1,
concat_input=False,
dropout_ratio=-1,
num_classes=19,
norm_cfg=norm_cfg,
align_corners=False,
loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
dict(
type='OCRHead',
in_channels=[18, 36, 72, 144],
in_index=(0, 1, 2, 3),
input_transform='resize_concat',
channels=512,
ocr_channels=256,
dropout_ratio=-1,
num_classes=19,
norm_cfg=norm_cfg,
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'))
18 changes: 18 additions & 0 deletions mmsegmentation/configs/_owj_/_base_/schedules/custom_schedule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# optimizer
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.)})
)
optimizer_config = dict()

lr_config = dict(policy='poly',
warmup='linear',
warmup_iters=1500,
warmup_ratio=1e-6,
power=1.0, min_lr=0.0, by_epoch=False)

# runtime settings
runner = dict(type='IterBasedRunner', max_iters=320000)
checkpoint_config = dict(by_epoch=False, interval=32000)
evaluation = dict(interval=32000, metric='mIoU')
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005)
optimizer_config = dict()
# learning policy
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False)
# runtime settings
runner = dict(type='IterBasedRunner', max_iters=160000)
checkpoint_config = dict(by_epoch=False, interval=16000)
evaluation = dict(interval=16000, metric='mIoU', pre_eval=True)
9 changes: 9 additions & 0 deletions mmsegmentation/configs/_owj_/_base_/schedules/schedule_20k.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005)
optimizer_config = dict()
# learning policy
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False)
# runtime settings
runner = dict(type='IterBasedRunner', max_iters=20000)
checkpoint_config = dict(by_epoch=False, interval=2000)
evaluation = dict(interval=2000, metric='mIoU', pre_eval=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005)
optimizer_config = dict()
# learning policy
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False)
# runtime settings
runner = dict(type='IterBasedRunner', max_iters=320000)
checkpoint_config = dict(by_epoch=False, interval=32000)
evaluation = dict(interval=32000, metric='mIoU')
9 changes: 9 additions & 0 deletions mmsegmentation/configs/_owj_/_base_/schedules/schedule_40k.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# optimizer
optimizer = dict(type='AdamW', lr=0.001, momentum=0.9, weight_decay=0.0005)
optimizer_config = dict()
# learning policy
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False)
# runtime settings
runner = dict(type='IterBasedRunner', max_iters=40000)
checkpoint_config = dict(by_epoch=False, interval=4000)
evaluation = dict(interval=4000, metric='mIoU', pre_eval=True)
9 changes: 9 additions & 0 deletions mmsegmentation/configs/_owj_/_base_/schedules/schedule_80k.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005)
optimizer_config = dict()
# learning policy
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False)
# runtime settings
runner = dict(type='IterBasedRunner', max_iters=80000)
checkpoint_config = dict(by_epoch=False, interval=8000)
evaluation = dict(interval=8000, metric='mIoU', pre_eval=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_base_ = './ccnet_r50-d8_512x1024_40k_cityscapes.py'
model = dict(pretrained='open-mmlab://resnet101_v1c', backbone=dict(depth=101))
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_base_ = [
'./_base_/models/ccnet_r50-d8.py', './_base_/datasets/pascal_context.py',
'./_base_/default_runtime.py', './_base_/schedules/custom_schedule.py'
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_base_ = [
'./_base_/models/ocrnet_hr18.py', './_base_/datasets/pascal_context.py',
'./_base_/default_runtime.py', './_base_/schedules/custom_schedule.py'
]
Loading

0 comments on commit d2f5f9f

Please sign in to comment.