Instructions to use zeromodels/vit_small_patch16_224_augreg_in1k with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use zeromodels/vit_small_patch16_224_augreg_in1k with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://zeromodels/vit_small_patch16_224_augreg_in1k") - Notebooks
- Google Colab
- Kaggle
Migrate to zeromodels (rename kf_*.json -> zm_*.json, fix refs in config + README, ensure tag + badge)
Browse files- README.md +39 -39
- kf_config.json → zm_config.json +21 -21
README.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
| 2 |
pipeline_tag: image-classification
|
| 3 |
license: apache-2.0
|
| 4 |
base_model: timm/vit_small_patch16_224.augreg_in1k
|
| 5 |
-
library_name:
|
| 6 |
tags:
|
| 7 |
- keras
|
| 8 |
-
-
|
| 9 |
- image-classification
|
| 10 |
- vit
|
| 11 |
- backbone
|
|
@@ -15,13 +15,13 @@ tags:
|
|
| 15 |
- tf
|
| 16 |
---
|
| 17 |
|
| 18 |
-
## ***See [our collection](https://huggingface.co/collections/
|
| 19 |
|
| 20 |
# Run ViT with Keras 3: JAX, PyTorch, or TensorFlow
|
| 21 |
|
| 22 |
-
[](https://arxiv.org/abs/2010.11929) · [HF Papers](https://huggingface.co/papers/2010.11929)
|
| 27 |
|
|
@@ -29,7 +29,7 @@ Vision Transformer (ViT) patches an image and runs a transformer encoder. Use `V
|
|
| 29 |
|
| 30 |
For more details on the model, please go to the upstream [model card](https://huggingface.co/timm/vit_small_patch16_224.augreg_in1k).
|
| 31 |
|
| 32 |
-
Pure-**Keras 3** conversion of [`timm/vit_small_patch16_224.augreg_in1k`](https://huggingface.co/timm/vit_small_patch16_224.augreg_in1k) for [
|
| 33 |
|
| 34 |
This is an **image-classification / backbone** checkpoint (`ViTImageClassify` / `ViTModel`).
|
| 35 |
|
|
@@ -41,11 +41,11 @@ os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
|
| 41 |
|
| 42 |
from PIL import Image
|
| 43 |
import numpy as np
|
| 44 |
-
from
|
| 45 |
|
| 46 |
-
model = ViTImageClassify.from_weights("
|
| 47 |
backbone = ViTModel.from_weights(
|
| 48 |
-
"
|
| 49 |
)
|
| 50 |
|
| 51 |
image = Image.open("your_image.jpg").convert("RGB")
|
|
@@ -56,43 +56,43 @@ feats = backbone(x)
|
|
| 56 |
print(len(feats), [tuple(f.shape) for f in feats])
|
| 57 |
```
|
| 58 |
|
| 59 |
-
Load any ViT variant the same way with `from_weights("
|
| 60 |
|
| 61 |
| Variant | Hub |
|
| 62 |
|---|---|
|
| 63 |
-
| `vit_base_patch16_224_augreg_in1k` | [`
|
| 64 |
-
| `vit_base_patch16_224_augreg_in21k` | [`
|
| 65 |
-
| `vit_base_patch16_224_augreg_in21k_ft_in1k` | [`
|
| 66 |
-
| `vit_base_patch16_224_orig_in21k_ft_in1k` | [`
|
| 67 |
-
| `vit_base_patch16_384_augreg_in1k` | [`
|
| 68 |
-
| `vit_base_patch16_384_augreg_in21k_ft_in1k` | [`
|
| 69 |
-
| `vit_base_patch16_384_orig_in21k_ft_in1k` | [`
|
| 70 |
-
| `vit_base_patch32_224_augreg_in1k` | [`
|
| 71 |
-
| `vit_base_patch32_224_augreg_in21k` | [`
|
| 72 |
-
| `vit_base_patch32_224_augreg_in21k_ft_in1k` | [`
|
| 73 |
-
| `vit_base_patch32_384_augreg_in1k` | [`
|
| 74 |
-
| `vit_base_patch32_384_augreg_in21k_ft_in1k` | [`
|
| 75 |
-
| `vit_large_patch16_224_augreg_in21k` | [`
|
| 76 |
-
| `vit_large_patch16_224_augreg_in21k_ft_in1k` | [`
|
| 77 |
-
| `vit_large_patch16_384_augreg_in21k_ft_in1k` | [`
|
| 78 |
-
| `vit_large_patch32_384_orig_in21k_ft_in1k` | [`
|
| 79 |
-
| `vit_small_patch16_224_augreg_in1k` | [`
|
| 80 |
-
| `vit_small_patch16_224_augreg_in21k` | [`
|
| 81 |
-
| `vit_small_patch16_224_augreg_in21k_ft_in1k` | [`
|
| 82 |
-
| `vit_small_patch16_384_augreg_in1k` | [`
|
| 83 |
-
| `vit_small_patch16_384_augreg_in21k_ft_in1k` | [`
|
| 84 |
-
| `vit_small_patch32_224_augreg_in21k` | [`
|
| 85 |
-
| `vit_small_patch32_224_augreg_in21k_ft_in1k` | [`
|
| 86 |
-
| `vit_small_patch32_384_augreg_in21k_ft_in1k` | [`
|
| 87 |
-
| `vit_tiny_patch16_224_augreg_in21k` | [`
|
| 88 |
-
| `vit_tiny_patch16_224_augreg_in21k_ft_in1k` | [`
|
| 89 |
-
| `vit_tiny_patch16_384_augreg_in21k_ft_in1k` | [`
|
| 90 |
|
| 91 |
## Tips
|
| 92 |
|
| 93 |
-
- Set `KERAS_BACKEND` **before** importing Keras /
|
| 94 |
- `ViTImageClassify` returns class logits; `ViTModel` returns features (`as_backbone=True` for multi-scale stages).
|
| 95 |
-
- See [docs](https://imvision12.github.io/
|
| 96 |
- Upstream / timm checkpoints: `ViTImageClassify.from_weights("hf:timm/vit_small_patch16_224.augreg_in1k")`.
|
| 97 |
|
| 98 |
## Special Thanks
|
|
|
|
| 2 |
pipeline_tag: image-classification
|
| 3 |
license: apache-2.0
|
| 4 |
base_model: timm/vit_small_patch16_224.augreg_in1k
|
| 5 |
+
library_name: zeromodels
|
| 6 |
tags:
|
| 7 |
- keras
|
| 8 |
+
- zeromodels
|
| 9 |
- image-classification
|
| 10 |
- vit
|
| 11 |
- backbone
|
|
|
|
| 15 |
- tf
|
| 16 |
---
|
| 17 |
|
| 18 |
+
## ***See [our collection](https://huggingface.co/collections/zeromodels/vit-6a6d51a16516088e6ab2ec60) for all versions of ViT.***
|
| 19 |
|
| 20 |
# Run ViT with Keras 3: JAX, PyTorch, or TensorFlow
|
| 21 |
|
| 22 |
+
[](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/classification_backbones/) [](https://huggingface.co/collections/zeromodels/vit-6a6d51a16516088e6ab2ec60)
|
| 23 |
|
| 24 |
+
# zeromodels/vit_small_patch16_224_augreg_in1k
|
| 25 |
|
| 26 |
Paper: [An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale (arXiv:2010.11929)](https://arxiv.org/abs/2010.11929) · [HF Papers](https://huggingface.co/papers/2010.11929)
|
| 27 |
|
|
|
|
| 29 |
|
| 30 |
For more details on the model, please go to the upstream [model card](https://huggingface.co/timm/vit_small_patch16_224.augreg_in1k).
|
| 31 |
|
| 32 |
+
Pure-**Keras 3** conversion of [`timm/vit_small_patch16_224.augreg_in1k`](https://huggingface.co/timm/vit_small_patch16_224.augreg_in1k) for [zeromodels](https://github.com/IMvision12/ZeroModels). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
|
| 33 |
|
| 34 |
This is an **image-classification / backbone** checkpoint (`ViTImageClassify` / `ViTModel`).
|
| 35 |
|
|
|
|
| 41 |
|
| 42 |
from PIL import Image
|
| 43 |
import numpy as np
|
| 44 |
+
from zeromodels.models.vit import ViTImageClassify, ViTModel
|
| 45 |
|
| 46 |
+
model = ViTImageClassify.from_weights("zeromodels/vit_small_patch16_224_augreg_in1k")
|
| 47 |
backbone = ViTModel.from_weights(
|
| 48 |
+
"zeromodels/vit_small_patch16_224_augreg_in1k", as_backbone=True
|
| 49 |
)
|
| 50 |
|
| 51 |
image = Image.open("your_image.jpg").convert("RGB")
|
|
|
|
| 56 |
print(len(feats), [tuple(f.shape) for f in feats])
|
| 57 |
```
|
| 58 |
|
| 59 |
+
Load any ViT variant the same way with `from_weights("zeromodels/<variant>")`:
|
| 60 |
|
| 61 |
| Variant | Hub |
|
| 62 |
|---|---|
|
| 63 |
+
| `vit_base_patch16_224_augreg_in1k` | [`zeromodels/vit_base_patch16_224_augreg_in1k`](https://huggingface.co/zeromodels/vit_base_patch16_224_augreg_in1k) |
|
| 64 |
+
| `vit_base_patch16_224_augreg_in21k` | [`zeromodels/vit_base_patch16_224_augreg_in21k`](https://huggingface.co/zeromodels/vit_base_patch16_224_augreg_in21k) |
|
| 65 |
+
| `vit_base_patch16_224_augreg_in21k_ft_in1k` | [`zeromodels/vit_base_patch16_224_augreg_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_base_patch16_224_augreg_in21k_ft_in1k) |
|
| 66 |
+
| `vit_base_patch16_224_orig_in21k_ft_in1k` | [`zeromodels/vit_base_patch16_224_orig_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_base_patch16_224_orig_in21k_ft_in1k) |
|
| 67 |
+
| `vit_base_patch16_384_augreg_in1k` | [`zeromodels/vit_base_patch16_384_augreg_in1k`](https://huggingface.co/zeromodels/vit_base_patch16_384_augreg_in1k) |
|
| 68 |
+
| `vit_base_patch16_384_augreg_in21k_ft_in1k` | [`zeromodels/vit_base_patch16_384_augreg_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_base_patch16_384_augreg_in21k_ft_in1k) |
|
| 69 |
+
| `vit_base_patch16_384_orig_in21k_ft_in1k` | [`zeromodels/vit_base_patch16_384_orig_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_base_patch16_384_orig_in21k_ft_in1k) |
|
| 70 |
+
| `vit_base_patch32_224_augreg_in1k` | [`zeromodels/vit_base_patch32_224_augreg_in1k`](https://huggingface.co/zeromodels/vit_base_patch32_224_augreg_in1k) |
|
| 71 |
+
| `vit_base_patch32_224_augreg_in21k` | [`zeromodels/vit_base_patch32_224_augreg_in21k`](https://huggingface.co/zeromodels/vit_base_patch32_224_augreg_in21k) |
|
| 72 |
+
| `vit_base_patch32_224_augreg_in21k_ft_in1k` | [`zeromodels/vit_base_patch32_224_augreg_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_base_patch32_224_augreg_in21k_ft_in1k) |
|
| 73 |
+
| `vit_base_patch32_384_augreg_in1k` | [`zeromodels/vit_base_patch32_384_augreg_in1k`](https://huggingface.co/zeromodels/vit_base_patch32_384_augreg_in1k) |
|
| 74 |
+
| `vit_base_patch32_384_augreg_in21k_ft_in1k` | [`zeromodels/vit_base_patch32_384_augreg_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_base_patch32_384_augreg_in21k_ft_in1k) |
|
| 75 |
+
| `vit_large_patch16_224_augreg_in21k` | [`zeromodels/vit_large_patch16_224_augreg_in21k`](https://huggingface.co/zeromodels/vit_large_patch16_224_augreg_in21k) |
|
| 76 |
+
| `vit_large_patch16_224_augreg_in21k_ft_in1k` | [`zeromodels/vit_large_patch16_224_augreg_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_large_patch16_224_augreg_in21k_ft_in1k) |
|
| 77 |
+
| `vit_large_patch16_384_augreg_in21k_ft_in1k` | [`zeromodels/vit_large_patch16_384_augreg_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_large_patch16_384_augreg_in21k_ft_in1k) |
|
| 78 |
+
| `vit_large_patch32_384_orig_in21k_ft_in1k` | [`zeromodels/vit_large_patch32_384_orig_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_large_patch32_384_orig_in21k_ft_in1k) |
|
| 79 |
+
| `vit_small_patch16_224_augreg_in1k` | [`zeromodels/vit_small_patch16_224_augreg_in1k`](https://huggingface.co/zeromodels/vit_small_patch16_224_augreg_in1k) |
|
| 80 |
+
| `vit_small_patch16_224_augreg_in21k` | [`zeromodels/vit_small_patch16_224_augreg_in21k`](https://huggingface.co/zeromodels/vit_small_patch16_224_augreg_in21k) |
|
| 81 |
+
| `vit_small_patch16_224_augreg_in21k_ft_in1k` | [`zeromodels/vit_small_patch16_224_augreg_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_small_patch16_224_augreg_in21k_ft_in1k) |
|
| 82 |
+
| `vit_small_patch16_384_augreg_in1k` | [`zeromodels/vit_small_patch16_384_augreg_in1k`](https://huggingface.co/zeromodels/vit_small_patch16_384_augreg_in1k) |
|
| 83 |
+
| `vit_small_patch16_384_augreg_in21k_ft_in1k` | [`zeromodels/vit_small_patch16_384_augreg_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_small_patch16_384_augreg_in21k_ft_in1k) |
|
| 84 |
+
| `vit_small_patch32_224_augreg_in21k` | [`zeromodels/vit_small_patch32_224_augreg_in21k`](https://huggingface.co/zeromodels/vit_small_patch32_224_augreg_in21k) |
|
| 85 |
+
| `vit_small_patch32_224_augreg_in21k_ft_in1k` | [`zeromodels/vit_small_patch32_224_augreg_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_small_patch32_224_augreg_in21k_ft_in1k) |
|
| 86 |
+
| `vit_small_patch32_384_augreg_in21k_ft_in1k` | [`zeromodels/vit_small_patch32_384_augreg_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_small_patch32_384_augreg_in21k_ft_in1k) |
|
| 87 |
+
| `vit_tiny_patch16_224_augreg_in21k` | [`zeromodels/vit_tiny_patch16_224_augreg_in21k`](https://huggingface.co/zeromodels/vit_tiny_patch16_224_augreg_in21k) |
|
| 88 |
+
| `vit_tiny_patch16_224_augreg_in21k_ft_in1k` | [`zeromodels/vit_tiny_patch16_224_augreg_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_tiny_patch16_224_augreg_in21k_ft_in1k) |
|
| 89 |
+
| `vit_tiny_patch16_384_augreg_in21k_ft_in1k` | [`zeromodels/vit_tiny_patch16_384_augreg_in21k_ft_in1k`](https://huggingface.co/zeromodels/vit_tiny_patch16_384_augreg_in21k_ft_in1k) |
|
| 90 |
|
| 91 |
## Tips
|
| 92 |
|
| 93 |
+
- Set `KERAS_BACKEND` **before** importing Keras / zeromodels.
|
| 94 |
- `ViTImageClassify` returns class logits; `ViTModel` returns features (`as_backbone=True` for multi-scale stages).
|
| 95 |
+
- See [docs](https://imvision12.github.io/ZeroModels/classification_backbones/) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/).
|
| 96 |
- Upstream / timm checkpoints: `ViTImageClassify.from_weights("hf:timm/vit_small_patch16_224.augreg_in1k")`.
|
| 97 |
|
| 98 |
## Special Thanks
|
kf_config.json → zm_config.json
RENAMED
|
@@ -1,22 +1,22 @@
|
|
| 1 |
-
{
|
| 2 |
-
"library_name": "
|
| 3 |
-
"
|
| 4 |
-
"model_module": "
|
| 5 |
-
"model_class": "ViTImageClassify",
|
| 6 |
-
"variant": "vit_small_patch16_224_augreg_in1k",
|
| 7 |
-
"weights": "model.weights.h5",
|
| 8 |
-
"schema_version": 2,
|
| 9 |
-
"weight_dtype": "float32",
|
| 10 |
-
"model_type": "vit",
|
| 11 |
-
"vision_config": {
|
| 12 |
-
"patch_size": 16,
|
| 13 |
-
"embed_dim": 384,
|
| 14 |
-
"depth": 12,
|
| 15 |
-
"num_heads": 6,
|
| 16 |
-
"mlp_ratio": 4.0,
|
| 17 |
-
"qkv_bias": true,
|
| 18 |
-
"qk_norm": false,
|
| 19 |
-
"image_size": 224,
|
| 20 |
-
"num_classes": 1000
|
| 21 |
-
}
|
| 22 |
}
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"library_name": "zeromodels",
|
| 3 |
+
"zeromodels_version": "1.2.1",
|
| 4 |
+
"model_module": "zeromodels.models.vit",
|
| 5 |
+
"model_class": "ViTImageClassify",
|
| 6 |
+
"variant": "vit_small_patch16_224_augreg_in1k",
|
| 7 |
+
"weights": "model.weights.h5",
|
| 8 |
+
"schema_version": 2,
|
| 9 |
+
"weight_dtype": "float32",
|
| 10 |
+
"model_type": "vit",
|
| 11 |
+
"vision_config": {
|
| 12 |
+
"patch_size": 16,
|
| 13 |
+
"embed_dim": 384,
|
| 14 |
+
"depth": 12,
|
| 15 |
+
"num_heads": 6,
|
| 16 |
+
"mlp_ratio": 4.0,
|
| 17 |
+
"qkv_bias": true,
|
| 18 |
+
"qk_norm": false,
|
| 19 |
+
"image_size": 224,
|
| 20 |
+
"num_classes": 1000
|
| 21 |
+
}
|
| 22 |
}
|