card: update from fastforks 1cbf1671
Browse files
README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: "fastforks"
|
| 3 |
+
pipeline_tag: "image-classification"
|
| 4 |
+
license: "apache-2.0"
|
| 5 |
+
tags:
|
| 6 |
+
- "classification"
|
| 7 |
+
- "image-classification"
|
| 8 |
+
- "cuda"
|
| 9 |
+
- "pytorch"
|
| 10 |
+
- "fastforks"
|
| 11 |
+
- "fastforks-card"
|
| 12 |
+
---
|
| 13 |
+
# DaViT (fastforks)
|
| 14 |
+
|
| 15 |
+
DaViT (Ding et al. 2022): a hierarchical vision transformer that alternates window (spatial) attention and channel-group attention.
|
| 16 |
+
|
| 17 |
+
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/pytorch-image-models> at `0df212b369a5`.
|
| 18 |
+
|
| 19 |
+
Author weight repos: <https://huggingface.co/timm/davit_base.msft_in1k>, <https://huggingface.co/timm/davit_small.msft_in1k>, <https://huggingface.co/timm/davit_tiny.msft_in1k>.
|
| 20 |
+
|
| 21 |
+
Task: classification. Tier: experimental. Outputs: `logits`. Backends: `portable`.
|
| 22 |
+
|
| 23 |
+
Input: one RGB image. Output: ImageNet-1k class logits.
|
| 24 |
+
|
| 25 |
+
## Variants
|
| 26 |
+
|
| 27 |
+
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/classification/models/davit/card.toml).
|
| 28 |
+
|
| 29 |
+
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|
| 30 |
+
|---|---|---|---|---|
|
| 31 |
+
| `davit_base.msft_in1k@1` | [davit_base.msft_in1k.safetensors](https://huggingface.co/timm/davit_base.msft_in1k/resolve/67a8d7bc5f9c24978590dffab45c4bec6bcacef9/model.safetensors) | `cd12f8bd194e` | Apache-2.0 | yes |
|
| 32 |
+
| `davit_small.msft_in1k@1` | [davit_small.msft_in1k.safetensors](https://huggingface.co/timm/davit_small.msft_in1k/resolve/34eef293500352e8dbf7eee82b1c55cb146bfd6e/model.safetensors) | `cef0f04c7349` | Apache-2.0 | yes |
|
| 33 |
+
| `davit_tiny.msft_in1k@1` | [davit_tiny.msft_in1k.safetensors](https://huggingface.co/timm/davit_tiny.msft_in1k/resolve/982f32c73d98f9966df4a7178b32b820bed3c1b1/model.safetensors) | `085937207d2e` | Apache-2.0 | yes |
|
| 34 |
+
|
| 35 |
+
## Licence
|
| 36 |
+
|
| 37 |
+
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0.
|
| 38 |
+
|
| 39 |
+
Training data: ImageNet-1k (ILSVRC 2012 classification).
|
| 40 |
+
|
| 41 |
+
Licence evidence: <https://huggingface.co/timm/davit_tiny.msft_in1k/blob/982f32c73d98f9966df4a7178b32b820bed3c1b1/README.md>
|
| 42 |
+
|
| 43 |
+
## Input size
|
| 44 |
+
|
| 45 |
+
fixed 224x224: the input is resized (short side 235) and centre-cropped to it
|
| 46 |
+
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `davit_base.msft_in1k` 224x224 (0.2 GiB peak allocated, 0.2 reserved); `davit_small.msft_in1k` 224x224 (0.1 GiB peak allocated, 0.1 reserved); `davit_tiny.msft_in1k` 224x224 (0.1 GiB peak allocated, 0.1 reserved)
|
| 47 |
+
|
| 48 |
+
## Speed and memory
|
| 49 |
+
|
| 50 |
+
### Classification, synthetic
|
| 51 |
+
|
| 52 |
+
| model | input | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|
| 53 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 54 |
+
| `davit_base.msft_in1k` | 224x224 | 13.4 | 20.0 | 11.7 | β | β | β | 537 / 548 | 212 / 224 | β |
|
| 55 |
+
| `davit_small.msft_in1k` | 224x224 | 13.0 | 18.8 | 12.8 | β | β | β | 319 / 324 | 136 / 150 | β |
|
| 56 |
+
| `davit_tiny.msft_in1k` | 224x224 | 6.93 | 9.88 | 6.33 | β | β | β | 196 / 204 | 96 / 116 | β |
|
| 57 |
+
|
| 58 |
+
### Startup and first call
|
| 59 |
+
|
| 60 |
+
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|
| 61 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 62 |
+
| `davit_base.msft_in1k` | 0.99 | 1.84 | β | 0.56 | 0.27 | β |
|
| 63 |
+
| `davit_small.msft_in1k` | 0.53 | 1.60 | β | 0.02 | 0.23 | β |
|
| 64 |
+
| `davit_tiny.msft_in1k` | 0.39 | 1.47 | β | 0.85 | 0.25 | β |
|
| 65 |
+
|
| 66 |
+
### torch.compile and TensorRT
|
| 67 |
+
|
| 68 |
+
| model | input | time: portable | compile | TensorRT fp16 | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) |
|
| 69 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 70 |
+
| `davit_base.msft_in1k` | 224x224 | 11.7 ms | 5.48 ms | 2.28 ms | β | 21.8 s | 71.1 s | 212 / 224 | 242 / 262 | β | 403 / 422 |
|
| 71 |
+
| `davit_small.msft_in1k` | 224x224 | 12.8 ms | 5.54 ms | 1.92 ms | β | 21.8 s | 66.4 s | 136 / 150 | 166 / 190 | β | 234 / 254 |
|
| 72 |
+
| `davit_tiny.msft_in1k` | 224x224 | 6.33 ms | 3.10 ms | 1.03 ms | β | 15.5 s | 53.8 s | 96 / 116 | 125 / 136 | β | 159 / 166 |
|
| 73 |
+
|
| 74 |
+
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
|
| 75 |
+
|
| 76 |
+
Hardware, protocol and caveats: [benchmarks](https://github.com/kleinicke/fastforks/blob/main/docs/benchmarks.md) (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above 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.
|
| 77 |
+
|
| 78 |
+
## Accuracy
|
| 79 |
+
|
| 80 |
+
### On public datasets
|
| 81 |
+
|
| 82 |
+
fastforks: the model's own resize / crop on the GPU; original: the library's pretrained loader and its PIL eval transform. Original = the original code named under Details, same checkpoint and protocol.
|
| 83 |
+
|
| 84 |
+
| variant | dataset | original fp32 | original fp16 | portable | note |
|
| 85 |
+
|---|---|---|---|---|---|
|
| 86 |
+
| `davit_tiny.msft_in1k` | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 83.94 / 96.50 | 83.92 / 96.50 | 83.94 / 96.56 | |
|
| 87 |
+
| `davit_small.msft_in1k` | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 85.18 / 97.20 | 85.16 / 97.20 | 85.24 / 97.18 | |
|
| 88 |
+
| `davit_base.msft_in1k` | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 85.58 / 97.10 | 85.58 / 97.10 | 85.66 / 97.12 | |
|
| 89 |
+
|
| 90 |
+
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 7ba7307f, 2026-11-11.
|
| 91 |
+
|
| 92 |
+
### Parity with the original code
|
| 93 |
+
|
| 94 |
+
Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 3.3e-06 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0026 and p99 <= 0.011 (absolute error of the output `logits`).
|
| 95 |
+
|
| 96 |
+
## Usage
|
| 97 |
+
|
| 98 |
+
```python
|
| 99 |
+
from fastforks import classification
|
| 100 |
+
|
| 101 |
+
model = classification.load("davit_base.msft_in1k") # mode="auto": the preferred backend from recorded measurements
|
| 102 |
+
result = model("photo.jpg")
|
| 103 |
+
result.top(5) # top-5 classes
|
| 104 |
+
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `davit_base.msft_in1k`, `davit_small.msft_in1k`, `davit_tiny.msft_in1k`.
|
| 108 |
+
|
| 109 |
+
## Kernels backend
|
| 110 |
+
|
| 111 |
+
No kernels backend: not implemented: window attention and channel attention with depthwise position convolutions: needs its own runner.
|
| 112 |
+
|
| 113 |
+
<!-- staged from fastforks 1cbf1671 (2026-11-15) -->
|