Skip to content

Commit ede6ace

Browse files
Throw exception on invalid images in retinanet detector (#8515)
Fixes # . ### Description This small PR throws an exception on invalid images in retinanet detector. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [x] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [x] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Corrected an issue where an exception was not properly raised for unsupported image dimensions. * **Documentation** * Fixed a typo in the method description to improve clarity. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com> Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
1 parent 1dc0e68 commit ede6ace

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

monai/apps/detection/networks/retinanet_detector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def set_atss_matcher(self, num_candidates: int = 4, center_in_gt: bool = False)
357357
num_candidates: number of positions to select candidates from.
358358
Smaller value will result in a higher matcher threshold and less matched candidates.
359359
center_in_gt: If False (default), matched anchor center points do not need
360-
to lie withing the ground truth box. Recommend False for small objects.
360+
to lie within the ground truth box. Recommend False for small objects.
361361
If True, will result in a strict matcher and less matched candidates.
362362
"""
363363
self.proposal_matcher = ATSSMatcher(num_candidates, self.box_overlap_metric, center_in_gt, debug=self.debug)
@@ -611,7 +611,7 @@ def _reshape_maps(self, result_maps: list[Tensor]) -> Tensor:
611611
elif self.spatial_dims == 3:
612612
reshaped_result_map = reshaped_result_map.permute(0, 3, 4, 5, 1, 2)
613613
else:
614-
ValueError("Images can only be 2D or 3D.")
614+
raise ValueError("Images can only be 2D or 3D.")
615615

616616
# reshaped_result_map will become (B, HWA, num_channel) or (B, HWDA, num_channel)
617617
reshaped_result_map = reshaped_result_map.reshape(batch_size, -1, num_channel)

0 commit comments

Comments
 (0)