Skip to content

Commit

Permalink
558 Update brats seg to use seperated CheckpointLoader (Project-MONAI…
Browse files Browse the repository at this point in the history
…#559)

Fixes Project-MONAI#558 .

### Description
A few sentences describing the changes proposed in this pull request.

### Status
**Ready/Work in progress/Hold**

### Please ensure all the checkboxes:
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Codeformat tests passed locally by running `./runtests.sh
--codeformat`.
- [ ] In-line docstrings updated.
- [ ] Update `version` and `changelog` in `metadata.json` if changing an
existing bundle.
- [ ] Please ensure the naming rules in config files meet our
requirements (please refer to: `CONTRIBUTING.md`).
- [ ] Ensure versions of packages such as `monai`, `pytorch` and `numpy`
are correct in `metadata.json`.
- [ ] Descriptions should be consistent with the content, such as
`eval_metrics` of the provided weights and TorchScript modules.
- [ ] Files larger than 25MB are excluded and replaced by providing
download links in `large_file.yml`.
- [ ] Avoid using path that contains personal information within config
files (such as use `/home/your_name/` for `"bundle_root"`).

---------

Signed-off-by: Yiheng Wang <[email protected]>
  • Loading branch information
yiheng-wang-nv authored Feb 20, 2024
1 parent 4c78c3a commit 5f26706
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
35 changes: 22 additions & 13 deletions models/brats_mri_segmentation/configs/inference.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{
"imports": [
"$import glob",
"$import numpy",
"$import os"
],
"bundle_root": ".",
"image_key": "image",
"ckpt_dir": "$@bundle_root + '/models'",
"output_dir": "$@bundle_root + '/eval'",
"output_ext": ".nii.gz",
"output_dtype": "uint8",
"output_postfix": "seg",
"separate_folder": true,
"data_list_file_path": "$@bundle_root + '/configs/datalist.json'",
"dataset_dir": "/workspace/data/medical/brats2018challenge",
"test_datalist": "$monai.data.load_decathlon_datalist(@data_list_file_path, data_list_key='testing', base_dir=@dataset_dir)",
Expand Down Expand Up @@ -35,12 +41,12 @@
"transforms": [
{
"_target_": "LoadImaged",
"keys": "image",
"keys": "@image_key",
"image_only": false
},
{
"_target_": "NormalizeIntensityd",
"keys": "image",
"keys": "@image_key",
"nonzero": true,
"channel_wise": true
}
Expand Down Expand Up @@ -80,7 +86,7 @@
"_target_": "Invertd",
"keys": "pred",
"transform": "@preprocessing",
"orig_keys": "image",
"orig_keys": "@image_key",
"meta_keys": "pred_meta_dict",
"nearest_interp": false,
"to_tensor": true
Expand All @@ -100,21 +106,16 @@
"keys": "pred",
"meta_keys": "pred_meta_dict",
"output_dir": "@output_dir",
"output_postfix": "seg",
"output_dtype": "uint8",
"output_ext": "@output_ext",
"output_dtype": "@output_dtype",
"output_postfix": "@output_postfix",
"separate_folder": "@separate_folder",
"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
Expand All @@ -130,8 +131,16 @@
"val_handlers": "@handlers",
"amp": true
},
"checkpointloader": {
"_target_": "CheckpointLoader",
"load_path": "$@bundle_root + '/models/model.pt'",
"load_dict": {
"model": "@network"
}
},
"initialize": [
"$setattr(torch.backends.cudnn, 'benchmark', True)"
"$setattr(torch.backends.cudnn, 'benchmark', True)",
"$@checkpointloader(@evaluator)"
],
"run": [
"[email protected]()"
Expand Down
6 changes: 4 additions & 2 deletions models/brats_mri_segmentation/configs/inference_trt.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"$import os",
"$import torch_tensorrt"
],
"handlers#0#_disabled_": true,
"network_def": "$torch.jit.load(@bundle_root + '/models/model_trt.ts')",
"evaluator#amp": false
"evaluator#amp": false,
"initialize": [
"$monai.utils.set_determinism(seed=123)"
]
}
3 changes: 2 additions & 1 deletion models/brats_mri_segmentation/configs/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
"version": "0.4.8",
"version": "0.4.9",
"changelog": {
"0.4.9": "add checkpoint loader for infer",
"0.4.8": "fix the wrong GPU index issue of multi-node",
"0.4.7": "enhance prepare datalist file",
"0.4.6": "add dataset dir example",
Expand Down

0 comments on commit 5f26706

Please sign in to comment.