Instructions to use kerasformers/dinov2_vits14 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasFormers
How to use kerasformers/dinov2_vits14 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 kerasformers/dinov2_vits14 with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://kerasformers/dinov2_vits14") - Notebooks
- Google Colab
- Kaggle
See our collection for all versions of DINOv2.
Run DINOv2 with Keras 3: JAX, PyTorch, or TensorFlow
kerasformers/dinov2_vits14
Paper: DINOv2: Learning Robust Visual Features without Supervision (arXiv:2304.07193) · HF Papers
DINOv2 scales self-supervised ViT pretraining for strong transferable visual features without labels. These checkpoints are backbones that return patch tokens for downstream heads.
For more details on the model, please go to the upstream model card.
Pure-Keras 3 conversion of facebook/dinov2-small for kerasformers. One implementation runs unmodified on TensorFlow / Torch / JAX.
This is a self-supervised backbone (DinoV2Model), not a task head.
✨ Quick start
import os
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
import numpy as np
from PIL import Image
from kerasformers.models.dino_v2 import DinoV2Model
model = DinoV2Model.from_weights("kerasformers/dinov2_vits14", image_size=448)
image = Image.open("your_image.jpg").convert("RGB")
x = np.asarray(image.resize((448, 448)))[None].astype("float32")
tokens = model(x, training=False)
print(tokens.shape)
Load any DINOv2 variant the same way with from_weights("kerasformers/<variant>"):
| Variant | Hub | Backbone |
|---|---|---|
dinov2_vits14 |
kerasformers/dinov2_vits14 |
ViT-S/14 |
dinov2_vitb14 |
kerasformers/dinov2_vitb14 |
ViT-B/14 |
dinov2_vitl14 |
kerasformers/dinov2_vitl14 |
ViT-L/14 |
Tips
- Set
KERAS_BACKENDbefore importing Keras / kerasformers. - Feed raw
[0, 255]pixels; normalization happens inside by default. - See DINOv2 docs and Loading Weights.
- Community / upstream weights:
DinoV2Model.from_weights("hf:facebook/dinov2-small").
Special Thanks
A huge thank you to the Facebook AI Research DINOv2 authors for creating and releasing these models.
License: Apache 2.0.
- Downloads last month
- 20
Model tree for kerasformers/dinov2_vits14
Base model
facebook/dinov2-small