Faster R-CNN M
Fit diagram
Read at 100%
Clear selection
Download SVG
Download PNG
Click a block to read its description, or select it with Tab and Enter.
Faster R-CNN M
800 × 800 RGB canvas; batch 1; eval. COCO: 91 internal slots mapped to 80 classes. R and N are data-dependent counts.
LibreYOLO
Faster R-CNN M
800 × 800 RGB canvas; batch 1; eval. COCO: 91 internal slots mapped to 80 classes. R and N are data-dependent counts.
Input transform
RGB image
Values in [0,1]
Channel normalization
Mean .485/.456/.406; std .229/.224/.225
Bilinear resize
Min edge 800; max edge 1333
Pad right/bottom to multiple of 32
Canvas unchanged for the selected square input
ResNet-50 backbone
Input
3 × 800 × 800
Conv2d 7×7, s=2, p=3
64 × 400 × 400; no bias
FrozenBatchNorm2d + ReLU
64 × 400 × 400; eps=0
MaxPool2d 3×3, s=2, p=1
64 × 200 × 200
C2: 1 projection + 2 identity blocks
256 × 200 × 200; hidden 64
C3: 1 projection + 3 identity blocks
512 × 100 × 100; hidden 128
C4: 1 projection + 5 identity blocks
1024 × 50 × 50; hidden 256
C5: 1 projection + 2 identity blocks
2048 × 25 × 25; hidden 512
Projection strides: C2=1, C3/C4/C5=2.
The stride is in the bottleneck 3×3 convolution.
Feature pyramid
C5: Conv2d 1×1
2048 input; 256 × 25 square
Conv2d 3×3, p=1
F3: 256 × 25 square
C4: Conv2d 1×1
1024 input; 256 × 50 square
Conv2d 3×3, p=1
F2: 256 × 50 square
+
Nearest resize
256 × 50 square
C3: Conv2d 1×1
512 input; 256 × 100 square
Conv2d 3×3, p=1
F1: 256 × 100 square
+
Nearest resize
256 × 100 square
C2: Conv2d 1×1
256 input; 256 × 200 square
Conv2d 3×3, p=1
F0: 256 × 200 square
+
Nearest resize
256 × 200 square
F3 continuation
256 × 25 × 25
MaxPool2d 1×1, s=2
pool: 256 × 13 × 13
RPN receives 5 feature maps. RoIAlign excludes the extra pooled map.
FPN normalization: none; all FPN convs have bias.
Region Proposal Network (RPN)
Each FPN feature independently
256 channels; shared RPN weights
Conv2d 3×3 + ReLU
256 channels; repeat 1; no norm
Conv2d 1×1
3 objectness logits/location
Conv2d 1×1
12 box deltas/location
Top-K per level, then sigmoid
1000 pre-NMS proposals per level
Flatten anchor rows
Weights for box delta decode: 1,1,1,1
Generate anchors
3 per location; one size per level
Decode anchor-relative deltas
Center shift; exp sizes; clip log-scale
Filter proposals and level-wise NMS
score ≥ 0.0; NMS IoU 0.7
Retain at most 1000 proposals
R × 4 boxes; R varies with image values
Anchor ratios: 0.5, 1, 2. Sizes: 32, 64, 128, 256, 512.
Raw anchor rows on this canvas: 159,882.
Clip to canvas; remove boxes smaller than 0.001 pixels.
Box size exponent clamp: log(1000/16).
Box RoI head and final detection selection
Selected FPN features
F0/F1/F2/F3 (strides4/8/16/32)
RPN proposals
R × 4 boxes
MultiScaleRoIAlign
R × 256 × 7 × 7; sampling_ratio=2
Flatten; Linear 12544 to 1024; ReLU
R × 1024
Linear 1024 to 1024; ReLU
R × 1024
Linear 1024 to 91
R × 91 class logits
Linear 1024 to 364
R × 91 × 4 class-specific deltas
Softmax across 91 slots
Drop background slot 0
Decode against proposals
Box coder weights 10,10,5,5; clip to canvas
Score > 0.05; remove tiny boxes; class NMS 0.5; top 100
N ≤100 boxes, labels and scores; invert input resize
R and N are dynamic. Their upper limits are fixed:
R ≤1000 and N ≤100. All per-RoI dimensions are resolved.
Model outputs use 91-class IDs; the library maps valid COCO IDs to 80.
Flatten spatial features
12544 values; skip for second FC
Linear
1024 output features; bias=True
ReLU
Fully connected unit
Projection bottleneck
Stage order: C2 / C3 / C4 / C5.
Input
64 / 256 / 512 / 1024 ch
Conv2d 1×1
64 / 128 / 256 / 512 output channels
FrozenBatchNorm2d
64 / 128 / 256 / 512 channels
ReLU
Conv2d 3×3, p=1
s=1/2/2/2
FrozenBatchNorm2d
64 / 128 / 256 / 512 channels
ReLU
Conv2d 1×1
256 / 512 / 1024 / 2048 output channels
FrozenBatchNorm2d
No activation before addition
+
ReLU
Block output
Conv2d 1×1
256 / 512 / 1024 / 2048 ch
FrozenBatchNorm2d
Stride 1 / 2 / 2 / 2
Identity bottleneck
Stage order: C2 / C3 / C4 / C5.
Input
256 / 512 / 1024 / 2048 ch
Conv2d 1×1
64 / 128 / 256 / 512 output channels
FrozenBatchNorm2d
64 / 128 / 256 / 512 channels
ReLU
Conv2d 3×3, p=1
s=1
FrozenBatchNorm2d
64 / 128 / 256 / 512 channels
ReLU
Conv2d 1×1
256 / 512 / 1024 / 2048 output channels
FrozenBatchNorm2d
No activation before addition
+
ReLU
Block output
identity
Normalization and RoIAlign
FrozenBatchNorm2d
eps=0; stored statistics in eval
ReLU or Hardswish
Hardswish(x) = x × clamp(x + 3, 0, 6) / 6
RPN repeated unit (no normalization)
Conv2d 3×3, p=1
256 channels; bias=True
ReLU
Preserve spatial dimensions
Choose a feature level per proposal
floor(4 + log2(sqrt(box area) / 224)); clip level range
RoIAlign: scale box to feature coordinates
Aligned=False; bilinear samples; sampling_ratio=2
Average 2 × 2 samples in every bin
7 × 7 bins for boxes; 14 × 14 bins for masks
R is proposal count and N is final detection count.
These dimensions depend on image values, even at fixed input size.
ResNet box/mask RoIAlign selects among P2...P5.
Complete native inference path with random-weight CPU validation. Data-dependent selection counts are not fixed tensor dimensions.
Source: models/faster_rcnn/nn.py; models/faster_rcnn/nn.py. Revision a4d0ecc9e17f.
libreyolo.com