Flor commited on
Commit
3eeccd4
Β·
verified Β·
1 Parent(s): d10d98d

card: update from fastforks 1cbf1671

Browse files
Files changed (1) hide show
  1. README.md +113 -0
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
+ # EfficientFormer (fastforks)
14
+
15
+ EfficientFormer (Li et al. 2022, Snap Research): a hybrid classifier, pooling blocks on feature maps followed by transformer blocks on tokens.
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/efficientformer_l1.snap_dist_in1k>, <https://huggingface.co/timm/efficientformer_l3.snap_dist_in1k>, <https://huggingface.co/timm/efficientformer_l7.snap_dist_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/efficientformer/card.toml).
28
+
29
+ | variant | weights (author link) | SHA-256 | weights licence | commercial use |
30
+ |---|---|---|---|---|
31
+ | `efficientformer_l1.snap_dist_in1k@1` | [efficientformer_l1.snap_dist_in1k.safetensors](https://huggingface.co/timm/efficientformer_l1.snap_dist_in1k/resolve/8738a58190800aaf5995f453b05f643df453a565/model.safetensors) | `dab9ad0e328f` | Apache-2.0 | yes |
32
+ | `efficientformer_l3.snap_dist_in1k@1` | [efficientformer_l3.snap_dist_in1k.safetensors](https://huggingface.co/timm/efficientformer_l3.snap_dist_in1k/resolve/ca929ef48f056232098ad9226a69e4c29a00cc46/model.safetensors) | `ab0c5bfd7c18` | Apache-2.0 | yes |
33
+ | `efficientformer_l7.snap_dist_in1k@1` | [efficientformer_l7.snap_dist_in1k.safetensors](https://huggingface.co/timm/efficientformer_l7.snap_dist_in1k/resolve/f9689bcd000eaeaf0d80ce3c5c353494af2d661a/model.safetensors) | `c497103536ff` | 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/efficientformer_l1.snap_dist_in1k/blob/8738a58190800aaf5995f453b05f643df453a565/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): `efficientformer_l1.snap_dist_in1k` 224x224 (0.1 GiB peak allocated, 0.1 reserved); `efficientformer_l3.snap_dist_in1k` 224x224 (0.2 GiB peak allocated, 0.2 reserved); `efficientformer_l7.snap_dist_in1k` 224x224 (0.3 GiB peak allocated, 0.3 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
+ | `efficientformer_l1.snap_dist_in1k` | 224x224 | 4.87 | 6.40 | 3.72 | – | – | – | 104 / 124 | 93 / 104 | – |
55
+ | `efficientformer_l3.snap_dist_in1k` | 224x224 | 8.39 | 11.0 | 6.37 | – | – | – | 214 / 236 | 161 / 216 | – |
56
+ | `efficientformer_l7.snap_dist_in1k` | 224x224 | 12.3 | 15.9 | 9.65 | – | – | – | 505 / 522 | 300 / 324 | – |
57
+
58
+ ### Startup and first call
59
+
60
+ | model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
61
+ | --- | --- | --- | --- | --- | --- | --- |
62
+ | `efficientformer_l1.snap_dist_in1k` | 0.22 | 1.71 | – | 0.22 | 0.07 | – |
63
+ | `efficientformer_l3.snap_dist_in1k` | 0.37 | 1.86 | – | 0.03 | 0.08 | – |
64
+ | `efficientformer_l7.snap_dist_in1k` | 0.93 | 2.27 | – | 0.03 | 0.07 | – |
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
+ | `efficientformer_l1.snap_dist_in1k` | 224x224 | 3.72 ms | 1.69 ms | 0.335 ms | – | 9.10 s | 35.4 s | 93 / 104 | 125 / 144 | – | 128 / 142 |
71
+ | `efficientformer_l3.snap_dist_in1k` | 224x224 | 6.37 ms | 2.57 ms | 0.750 ms | – | 11.8 s | 39.4 s | 161 / 216 | 193 / 216 | – | 227 / 286 |
72
+ | `efficientformer_l7.snap_dist_in1k` | 224x224 | 9.65 ms | 3.69 ms | 1.40 ms | – | 14.4 s | 40.0 s | 300 / 324 | 332 / 364 | – | 460 / 490 |
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
+ | `efficientformer_l1.snap_dist_in1k` | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 81.14 / 95.22 | 81.16 / 95.24 | 81.14 / 95.12 | |
87
+ | `efficientformer_l3.snap_dist_in1k` | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 83.12 / 96.32 | 83.14 / 96.32 | 83.16 / 96.32 | |
88
+ | `efficientformer_l7.snap_dist_in1k` | ImageNet-1k val, 5000 random images, top-1 / top-5 % | 84.44 / 96.68 | 84.44 / 96.66 | 84.38 / 96.68 | |
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| <= 1.3e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0046 and p99 <= 0.019 (absolute error of the output `logits`).
95
+
96
+ ## Usage
97
+
98
+ ```python
99
+ from fastforks import classification
100
+
101
+ model = classification.load("efficientformer_l1.snap_dist_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: `efficientformer_l1.snap_dist_in1k`, `efficientformer_l3.snap_dist_in1k`, `efficientformer_l7.snap_dist_in1k`.
108
+
109
+ ## Kernels backend
110
+
111
+ No kernels backend: not built yet: pooling blocks with Conv-BN MLPs and LayerNorm transformer blocks with learned attention bias tables need a dedicated kernels runner.
112
+
113
+ <!-- staged from fastforks 1cbf1671 (2026-11-15) -->