oneformer / README.md
Flor's picture
Model card from fastforks 03e6fdbc
2416425 verified
|
Raw History Blame Contribute Delete
5.52 kB
---
library_name: "fastforks"
pipeline_tag: "image-segmentation"
license: "mit"
tags:
- "segmentation"
- "semantic-segmentation"
- "cuda"
- "pytorch"
- "fastforks"
---
# OneFormer (fastforks)
OneFormer (Jain et al. 2023): Mask2Former-style universal segmentation conditioned on a task token; Swin backbone, run here for the semantic task.
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/huggingface/transformers> at `c4c4605f9618`.
Author weight repos: <https://huggingface.co/shi-labs/oneformer_ade20k_swin_large>.
Task: segmentation. Tier: stable. Outputs: `logits`. Backends: `portable`, `kernels`.
Input: one RGB image. Output: per-pixel class logits.
## Variants
Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in [`card.toml`](https://github.com/kleinicke/fastforks/blob/main/src/fastforks/segmentation/models/oneformer/card.toml).
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
| `oneformer-swinl-ade20k@1` | [oneformer-swinl-ade20k.config.json](https://huggingface.co/shi-labs/oneformer_ade20k_swin_large/resolve/4a5bac8e64f82681a12db2e151a4c2f4ce6092b2/config.json)<br>[oneformer-swinl-ade20k.bin](https://huggingface.co/shi-labs/oneformer_ade20k_swin_large/resolve/4a5bac8e64f82681a12db2e151a4c2f4ce6092b2/pytorch_model.bin) | `27452b656a46`<br>`c0b2fe11dfec` | MIT | yes |
## Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Files: .
Training data: ImageNet-21k / ImageNet-22k (full ImageNet, fall 2011 release), ADE20K (SceneParsing, 150 classes).
Licence evidence: <https://huggingface.co/shi-labs/oneformer_ade20k_swin_large/blob/4a5bac8e64f82681a12db2e151a4c2f4ce6092b2/README.md>
## 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)
## Speed and memory
### Segmentation, synthetic, 1024x2048
| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `oneformer-swinl-ade20k` | 307.22 | 205.1 | 139.06 | 99.95 | 2.1x | 1.4x | 7395 / 7792 | 2054 / 2476 | 2054 / 2476 |
### Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- |
| `oneformer-swinl-ade20k` | 5.08 (512x512) | 4.10 | 3.27† | 0.81 (512x512) | 0.15† | 0.11† |
### torch.compile and TensorRT
| model | input | portable ms | compile ms | compile s (cold) | TensorRT fp16 ms | ONNX + build s | kernels ms | peak MiB (alloc / reserved): portable | compile | TensorRT (device) |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `oneformer-swinl-ade20k` | 1024x2048 | 139.06 | 138.6 | 0.4 | fails: ONNX export: conversion failed | – | 99.95 | 2054 / 2476 | 2046 / 2474 | – |
### Fixed-size speed and peak memory, all models
| model | mode | 640x480 | 1280x720 | 1920x1080 | 12 MP 4000x3000 |
| --- | --- | --- | --- | --- | --- |
| `oneformer-swinl-ade20k` | portable | 86.2 ms / 1295 / 1940 | 120.8 ms / 2220 / 3960 | 138.9 ms / 3772 / 6702 | OOM |
| `oneformer-swinl-ade20k` | kernels | 59.0 ms / 1295 / 1858 | 85.4 ms / 2222 / 3854 | 103.3 ms / 3772 / 6642 | OOM |
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
Hardware, protocol and caveats: [benchmarks](https://github.com/kleinicke/fastforks/blob/main/docs/benchmarks.md) (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| <= 0.001 and p99 <= 0.01 (absolute error of the output `logits`).
## Usage
```python
from fastforks import segmentation
model = segmentation.load("oneformer-swinl-ade20k") # mode="auto": the preferred backend from recorded measurements
result = model("photo.jpg")
result.labels # [H, W] per-pixel class index
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: `oneformer-swinl-ade20k`.
## Kernels backend
`segmentation.load("oneformer-swinl-ade20k", mode="kernels")` runs our CUDA kernels (`fvm_seg`, `seg_up`). 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.
<!-- staged from fastforks 03e6fdbc (2026-11-05) -->