MTKD / TTP /distill /config.py
circleLZY's picture
Upload 10 files
bfc7be4 verified
_base_ = [
'/home/liuziyuan/proj/rmcd-kd/configs/_base_/models/KD-ttp_vit-sam-l.py',
'/home/liuziyuan/proj/rmcd-kd/configs/common/standard_512x512_300e_cgwx.py']
dataset_type = 'LEVIR_CD_Dataset'
data_root = '/nas/datasets/lzy/RS-ChangeDetection/CGWX'
crop_size = (512, 512)
checkpoint_student = '/nas/datasets/lzy/RS-ChangeDetection/checkpoints_distill/TTP/teacher_ckpt/initial/best_mIoU_epoch_110.pth'
checkpoint_teacher_l = '/nas/datasets/lzy/RS-ChangeDetection/checkpoints_distill/TTP/teacher_ckpt/large/best_mIoU_epoch_90.pth'
checkpoint_teacher_m = '/nas/datasets/lzy/RS-ChangeDetection/checkpoints_distill/TTP/teacher_ckpt/medium/best_mIoU_epoch_100.pth'
checkpoint_teacher_s = '/nas/datasets/lzy/RS-ChangeDetection/checkpoints_distill/TTP/teacher_ckpt/small/best_mIoU_epoch_115.pth'
model = dict(
# student
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_student),
# teacher large
init_cfg_t_l = dict(type='Pretrained', checkpoint=checkpoint_teacher_l),
# teacher medium
init_cfg_t_m = dict(type='Pretrained', checkpoint=checkpoint_teacher_m),
# teacher small
init_cfg_t_s = dict(type='Pretrained', checkpoint=checkpoint_teacher_s),
backbone=dict(
encoder_cfg=dict(img_size=crop_size)),
test_cfg=dict(mode='slide', crop_size=crop_size, stride=(crop_size[0]//2, crop_size[1]//2)))
train_pipeline = [
dict(type='MultiImgLoadImageFromFile'),
dict(type='MultiImgLoadAnnotations'),
dict(type='MultiImgRandomRotate', prob=0.5, degree=180),
dict(type='MultiImgRandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
dict(type='MultiImgRandomFlip', prob=0.5, direction='horizontal'),
dict(type='MultiImgRandomFlip', prob=0.5, direction='vertical'),
# dict(type='MultiImgExchangeTime', prob=0.5),
dict(
type='MultiImgPhotoMetricDistortion',
brightness_delta=10,
contrast_range=(0.8, 1.2),
saturation_range=(0.8, 1.2),
hue_delta=10),
dict(type='MultiImgPackSegInputs')
]
# By default, models are trained on 8 GPUs with 2 images per GPU
train_dataloader = dict(
batch_size=8,
num_workers=4,
sampler=dict(type='DefaultSampler', shuffle=True),
dataset=dict(pipeline=train_pipeline))
# optimizer
max_epochs = 100
optim_wrapper = dict(
_delete_=True,
type='OptimWrapper',
optimizer=dict(
type='AdamW', lr=0.0004, betas=(0.9, 0.999), weight_decay=0.05))
param_scheduler = [
dict(
type='LinearLR', start_factor=1e-4, by_epoch=True, begin=0, end=5, convert_to_iter_based=True),
dict(
type='CosineAnnealingLR',
T_max=max_epochs,
begin=5,
by_epoch=True,
end=max_epochs,
convert_to_iter_based=True
),
]
test_pipeline = [
dict(type='MultiImgLoadImageFromFile'),
dict(type='MultiImgResize', scale=(512, 512), keep_ratio=True),
# add loading annotation after ``Resize`` because ground truth
# does not need to do resize data transform
dict(type='MultiImgLoadAnnotations'),
dict(type='MultiImgPackSegInputs')
]
train_cfg = dict(type='EpochBasedTrainLoop', max_epochs=max_epochs, val_interval=2)
default_hooks = dict(checkpoint=dict(interval=2))