card: update from fastforks 1cbf1671
Browse files
README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: "fastforks"
|
| 3 |
+
pipeline_tag: "image-feature-extraction"
|
| 4 |
+
license: "apache-2.0"
|
| 5 |
+
tags:
|
| 6 |
+
- "features"
|
| 7 |
+
- "backbone"
|
| 8 |
+
- "feature-extraction"
|
| 9 |
+
- "cuda"
|
| 10 |
+
- "pytorch"
|
| 11 |
+
- "fastforks"
|
| 12 |
+
- "fastforks-card"
|
| 13 |
+
base_model:
|
| 14 |
+
- "google/tipsv2-b14"
|
| 15 |
+
- "google/tipsv2-l14"
|
| 16 |
+
---
|
| 17 |
+
# TIPSv2 (fastforks)
|
| 18 |
+
|
| 19 |
+
TIPSv2 (Google DeepMind, CVPR 2026) image encoders: ViT-B / L at patch 14 from text-image pretraining with patch-text alignment; dense patch tokens and two global tokens at any size (native 448 px).
|
| 20 |
+
|
| 21 |
+
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/google-deepmind/tips> at `bf10a73`.
|
| 22 |
+
|
| 23 |
+
Author weight repos: <https://huggingface.co/google/tipsv2-b14>, <https://huggingface.co/google/tipsv2-l14>.
|
| 24 |
+
|
| 25 |
+
Task: features. Tier: experimental. Outputs: `last_hidden_state`, `pooler_output`, `hidden_states`. Backends: `portable`, `kernels`.
|
| 26 |
+
|
| 27 |
+
Input: one RGB image. Output: dense patch features and a pooled image feature.
|
| 28 |
+
|
| 29 |
+
## Variants
|
| 30 |
+
|
| 31 |
+
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/features/models/tipsv2/card.toml).
|
| 32 |
+
|
| 33 |
+
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|
| 34 |
+
|---|---|---|---|---|
|
| 35 |
+
| `tipsv2-b14@1` | [tipsv2-b14/model.safetensors](https://huggingface.co/google/tipsv2-b14/resolve/ed1e4dc6b74bf3935ae099e9d5eb30fa96528454/model.safetensors) | `c19aec1a777c` | Apache-2.0 | yes |
|
| 36 |
+
| `tipsv2-l14@1` | [tipsv2-l14/model.safetensors](https://huggingface.co/google/tipsv2-l14/resolve/52847a71eb02a3082c370fbcd98cd799687bd4d0/model.safetensors) | `c75707eabca6` | Apache-2.0 | yes |
|
| 37 |
+
|
| 38 |
+
## Licence
|
| 39 |
+
|
| 40 |
+
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Licence files: `LICENSE`.
|
| 41 |
+
|
| 42 |
+
Training data: image-text pairs; the dataset is not named in the repository README or on the model cards at the pinned revisions.
|
| 43 |
+
|
| 44 |
+
Licence evidence: https://huggingface.co/google/tipsv2-b14/blob/ed1e4dc6b74bf3935ae099e9d5eb30fa96528454/README.md (license: apache-2.0); code: https://github.com/google-deepmind/tips/blob/bf10a73765b048edfbfcdf1f7e6ca8292542baae/LICENSE
|
| 45 |
+
|
| 46 |
+
## Input size
|
| 47 |
+
|
| 48 |
+
any H x W >= 1, resized or padded inside the model
|
| 49 |
+
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `tipsv2-b14` 3000x4000 (1.4 GiB peak allocated, 2.2 reserved); `tipsv2-l14` 3000x4000 (2.2 GiB peak allocated, 2.2 reserved)
|
| 50 |
+
|
| 51 |
+
## Speed and memory
|
| 52 |
+
|
| 53 |
+
### Features, synthetic, 224x224
|
| 54 |
+
|
| 55 |
+
| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|
| 56 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 57 |
+
| `tipsv2-b14` | 7.03 | 7.21 | 2.93 | 1.49 | 4.7x | 2.0x | 529 / 548 | 204 / 224 | 206 / 226 |
|
| 58 |
+
| `tipsv2-l14` | 21.9 | 14.2 | 6.15 | 4.58 | 3.1x | 1.3x | 1776 / 1786 | 621 / 624 | 624 / 648 |
|
| 59 |
+
|
| 60 |
+
### Startup and first call
|
| 61 |
+
|
| 62 |
+
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|
| 63 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 64 |
+
| `tipsv2-b14` | 0.90 | 0.20 | 1.42 | 0.07 | 0.18 | 0.09 |
|
| 65 |
+
| `tipsv2-l14` | 3.10 | 2.91 | 1.44 | 0.02 | 0.08 | 0.11 |
|
| 66 |
+
|
| 67 |
+
### torch.compile and TensorRT
|
| 68 |
+
|
| 69 |
+
| 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) |
|
| 70 |
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
| 71 |
+
| `tipsv2-b14` | 224x224 | 2.93 ms | 2.18 ms | 1.33 ms | 1.49 ms | 9.18 s | 41.5 s | 204 / 224 | 239 / 266 | 206 / 226 | 398 / 422 |
|
| 72 |
+
| `tipsv2-l14` | 224x224 | 6.15 ms | 6.04 ms | 4.28 ms | 4.58 ms | 12.4 s | 47.9 s | 621 / 624 | 659 / 666 | 624 / 648 | 1236 / 1264 |
|
| 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 |
+
Two disjoint seeded subsets of the val folders; each image shorter side 256 (bicubic), centre crop 224, the CLS / pooled feature; cosine kNN, vote weighted by similarity. Original = the original code named under Details, same checkpoint and protocol.
|
| 83 |
+
|
| 84 |
+
| variant | dataset | original fp32 | original fp16 | portable | kernels | note |
|
| 85 |
+
|---|---|---|---|---|---|---|
|
| 86 |
+
| `tipsv2-b14` | ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) | 59.34 | 59.30 | 59.36 | 59.16 | |
|
| 87 |
+
| `tipsv2-l14` | ImageNet-1k val, kNN top-1 % (k = 20, 10000 labelled / 5000 test images) | 63.48 | 63.44 | 63.42 | 63.42 | |
|
| 88 |
+
|
| 89 |
+
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 8b2f2df5, 2026-11-10.
|
| 90 |
+
|
| 91 |
+
### Parity with the original code
|
| 92 |
+
|
| 93 |
+
Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 6.9e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 1.9 % and p99 <= 6.9 % of the reference's median |value| (absolute error of the output `last_hidden_state`).
|
| 94 |
+
|
| 95 |
+
## Limitations
|
| 96 |
+
|
| 97 |
+
- Image encoder only: the text encoder in the checkpoint is not loaded (the features task has no text input), although the file is downloaded whole.
|
| 98 |
+
- last_hidden_state holds 2 prefix tokens, then the patches: upstream's first cls token (pooler_output, the global image embedding aligned with text) and its second cls token (index 1, the spatially aware global embedding).
|
| 99 |
+
- kernels replays a CUDA graph per small input shape without hidden states (up to about 520k activations: ViT-B ~360 px, ViT-L ~310 px), captured on the shape's second call, at most 4 per model; `model.release_graphs()` frees them.
|
| 100 |
+
|
| 101 |
+
## Usage
|
| 102 |
+
|
| 103 |
+
```python
|
| 104 |
+
from fastforks import features
|
| 105 |
+
|
| 106 |
+
model = features.load("tipsv2-b14") # mode="auto": the preferred backend from recorded measurements
|
| 107 |
+
result = model("photo.jpg", size=518)
|
| 108 |
+
result.last_hidden_state # tokens [N, C], as Hugging Face's output
|
| 109 |
+
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `tipsv2-b14`, `tipsv2-l14`.
|
| 113 |
+
|
| 114 |
+
## Kernels backend
|
| 115 |
+
|
| 116 |
+
`features.load("tipsv2-b14", mode="kernels")` runs our CUDA kernels (`fastbb`, `dpt_fused`). 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.
|
| 117 |
+
|
| 118 |
+
<!-- staged from fastforks 1cbf1671 (2026-11-15) -->
|