{ "imports": [ "$import glob", "$import os" ], "bundle_root": ".", "ckpt_dir": "$@bundle_root + '/models'", "output_dir": "$@bundle_root + '/eval'", "data_list_file_path": "$@bundle_root + '/configs/datalist.json'", "data_file_base_dir": "/workspace/data/medical/brats2018challenge", "train_datalist": "$monai.data.load_decathlon_datalist(@data_list_file_path, data_list_key='training', base_dir=@data_file_base_dir)", "val_datalist": "$monai.data.load_decathlon_datalist(@data_list_file_path, data_list_key='validation', base_dir=@data_file_base_dir)", "device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')", "epochs": 300, "val_interval": 1, "learning_rate": 0.0001, "amp": true, "network_def": { "_target_": "SegResNet", "blocks_down": [ 1, 2, 2, 4 ], "blocks_up": [ 1, 1, 1 ], "init_filters": 16, "in_channels": 4, "out_channels": 3, "dropout_prob": 0.2 }, "network": "$@network_def.to(@device)", "loss": { "_target_": "DiceLoss", "smooth_nr": 0, "smooth_dr": 1e-05, "squared_pred": true, "to_onehot_y": false, "sigmoid": true }, "optimizer": { "_target_": "torch.optim.Adam", "params": "$@network.parameters()", "lr": "@learning_rate", "weight_decay": 1e-05 }, "lr_scheduler": { "_target_": "torch.optim.lr_scheduler.CosineAnnealingLR", "optimizer": "@optimizer", "T_max": "@epochs" }, "train": { "preprocessing_transforms": [ { "_target_": "LoadImaged", "keys": [ "image", "label" ] }, { "_target_": "ConvertToMultiChannelBasedOnBratsClassesd", "keys": "label" }, { "_target_": "NormalizeIntensityd", "keys": "image", "nonzero": true, "channel_wise": true } ], "random_transforms": [ { "_target_": "RandSpatialCropd", "keys": [ "image", "label" ], "roi_size": [ 224, 224, 144 ], "random_size": false }, { "_target_": "RandFlipd", "keys": [ "image", "label" ], "prob": 0.5, "spatial_axis": 0 }, { "_target_": "RandFlipd", "keys": [ "image", "label" ], "prob": 0.5, "spatial_axis": 1 }, { "_target_": "RandFlipd", "keys": [ "image", "label" ], "prob": 0.5, "spatial_axis": 2 }, { "_target_": "RandScaleIntensityd", "keys": "image", "factors": 0.1, "prob": 1.0 }, { "_target_": "RandShiftIntensityd", "keys": "image", "offsets": 0.1, "prob": 1.0 } ], "preprocessing": { "_target_": "Compose", "transforms": "$@train#preprocessing_transforms + @train#random_transforms" }, "dataset": { "_target_": "Dataset", "data": "@train_datalist", "transform": "@train#preprocessing" }, "dataloader": { "_target_": "DataLoader", "dataset": "@train#dataset", "batch_size": 1, "shuffle": true, "num_workers": 4 }, "inferer": { "_target_": "SimpleInferer" }, "postprocessing": { "_target_": "Compose", "transforms": [ { "_target_": "Activationsd", "keys": "pred", "sigmoid": true }, { "_target_": "AsDiscreted", "keys": "pred", "threshold": 0.5 } ] }, "handlers": [ { "_target_": "LrScheduleHandler", "lr_scheduler": "@lr_scheduler", "print_lr": true }, { "_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": true, "output_transform": "$monai.handlers.from_engine(['pred', 'label'])" } }, "trainer": { "_target_": "SupervisedTrainer", "max_epochs": "@epochs", "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", "amp": "@amp" } }, "validate": { "preprocessing": { "_target_": "Compose", "transforms": "$@train#preprocessing_transforms" }, "dataset": { "_target_": "Dataset", "data": "@val_datalist", "transform": "@validate#preprocessing" }, "dataloader": { "_target_": "DataLoader", "dataset": "@validate#dataset", "batch_size": 1, "shuffle": false, "num_workers": 4 }, "inferer": { "_target_": "SlidingWindowInferer", "roi_size": [ 240, 240, 160 ], "sw_batch_size": 1, "overlap": 0.5 }, "postprocessing": { "_target_": "Compose", "transforms": [ { "_target_": "Activationsd", "keys": "pred", "sigmoid": true }, { "_target_": "AsDiscreted", "keys": "pred", "threshold": 0.5 }, { "_target_": "SplitDimd", "keys": [ "pred", "label" ], "output_postfixes": [ "tc", "wt", "et" ] } ] }, "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": true, "output_transform": "$monai.handlers.from_engine(['pred', 'label'])" } }, "additional_metrics": { "val_mean_dice_tc": { "_target_": "MeanDice", "include_background": true, "output_transform": "$monai.handlers.from_engine(['pred_tc', 'label_tc'])" }, "val_mean_dice_wt": { "_target_": "MeanDice", "include_background": true, "output_transform": "$monai.handlers.from_engine(['pred_wt', 'label_wt'])" }, "val_mean_dice_et": { "_target_": "MeanDice", "include_background": true, "output_transform": "$monai.handlers.from_engine(['pred_et', 'label_et'])" } }, "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": "@amp" } }, "training": [ "$monai.utils.set_determinism(seed=123)", "$setattr(torch.backends.cudnn, 'benchmark', True)", "$@train#trainer.run()" ] }