Instructions to use zeromodels/dinov2-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ZeroModels
How to use zeromodels/dinov2-base with ZeroModels:
# pip install -U zeromodels # ZeroModels is pure Keras 3, so pick a backend: "jax", "torch" or "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" from zeromodels import AutoZModel # AutoZModel reads the repo's model_type and loads the matching class. # For a task head use the matching loader, e.g. AutoZMImageClassify / AutoZMDetect / # AutoZMSemanticSegment / AutoZMTextGenerate (see zeromodels.auto). model = AutoZModel.from_weights("zeromodels/dinov2-base") - Keras
How to use zeromodels/dinov2-base with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://zeromodels/dinov2-base") - Notebooks
- Google Colab
- Kaggle
fix readme.md
Browse files
README.md
CHANGED
|
@@ -25,7 +25,8 @@ tags:
|
|
| 25 |
|
| 26 |
Paper: [DINOv2: Learning Robust Visual Features without Supervision (arXiv:2304.07193)](https://arxiv.org/abs/2304.07193) 路 [HF Papers](https://huggingface.co/papers/2304.07193)
|
| 27 |
|
| 28 |
-
DINOv2 scales self-supervised ViT pretraining for strong transferable visual features without labels. These checkpoints are backbones that return patch tokens for downstream heads.
|
|
|
|
| 29 |
For more details on the model, please go to the upstream [model card](https://huggingface.co/facebook/dinov2-base).
|
| 30 |
|
| 31 |
Pure-**Keras 3** conversion of [`facebook/dinov2-base`](https://huggingface.co/facebook/dinov2-base) for [kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
|
|
@@ -40,9 +41,9 @@ os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
|
| 40 |
|
| 41 |
import numpy as np
|
| 42 |
from PIL import Image
|
| 43 |
-
from
|
| 44 |
|
| 45 |
-
model =
|
| 46 |
image = Image.open("your_image.jpg").convert("RGB")
|
| 47 |
x = np.asarray(image.resize((448, 448)))[None].astype("float32")
|
| 48 |
tokens = model(x, training=False)
|
|
|
|
| 25 |
|
| 26 |
Paper: [DINOv2: Learning Robust Visual Features without Supervision (arXiv:2304.07193)](https://arxiv.org/abs/2304.07193) 路 [HF Papers](https://huggingface.co/papers/2304.07193)
|
| 27 |
|
| 28 |
+
DINOv2 scales self-supervised ViT pretraining for strong transferable visual features without labels. These checkpoints are backbones that return patch tokens for downstream heads.
|
| 29 |
+
|
| 30 |
For more details on the model, please go to the upstream [model card](https://huggingface.co/facebook/dinov2-base).
|
| 31 |
|
| 32 |
Pure-**Keras 3** conversion of [`facebook/dinov2-base`](https://huggingface.co/facebook/dinov2-base) for [kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
|
|
|
|
| 41 |
|
| 42 |
import numpy as np
|
| 43 |
from PIL import Image
|
| 44 |
+
from kerasformers.models.dino_v2 import DinoV2Model
|
| 45 |
|
| 46 |
+
model = DinoV2Model.from_weights("kerasformers/dinov2_vitb14", image_size=448)
|
| 47 |
image = Image.open("your_image.jpg").convert("RGB")
|
| 48 |
x = np.asarray(image.resize((448, 448)))[None].astype("float32")
|
| 49 |
tokens = model(x, training=False)
|