See our collection for all versions of DINO.

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

GitHub Docs Collection

kerasformers/dino_resnet50

Paper: Emerging Properties in Self-Supervised Vision Transformers (arXiv:2104.14294) · HF Papers

DINO is self-supervised: a student and teacher match across crops of the same image with no labels. The resulting features are semantic for free. These checkpoints are backbones that return tokens / feature maps.

Pure-Keras 3 port for kerasformers, converted from the official upstream release. One implementation runs unmodified on TensorFlow / Torch / JAX.

This is a self-supervised backbone (DinoResNetModel), 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 import DinoResNetModel

model = DinoResNetModel.from_weights("kerasformers/dino_resnet50", 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 DINO variant the same way with from_weights("kerasformers/<variant>"):

Variant Hub Backbone
dino_vits16 kerasformers/dino_vits16 ViT-S/16
dino_vits8 kerasformers/dino_vits8 ViT-S/8
dino_vitb16 kerasformers/dino_vitb16 ViT-B/16
dino_vitb8 kerasformers/dino_vitb8 ViT-B/8
dino_resnet50 kerasformers/dino_resnet50 ResNet-50

Tips

  • Set KERAS_BACKEND before importing Keras / kerasformers.
  • Feed raw [0, 255] pixels; normalization happens inside by default.
  • dino_resnet50 was converted from torch.hub facebookresearch/dino.
  • See DINO docs and Loading Weights.
  • Community / upstream weights: See the KerasFormers docs for upstream conversion notes.

Special Thanks

A huge thank you to the Facebook AI Research DINO authors for creating and releasing these models.

License: Apache 2.0.

Downloads last month
34
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Collection including kerasformers/dino_resnet50

Paper for kerasformers/dino_resnet50