Instructions to use zeromodels/tipsv2-so400m14 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasFormers
How to use zeromodels/tipsv2-so400m14 with KerasFormers:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Keras
How to use zeromodels/tipsv2-so400m14 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/tipsv2-so400m14") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files- README.md +83 -0
- kf_config.json +39 -0
- kf_preprocessor.json +22 -0
- model.weights.h5 +3 -0
- tokenizer.json +0 -0
README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pipeline_tag: zero-shot-image-classification
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
base_model: google/tipsv2-so400m14
|
| 5 |
+
library_name: kerasformers
|
| 6 |
+
tags:
|
| 7 |
+
- keras
|
| 8 |
+
- kerasformers
|
| 9 |
+
- tipsv2
|
| 10 |
+
- zero-shot-image-classification
|
| 11 |
+
- vision
|
| 12 |
+
- arxiv:2604.12012
|
| 13 |
+
- pytorch
|
| 14 |
+
- jax
|
| 15 |
+
- tf
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
## ***See [our collection](https://huggingface.co/collections/kerasformers/tipsv2-6a8a3f36af77204954a49fb4) for all versions of TIPSv2.***
|
| 19 |
+
|
| 20 |
+
# Run TIPSv2 with Keras 3: JAX, PyTorch, or TensorFlow
|
| 21 |
+
|
| 22 |
+
[](https://github.com/IMvision12/KerasFormers) [](https://huggingface.co/collections/kerasformers/tipsv2-6a8a3f36af77204954a49fb4)
|
| 23 |
+
|
| 24 |
+
# kerasformers/tipsv2-so400m14
|
| 25 |
+
|
| 26 |
+
Paper: [TIPSv2: Advancing Vision-Language Pretraining with Enhanced Patch-Text Alignment (arXiv:2604.12012)](https://huggingface.co/papers/2604.12012)
|
| 27 |
+
|
| 28 |
+
TIPSv2 (Google DeepMind) is a CLIP/SigLIP-style dual encoder: a DINOv2-style ViT vision tower with register tokens plus a bidirectional text tower, aligned with a temperature-scaled contrastive objective.
|
| 29 |
+
|
| 30 |
+
For more details on the model, please go to the upstream [model card](https://huggingface.co/google/tipsv2-so400m14).
|
| 31 |
+
|
| 32 |
+
Pure-**Keras 3** conversion of [`google/tipsv2-so400m14`](https://huggingface.co/google/tipsv2-so400m14) for [kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on **TensorFlow / Torch / JAX**. The full model and both towers load from this single repo.
|
| 33 |
+
|
| 34 |
+
## ✨ Quick start (zero-shot)
|
| 35 |
+
|
| 36 |
+
```python
|
| 37 |
+
import os
|
| 38 |
+
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 39 |
+
|
| 40 |
+
from PIL import Image
|
| 41 |
+
import numpy as np
|
| 42 |
+
import keras
|
| 43 |
+
from kerasformers.models.tipsv2 import Tipsv2Model, Tipsv2Processor
|
| 44 |
+
|
| 45 |
+
model = Tipsv2Model.from_weights("kerasformers/tipsv2-so400m14")
|
| 46 |
+
processor = Tipsv2Processor.from_weights("kerasformers/tipsv2-so400m14")
|
| 47 |
+
|
| 48 |
+
image = Image.open("your_image.jpg").convert("RGB")
|
| 49 |
+
texts = ["a photo of a cat", "a photo of a dog", "a photo of a car"]
|
| 50 |
+
inputs = processor(text=texts, images=np.array(image))
|
| 51 |
+
out = model(inputs)
|
| 52 |
+
probs = keras.ops.softmax(out["logits_per_image"], axis=-1)
|
| 53 |
+
print(keras.ops.convert_to_numpy(probs)[0])
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
Towers only:
|
| 57 |
+
|
| 58 |
+
```python
|
| 59 |
+
from kerasformers.models.tipsv2 import Tipsv2VisionModel, Tipsv2TextModel
|
| 60 |
+
vision = Tipsv2VisionModel.from_weights("kerasformers/tipsv2-so400m14")
|
| 61 |
+
text = Tipsv2TextModel.from_weights("kerasformers/tipsv2-so400m14")
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
All TIPSv2 variants load the same way with `from_weights("kerasformers/<variant>")`:
|
| 65 |
+
|
| 66 |
+
| Variant | Hub |
|
| 67 |
+
|---|---|
|
| 68 |
+
| `tipsv2-b14` | [`kerasformers/tipsv2-b14`](https://huggingface.co/kerasformers/tipsv2-b14) |
|
| 69 |
+
| `tipsv2-l14` | [`kerasformers/tipsv2-l14`](https://huggingface.co/kerasformers/tipsv2-l14) |
|
| 70 |
+
| `tipsv2-so400m14` | [`kerasformers/tipsv2-so400m14`](https://huggingface.co/kerasformers/tipsv2-so400m14) |
|
| 71 |
+
| `tipsv2-g14` | [`kerasformers/tipsv2-g14`](https://huggingface.co/kerasformers/tipsv2-g14) |
|
| 72 |
+
|
| 73 |
+
## Tips
|
| 74 |
+
|
| 75 |
+
- Set `KERAS_BACKEND` **before** importing Keras / kerasformers.
|
| 76 |
+
- The image processor rescales to `[0, 1]` (no mean/std normalization); input resolution is 448.
|
| 77 |
+
- Upstream checkpoints: `Tipsv2Model.from_weights("hf:google/tipsv2-so400m14")`.
|
| 78 |
+
|
| 79 |
+
## Special Thanks
|
| 80 |
+
|
| 81 |
+
A huge thank you to the TIPSv2 authors (Google DeepMind) and the HF community.
|
| 82 |
+
|
| 83 |
+
License: Apache-2.0 (matches the upstream `google/tipsv2-so400m14` checkpoint).
|
kf_config.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"library_name": "kerasformers",
|
| 3 |
+
"kerasformers_version": "1.2.5",
|
| 4 |
+
"model_module": "kerasformers.models.tipsv2",
|
| 5 |
+
"model_class": "Tipsv2Model",
|
| 6 |
+
"variant": "tipsv2-so400m14",
|
| 7 |
+
"weights": "model.weights.h5",
|
| 8 |
+
"schema_version": 2,
|
| 9 |
+
"model_type": "tipsv2",
|
| 10 |
+
"text_config": {
|
| 11 |
+
"hidden_dim": 1152,
|
| 12 |
+
"num_layers": 27,
|
| 13 |
+
"num_heads": 16,
|
| 14 |
+
"mlp_dim": 4304,
|
| 15 |
+
"vocab_size": 32000,
|
| 16 |
+
"max_seq_len": 64,
|
| 17 |
+
"hidden_act": "relu",
|
| 18 |
+
"layer_norm_eps": 1e-05,
|
| 19 |
+
"scale_sqrt_depth": true,
|
| 20 |
+
"pooling_epsilon": 1e-08,
|
| 21 |
+
"pad_token_id": 0
|
| 22 |
+
},
|
| 23 |
+
"vision_config": {
|
| 24 |
+
"hidden_dim": 1152,
|
| 25 |
+
"num_layers": 27,
|
| 26 |
+
"num_heads": 16,
|
| 27 |
+
"mlp_ratio": 3.736111111111111,
|
| 28 |
+
"hidden_act": "gelu",
|
| 29 |
+
"image_size": 448,
|
| 30 |
+
"patch_size": 14,
|
| 31 |
+
"num_channels": 3,
|
| 32 |
+
"qkv_bias": true,
|
| 33 |
+
"layerscale_value": 1.0,
|
| 34 |
+
"use_swiglu_ffn": false,
|
| 35 |
+
"num_register_tokens": 1,
|
| 36 |
+
"layer_norm_eps": 1e-06
|
| 37 |
+
},
|
| 38 |
+
"temperature_init_value": 0.004638021811842918
|
| 39 |
+
}
|
kf_preprocessor.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"library_name": "kerasformers",
|
| 3 |
+
"kerasformers_version": "1.2.5",
|
| 4 |
+
"preprocessor_module": "kerasformers.models.tipsv2",
|
| 5 |
+
"preprocessor_class": "Tipsv2ImageProcessor",
|
| 6 |
+
"variant": "tipsv2-so400m14",
|
| 7 |
+
"image_resolution": 448,
|
| 8 |
+
"resample": "bilinear",
|
| 9 |
+
"do_normalize": false,
|
| 10 |
+
"do_resize": true,
|
| 11 |
+
"mean": [
|
| 12 |
+
0.0,
|
| 13 |
+
0.0,
|
| 14 |
+
0.0
|
| 15 |
+
],
|
| 16 |
+
"std": [
|
| 17 |
+
1.0,
|
| 18 |
+
1.0,
|
| 19 |
+
1.0
|
| 20 |
+
],
|
| 21 |
+
"data_format": "channels_last"
|
| 22 |
+
}
|
model.weights.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d60410212fde63658171a9f22efa9e4b97ced41aaf14d32e205bb24416741a35
|
| 3 |
+
size 3449079056
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|