| { | |
| "displayable_configs": { | |
| "highres": true, | |
| "sw_overlap": 0.25, | |
| "sw_batch_size": 1 | |
| }, | |
| "imports": [ | |
| "$import glob", | |
| "$import numpy", | |
| "$import os" | |
| ], | |
| "bundle_root": ".", | |
| "image_key": "image", | |
| "output_dir": "$@bundle_root + '/eval'", | |
| "output_ext": ".nii.gz", | |
| "output_dtype": "$numpy.float32", | |
| "output_postfix": "trans", | |
| "separate_folder": true, | |
| "load_pretrain": true, | |
| "dataset_dir": "sampledata", | |
| "datalist": "$list(sorted(glob.glob(@dataset_dir + '/imagesTs/*.nii.gz')))", | |
| "device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')", | |
| "pixdim": "$[1.5, 1.5, 1.5] if @displayable_configs#highres else [3.0, 3.0, 3.0]", | |
| "modelname": "$'model.pt' if @displayable_configs#highres else 'model_lowres.pt'", | |
| "network_def": { | |
| "_target_": "SegResNet", | |
| "spatial_dims": 3, | |
| "in_channels": 1, | |
| "out_channels": 105, | |
| "init_filters": 32, | |
| "blocks_down": [ | |
| 1, | |
| 2, | |
| 2, | |
| 4 | |
| ], | |
| "blocks_up": [ | |
| 1, | |
| 1, | |
| 1 | |
| ], | |
| "dropout_prob": 0.2 | |
| }, | |
| "network": "$@network_def.to(@device)", | |
| "preprocessing": { | |
| "_target_": "Compose", | |
| "transforms": [ | |
| { | |
| "_target_": "LoadImaged", | |
| "keys": "@image_key" | |
| }, | |
| { | |
| "_target_": "EnsureTyped", | |
| "keys": "@image_key" | |
| }, | |
| { | |
| "_target_": "EnsureChannelFirstd", | |
| "keys": "@image_key" | |
| }, | |
| { | |
| "_target_": "Orientationd", | |
| "keys": "@image_key", | |
| "axcodes": "RAS" | |
| }, | |
| { | |
| "_target_": "Spacingd", | |
| "keys": "@image_key", | |
| "pixdim": "@pixdim", | |
| "mode": "bilinear" | |
| }, | |
| { | |
| "_target_": "NormalizeIntensityd", | |
| "keys": "@image_key", | |
| "nonzero": true | |
| }, | |
| { | |
| "_target_": "ScaleIntensityd", | |
| "keys": "@image_key", | |
| "minv": -1.0, | |
| "maxv": 1.0 | |
| } | |
| ] | |
| }, | |
| "dataset": { | |
| "_target_": "Dataset", | |
| "data": "$[{'image': i} for i in @datalist]", | |
| "transform": "@preprocessing" | |
| }, | |
| "dataloader": { | |
| "_target_": "DataLoader", | |
| "dataset": "@dataset", | |
| "batch_size": 1, | |
| "shuffle": false, | |
| "num_workers": 1 | |
| }, | |
| "inferer": { | |
| "_target_": "SlidingWindowInferer", | |
| "roi_size": [ | |
| 96, | |
| 96, | |
| 96 | |
| ], | |
| "sw_batch_size": "@displayable_configs#sw_batch_size", | |
| "overlap": "@displayable_configs#sw_overlap", | |
| "padding_mode": "replicate", | |
| "mode": "gaussian", | |
| "device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')" | |
| }, | |
| "postprocessing": { | |
| "_target_": "Compose", | |
| "transforms": [ | |
| { | |
| "_target_": "Activationsd", | |
| "keys": "pred", | |
| "softmax": true | |
| }, | |
| { | |
| "_target_": "AsDiscreted", | |
| "keys": "pred", | |
| "argmax": true | |
| }, | |
| { | |
| "_target_": "Invertd", | |
| "keys": "pred", | |
| "transform": "@preprocessing", | |
| "orig_keys": "@image_key", | |
| "nearest_interp": true, | |
| "to_tensor": true | |
| }, | |
| { | |
| "_target_": "SaveImaged", | |
| "keys": "pred", | |
| "output_dir": "@output_dir", | |
| "output_ext": "@output_ext", | |
| "output_dtype": "@output_dtype", | |
| "output_postfix": "@output_postfix", | |
| "separate_folder": "@separate_folder" | |
| } | |
| ] | |
| }, | |
| "handlers": [ | |
| { | |
| "_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 | |
| }, | |
| "checkpointloader": { | |
| "_target_": "CheckpointLoader", | |
| "load_path": "$@bundle_root + '/models/' + @modelname", | |
| "load_dict": { | |
| "model": "@network" | |
| } | |
| }, | |
| "initialize": [ | |
| "$setattr(torch.backends.cudnn, 'benchmark', True)", | |
| "$@checkpointloader(@evaluator) if @load_pretrain else None" | |
| ], | |
| "run": [ | |
| "$@evaluator.run()" | |
| ] | |
| } | |