Skip to content
mask_rcnn(pretrained: bool | str = False, weights: MaskRCNNResNet50FPNWeights | None = None, overrides: object = {})

Mask R-CNN with a ResNet-50-FPN backbone (He et al., ICCV 2017).

Alias of mask_rcnn_resnet50_fpn — the canonical reference configuration: Faster R-CNN's ResNet-50 trunk (frozen BN) + Feature Pyramid Network + Region Proposal Network + Fast R-CNN box head, plus a parallel FCN mask branch. The COCO config uses num_classes = 91. Reaches COCO box AP 37.9 / mask AP 34.6 (reference maskrcnn_resnet50_fpn).

Model Size

Parameters

pretrainedbool or str= False
Pretrained-weight selector. False → random init; True → the DEFAULT tag (MaskRCNNResNet50FPNWeights.COCO_V1); a tag string → that specific checkpoint. Mutually exclusive with weights (which wins if both are given).
weights(MaskRCNNResNet50FPNWeights, optional, keyword - only)= None
Explicit weights enum member. Takes precedence over pretrained.
**overridesobject= {}
Keyword overrides forwarded into MaskRCNNConfig (num_classes, rpn_pre_nms_top_n, score_thresh, ...).

Returns

MaskRCNNForObjectDetection

Detector with the ResNet-50-FPN configuration applied (or with overrides merged on top of it).

Examples

>>> import lucid
>>> from lucid.models.vision.mask_rcnn import mask_rcnn
>>> model = mask_rcnn(num_classes=91).eval()
>>> x = lucid.randn(1, 3, 224, 224)
>>> out = model(x)
>>> out.pred_masks.shape[-2:]
(28, 28)

Used by 1