|
{ |
|
"imports": [ |
|
"$import glob", |
|
"$import os", |
|
"$import ignite" |
|
], |
|
"bundle_root": ".", |
|
"ckpt_dir": "$@bundle_root + '/models'", |
|
"output_dir": "$@bundle_root + '/eval'", |
|
"dataset_dir": "$@bundle_root + '/data'", |
|
"images": "$[{'artery':a, 'vein':b, 'excret':c }for a,b,c in zip(glob.glob(@dataset_dir + '/*/12.nii.gz'), glob.glob(@dataset_dir + '/*/22-.nii.gz'), glob.glob(@dataset_dir + '/*/32-.nii.gz'))]", |
|
"labels": "$list(glob.glob(@dataset_dir + '/*/merged.nii.gz'))", |
|
"val_interval": 50, |
|
"dont_finetune": true, |
|
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')", |
|
"network_def": { |
|
"_target_": "SegResNet", |
|
"in_channels": 3, |
|
"out_channels": 6, |
|
"init_filters": 32, |
|
"upsample_mode": "deconv", |
|
"dropout_prob": 0.2, |
|
"norm_name": "group", |
|
"blocks_down": [ |
|
1, |
|
2, |
|
2, |
|
4 |
|
], |
|
"blocks_up": [ |
|
1, |
|
1, |
|
1 |
|
] |
|
}, |
|
"network": "$@network_def.to(@device)", |
|
"loss": { |
|
"_target_": "DiceLoss", |
|
"include_background": false, |
|
"to_onehot_y": true, |
|
"sigmoid": true, |
|
"softmax": false, |
|
"squared_pred": false, |
|
"jaccard": false, |
|
"reduction": "mean", |
|
"smooth_nr": 0.0, |
|
"smooth_dr": 1e-05, |
|
"batch": false |
|
}, |
|
"optimizer": { |
|
"_target_": "Novograd", |
|
"params": "$@network.parameters()", |
|
"lr": 0.001, |
|
"betas": [ |
|
0.9, |
|
0.98 |
|
], |
|
"eps": 1e-08, |
|
"weight_decay": 0, |
|
"grad_averaging": false, |
|
"amsgrad": false |
|
}, |
|
"train": { |
|
"deterministic_transforms": [ |
|
{ |
|
"_target_": "LoadImaged", |
|
"keys": [ |
|
"artery", |
|
"vein", |
|
"excret", |
|
"label" |
|
], |
|
"reader": null, |
|
"overwriting": false, |
|
"dtype": "float32", |
|
"as_closest_canonical": true |
|
}, |
|
{ |
|
"_target_": "EnsureChannelFirstd", |
|
"keys": [ |
|
"artery", |
|
"vein", |
|
"excret", |
|
"label" |
|
] |
|
}, |
|
{ |
|
"_target_": "MapLabelValued", |
|
"keys": "label", |
|
"orig_labels": [ |
|
0, |
|
1, |
|
2, |
|
3, |
|
4, |
|
5, |
|
6 |
|
], |
|
"target_labels": [ |
|
0, |
|
1, |
|
2, |
|
3, |
|
4, |
|
4, |
|
5 |
|
] |
|
}, |
|
{ |
|
"_target_": "ToTensord", |
|
"keys": [ |
|
"artery", |
|
"vein", |
|
"excret", |
|
"label" |
|
] |
|
}, |
|
{ |
|
"_target_": "Spacingd", |
|
"keys": [ |
|
"artery", |
|
"vein", |
|
"excret", |
|
"label" |
|
], |
|
"pixdim": [ |
|
0.8, |
|
0.8, |
|
0.8 |
|
], |
|
"mode": [ |
|
"bilinear", |
|
"bilinear", |
|
"bilinear", |
|
"nearest" |
|
] |
|
}, |
|
{ |
|
"_target_": "ScaleIntensityRanged", |
|
"keys": [ |
|
"artery", |
|
"vein", |
|
"excret" |
|
], |
|
"a_min": -1000, |
|
"a_max": 1000, |
|
"b_min": 0.0, |
|
"b_max": 1.0, |
|
"clip": true |
|
}, |
|
{ |
|
"_target_": "scripts.my_transforms.ConcatImages", |
|
"keys_merge": [ |
|
"artery", |
|
"vein", |
|
"excret" |
|
], |
|
"keys_out": "image" |
|
}, |
|
{ |
|
"_target_": "ToTensord", |
|
"keys": [ |
|
"image" |
|
] |
|
} |
|
], |
|
"random_transforms": [ |
|
{ |
|
"_target_": "RandZoomd", |
|
"keys": [ |
|
"image", |
|
"label" |
|
], |
|
"prob": 0.3 |
|
}, |
|
{ |
|
"_target_": "RandAxisFlipd", |
|
"keys": [ |
|
"image", |
|
"label" |
|
], |
|
"prob": 0.3 |
|
}, |
|
{ |
|
"_target_": "RandRotate90d", |
|
"keys": [ |
|
"image", |
|
"label" |
|
], |
|
"prob": 0.3 |
|
}, |
|
{ |
|
"_target_": "RandAdjustContrastd", |
|
"keys": [ |
|
"image" |
|
], |
|
"prob": 0.5 |
|
}, |
|
{ |
|
"_target_": "RandHistogramShiftd", |
|
"keys": "image", |
|
"num_control_points": 10, |
|
"prob": 0.3 |
|
}, |
|
{ |
|
"_target_": "DivisiblePadd", |
|
"keys": [ |
|
"image", |
|
"label" |
|
], |
|
"k": 32 |
|
}, |
|
{ |
|
"_target_": "RandCropByLabelClassesd", |
|
"keys": [ |
|
"image", |
|
"label" |
|
], |
|
"label_key": "label", |
|
"num_classes": 6, |
|
"spatial_size": [ |
|
96, |
|
96, |
|
96 |
|
], |
|
"ratios": [ |
|
1, |
|
2, |
|
2, |
|
3, |
|
3, |
|
1 |
|
], |
|
"num_samples": 4 |
|
} |
|
], |
|
"preprocessing": { |
|
"_target_": "Compose", |
|
"transforms": "$@train#deterministic_transforms + @train#random_transforms" |
|
}, |
|
"dataset": { |
|
"_target_": "CacheDataset", |
|
"data": "$[{'label': l, **i} for i, l in zip(@images, @labels)]", |
|
"transform": "@train#preprocessing", |
|
"cache_rate": 1.0, |
|
"num_workers": 4 |
|
}, |
|
"dataloader": { |
|
"_target_": "DataLoader", |
|
"dataset": "@train#dataset", |
|
"batch_size": 1, |
|
"shuffle": true, |
|
"num_workers": 2 |
|
}, |
|
"inferer": { |
|
"_target_": "SimpleInferer" |
|
}, |
|
"postprocessing": { |
|
"_target_": "Compose", |
|
"transforms": [ |
|
{ |
|
"_target_": "Activationsd", |
|
"keys": "pred", |
|
"softmax": false, |
|
"sigmoid": true |
|
}, |
|
{ |
|
"_target_": "AsDiscreted", |
|
"keys": [ |
|
"pred", |
|
"label" |
|
], |
|
"argmax": [ |
|
false, |
|
false |
|
], |
|
"to_onehot": [ |
|
null, |
|
6 |
|
], |
|
"threshold": [ |
|
0.5, |
|
null |
|
] |
|
}, |
|
{ |
|
"_target_": "SplitChanneld", |
|
"keys": [ |
|
"pred", |
|
"label" |
|
], |
|
"output_postfixes": [ |
|
"bck", |
|
"ar", |
|
"ve", |
|
"ur", |
|
"tu", |
|
"ki" |
|
] |
|
} |
|
] |
|
}, |
|
"handlers": [ |
|
{ |
|
"_target_": "CheckpointLoader", |
|
"_disabled_": "@dont_finetune", |
|
"load_path": "$@ckpt_dir + '/model.pt'", |
|
"load_dict": { |
|
"model": "@network" |
|
} |
|
}, |
|
{ |
|
"_target_": "ValidationHandler", |
|
"validator": "@validate#evaluator", |
|
"epoch_level": true, |
|
"interval": "@val_interval" |
|
}, |
|
{ |
|
"_target_": "StatsHandler", |
|
"tag_name": "train_loss", |
|
"output_transform": "$monai.handlers.from_engine(['loss'], first=True)" |
|
}, |
|
{ |
|
"_target_": "TensorBoardStatsHandler", |
|
"log_dir": "@output_dir", |
|
"tag_name": "train_loss", |
|
"output_transform": "$monai.handlers.from_engine(['loss'], first=True)" |
|
} |
|
], |
|
"key_metric": { |
|
"train/mean_dice": { |
|
"_target_": "MeanDice", |
|
"include_background": false, |
|
"output_transform": "$monai.handlers.from_engine(['pred', 'label'])" |
|
} |
|
}, |
|
"additional_metrics": { |
|
"train/tu_dice": { |
|
"_target_": "MeanDice", |
|
"include_background": true, |
|
"output_transform": "$monai.handlers.from_engine(['pred_tu', 'label_tu'])" |
|
} |
|
}, |
|
"trainer": { |
|
"_target_": "SupervisedTrainer", |
|
"max_epochs": 10000, |
|
"device": "@device", |
|
"train_data_loader": "@train#dataloader", |
|
"network": "@network", |
|
"loss_function": "@loss", |
|
"optimizer": "@optimizer", |
|
"inferer": "@train#inferer", |
|
"postprocessing": "@train#postprocessing", |
|
"key_train_metric": "@train#key_metric", |
|
"train_handlers": "@train#handlers", |
|
"additional_metrics": "@train#additional_metrics", |
|
"amp": true |
|
} |
|
}, |
|
"validate": { |
|
"preprocessing": { |
|
"_target_": "Compose", |
|
"transforms": "$@train#deterministic_transforms" |
|
}, |
|
"dataset": { |
|
"_target_": "CacheDataset", |
|
"data": "$[{'label': l, **i} for i, l in zip(@images, @labels)]", |
|
"transform": "@validate#preprocessing", |
|
"cache_rate": 1.0 |
|
}, |
|
"dataloader": { |
|
"_target_": "DataLoader", |
|
"dataset": "@validate#dataset", |
|
"batch_size": 1, |
|
"shuffle": false, |
|
"num_workers": 4 |
|
}, |
|
"inferer": { |
|
"_target_": "SlidingWindowInferer", |
|
"roi_size": [ |
|
96, |
|
96, |
|
96 |
|
], |
|
"sw_batch_size": 4, |
|
"overlap": 0.25 |
|
}, |
|
"postprocessing": { |
|
"_target_": "Compose", |
|
"transforms": [ |
|
{ |
|
"_target_": "Invertd", |
|
"transform": "%validate#preprocessing", |
|
"device": "@device", |
|
"keys": [ |
|
"pred", |
|
"label" |
|
], |
|
"orig_keys": [ |
|
"artery", |
|
"label" |
|
], |
|
"meta_keys": [ |
|
"pred_meta_dict", |
|
"label_meta_dict" |
|
], |
|
"nearest_interp": [ |
|
false, |
|
true |
|
], |
|
"to_tensor": true |
|
}, |
|
"%train#postprocessing#transforms#0", |
|
"%train#postprocessing#transforms#1", |
|
"%train#postprocessing#transforms#2" |
|
] |
|
}, |
|
"handlers": [ |
|
{ |
|
"_target_": "StatsHandler", |
|
"iteration_log": false |
|
}, |
|
{ |
|
"_target_": "TensorBoardStatsHandler", |
|
"log_dir": "@output_dir", |
|
"iteration_log": false |
|
}, |
|
{ |
|
"_target_": "CheckpointSaver", |
|
"save_dir": "@ckpt_dir", |
|
"save_dict": { |
|
"model": "@network" |
|
}, |
|
"save_key_metric": true, |
|
"key_metric_filename": "model.pt" |
|
} |
|
], |
|
"key_metric": { |
|
"val_mean_dice": { |
|
"_target_": "MeanDice", |
|
"include_background": false, |
|
"output_transform": "$monai.handlers.from_engine(['pred', 'label'])" |
|
} |
|
}, |
|
"additional_metrics": { |
|
"ar/dice": { |
|
"_target_": "MeanDice", |
|
"include_background": false, |
|
"output_transform": "$monai.handlers.from_engine(['pred_ar', 'label_ar'])" |
|
}, |
|
"ve/dice": { |
|
"_target_": "MeanDice", |
|
"include_background": false, |
|
"output_transform": "$monai.handlers.from_engine(['pred_ve', 'label_ve'])" |
|
}, |
|
"ur/dice": { |
|
"_target_": "MeanDice", |
|
"include_background": false, |
|
"output_transform": "$monai.handlers.from_engine(['pred_ur', 'label_ur'])" |
|
}, |
|
"ki/dice": { |
|
"_target_": "MeanDice", |
|
"include_background": false, |
|
"output_transform": "$monai.handlers.from_engine(['pred_ki', 'label_ki'])" |
|
}, |
|
"tu/dice": { |
|
"_target_": "MeanDice", |
|
"include_background": false, |
|
"output_transform": "$monai.handlers.from_engine(['pred_tu', 'label_tu'])" |
|
}, |
|
"tu/haunsdorff": { |
|
"_target_": "HausdorffDistance", |
|
"include_background": false, |
|
"output_transform": "$monai.handlers.from_engine(['pred_tu', 'label_tu'])" |
|
}, |
|
"tu/surface": { |
|
"_target_": "SurfaceDistance", |
|
"include_background": false, |
|
"output_transform": "$monai.handlers.from_engine(['pred_tu', 'label_tu'])" |
|
} |
|
}, |
|
"evaluator": { |
|
"_target_": "SupervisedEvaluator", |
|
"device": "@device", |
|
"val_data_loader": "@validate#dataloader", |
|
"network": "@network", |
|
"inferer": "@validate#inferer", |
|
"postprocessing": "@validate#postprocessing", |
|
"key_val_metric": "@validate#key_metric", |
|
"additional_metrics": "@validate#additional_metrics", |
|
"val_handlers": "@validate#handlers", |
|
"amp": true |
|
} |
|
}, |
|
"training": [ |
|
"$monai.utils.set_determinism(seed=42)", |
|
"$setattr(torch.backends.cudnn, 'benchmark', True)", |
|
"$@train#trainer.run()" |
|
] |
|
} |
|
|