Skip to content

Commit

Permalink
481 rotation of output images in prostate mri anatomy (#482)
Browse files Browse the repository at this point in the history
### 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]>
  • Loading branch information
FaresAlMohamad authored Aug 29, 2023
1 parent e6ecc28 commit 3126f3c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
17 changes: 15 additions & 2 deletions models/prostate_mri_anatomy/configs/inference.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
],
"bundle_root": "/workspace/data/prostate_mri_anatomy",
"output_dir": "$@bundle_root + '/eval'",
"dataset_dir": "/workspace/data/prostate158/prostate158_train/",
"datalist": "$list(@dataset_dir + pd.read_csv(@dataset_dir + 'valid.csv').t2)",
"dataset_dir": "/workspace/data/prostate158/prostate158_test/",
"datalist": "$list(@dataset_dir + pd.read_csv(@dataset_dir + 'test.csv').t2)",
"device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
"network_def": {
"_target_": "UNet",
Expand Down Expand Up @@ -114,6 +114,15 @@
2
]
},
{
"_target_": "Invertd",
"keys": "pred",
"transform": "@preprocessing",
"orig_keys": "image",
"meta_key_postfix": "meta_dict",
"nearest_interp": false,
"to_tensor": true
},
{
"_target_": "SaveImaged",
"keys": "pred",
Expand All @@ -127,6 +136,10 @@
{
"_target_": "CheckpointLoader",
"load_path": "$@bundle_root + '/models/model.pt'",
"map_location": {
"_target_": "torch.device",
"device": "@device"
},
"load_dict": {
"model": "@network"
}
Expand Down
5 changes: 3 additions & 2 deletions models/prostate_mri_anatomy/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.3.2",
"version": "0.3.3",
"changelog": {
"0.3.3": "add invertd transformation",
"0.3.2": "add name tag",
"0.3.1": "fix license Copyright error",
"0.3.0": "update license files",
Expand All @@ -14,7 +15,7 @@
"numpy_version": "1.22.3",
"optional_packages_version": {
"nibabel": "3.2.2",
"itk": "5.2.1",
"itk": "5.3",
"pytorch-ignite": "0.4.9",
"pandas": "1.4.2"
},
Expand Down

0 comments on commit 3126f3c

Please sign in to comment.