Skip to content

Commit

Permalink
Add option to validate at training start of deepedit (#515)
Browse files Browse the repository at this point in the history
### Description

Modify bundle as the new feature enabled in
Project-MONAI/MONAI@fc1350a

### 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: Mingxin Zheng <[email protected]>
Signed-off-by: KumoLiu <[email protected]>
Co-authored-by: KumoLiu <[email protected]>
  • Loading branch information
mingxin-zheng and KumoLiu authored Oct 11, 2023
1 parent a9acb18 commit 28926e2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
3 changes: 1 addition & 2 deletions models/spleen_deepedit_annotation/configs/evaluate.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"_target_": "SaveImaged",
"_disabled_": true,
"keys": "pred",
"meta_keys": "pred_meta_dict",
"output_dir": "@output_dir",
"resample": false,
"squeeze_end_dims": true
Expand Down Expand Up @@ -53,7 +52,7 @@
"metric_details": [
"val_mean_dice"
],
"batch_transform": "$monai.handlers.from_engine(['image_meta_dict'])",
"batch_transform": "$lambda x: [xx['image'].meta for xx in x]",
"summary_ops": "*"
}
],
Expand Down
36 changes: 22 additions & 14 deletions models/spleen_deepedit_annotation/configs/inference.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{
"imports": [
"$import glob",
"$import numpy",
"$import os",
"$import ignite"
],
"bundle_root": ".",
"image_key": "image",
"output_dir": "$@bundle_root + '/eval'",
"output_ext": ".nii.gz",
"output_dtype": "$numpy.float32",
"output_postfix": "trans",
"separate_folder": true,
"dataset_dir": "/workspace/Datasets/MSD_datasets/Task09_Spleen",
"datalist": "$list(sorted(glob.glob(@dataset_dir + '/imagesTs/*.nii.gz')))",
"label_names": {
Expand Down Expand Up @@ -63,21 +69,21 @@
"preprocessing_transforms": [
{
"_target_": "LoadImaged",
"keys": "image",
"keys": "@image_key",
"reader": "ITKReader"
},
{
"_target_": "EnsureChannelFirstd",
"keys": "image"
"keys": "@image_key"
},
{
"_target_": "Orientationd",
"keys": "image",
"keys": "@image_key",
"axcodes": "RAS"
},
{
"_target_": "ScaleIntensityRanged",
"keys": "image",
"keys": "@image_key",
"a_min": -175,
"a_max": 250,
"b_min": 0.0,
Expand All @@ -88,37 +94,37 @@
"deepedit_transforms": [
{
"_target_": "scripts.transforms.OrientationGuidanceMultipleLabelDeepEditd",
"ref_image": "image",
"ref_image": "@image_key",
"label_names": "@label_names"
},
{
"_target_": "AddGuidanceFromPointsDeepEditd",
"ref_image": "image",
"ref_image": "@image_key",
"guidance": "guidance",
"label_names": "@label_names"
},
{
"_target_": "Resized",
"keys": "image",
"keys": "@image_key",
"spatial_size": "@spatial_size",
"mode": "area"
},
{
"_target_": "ResizeGuidanceMultipleLabelDeepEditd",
"guidance": "guidance",
"ref_image": "image"
"ref_image": "@image_key"
},
{
"_target_": "AddGuidanceSignalDeepEditd",
"keys": "image",
"keys": "@image_key",
"guidance": "guidance",
"number_intensity_ch": "@number_intensity_ch"
}
],
"extra_transforms": [
{
"_target_": "EnsureTyped",
"keys": "image"
"keys": "@image_key"
}
],
"preprocessing": {
Expand Down Expand Up @@ -156,8 +162,7 @@
"_target_": "Invertd",
"keys": "pred",
"transform": "@preprocessing",
"orig_keys": "image",
"meta_key_postfix": "meta_dict",
"orig_keys": "@image_key",
"nearest_interp": false,
"to_tensor": true
},
Expand All @@ -169,8 +174,11 @@
{
"_target_": "SaveImaged",
"keys": "pred",
"meta_keys": "pred_meta_dict",
"output_dir": "@output_dir"
"output_dir": "@output_dir",
"output_ext": "@output_ext",
"output_dtype": "@output_dtype",
"output_postfix": "@output_postfix",
"separate_folder": "@separate_folder"
}
]
},
Expand Down
5 changes: 3 additions & 2 deletions models/spleen_deepedit_annotation/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.5.0",
"version": "0.5.1",
"changelog": {
"0.5.1": "add option to validate at training start, and I/O param entries",
"0.5.0": "enable finetune and early stop",
"0.4.9": "fix orientation issue on clicks",
"0.4.8": "Add infer transforms to manage clicks from viewer",
Expand All @@ -27,7 +28,7 @@
"0.1.0": "complete the model package",
"0.0.1": "initialize the model package structure"
},
"monai_version": "1.2.0",
"monai_version": "1.3.0rc5",
"pytorch_version": "1.13.1",
"numpy_version": "1.22.2",
"optional_packages_version": {
Expand Down
2 changes: 2 additions & 0 deletions models/spleen_deepedit_annotation/configs/train.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"deepgrow_probability_train": 0.4,
"deepgrow_probability_val": 1.0,
"val_interval": 1,
"val_at_start": false,
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
"network_def": {
"_target_": "DynUNet",
Expand Down Expand Up @@ -324,6 +325,7 @@
"_target_": "ValidationHandler",
"validator": "@validate#evaluator",
"epoch_level": true,
"exec_at_start": "@val_at_start",
"interval": "@val_interval"
},
{
Expand Down

0 comments on commit 28926e2

Please sign in to comment.