From a9e2ffceb46b9a5507478c502d6317d2c448ac6d Mon Sep 17 00:00:00 2001 From: vhehduatks Date: Wed, 4 May 2022 08:32:23 +0000 Subject: [PATCH 1/2] [hotfix]swintrain --- .gitignore | 3 ++- .../configs/_base_/schedules/custom_schedule.py | 2 +- Swin-Transformer-Semantic-Segmentation/simple_train.py | 8 ++++++-- Swin-Transformer-Semantic-Segmentation/train.yaml | 8 ++++---- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 5ce73e2..69cfdca 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ __pycache__/ mmsegmentation/work_dirs mmsegmentation/out -mmsegmentation/wandb \ No newline at end of file +mmsegmentation/wandb +*.jpg \ No newline at end of file diff --git a/Swin-Transformer-Semantic-Segmentation/configs/_base_/schedules/custom_schedule.py b/Swin-Transformer-Semantic-Segmentation/configs/_base_/schedules/custom_schedule.py index e3fe4df..296e332 100644 --- a/Swin-Transformer-Semantic-Segmentation/configs/_base_/schedules/custom_schedule.py +++ b/Swin-Transformer-Semantic-Segmentation/configs/_base_/schedules/custom_schedule.py @@ -13,5 +13,5 @@ # runtime settings runner = dict(type='IterBasedRunner', max_iters=320000) -checkpoint_config = dict(by_epoch=False, interval=32000) +checkpoint_config = dict(by_epoch=False, interval=2000) evaluation = dict(interval=32000, metric='mIoU') diff --git a/Swin-Transformer-Semantic-Segmentation/simple_train.py b/Swin-Transformer-Semantic-Segmentation/simple_train.py index 5e4474f..544032c 100644 --- a/Swin-Transformer-Semantic-Segmentation/simple_train.py +++ b/Swin-Transformer-Semantic-Segmentation/simple_train.py @@ -45,10 +45,14 @@ def main(config_train): if config_train['save_best_model']: cfg.evaluation['save_best'] = 'mIoU' cfg.evaluation['interval'] = config_train['eval_interval'] + cfg.checkpoint_config['interval'] = config_train['eval_interval'] # -- dataset - if config_train['train_data_dir']: - cfg.data.data_root=config_train['train_data_dir'] + if config_train['train_data_dir_root']: + cfg.data['train']['img_dir']=os.path.join(config_train['train_data_dir_root'],'images/training') + cfg.data['train']['ann_dir']=os.path.join(config_train['train_data_dir_root'],'annotations/training') + cfg.data['val']['img_dir']=os.path.join(config_train['train_data_dir_root'],'images/training') + cfg.data['val']['ann_dir']=os.path.join(config_train['train_data_dir_root'],'annotations/training') datasets = [build_dataset(cfg.data.train)] # -- build model diff --git a/Swin-Transformer-Semantic-Segmentation/train.yaml b/Swin-Transformer-Semantic-Segmentation/train.yaml index 0d9dbd9..bebbdd0 100644 --- a/Swin-Transformer-Semantic-Segmentation/train.yaml +++ b/Swin-Transformer-Semantic-Segmentation/train.yaml @@ -4,8 +4,8 @@ config_file : 'custom_config' ## -- wandb wandb : False -wandb_proj : 'Segmentation' -wandb_name : 'Swin-L' +wandb_proj : 'Semantic Segmentation' +wandb_name : 'uperswin_512_512' log_interval : 50 # -- hyperparameter @@ -14,7 +14,7 @@ batch_size : 8 lr : 0.00006 # -- validation -validate : False +validate : True eval_interval : 2000 # -- checkpoint @@ -24,5 +24,5 @@ ckpt_name : 'upernet_swin_base_patch4_window7_512x512' ## -- save best model save_best_model : True -train_data_dir : '/opt/ml/input/mmseg' +train_data_dir_root : '/opt/ml/input/mmseg' From 1bba5eabfc22251446ef58dda1e1b36cbdd1d2d7 Mon Sep 17 00:00:00 2001 From: vhehduatks Date: Wed, 4 May 2022 09:32:33 +0000 Subject: [PATCH 2/2] [hotfix] swintrainyaml --- Swin-Transformer-Semantic-Segmentation/simple_train.py | 10 +++++----- Swin-Transformer-Semantic-Segmentation/train.yaml | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Swin-Transformer-Semantic-Segmentation/simple_train.py b/Swin-Transformer-Semantic-Segmentation/simple_train.py index 544032c..425c4d8 100644 --- a/Swin-Transformer-Semantic-Segmentation/simple_train.py +++ b/Swin-Transformer-Semantic-Segmentation/simple_train.py @@ -48,11 +48,11 @@ def main(config_train): cfg.checkpoint_config['interval'] = config_train['eval_interval'] # -- dataset - if config_train['train_data_dir_root']: - cfg.data['train']['img_dir']=os.path.join(config_train['train_data_dir_root'],'images/training') - cfg.data['train']['ann_dir']=os.path.join(config_train['train_data_dir_root'],'annotations/training') - cfg.data['val']['img_dir']=os.path.join(config_train['train_data_dir_root'],'images/training') - cfg.data['val']['ann_dir']=os.path.join(config_train['train_data_dir_root'],'annotations/training') + if config_train['data_dir_root']: + cfg.data['train']['img_dir']=os.path.join(config_train['data_dir_root'],'images/training') + cfg.data['train']['ann_dir']=os.path.join(config_train['data_dir_root'],'annotations/training') + cfg.data['val']['img_dir']=os.path.join(config_train['data_dir_root'],'images/validation') + cfg.data['val']['ann_dir']=os.path.join(config_train['data_dir_root'],'annotations/validation') datasets = [build_dataset(cfg.data.train)] # -- build model diff --git a/Swin-Transformer-Semantic-Segmentation/train.yaml b/Swin-Transformer-Semantic-Segmentation/train.yaml index bebbdd0..699866d 100644 --- a/Swin-Transformer-Semantic-Segmentation/train.yaml +++ b/Swin-Transformer-Semantic-Segmentation/train.yaml @@ -3,13 +3,13 @@ config_dir : '_base_/custom' config_file : 'custom_config' ## -- wandb -wandb : False +wandb : True wandb_proj : 'Semantic Segmentation' wandb_name : 'uperswin_512_512' log_interval : 50 # -- hyperparameter -seed : 1995 +seed : 84 batch_size : 8 lr : 0.00006 @@ -24,5 +24,5 @@ ckpt_name : 'upernet_swin_base_patch4_window7_512x512' ## -- save best model save_best_model : True -train_data_dir_root : '/opt/ml/input/mmseg' +data_dir_root : '/opt/ml/input/mmseg'