monai
medical
katielink's picture
initialize the model package structure
c53e252
raw
history blame
3.33 kB
{
"imports": [
"$import glob",
"$import json",
"$import pathlib",
"$import os"
],
"bundle_root": "/workspace/data/pathology_nuclei_classification",
"output_dir": "$@bundle_root + '/eval'",
"dataset_dir": "/workspace/data/CoNSePNuclei",
"images": "$list(sorted(glob.glob(@dataset_dir + '/Test/Images/*.png')))[:1]",
"labels": "$list(sorted(glob.glob(@dataset_dir + '/Test/Labels/*.png')))[:1]",
"input_data": "$[{'image': i, 'label': l} for i,l in zip(@images, @labels)]",
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
"network_def": {
"_target_": "DenseNet121",
"spatial_dims": 2,
"in_channels": 4,
"out_channels": 4
},
"network": "$@network_def.to(@device)",
"preprocessing": {
"_target_": "Compose",
"transforms": [
{
"_target_": "LoadImaged",
"keys": [
"image",
"label"
],
"dtype": "uint8"
},
{
"_target_": "EnsureChannelFirstd",
"keys": [
"image",
"label"
]
},
{
"_target_": "ScaleIntensityRanged",
"keys": "image",
"a_min": 0.0,
"a_max": 255.0,
"b_min": -1.0,
"b_max": 1.0
},
{
"_target_": "AddLabelAsGuidanced",
"keys": "image",
"source": "label"
}
]
},
"dataset": {
"_target_": "Dataset",
"data": "@input_data",
"transform": "@preprocessing"
},
"dataloader": {
"_target_": "DataLoader",
"dataset": "@dataset",
"batch_size": 1,
"shuffle": false,
"num_workers": 4
},
"inferer": {
"_target_": "SimpleInferer"
},
"postprocessing": {
"_target_": "Compose",
"transforms": [
{
"_target_": "Activationsd",
"keys": "pred",
"softmax": true
},
{
"_target_": "SaveImaged",
"keys": "pred",
"meta_keys": "pred_meta_dict",
"output_dir": "@output_dir",
"output_ext": ".json"
}
]
},
"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)",
"$import scripts",
"$monai.data.register_writer('json', scripts.ClassificationWriter)",
"[email protected]()"
]
}