Skip to content

Commit 33bf33a

Browse files
481 rotation of output images in prostate mri anatomy (Project-MONAI#482)
### Description 481-Rotation of output images in prostate_mri_anatomy - The transformations applied to the test data during preprocessing are not reversed during postprocessing. Thus, the resulting predictions have a different rotation compared to the original images and labels. I added an 'invertd()' function that reverses all the traceable transformations in the preprocessing. - Running the inference on a PC without a GPU leads to an error because the handlers function 'CheckpointLoader' attempts to load the model onto the GPU. I set the map_location argument to torch.device(device) so that it automatically loads the model onto the CPU when a GPU is not available. - Additionally, I changed some of the config directories as they were referring to the validation dataset rather than the test dataset. ### Status Ready ### 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`. - [x] Update `version` and `changelog` in `metadata.json` if changing an existing bundle. - [x] Please ensure the naming rules in config files meet our requirements (please refer to: `CONTRIBUTING.md`). - [x] Ensure versions of packages such as `monai`, `pytorch` and `numpy` are correct in `metadata.json`. - [x] Descriptions should be consistent with the content, such as `eval_metrics` of the provided weights and TorchScript modules. - [x] Files larger than 25MB are excluded and replaced by providing download links in `large_file.yml`. - [x] Avoid using path that contains personal information within config files (such as use `/home/your_name/` for `"bundle_root"`). --------- Signed-off-by: FaresAlMohamad <[email protected]>
1 parent e7b5084 commit 33bf33a

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

models/prostate_mri_anatomy/configs/inference.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
],
66
"bundle_root": "/workspace/data/prostate_mri_anatomy",
77
"output_dir": "$@bundle_root + '/eval'",
8-
"dataset_dir": "/workspace/data/prostate158/prostate158_train/",
9-
"datalist": "$list(@dataset_dir + pd.read_csv(@dataset_dir + 'valid.csv').t2)",
8+
"dataset_dir": "/workspace/data/prostate158/prostate158_test/",
9+
"datalist": "$list(@dataset_dir + pd.read_csv(@dataset_dir + 'test.csv').t2)",
1010
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
1111
"network_def": {
1212
"_target_": "UNet",
@@ -114,6 +114,15 @@
114114
2
115115
]
116116
},
117+
{
118+
"_target_": "Invertd",
119+
"keys": "pred",
120+
"transform": "@preprocessing",
121+
"orig_keys": "image",
122+
"meta_key_postfix": "meta_dict",
123+
"nearest_interp": false,
124+
"to_tensor": true
125+
},
117126
{
118127
"_target_": "SaveImaged",
119128
"keys": "pred",
@@ -127,6 +136,10 @@
127136
{
128137
"_target_": "CheckpointLoader",
129138
"load_path": "$@bundle_root + '/models/model.pt'",
139+
"map_location": {
140+
"_target_": "torch.device",
141+
"device": "@device"
142+
},
130143
"load_dict": {
131144
"model": "@network"
132145
}

models/prostate_mri_anatomy/configs/metadata.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20220324.json",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"changelog": {
5+
"0.3.3": "add invertd transformation",
56
"0.3.2": "add name tag",
67
"0.3.1": "fix license Copyright error",
78
"0.3.0": "update license files",
@@ -14,7 +15,7 @@
1415
"numpy_version": "1.22.3",
1516
"optional_packages_version": {
1617
"nibabel": "3.2.2",
17-
"itk": "5.2.1",
18+
"itk": "5.3",
1819
"pytorch-ignite": "0.4.9",
1920
"pandas": "1.4.2"
2021
},

0 commit comments

Comments
 (0)