data
FasterRCNNConfig
extends
ModelConfigFasterRCNNConfig(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_size: int = 7, roi_sampling_ratio: int = 2, roi_representation_size: 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, score_thresh: float = 0.05, nms_thresh: float = 0.5, max_detections: int = 100)Configuration for Faster R-CNN.
Faster R-CNN (Ren et al., NeurIPS 2015) replaces external proposal methods (selective search) with a learned Region Proposal Network (RPN) that shares convolutional features with the detection head. This makes the entire pipeline end-to-end trainable and near real-time.
Architecture overview (ResNet-50-FPN variant): Image → ResNet-50 backbone (frozen BN, C2-C5) → FPN (P2-P5 + pool) FPN levels → RPN head → region proposals (per-level top-k + NMS) FPN levels + proposals → MultiScale RoI Align (7×7) → TwoMLPHead (fc6/fc7) → FastRCNNPredictor (cls + per-class bbox)
Parameters
num_classesint= 91Object classes incl. background (91 for COCO).
in_channelsint= 3Input image channels.
backbone_layerstuple[int, int, int, int]= (3, 4, 6, 3)ResNet bottleneck counts (default 3,4,6,3 = R50).
backbone_bn_epsfloat= 0.0FrozenBatchNorm2d epsilon (reference uses 0).
fpn_out_channelsint= 256Unified FPN channel count (256).
rpn_anchor_sizestuple[int, ...]= (32, 64, 128, 256, 512)One anchor scale per FPN level (5 levels).
rpn_anchor_ratiostuple[float, ...]= (0.5, 1.0, 2.0)Aspect ratios for anchor generation.
rpn_pre_nms_top_nint= 1000Proposals kept per level before NMS (test 1000).
rpn_post_nms_top_nint= 1000Proposals kept per image after NMS (test 1000).
rpn_nms_threshfloat= 0.7RPN NMS IoU threshold.
rpn_min_sizefloat= 0.001Minimum proposal side length (pixels).
rpn_score_threshfloat= 0.0Minimum RPN objectness score.
rpn_fg_iou_threshfloat= 0.7Anchor→GT IoU for foreground assignment.
rpn_bg_iou_threshfloat= 0.3Anchor→GT IoU upper bound for background.
roi_sizeint= 7RoI Align output spatial size (7 → 7×7).
roi_sampling_ratioint= 2RoI Align sub-bin sampling ratio (2).
roi_representation_sizeint= 1024TwoMLPHead hidden width (1024).
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 (10,10,5,5).
canonical_scaleint= 224FPN level-assignment canonical scale (224).
canonical_levelint= 4FPN level-assignment canonical level (4).
score_threshfloat= 0.05Minimum final class score (0.05).
nms_threshfloat= 0.5Per-class NMS IoU threshold (0.5).
max_detectionsint= 100Maximum detections returned per image (100).
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_size: int = 7, roi_sampling_ratio: int = 2, roi_representation_size: 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, score_thresh: float = 0.05, nms_thresh: float = 0.5, max_detections: int = 100)