Commit ·
fd993c5
0
Parent(s):
fastforks 0.1.0
Browse files- .gitattributes +35 -0
- README.md +100 -0
.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: "fastforks"
|
| 3 |
+
pipeline_tag: "image-segmentation"
|
| 4 |
+
license: "cc-by-nc-4.0"
|
| 5 |
+
tags:
|
| 6 |
+
- "segmentation"
|
| 7 |
+
- "semantic-segmentation"
|
| 8 |
+
- "cuda"
|
| 9 |
+
- "pytorch"
|
| 10 |
+
- "fastforks"
|
| 11 |
+
---
|
| 12 |
+
# Mask2Former (fastforks)
|
| 13 |
+
|
| 14 |
+
Mask2Former (Cheng et al. 2022): Swin backbone, multi-scale deformable attention pixel decoder and a masked-attention transformer decoder; semantic logits from mask classification.
|
| 15 |
+
|
| 16 |
+
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`.
|
| 17 |
+
|
| 18 |
+
Author weight repos: <https://huggingface.co/facebook/mask2former-swin-large-ade-semantic>.
|
| 19 |
+
|
| 20 |
+
Task: segmentation. Tier: stable. Outputs: `logits`. Backends: `portable`, `kernels`.
|
| 21 |
+
|
| 22 |
+
Input: one RGB image. Output: per-pixel class labels (logits with `logits=True`).
|
| 23 |
+
|
| 24 |
+
## Variants
|
| 25 |
+
|
| 26 |
+
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/mask2former/card.toml).
|
| 27 |
+
|
| 28 |
+
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|
| 29 |
+
|---|---|---|---|---|
|
| 30 |
+
| `mask2former-swinl-ade20k@1` | [mask2former-swinl-ade20k.config.json](https://huggingface.co/facebook/mask2former-swin-large-ade-semantic/resolve/aa25c92404a40599614215e76514c79b427c7527/config.json)<br>[mask2former-swinl-ade20k.safetensors](https://huggingface.co/facebook/mask2former-swin-large-ade-semantic/resolve/aa25c92404a40599614215e76514c79b427c7527/model.safetensors) | `573b9330846e`<br>`b143c144341c` | CC-BY-NC-4.0 | **no** |
|
| 31 |
+
|
| 32 |
+
## Licence
|
| 33 |
+
|
| 34 |
+
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Files: .
|
| 35 |
+
|
| 36 |
+
Training data: ImageNet-21k / ImageNet-22k (full ImageNet, fall 2011 release), ADE20K (SceneParsing, 150 classes).
|
| 37 |
+
|
| 38 |
+
Licence evidence: <https://github.com/facebookresearch/Mask2Former/blob/9b0651c6c1d5b3af2e6da0589b719c514ec0d69a/MODEL_ZOO.md#license>
|
| 39 |
+
|
| 40 |
+
## Input size
|
| 41 |
+
|
| 42 |
+
any H x W >= 1, resized or padded inside the model
|
| 43 |
+
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `mask2former-swinl-ade20k` 3000x4000 (14.1 GiB peak allocated, 15.1 reserved)
|
| 44 |
+
|
| 45 |
+
## Speed and memory
|
| 46 |
+
|
| 47 |
+
### Segmentation, synthetic, 1024x2048
|
| 48 |
+
|
| 49 |
+
| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|
| 50 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 51 |
+
| `mask2former-swinl-ade20k` | 244 | 145 | 103 | 60.4 | 2.4x | 1.7x | 3572 / 3878 | 1164 / 1400 | 1164 / 1400 |
|
| 52 |
+
|
| 53 |
+
### Startup and first call
|
| 54 |
+
|
| 55 |
+
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|
| 56 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 57 |
+
| `mask2former-swinl-ade20k` | 4.86 (512x512) | 3.03 | 3.17† | 0.76 (512x512) | 0.13 | 0.07† |
|
| 58 |
+
|
| 59 |
+
### torch.compile and TensorRT
|
| 60 |
+
|
| 61 |
+
| 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) |
|
| 62 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 63 |
+
| `mask2former-swinl-ade20k` | 1024x2048 | 103 | 103.2 | 0.4 | 55.6 | 129 | 60.4 | 1164 / 1400 | 1155 / 1338 | 1816 |
|
| 64 |
+
|
| 65 |
+
### Fixed-size speed and peak memory, all models
|
| 66 |
+
|
| 67 |
+
| model | mode | 480x640 | 720x1280 | 1080x1920 | 12 MP 3000x4000 |
|
| 68 |
+
| --- | --- | --- | --- | --- | --- |
|
| 69 |
+
| `mask2former-swinl-ade20k` | portable | 71.9 ms / 1194 / 1912 | 96.1 ms / 1698 / 3182 | 104.1 ms / 2985 / 4500 | 152.8 ms / 14457 / 15480 |
|
| 70 |
+
| `mask2former-swinl-ade20k` | kernels | 45.3 ms / 1194 / 1816 | 60.5 ms / 1699 / 3056 | 68.5 ms / 2986 / 4374 | 126.0 ms / 14457 / 15344 |
|
| 71 |
+
|
| 72 |
+
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
|
| 73 |
+
|
| 74 |
+
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.
|
| 75 |
+
|
| 76 |
+
## Accuracy
|
| 77 |
+
|
| 78 |
+
### Parity with the original code
|
| 79 |
+
|
| 80 |
+
Every variant is checked against reference 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`).
|
| 81 |
+
|
| 82 |
+
## Usage
|
| 83 |
+
|
| 84 |
+
```python
|
| 85 |
+
from fastforks import segmentation
|
| 86 |
+
|
| 87 |
+
# non-commercial weights: run with FASTFORKS_NONCOMMERCIAL=1 in the environment
|
| 88 |
+
model = segmentation.load("mask2former-swinl-ade20k") # mode="auto": the preferred backend from recorded measurements
|
| 89 |
+
result = model("photo.jpg")
|
| 90 |
+
result.labels # [H, W] per-pixel class index
|
| 91 |
+
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `mask2former-swinl-ade20k`.
|
| 95 |
+
|
| 96 |
+
## Kernels backend
|
| 97 |
+
|
| 98 |
+
`segmentation.load("mask2former-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.
|
| 99 |
+
|
| 100 |
+
<!-- staged from fastforks feccac41 (2026-11-06) -->
|