From d3317d0a4ee758d69f70f7e330c82fee5947c578 Mon Sep 17 00:00:00 2001 From: Emmanuel Ferdman Date: Sat, 19 Jul 2025 12:38:56 -0700 Subject: [PATCH] Throw exception on invalid images in retinanet detector Signed-off-by: Emmanuel Ferdman --- monai/apps/detection/networks/retinanet_detector.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monai/apps/detection/networks/retinanet_detector.py b/monai/apps/detection/networks/retinanet_detector.py index e996ae81bc..3220f80587 100644 --- a/monai/apps/detection/networks/retinanet_detector.py +++ b/monai/apps/detection/networks/retinanet_detector.py @@ -357,7 +357,7 @@ def set_atss_matcher(self, num_candidates: int = 4, center_in_gt: bool = False) num_candidates: number of positions to select candidates from. Smaller value will result in a higher matcher threshold and less matched candidates. center_in_gt: If False (default), matched anchor center points do not need - to lie withing the ground truth box. Recommend False for small objects. + to lie within the ground truth box. Recommend False for small objects. If True, will result in a strict matcher and less matched candidates. """ 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: elif self.spatial_dims == 3: reshaped_result_map = reshaped_result_map.permute(0, 3, 4, 5, 1, 2) else: - ValueError("Images can only be 2D or 3D.") + raise ValueError("Images can only be 2D or 3D.") # reshaped_result_map will become (B, HWA, num_channel) or (B, HWDA, num_channel) reshaped_result_map = reshaped_result_map.reshape(batch_size, -1, num_channel)