Models · Semantic segmentation

OneFormer

OneFormer (SHI Labs): one network for several segmentation tasks, used here for ADE20K scene segmentation.

stable Fork of huggingface/transformers@c4c4605 · backends: portable, kernels

Checkpoint oneformer-swinl-ade20k

Paper 2022 Added in 0.1.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 100.0 ms 1024x2048, fp16
vs the faster original 2.1× original fp16: 205 ms
Peak memory 2,054 MiB original: 7,395 MiB
Accuracy vs original fp32 −0.11 kernels mIoU %, ADE20K val (54.49 original)

Use it

pip install fastforks

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

from fastforks import segmentation

model = segmentation.load("oneformer-swinl-ade20k")  # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.logits
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench oneformer-swinl-ade20k

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.

BackenddtypeTime per call (ms)vs original fp16Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32fp32 3070.67×6,853 MiB/7,808 MiB––
Original fp16torch.autocast(fp16) around the forwardfp16 205–7,395 MiB/7,792 MiB––
Portable fp32fp32not measured ––––
Portablefp16 1391.5×2,054 MiB/2,476 MiB4.10.15
Kernelsfp16 100.02.1×2,054 MiB/2,476 MiB3.30.11
Portable + torch.compileInductor: Triton kernel does not compile (torch bug)fails––––
TensorRT fp16fp16 83.32.5×3,258 MiBenginenot comparable140 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-03 to 2026-11-04. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5 (tools/speed_check.py), synthetic CUDA input (bench_inputs); 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-12Originalfp32out of memory–1024x2048
Portablefp161161 5,559 MiB processmatches1024x2048
Portablefp321127 9,492 MiB processmatches1024x2048
Kernelsfp16not implemented–1024x2048
NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16174 2,022 MiB/2,454 MiB–1024x2048
Kernelsfp16134 2,022 MiB/2,434 MiB–1024x2048
NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1661.9 2,022 MiB/2,454 MiB–1024x2048
Kernelsfp1647.2 2,022 MiB/2,434 MiB–1024x2048
NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp16133 2,022 MiB/2,454 MiB–1024x2048
Kernelsfp16109 2,022 MiB/2,434 MiB–1024x2048
NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07Portablefp1671.6 2,022 MiB/2,454 MiB–1024x2048
Kernelsfp1658.9 2,022 MiB/2,434 MiB–1024x2048
NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08Portablefp1637.7 2,046 MiB/2,474 MiB–1024x2048
Kernelsfp1631.4 2,046 MiB/2,454 MiB–1024x2048

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
Weights
MIT source
Training data

Our reading of the licences, not legal advice.

Weights

oneformer-swinl-ade20k.config.json 84.3 KB· hosted on Hugging Face
oneformer-swinl-ade20k.bin 880 MB· hosted on Hugging Face

fastforks downloads and checks these files on first use (fastforks download oneformer-swinl-ade20k).

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.

ADE20K val

every 4th image, mIoU / aAcc %

RundtypemIoU % ↑aAcc % ↑Δ mIoU % vs fp32 originalimagesms / image
Original fp32fp3254.4985.06 reference 500 191
Original fp16fp1654.2685.05 −0.23 500 123
Portable fp32fp3254.4685.05 −0.03 500 188
Portablefp1654.3785.05 −0.12 500 85.3
Kernelsfp1654.3885.14 −0.11 500 58.6

Each image at its own size, argmax of the logits. 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| <= 0.001 and p99 <= 0.01 (absolute error of the output logits).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.002 not recorded
GPU default dtypes, mean |diff|≤ 0.001 0.00004
GPU default dtypes, p99 |diff|≤ 0.01 0.00197

Recorded for oneformer-swinl-ade20k on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-04, with these kernels: fvm_segseg_up

Details

OneFormer (Jain et al. 2023): Mask2Former-style universal segmentation conditioned on a task token; Swin backbone, run here for the semantic task.

Input / output
Input: one RGB image. Output: per-pixel class labels (logits with logits=True).
Input size
any H x W >= 1, resized or padded inside the model; tested up to 1988x2880 (8,614 MiB allocated)
Outputs
logits
CUDA kernels
  • fvm_segfused kernels for Mask2Former and OneFormer
  • seg_upfused resize and argmax of segmentation scores
Apple (MPS)
fp32, fp16
Full reference, generated from the repository

OneFormer (SHI Labs): one network for several segmentation tasks, used here for ADE20K scene segmentation.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
oneformer-swinl-ade20ksynthetic (1024x2048)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
307
205
139
100
fails: Inductor: Triton kernel does not compile (torch bug)
83.3
6853 / 7808
7395 / 7792
2054 / 2476
2054 / 2476
–
4524 / 4576
Details
  • Original code: https://github.com/huggingface/transformers at c4c4605f9618
  • Code licence: Apache-2.0 (permissive); files:
  • Weights licence: MIT
  • Licence evidence: https://huggingface.co/shi-labs/oneformer_ade20k_swin_large/blob/4a5bac8e64f82681a12db2e151a4c2f4ce6092b2/README.md
  • Training data: ImageNet-21k / ImageNet-22k (full ImageNet, fall 2011 release), ADE20K (SceneParsing, 150 classes)
  • Kernel libraries: fvm_seg, seg_up
  • Variants: oneformer-swinl-ade20k
  • Outputs: logits; label_set: ade20k-150
  • Input size: any H x W >= 1, resized or padded inside the model
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): oneformer-swinl-ade20k 1988x2880 (8.4 GiB peak allocated, 14.9 reserved)
  • oneformer-swinl-ade20k 1024x2048, first call: TensorRT fp16 140 s (ONNX + engine).
  • oneformer-swinl-ade20k original 1024x2048: torch.autocast(fp16) around the forward
  • oneformer-swinl-ade20k load / first call: original 5.08 s / 0.805 s (512x512), portable 4.1 s / 0.147† s, kernels 3.27† s / 0.109† 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, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5 (tools/speed_check.py), synthetic CUDA input (bench_inputs); peak = max over the first call and the timed calls

Measured

Each image at its own size, argmax of the logits. Original = the original code named under Details, same checkpoint and protocol.

variantdatasetoriginal fp32original fp16portableportable fp32kernelsnote
oneformer-swinl-ade20kADE20K val, every 4th image, mIoU / aAcc %54.49 / 85.0654.26 / 85.0554.37 / 85.0554.46 / 85.0554.38 / 85.14

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| <= 0.001 and p99 <= 0.01 (absolute error of the output logits).

variantkernels error vs original, mean / p99GPU, torchkernels used
oneformer-swinl-ade20k4e-05 / 0.00197RTX 5060 Ti, torch 2.14.1+cu130fvm_seg@739693dff3b4:sm_120, seg_up@3e44e71200cd:sm_120

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
  • table 62%
  • plate 26%
  • book 8.6%
  • wall 3.4%
A cup of coffee, input
Input · 100%

Input: A cup of coffee, Rachel Michetti (CC0).