Models · Object detection

detectron2 Mask / Faster R-CNN (R50-FPN)

Faster R-CNN and Mask R-CNN from the detectron2 model zoo (ResNet-50 FPN, COCO): boxes, classes and, for Mask R-CNN, instance masks.

stable Fork of facebookresearch/detectron2@1e3e13b · backends: portable, kernels

  • Paper Mask R-CNN ICCV 2017 · first released 20 Mar 2017
Checkpoint

Paper 2017 Added in 0.1.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 21.0 ms 800x1344, fp16
vs the faster original 2.1× original fp16: 43.5 ms
Peak memory 353 MiB original: 604 MiB
Accuracy vs original fp32 −0.03 kernels box mAP, COCO val2017 (42.13 original)

Use it

pip install fastforks

Lean install with only what this model needs: pip install "fastforks-core[torchvision]"

from fastforks import detection

model = detection.load("mask-rcnn-r50-fpn-3x-coco")  # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.boxes  # also: scores, labels, masks
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench mask-rcnn-r50-fpn-3x-coco

Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.

Speed and memory

Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.

Input: synthetic, 800x1344 (the task’s standard size)

BackenddtypeTime per call (ms)vs original fp16Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32fp32 85.40.51×1,601 MiB/1,918 MiB0.50.24
Original fp16torch.autocast(fp16) around the forwardfp16 43.5–604 MiB/650 MiB1.00.84
Portable fp32fp32not measured ––––
Portablefp16 24.61.8×352 MiB/440 MiB1.50.42
Kernelsfp16 21.02.1×353 MiB/400 MiB0.20.04
Portable + torch.compile 21.52.0×333 MiB/358 MiB29 (build)–
TensorRT fp16backbone + FPN onlyfp16 5.348.1×258 MiBenginenot comparable18 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-01 to 2026-11-03. Median of 5 after 3 warm-up, uint8 CUDA input (synthetic for bench_inputs sizes), card defaults; gc before each load; peak = max over the first call and the timed calls. Ratios divide two times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.

Other devices

DeviceBackenddtypems / callPeak memoryOutput vs referenceInput
Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14Originalfp32245 1,964 MiB processmatches800x1344
Portablefp16203 1,931 MiB processmatches800x1344
Portablefp32222 1,930 MiB processmatches800x1344
Kernelsfp16not implemented–800x1344
NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1625.7 328 MiB/380 MiB–800x1344
Kernelsfp1622.1 329 MiB/400 MiB–800x1344
NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1612.6 328 MiB/380 MiB–800x1344
Kernelsfp1611.8 330 MiB/380 MiB–800x1344
NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1624.5 328 MiB/380 MiB–800x1344
Kernelsfp1620.1 328 MiB/380 MiB–800x1344
NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1615.0 328 MiB/380 MiB–800x1344
Kernelsfp1614.7 328 MiB/380 MiB–800x1344
NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp166.82 352 MiB/440 MiB–800x1344
Kernelsfp166.55 356 MiB/420 MiB–800x1344

CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.

Licence and weights

Commercial use allowed

Code
Apache-2.0 LICENSE
Weights
CC-BY-SA-3.0 source
Training data
  • share-alike: weights CC-BY-SA-3.0; fine-tuned or adapted weights keep this licence
  • The detectron2 model-zoo weights are CC-BY-SA-3.0 (share-alike), and the COCO images carry their own licences.

Our reading of the licences, not legal advice.

Weights

mask_rcnn_R_50_FPN_3x.pkl 178 MB· hosted on Meta (fbaipublicfiles)

fastforks downloads and checks these files on first use (fastforks download mask-rcnn-r50-fpn-3x-coco).

Accuracy

The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.

COCO val2017

every 10th image, box mAP

Rundtypebox mAP ↑mask mAP ↑Δ box mAP vs fp32 originalimagesms / image
Original fp32fp3242.1338.67 reference 500 62.6
Original fp16fp1642.1338.66 ±0.00 500 42.1
Portable fp32fp3242.1338.66 ±0.00 500 45.8
Portablefp1642.1238.65 −0.01 500 23.0
Kernelsfp1642.1038.64 −0.03 500 20.0

pycocotools COCOeval of the top 100 detections per image. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 44640884, 2026-11-17; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.

Closeness to the original

Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 1.0 and p99 <= 2.0 (absolute error of the output boxes).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.002 not recorded
GPU default dtypes, mean |diff|≤ 1 0.09391
GPU default dtypes, p99 |diff|≤ 2 0.46488

Recorded for mask-rcnn-r50-fpn-3x-coco on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-03, with these kernels: cudnn_hacc

Details

Mask R-CNN (He et al. 2017) and Faster R-CNN (Ren et al. 2015) from the detectron2 model zoo, COCO, ResNet-50 + FPN backbone, RPN proposals, ROIAlign box head (+ mask head); returns boxes, classes and instance masks at the input size. The portable `module()` is backbone + FPN.

Input / output
Input: one RGB image. Output: boxes, class labels, scores and instance masks.
Input size
any H x W >= 32, padded to a multiple of 32; tested up to 3000x4000 (607 MiB allocated)
Options
  • score_threshold=0.050.0 to 1.0· changes the output
  • max_detections=100>= 1· changes the output
Outputs
boxes, scores, labels, masks
Checkpoint
mask=true
CUDA kernels
  • cudnn_haccconvolutions with fp16 accumulation (cuDNN)
Apple (MPS)
fp32, fp16
Full reference, generated from the repository

Faster R-CNN and Mask R-CNN from the detectron2 model zoo (ResNet-50 FPN, COCO): boxes, classes and, for Mask R-CNN, instance masks.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
mask-rcnn-r50-fpn-3x-cocosynthetic (800x1344)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
85.4
43.5
24.6
21.0
21.5
5.34 (backbone + FPN only)
1601 / 1918
604 / 650
352 / 440
353 / 400
333 / 358
444 / 496
faster-rcnn-r50-fpn-3x-cocosynthetic (800x1344)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
83.6
41.4
22.8
19.5
18.9
5.35 (backbone + FPN only)
1591 / 1898
626 / 708
390 / 490
391 / 450
413 / 438
439 / 494
Details
  • Original code: https://github.com/facebookresearch/detectron2 at 1e3e13b
  • Code licence: Apache-2.0 (permissive); files: LICENSE
  • Weights licence: CC-BY-SA-3.0
  • Licence evidence: https://github.com/facebookresearch/detectron2/blob/1e3e13bbf607b54f62205c4c33922521822fb298/MODEL_ZOO.md (License section)
  • Training data: COCO 2017 (train, instance annotations) (COCO 2017 train (3x schedule); the ResNet-50 backbone was initialised from MSRA's ImageNet-1k model)
  • Licence note: The detectron2 model-zoo weights are CC-BY-SA-3.0 (share-alike), and the COCO images carry their own licences.
  • Options: score_threshold = 0.05 (0.0 to 1.0), max_detections = 100 (>= 1)
  • Kernel libraries: cudnn_hacc
  • Variants: mask-rcnn-r50-fpn-3x-coco, faster-rcnn-r50-fpn-3x-coco
  • Outputs: boxes, scores, labels, masks; label_set: coco-80
  • Input size: any H x W >= 32, padded to a multiple of 32
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): mask-rcnn-r50-fpn-3x-coco 3000x4000 (0.6 GiB peak allocated, 0.7 reserved); faster-rcnn-r50-fpn-3x-coco 3000x4000 (0.6 GiB peak allocated, 0.7 reserved)
  • mask-rcnn-r50-fpn-3x-coco 800x1344, first call: portable + torch.compile 29 s (cold Inductor cache), TensorRT fp16 18 s (ONNX + engine).
  • faster-rcnn-r50-fpn-3x-coco 800x1344, first call: portable + torch.compile 26 s (cold Inductor cache), TensorRT fp16 16 s (ONNX + engine).
  • mask-rcnn-r50-fpn-3x-coco original 800x1344: torch.autocast(fp16) around the forward
  • faster-rcnn-r50-fpn-3x-coco original 800x1344: torch.autocast(fp16) around the forward
  • mask-rcnn-r50-fpn-3x-coco load / first call: original 0.97 s / 0.836 s, portable 1.5 s / 0.417 s, kernels 0.22† s / 0.043 s
  • faster-rcnn-r50-fpn-3x-coco load / first call: original 0.73 s / 0.045 s, portable 0.53 s / 0.247 s, kernels 0.14† s / 0.04 s
  • † measured in the speed sweep after the portable load (or an earlier size) in the same process: file cache and kernels are warm, so the time is lower than a fresh start.
  • Protocol, median of 5 after 3 warm-up, uint8 CUDA input (synthetic for bench_inputs sizes), card defaults; gc before each load; peak = max over the first call and the timed calls

Measured

pycocotools COCOeval of the top 100 detections per image. Original = the original code named under Details, same checkpoint and protocol.

variantdatasetoriginal fp32original fp16portableportable fp32kernelsnote
mask-rcnn-r50-fpn-3x-cocoCOCO val2017, every 10th image, box mAP / mask mAP42.13 / 38.6742.13 / 38.6642.12 / 38.6542.13 / 38.6642.10 / 38.64
faster-rcnn-r50-fpn-3x-cocoCOCO val2017, every 10th image, box mAP41.5441.4441.5841.5741.58

Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 44640884, 2026-11-17; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.

Parity

CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 1.0 and p99 <= 2.0 (absolute error of the output boxes).

variantkernels error vs original, mean / p99GPU, torchkernels used
mask-rcnn-r50-fpn-3x-coco0.09391 / 0.46488RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
faster-rcnn-r50-fpn-3x-coco0.49736 / 2.92376RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400

Example output

One fixed input through this checkpoint, the same for every model of the task (kernels · float16 · NVIDIA GeForce RTX 5060 Ti).

Input
Output
  • person 0.99
Astronaut Eileen Collins, input
Input · 100%

Input: Astronaut Eileen Collins, NASA (public domain).