data
MaskRCNNConfig
extends
ModelConfigMaskRCNNConfig(num_classes: int = 91, in_channels: int = 3, backbone_layers: tuple[int, int, int, int] = (3, 4, 6, 3), backbone_bn_eps: float = 0.0, fpn_out_channels: int = 256, rpn_anchor_sizes: tuple[int, ...] = (32, 64, 128, 256, 512), rpn_anchor_ratios: tuple[float, ...] = (0.5, 1.0, 2.0), rpn_pre_nms_top_n: int = 1000, rpn_post_nms_top_n: int = 1000, rpn_nms_thresh: float = 0.7, rpn_min_size: float = 0.001, rpn_score_thresh: float = 0.0, rpn_fg_iou_thresh: float = 0.7, rpn_bg_iou_thresh: float = 0.3, roi_det_size: int = 7, roi_sampling_ratio: int = 2, roi_representation: int = 1024, roi_fg_iou_thresh: float = 0.5, roi_bg_iou_thresh: float = 0.5, bbox_reg_weights: tuple[float, float, float, float] = (10.0, 10.0, 5.0, 5.0), canonical_scale: int = 224, canonical_level: int = 4, roi_mask_size: int = 14, mask_hidden_channels: int = 256, mask_num_convs: int = 4, mask_predictor_hidden: int = 256, score_thresh: float = 0.05, nms_thresh: float = 0.5, max_detections: int = 100, mask_thresh: float = 0.5)Configuration for Mask R-CNN.
Mask R-CNN (He et al., ICCV 2017) extends Faster R-CNN with:
- Feature Pyramid Network (FPN) backbone replacing single-scale VGG16.
- RoI Align replacing RoI Pool (eliminating quantisation misalignment).
- A parallel mask branch predicting K binary segmentation masks per RoI.
Parameters
num_classesint= 91Foreground categories (background = class 0).
in_channelsint= 3Input image channels.
backbone_layerstuple[int, int, int, int]= (3, 4, 6, 3)ResNet layer counts (default ResNet-50 = 3,4,6,3).
backbone_bn_epsfloat= 0.0FrozenBatchNorm2d epsilon (reference uses 0).
fpn_out_channelsint= 256Channel width of every FPN output level.
rpn_anchor_sizestuple[int, ...]= (32, 64, 128, 256, 512)One anchor size per FPN level (P2–P6).
rpn_anchor_ratiostuple[float, ...]= (0.5, 1.0, 2.0)Aspect ratios shared across all levels.
rpn_pre_nms_top_nint= 1000Proposals kept per level before NMS.
rpn_post_nms_top_nint= 1000Proposals kept per image after NMS.
rpn_nms_threshfloat= 0.7RPN NMS IoU threshold.
rpn_min_sizefloat= 0.001Minimum proposal side length (feature pixels).
rpn_score_threshfloat= 0.0Minimum objectness score (post-sigmoid).
rpn_fg_iou_threshfloat= 0.7Anchor→GT IoU for foreground label.
rpn_bg_iou_threshfloat= 0.3Anchor→GT IoU upper bound for background.
roi_det_sizeint= 7RoI Align output for detection (7 → 7×7).
roi_sampling_ratioint= 2RoI Align sub-bin sampling ratio (2).
roi_representationint= 1024Hidden size of the 2-FC detection head.
roi_fg_iou_threshfloat= 0.5Proposal→GT IoU for fg assignment.
roi_bg_iou_threshfloat= 0.5Proposal→GT IoU upper bound for bg.
bbox_reg_weightstuple[float, float, float, float]= (10.0, 10.0, 5.0, 5.0)Per-component bbox delta scale.
canonical_scaleint= 224FPN level-assignment canonical scale (224).
canonical_levelint= 4FPN level-assignment canonical level (4).
roi_mask_sizeint= 14RoI Align output for the mask branch (14 → 14×14).
mask_hidden_channelsint= 256Channel width inside the mask FCN.
mask_num_convsint= 4Number of 3×3 convs in the mask head (4).
mask_predictor_hiddenint= 256Channel width of the deconv upsampler (256).
score_threshfloat= 0.05Minimum final class score.
nms_threshfloat= 0.5Per-class NMS IoU threshold.
max_detectionsint= 100Maximum detections returned per image.
mask_threshfloat= 0.5Binarisation threshold applied to mask sigmoid output.
Notes
Image → ResNet-50 (C2–C5, strides 4/8/16/32) ↓ FPN (lateral convs + top-down merging) → [P2, P3, P4, P5, P6] (256ch) P2–P6 → RPN → proposals P2–P5 + proposals → FPN-level assignment → RoI Align (7×7) → 2-FC head → RoI Align (14×14) → Mask head
Used by 3
Constructors
1dunder
__init__
→None__init__(num_classes: int = 91, in_channels: int = 3, backbone_layers: tuple[int, int, int, int] = (3, 4, 6, 3), backbone_bn_eps: float = 0.0, fpn_out_channels: int = 256, rpn_anchor_sizes: tuple[int, ...] = (32, 64, 128, 256, 512), rpn_anchor_ratios: tuple[float, ...] = (0.5, 1.0, 2.0), rpn_pre_nms_top_n: int = 1000, rpn_post_nms_top_n: int = 1000, rpn_nms_thresh: float = 0.7, rpn_min_size: float = 0.001, rpn_score_thresh: float = 0.0, rpn_fg_iou_thresh: float = 0.7, rpn_bg_iou_thresh: float = 0.3, roi_det_size: int = 7, roi_sampling_ratio: int = 2, roi_representation: int = 1024, roi_fg_iou_thresh: float = 0.5, roi_bg_iou_thresh: float = 0.5, bbox_reg_weights: tuple[float, float, float, float] = (10.0, 10.0, 5.0, 5.0), canonical_scale: int = 224, canonical_level: int = 4, roi_mask_size: int = 14, mask_hidden_channels: int = 256, mask_num_convs: int = 4, mask_predictor_hidden: int = 256, score_thresh: float = 0.05, nms_thresh: float = 0.5, max_detections: int = 100, mask_thresh: float = 0.5)