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

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.

This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: https://github.com/kleinicke/fastforks. Kernels for the kernels backend: https://huggingface.co/fastforks/kernels. Original code: https://github.com/facebookresearch/detectron2 at 1e3e13b.

Task: detection. Tier: stable. Outputs: boxes, scores, labels, masks. Backends: portable, kernels.

Input: one RGB image. Output: boxes, class labels, scores and instance masks.

Variants

Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.

variant weights (author link) SHA-256 weights licence commercial use
faster-rcnn-r50-fpn-3x-coco@1 faster_rcnn_R_50_FPN_3x.pkl 3c25caca37ba CC-BY-SA-3.0 yes
mask-rcnn-r50-fpn-3x-coco@1 mask_rcnn_R_50_FPN_3x.pkl 9a737e290372 CC-BY-SA-3.0 yes

Licence

Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Files: LICENSE.

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.

Licence evidence: https://github.com/facebookresearch/detectron2/blob/1e3e13bbf607b54f62205c4c33922521822fb298/MODEL_ZOO.md (License section)

Input size

any H x W >= 32, padded to a multiple of 32 Tested up to (portable, fp16, RTX 5060 Ti 16 GB): faster-rcnn-r50-fpn-3x-coco 3000x4000 (0.6 GiB peak allocated, 0.7 reserved); mask-rcnn-r50-fpn-3x-coco 3000x4000 (0.6 GiB peak allocated, 0.7 reserved)

Speed and memory

Detection, synthetic, 800x1344

model time (ms): original fp32 original portable kernels kernels speed-up: vs original vs portable peak memory (MiB, allocated / reserved): original portable kernels
faster-rcnn-r50-fpn-3x-coco 83.6 41.4 22.77 19.47 2.1x 1.2x 626 / 708 390 / 490 391 / 450
mask-rcnn-r50-fpn-3x-coco 85.4 43.5 24.59 20.98 2.1x 1.2x 604 / 650 352 / 440 353 / 400

Startup and first call

model load (s): original portable kernels first call (s): original portable kernels
faster-rcnn-r50-fpn-3x-coco 0.73 0.53 0.14โ€  0.04 0.25 0.04
mask-rcnn-r50-fpn-3x-coco 0.97 1.50 0.22โ€  0.84 0.42 0.04

Fixed-size speed and peak memory, all models

model mode 640x480 1280x720 1920x1080 12 MP 4000x3000
faster-rcnn-r50-fpn-3x-coco portable 18.5 ms / 309 / 420 21.5 ms / 338 / 426 22.2 ms / 352 / 454 27.2 ms / 602 / 734
faster-rcnn-r50-fpn-3x-coco kernels 16.1 ms / 310 / 422 18.7 ms / 339 / 460 18.4 ms / 353 / 488 24.6 ms / 602 / 736
mask-rcnn-r50-fpn-3x-coco portable 18.1 ms / 314 / 422 23.1 ms / 348 / 440 25.1 ms / 413 / 536 27.1 ms / 607 / 736
mask-rcnn-r50-fpn-3x-coco kernels 15.6 ms / 315 / 422 19.6 ms / 349 / 472 22.3 ms / 414 / 568 24.6 ms / 607 / 736

Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).

Hardware, protocol and caveats: benchmarks (RTX 5060 Ti 16 GB, sm_120). Original = the authors' code at the precision of portable (fp16, or (fp32) where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.

Accuracy

Parity with the original code

Every variant is checked against golden outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 1.0 px and p99 <= 2.0 px.

Usage

from fastforks import detection

model = detection.load("faster-rcnn-r50-fpn-3x-coco")  # portable PyTorch on the GPU if there is one, else the CPU
result = model("photo.jpg")
result.boxes, result.scores, result.labels  # [N, 4], [N], [N]
result.backend  # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')

Install with pip install fastforks (see https://github.com/kleinicke/fastforks). Other variants: faster-rcnn-r50-fpn-3x-coco, mask-rcnn-r50-fpn-3x-coco.

Kernels backend

detection.load("faster-rcnn-r50-fpn-3x-coco", mode="kernels") runs our CUDA kernels (cudnn_hacc). It needs a prebuilt kernel for your GPU architecture (downloaded from https://huggingface.co/fastforks/kernels on first use) and a recent NVIDIA driver; if there is none it raises BackendUnavailableError with the reason and never falls back silently. mode="auto" picks kernels when it can run and logs the choice.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support