See our collection for all versions of DINOv2.

Run DINOv2 with Keras 3: JAX, PyTorch, or TensorFlow

GitHub Docs Collection

kerasformers/dinov2-large

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-large 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"

from kerasformers.models.dino_v2 import DinoV2Model, DinoV2ImageProcessor

# The processor resizes + ImageNet-normalizes, so build the model with
# include_normalization=False (it would otherwise normalize a second time).
model = DinoV2Model.from_weights(
    "kerasformers/dinov2-large", include_normalization=False
)
processor = DinoV2ImageProcessor.from_weights("kerasformers/dinov2-large")

pixel_values = processor("your_image.jpg")["pixel_values"]
features = model(pixel_values, training=False)
print(pixel_values.shape, features.shape)

Load any DINOv2 variant the same way with from_weights("kerasformers/<variant>"):

Variant Hub Backbone
dinov2-small kerasformers/dinov2-small ViT-S/14
dinov2-base kerasformers/dinov2-base ViT-B/14
dinov2-large kerasformers/dinov2-large ViT-L/14
dinov2-giant kerasformers/dinov2-giant ViT-g/14

Tips

  • Set KERAS_BACKEND before importing Keras / kerasformers.
  • The processor normalizes; pair it with include_normalization=False. To skip it, feed raw [0, 255] pixels and keep the default include_normalization=True.
  • See DINOv2 docs and Loading Weights.
  • Community / upstream weights: DinoV2Model.from_weights("hf:facebook/dinov2-large").

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
24
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for kerasformers/dinov2-large

Finetuned
(38)
this model

Collection including kerasformers/dinov2-large

Paper for kerasformers/dinov2-large