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
Paper 2017 Added in 0.1.0 Evaluated with 0.2.0
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)
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 85.4 | 0.51× | 1,601 MiB/1,918 MiB | 0.5 | 0.24 |
| Original fp16torch.autocast(fp16) around the forward | fp16 | 43.5 | – | 604 MiB/650 MiB | 1.0 | 0.84 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 24.6 | 1.8× | 352 MiB/440 MiB | 1.5 | 0.42 |
| Kernels | fp16 | 21.0 | 2.1× | 353 MiB/400 MiB | 0.2 | 0.04 |
| Portable + torch.compile | 21.5 | 2.0× | 333 MiB/358 MiB | 29 (build) | – | |
| TensorRT fp16backbone + FPN only | fp16 | 5.34 | 8.1× | 258 MiBenginenot comparable | 18 (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
| Device | Backend | dtype | ms / call | Peak memory | Output vs reference | Input |
|---|---|---|---|---|---|---|
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14 | Original | fp32 | 245 | 1,964 MiB process | matches | 800x1344 |
| Portable | fp16 | 203 | 1,931 MiB process | matches | 800x1344 | |
| Portable | fp32 | 222 | 1,930 MiB process | matches | 800x1344 | |
| Kernels | fp16 | not implemented | – | 800x1344 | ||
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 25.7 | 328 MiB/380 MiB | – | 800x1344 |
| Kernels | fp16 | 22.1 | 329 MiB/400 MiB | – | 800x1344 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 12.6 | 328 MiB/380 MiB | – | 800x1344 |
| Kernels | fp16 | 11.8 | 330 MiB/380 MiB | – | 800x1344 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 24.5 | 328 MiB/380 MiB | – | 800x1344 |
| Kernels | fp16 | 20.1 | 328 MiB/380 MiB | – | 800x1344 | |
| NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 15.0 | 328 MiB/380 MiB | – | 800x1344 |
| Kernels | fp16 | 14.7 | 328 MiB/380 MiB | – | 800x1344 | |
| NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 6.82 | 352 MiB/440 MiB | – | 800x1344 |
| Kernels | fp16 | 6.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
-
- COCO 2017 (train, instance annotations) CC-BY-4.0
- 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
| Run | dtype | box mAP ↑ | mask mAP ↑ | Δ box mAP vs fp32 original | images | ms / image |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 42.13 | 38.67 | reference | 500 | 62.6 |
| Original fp16 | fp16 | 42.13 | 38.66 | ±0.00 | 500 | 42.1 |
| Portable fp32 | fp32 | 42.13 | 38.66 | ±0.00 | 500 | 45.8 |
| Portable | fp16 | 42.12 | 38.65 | −0.01 | 500 | 23.0 |
| Kernels | fp16 | 42.10 | 38.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).
| Check | Tolerance | Measured |
|---|---|---|
| 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 outputmax_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.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
mask-rcnn-r50-fpn-3x-coco | synthetic (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-coco | synthetic (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-coco3000x4000 (0.6 GiB peak allocated, 0.7 reserved);faster-rcnn-r50-fpn-3x-coco3000x4000 (0.6 GiB peak allocated, 0.7 reserved) mask-rcnn-r50-fpn-3x-coco800x1344, first call: portable + torch.compile 29 s (cold Inductor cache), TensorRT fp16 18 s (ONNX + engine).faster-rcnn-r50-fpn-3x-coco800x1344, first call: portable + torch.compile 26 s (cold Inductor cache), TensorRT fp16 16 s (ONNX + engine).mask-rcnn-r50-fpn-3x-cocooriginal 800x1344: torch.autocast(fp16) around the forwardfaster-rcnn-r50-fpn-3x-cocooriginal 800x1344: torch.autocast(fp16) around the forwardmask-rcnn-r50-fpn-3x-cocoload / first call: original 0.97 s / 0.836 s, portable 1.5 s / 0.417 s, kernels 0.22† s / 0.043 sfaster-rcnn-r50-fpn-3x-cocoload / 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.
| variant | dataset | original fp32 | original fp16 | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|
mask-rcnn-r50-fpn-3x-coco | COCO val2017, every 10th image, box mAP / mask mAP | 42.13 / 38.67 | 42.13 / 38.66 | 42.12 / 38.65 | 42.13 / 38.66 | 42.10 / 38.64 | |
faster-rcnn-r50-fpn-3x-coco | COCO val2017, every 10th image, box mAP | 41.54 | 41.44 | 41.58 | 41.57 | 41.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).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
mask-rcnn-r50-fpn-3x-coco | 0.09391 / 0.46488 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400 |
faster-rcnn-r50-fpn-3x-coco | 0.49736 / 2.92376 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_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).
- person 0.99
Input: Astronaut Eileen Collins, NASA (public domain).