facebookresearch/detectron2 · error · NotImplementedError

anchor_boundary_thresh is a legacy option not implemented fo

Error message

anchor_boundary_thresh is a legacy option not implemented for RRPN.

What it means

RRPN (Rotated RPN) does not support the legacy anchor_boundary_thresh option. The constructor explicitly rejects any non-negative value because clipping anchors to image boundaries was never ported to the rotated proposal generator.

Source

Thrown at detectron2/modeling/proposal_generator/rrpn.py:140

        res = Instances(image_size)
        res.proposal_boxes = boxes[keep]
        res.objectness_logits = scores_per_img[keep]
        results.append(res)
    return results


@PROPOSAL_GENERATOR_REGISTRY.register()
class RRPN(RPN):
    """
    Rotated Region Proposal Network described in :paper:`RRPN`.
    """

    @configurable
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        if self.anchor_boundary_thresh >= 0:
            raise NotImplementedError(
                "anchor_boundary_thresh is a legacy option not implemented for RRPN."
            )

    @classmethod
    def from_config(cls, cfg, input_shape: Dict[str, ShapeSpec]):
        ret = super().from_config(cfg, input_shape)
        ret["box2box_transform"] = Box2BoxTransformRotated(weights=cfg.MODEL.RPN.BBOX_REG_WEIGHTS)
        return ret

    @torch.no_grad()
    def label_and_sample_anchors(self, anchors: List[RotatedBoxes], gt_instances: List[Instances]):
        """
        Args:
            anchors (list[RotatedBoxes]): anchors for each feature map.
            gt_instances: the ground-truth instances for each image.

        Returns:
            list[Tensor]:

View on GitHub (pinned to a2f4a8771a)

Solutions

  1. Set cfg.MODEL.RPN.BOUNDARY_THRESH = -1 to disable boundary clipping (the only supported value for RRPN)
  2. Remove the BOUNDARY_THRESH key from your config
  3. Use RPN instead of RRPN if boundary clipping is required

Example fix

# before
cfg.MODEL.RPN.BOUNDARY_THRESH = 10
# after
cfg.MODEL.RPN.BOUNDARY_THRESH = -1
Defensive patterns

Strategy: validation

Validate before calling

assert cfg.MODEL.RPN.BOUNDARY_THRESH == -1 or cfg.MODEL.PROPOSAL_GENERATOR.NAME != 'RRPN', 'RRPN requires BOUNDARY_THRESH = -1'

Prevention

When it happens

Trigger: Constructing an RRPN (e.g. via cfg.MODEL.PROPOSAL_GENERATOR.NAME = 'RRPN') with cfg.MODEL.RPN.BOUNDARY_THRESH >= 0, then building the model; __init__ raises immediately.

Common situations: Copying a config from a standard Detectron/Faster R-CNN setup that sets SOLVER/RPN.BOUNDARY_THRESH, or using rotated-box detection (RRPN) with an old config dump.

Related errors


AI-assisted analysis of facebookresearch/detectron2@a2f4a8771a (2026-08-27). Data as JSON: /api/errors/1108564a487e260a. Report an issue: GitHub.