monai
medical
katielink's picture
update prepare datalist function
9daa8eb
raw
history blame
3.82 kB
{
"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",
"test_datalist": "$monai.data.load_decathlon_datalist(@data_list_file_path, data_list_key='testing', base_dir=@data_file_base_dir)",
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
"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)",
"preprocessing": {
"_target_": "Compose",
"transforms": [
{
"_target_": "LoadImaged",
"keys": "image"
},
{
"_target_": "NormalizeIntensityd",
"keys": "image",
"nonzero": true,
"channel_wise": true
}
]
},
"dataset": {
"_target_": "Dataset",
"data": "@test_datalist",
"transform": "@preprocessing"
},
"dataloader": {
"_target_": "DataLoader",
"dataset": "@dataset",
"batch_size": 1,
"shuffle": true,
"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_": "Invertd",
"keys": "pred",
"transform": "@preprocessing",
"orig_keys": "image",
"meta_keys": "pred_meta_dict",
"nearest_interp": false,
"to_tensor": true
},
{
"_target_": "AsDiscreted",
"keys": "pred",
"threshold": 0.5
},
{
"_target_": "Lambdad",
"keys": "pred",
"func": "$lambda x: torch.where(x[[2]] > 0, 4, torch.where(x[[0]] > 0, 1, torch.where(x[[1]] > 0, 2, 0)))"
},
{
"_target_": "SaveImaged",
"keys": "pred",
"meta_keys": "pred_meta_dict",
"output_dir": "@output_dir",
"output_postfix": "seg",
"output_dtype": "uint8",
"resample": false,
"squeeze_end_dims": true
}
]
},
"handlers": [
{
"_target_": "CheckpointLoader",
"load_path": "$@bundle_root + '/models/model.pt'",
"load_dict": {
"model": "@network"
}
},
{
"_target_": "StatsHandler",
"iteration_log": false
}
],
"evaluator": {
"_target_": "SupervisedEvaluator",
"device": "@device",
"val_data_loader": "@dataloader",
"network": "@network",
"inferer": "@inferer",
"postprocessing": "@postprocessing",
"val_handlers": "@handlers",
"amp": true
},
"evaluating": [
"$setattr(torch.backends.cudnn, 'benchmark', True)",
"$@evaluator.run()"
]
}