Commit ·
fbc9886
0
Parent(s):
fastforks 0.1.0
Browse files- .gitattributes +35 -0
- README.md +99 -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,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
---
|
| 12 |
+
# DeiT (fastforks)
|
| 13 |
+
|
| 14 |
+
DeiT (Touvron et al. 2021): ViT trained on ImageNet-1k only.
|
| 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/pytorch-image-models> at `0df212b369a5`.
|
| 17 |
+
|
| 18 |
+
Author weight repos: <https://huggingface.co/timm/deit_base_patch16_224.fb_in1k>.
|
| 19 |
+
|
| 20 |
+
Task: classification. Tier: stable. Outputs: `logits`. Backends: `portable`, `kernels`.
|
| 21 |
+
|
| 22 |
+
Input: one RGB image. Output: ImageNet-1k class logits.
|
| 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/classification/models/deit/card.toml).
|
| 27 |
+
|
| 28 |
+
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|
| 29 |
+
|---|---|---|---|---|
|
| 30 |
+
| `deit_base_patch16_224.fb_in1k@1` | [deit_base_patch16_224.fb_in1k.safetensors](https://huggingface.co/timm/deit_base_patch16_224.fb_in1k/resolve/b78cc5532a69df6bcad9c3a8d76653fd20b31ac6/model.safetensors) | `cd2da27b74ed` | Apache-2.0 | yes |
|
| 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-1k (ILSVRC 2012 classification).
|
| 37 |
+
|
| 38 |
+
Licence evidence: <https://huggingface.co/timm/deit_base_patch16_224.fb_in1k/blob/b78cc5532a69df6bcad9c3a8d76653fd20b31ac6/README.md>
|
| 39 |
+
|
| 40 |
+
## Input size
|
| 41 |
+
|
| 42 |
+
fixed 224x224: the input is resized (short side 248) and centre-cropped to it
|
| 43 |
+
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `deit_base_patch16_224.fb_in1k` 224x224 (0.2 GiB peak allocated, 0.3 reserved)
|
| 44 |
+
|
| 45 |
+
## Speed and memory
|
| 46 |
+
|
| 47 |
+
### Classification, synthetic, 224x224
|
| 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 |
+
| `deit_base_patch16_224.fb_in1k` | 6.39 | 5.46 | 2.98 | 1.64 | 3.3x | 1.8x | 531 / 548 | 203 / 386 | 300 / 370 |
|
| 52 |
+
|
| 53 |
+
### Startup and first call
|
| 54 |
+
|
| 55 |
+
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|
| 56 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 57 |
+
| `deit_base_patch16_224.fb_in1k` | 2.52 | 0.72 | 1.96 | 0.31 | 0.00 | 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 |
+
| `deit_base_patch16_224.fb_in1k` | 224x224 | 2.98 | 2.1 | 7.3 | 1.1 | 28 | 1.64 | 203 / 386 | 238 / 266 | 196 |
|
| 64 |
+
|
| 65 |
+
### Fixed-size speed and peak memory, all models
|
| 66 |
+
|
| 67 |
+
| model | mode | 224x224 |
|
| 68 |
+
| --- | --- | --- |
|
| 69 |
+
| `deit_base_patch16_224.fb_in1k` | portable | 2.9 ms / 214 / 338 |
|
| 70 |
+
| `deit_base_patch16_224.fb_in1k` | kernels | 1.8 ms / 316 / 418 |
|
| 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.02 and p99 <= 0.08 (absolute error of the output `logits`).
|
| 81 |
+
|
| 82 |
+
## Usage
|
| 83 |
+
|
| 84 |
+
```python
|
| 85 |
+
from fastforks import classification
|
| 86 |
+
|
| 87 |
+
model = classification.load("deit_base_patch16_224.fb_in1k") # mode="auto": the preferred backend from recorded measurements
|
| 88 |
+
result = model("photo.jpg")
|
| 89 |
+
result.top(5) # top-5 classes
|
| 90 |
+
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `deit_base_patch16_224.fb_in1k`.
|
| 94 |
+
|
| 95 |
+
## Kernels backend
|
| 96 |
+
|
| 97 |
+
`classification.load("deit_base_patch16_224.fb_in1k", mode="kernels")` runs our CUDA kernels (`cudnn_hacc`, `fvm_conv`, `fvm_extra`, `fvm_mb`, `fvm_r3`). 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.
|
| 98 |
+
|
| 99 |
+
<!-- staged from fastforks feccac41 (2026-11-06) -->
|