Mask R-CNN R50 segmentation

Click a block to read its description, or select it with Tab and Enter.

Mask R-CNN R50 segmentation800 × 800 RGB canvas; batch 1; eval. COCO: 91 internal slots mapped to 80 classes. R and N are data-dependent counts.LibreYOLOMask R-CNN R50 segmentation800 × 800 RGB canvas; batch 1; eval. COCO: 91 internal slots mapped to 80 classes. R and N are data-dependent counts.Input transformRGB imageValues in [0,1]Channel normalizationMean .485/.456/.406; std .229/.224/.225Bilinear resizeMin edge 800; max edge 1333Pad right/bottom to multiple of 32Canvas unchanged for the selected square inputResNet-50 backboneInput3 × 800 × 800Conv2d 7×7, s=2, p=364 × 400 × 400; no biasBatchNorm2d + ReLU64 × 400 × 400; eps=0.00001MaxPool2d 3×3, s=2, p=164 × 200 × 200C2: 1 projection + 2 identity blocks256 × 200 × 200; hidden 64C3: 1 projection + 3 identity blocks512 × 100 × 100; hidden 128C4: 1 projection + 5 identity blocks1024 × 50 × 50; hidden 256C5: 1 projection + 2 identity blocks2048 × 25 × 25; hidden 512Projection strides: C2=1, C3/C4/C5=2.The stride is in the bottleneck 3×3 convolution.Feature pyramidC5: Conv2d 1×1 + BN2048 input; 256 × 25 squareConv2d 3×3, p=1 + BNF3: 256 × 25 squareC4: Conv2d 1×1 + BN1024 input; 256 × 50 squareConv2d 3×3, p=1 + BNF2: 256 × 50 square+Nearest resize256 × 50 squareC3: Conv2d 1×1 + BN512 input; 256 × 100 squareConv2d 3×3, p=1 + BNF1: 256 × 100 square+Nearest resize256 × 100 squareC2: Conv2d 1×1 + BN256 input; 256 × 200 squareConv2d 3×3, p=1 + BNF0: 256 × 200 square+Nearest resize256 × 200 squareF3 continuation256 × 25 × 25MaxPool2d 1×1, s=2pool: 256 × 13 × 13RPN receives 5 feature maps. RoIAlign excludes the extra pooled map.FPN normalization: BatchNorm2d, eps=0.00001; no activation.Region Proposal Network (RPN)Each FPN feature independently256 channels; shared RPN weightsConv2d 3×3 + ReLU256 channels; repeat 2; no normConv2d 1×13 objectness logits/locationConv2d 1×112 box deltas/locationTop-K per level, then sigmoid1000 pre-NMS proposals per levelFlatten anchor rowsWeights for box delta decode: 1,1,1,1Generate anchors3 per location; one size per levelDecode anchor-relative deltasCenter shift; exp sizes; clip log-scaleFilter proposals and level-wise NMSscore ≥ 0.0; NMS IoU 0.7Retain at most 1000 proposalsR × 4 boxes; R varies with image valuesAnchor 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 selectionSelected FPN featuresF0/F1/F2/F3 (strides4/8/16/32)RPN proposalsR × 4 boxesMultiScaleRoIAlignR × 256 × 7 × 7; sampling_ratio=2Conv3×3 + BatchNorm + ReLU ×4R × 256 × 7 × 7; eps=0.00001Flatten; Linear 12544 to 1024; ReLUR × 1024Linear 1024 to 91R × 91 class logitsLinear 1024 to 364R × 91 × 4 class-specific deltasSoftmax across 91 slotsDrop background slot 0Decode against proposalsBox coder weights 10,10,5,5; clip to canvasScore > 0.05; remove tiny boxes; class NMS 0.5; top 100N ≤100 boxes, labels and scores; invert input resizeR 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.Conv2d 3×3, p=1256 channels; bias=FalseBatchNorm2deps=0.00001ReLURoI conv unitMask branch after box selectionRoIAlign on selected detection boxesN × 256 × 14 × 14; sampling_ratio=2Conv3×3 + BatchNorm + ReLU ×4N × 256 × 14 × 14ConvTranspose2d 2×2, s=2 + ReLUN × 256 × 28 × 28Conv2d 1×1N × 91 × 28 × 28 logitsSigmoid and select each detection classN × 1 × 28 × 28Pad masks 1 pixel and expand boxes30 × 30 masks; box scale 30/28Bilinear resize to each expanded boxalign_corners=False; dynamic box width/heightClip and paste onto original canvasN × 1 × 800 × 800The mask branch reuses FPN features and the final boxes from the box head. It does not rerun the backbone.91 mask channels are architectural slots; each detection selects its predicted class channel before pasting.Conv2d 3×3, p=1, no bias256 input/output channelsBatchNorm2deps=0.00001ReLUPer-RoI spatial size preservedProjection bottleneckStage order: C2 / C3 / C4 / C5.Input64 / 256 / 512 / 1024 chConv2d 1×164 / 128 / 256 / 512 output channelsBatchNorm2d64 / 128 / 256 / 512 channelsReLUConv2d 3×3, p=1s=1/2/2/2BatchNorm2d64 / 128 / 256 / 512 channelsReLUConv2d 1×1256 / 512 / 1024 / 2048 output channelsBatchNorm2dNo activation before addition+ReLUBlock outputConv2d 1×1256 / 512 / 1024 / 2048 chBatchNorm2dStride 1 / 2 / 2 / 2Identity bottleneckStage order: C2 / C3 / C4 / C5.Input256 / 512 / 1024 / 2048 chConv2d 1×164 / 128 / 256 / 512 output channelsBatchNorm2d64 / 128 / 256 / 512 channelsReLUConv2d 3×3, p=1s=1BatchNorm2d64 / 128 / 256 / 512 channelsReLUConv2d 1×1256 / 512 / 1024 / 2048 output channelsBatchNorm2dNo activation before addition+ReLUBlock outputidentityNormalization and RoIAlignBatchNorm2deps=0.00001; stored statistics in evalReLU or HardswishHardswish(x) = x × clamp(x + 3, 0, 6) / 6RPN repeated unit (no normalization)Conv2d 3×3, p=1256 channels; bias=TrueReLUPreserve spatial dimensionsChoose a feature level per proposalfloor(4 + log2(sqrt(box area) / 224)); clip level rangeRoIAlign: scale box to feature coordinatesAligned=False; bilinear samples; sampling_ratio=2Average 2 × 2 samples in every bin7 × 7 bins for boxes; 14 × 14 bins for masksR 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/mask_rcnn/nn.py; models/faster_rcnn/nn.py. Revision a4d0ecc9e17f.libreyolo.com