diff --git a/monai/apps/detection/utils/anchor_utils.py b/monai/apps/detection/utils/anchor_utils.py index 7f11302d0a..5821c0c353 100644 --- a/monai/apps/detection/utils/anchor_utils.py +++ b/monai/apps/detection/utils/anchor_utils.py @@ -234,7 +234,8 @@ def grid_anchors(self, grid_sizes: List[List[int]], strides: List[List[Tensor]]) """ anchors = [] cell_anchors = self.cell_anchors - assert cell_anchors is not None + if cell_anchors is None: + raise AssertionError if not (len(grid_sizes) == len(strides) == len(cell_anchors)): raise ValueError( diff --git a/monai/networks/blocks/feature_pyramid_network.py b/monai/networks/blocks/feature_pyramid_network.py index 09ed2c6e20..2f7b903a19 100644 --- a/monai/networks/blocks/feature_pyramid_network.py +++ b/monai/networks/blocks/feature_pyramid_network.py @@ -197,7 +197,8 @@ def __init__( nn.init.constant_(m.bias, 0.0) # type: ignore if extra_blocks is not None: - assert isinstance(extra_blocks, ExtraFPNBlock) + if not isinstance(extra_blocks, ExtraFPNBlock): + raise AssertionError self.extra_blocks = extra_blocks def get_result_from_inner_blocks(self, x: Tensor, idx: int) -> Tensor: