IMvision12 commited on
Commit
bf4b67a
·
verified ·
1 Parent(s): 55d4df3

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. README.md +83 -0
  2. kf_config.json +39 -0
  3. kf_preprocessor.json +22 -0
  4. model.weights.h5 +3 -0
  5. 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-g14
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
+ [![GitHub](https://img.shields.io/badge/GitHub-KerasFormers-black?logo=github)](https://github.com/IMvision12/KerasFormers) [![Collection](https://img.shields.io/badge/HF-TIPSv2%20collection-yellow)](https://huggingface.co/collections/kerasformers/tipsv2-6a8a3f36af77204954a49fb4)
23
+
24
+ # kerasformers/tipsv2-g14
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-g14).
31
+
32
+ Pure-**Keras 3** conversion of [`google/tipsv2-g14`](https://huggingface.co/google/tipsv2-g14) 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-g14")
46
+ processor = Tipsv2Processor.from_weights("kerasformers/tipsv2-g14")
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-g14")
61
+ text = Tipsv2TextModel.from_weights("kerasformers/tipsv2-g14")
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-g14")`.
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-g14` 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-g14",
7
+ "weights": "model.weights.h5",
8
+ "schema_version": 2,
9
+ "model_type": "tipsv2",
10
+ "text_config": {
11
+ "hidden_dim": 1536,
12
+ "num_layers": 12,
13
+ "num_heads": 24,
14
+ "mlp_dim": 6144,
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": 1536,
25
+ "num_layers": 40,
26
+ "num_heads": 24,
27
+ "mlp_ratio": 4,
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": true,
35
+ "num_register_tokens": 1,
36
+ "layer_norm_eps": 1e-06
37
+ },
38
+ "temperature_init_value": 0.003622700460255146
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-g14",
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:cc01fe43d0102b70165d9a6ffdd69ee8569f1f4454d25c7b6818195bd45cd5bd
3
+ size 6102656128
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff