Instructions to use zeromodels/dino-resnet50 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ZeroModels
How to use zeromodels/dino-resnet50 with ZeroModels:
# 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 zeromodels/dino-resnet50 with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://zeromodels/dino-resnet50") - Notebooks
- Google Colab
- Kaggle
Add kf_preprocessor.json; load processor via from_weights
Browse files- README.md +75 -72
- kf_preprocessor.json +23 -0
README.md
CHANGED
|
@@ -1,72 +1,75 @@
|
|
| 1 |
-
---
|
| 2 |
-
pipeline_tag: image-feature-extraction
|
| 3 |
-
license: apache-2.0
|
| 4 |
-
library_name: kerasformers
|
| 5 |
-
tags:
|
| 6 |
-
- keras
|
| 7 |
-
- kerasformers
|
| 8 |
-
- dino
|
| 9 |
-
- feature-extraction
|
| 10 |
-
- vision
|
| 11 |
-
- arxiv:2104.14294
|
| 12 |
-
- pytorch
|
| 13 |
-
- jax
|
| 14 |
-
- tf
|
| 15 |
-
---
|
| 16 |
-
|
| 17 |
-
## ***See [our collection](https://huggingface.co/collections/kerasformers/dino-v1-v2-v3-6a6a94f8281a2f373f70e769) for all versions of DINO.***
|
| 18 |
-
|
| 19 |
-
# Run DINO with Keras 3: JAX, PyTorch, or TensorFlow
|
| 20 |
-
|
| 21 |
-
[](https://github.com/IMvision12/KerasFormers) [](https://imvision12.github.io/KerasFormers/dino/) [](https://huggingface.co/collections/kerasformers/dino-v1-v2-v3-6a6a94f8281a2f373f70e769)
|
| 22 |
-
|
| 23 |
-
# kerasformers/dino_resnet50
|
| 24 |
-
|
| 25 |
-
Paper: [Emerging Properties in Self-Supervised Vision Transformers (arXiv:2104.14294)](https://arxiv.org/abs/2104.14294) · [HF Papers](https://huggingface.co/papers/2104.14294)
|
| 26 |
-
|
| 27 |
-
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.
|
| 28 |
-
|
| 29 |
-
Pure-**Keras 3** port for [kerasformers](https://github.com/IMvision12/KerasFormers), converted from the official upstream release. One implementation runs unmodified on **TensorFlow / Torch / JAX**.
|
| 30 |
-
|
| 31 |
-
This is a **self-supervised backbone** (`DinoResNetModel`), not a task head.
|
| 32 |
-
|
| 33 |
-
## ✨ Quick start
|
| 34 |
-
|
| 35 |
-
```python
|
| 36 |
-
import os
|
| 37 |
-
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
model = DinoResNetModel.from_weights(
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
| 56 |
-
|
|
| 57 |
-
| `
|
| 58 |
-
| `
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
-
|
| 66 |
-
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pipeline_tag: image-feature-extraction
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
library_name: kerasformers
|
| 5 |
+
tags:
|
| 6 |
+
- keras
|
| 7 |
+
- kerasformers
|
| 8 |
+
- dino
|
| 9 |
+
- feature-extraction
|
| 10 |
+
- vision
|
| 11 |
+
- arxiv:2104.14294
|
| 12 |
+
- pytorch
|
| 13 |
+
- jax
|
| 14 |
+
- tf
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
## ***See [our collection](https://huggingface.co/collections/kerasformers/dino-v1-v2-v3-6a6a94f8281a2f373f70e769) for all versions of DINO.***
|
| 18 |
+
|
| 19 |
+
# Run DINO with Keras 3: JAX, PyTorch, or TensorFlow
|
| 20 |
+
|
| 21 |
+
[](https://github.com/IMvision12/KerasFormers) [](https://imvision12.github.io/KerasFormers/dino/) [](https://huggingface.co/collections/kerasformers/dino-v1-v2-v3-6a6a94f8281a2f373f70e769)
|
| 22 |
+
|
| 23 |
+
# kerasformers/dino_resnet50
|
| 24 |
+
|
| 25 |
+
Paper: [Emerging Properties in Self-Supervised Vision Transformers (arXiv:2104.14294)](https://arxiv.org/abs/2104.14294) · [HF Papers](https://huggingface.co/papers/2104.14294)
|
| 26 |
+
|
| 27 |
+
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.
|
| 28 |
+
|
| 29 |
+
Pure-**Keras 3** port for [kerasformers](https://github.com/IMvision12/KerasFormers), converted from the official upstream release. One implementation runs unmodified on **TensorFlow / Torch / JAX**.
|
| 30 |
+
|
| 31 |
+
This is a **self-supervised backbone** (`DinoResNetModel`), not a task head.
|
| 32 |
+
|
| 33 |
+
## ✨ Quick start
|
| 34 |
+
|
| 35 |
+
```python
|
| 36 |
+
import os
|
| 37 |
+
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 38 |
+
|
| 39 |
+
from kerasformers.models.dino import DinoResNetModel, DinoImageProcessor
|
| 40 |
+
|
| 41 |
+
# The processor resizes + ImageNet-normalizes, so build the model with
|
| 42 |
+
# include_normalization=False (it would otherwise normalize a second time).
|
| 43 |
+
model = DinoResNetModel.from_weights(
|
| 44 |
+
"kerasformers/dino_resnet50", include_normalization=False
|
| 45 |
+
)
|
| 46 |
+
processor = DinoImageProcessor.from_weights("kerasformers/dino_resnet50")
|
| 47 |
+
|
| 48 |
+
pixel_values = processor("your_image.jpg")["pixel_values"]
|
| 49 |
+
features = model(pixel_values, training=False)
|
| 50 |
+
print(pixel_values.shape, features.shape)
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
Load any DINO variant the same way with `from_weights("kerasformers/<variant>")`:
|
| 54 |
+
|
| 55 |
+
| Variant | Hub | Backbone |
|
| 56 |
+
|---|---|---|
|
| 57 |
+
| `dino_vits16` | [`kerasformers/dino_vits16`](https://huggingface.co/kerasformers/dino_vits16) | ViT-S/16 |
|
| 58 |
+
| `dino_vits8` | [`kerasformers/dino_vits8`](https://huggingface.co/kerasformers/dino_vits8) | ViT-S/8 |
|
| 59 |
+
| `dino_vitb16` | [`kerasformers/dino_vitb16`](https://huggingface.co/kerasformers/dino_vitb16) | ViT-B/16 |
|
| 60 |
+
| `dino_vitb8` | [`kerasformers/dino_vitb8`](https://huggingface.co/kerasformers/dino_vitb8) | ViT-B/8 |
|
| 61 |
+
| `dino_resnet50` | [`kerasformers/dino_resnet50`](https://huggingface.co/kerasformers/dino_resnet50) | ResNet-50 |
|
| 62 |
+
|
| 63 |
+
## Tips
|
| 64 |
+
|
| 65 |
+
- Set `KERAS_BACKEND` **before** importing Keras / kerasformers.
|
| 66 |
+
- The processor normalizes; pair it with `include_normalization=False`. To skip it, feed raw `[0, 255]` pixels and keep the default `include_normalization=True`.
|
| 67 |
+
- `dino_resnet50` was converted from torch.hub `facebookresearch/dino`.
|
| 68 |
+
- See [DINO docs](https://imvision12.github.io/KerasFormers/dino/) and [Loading Weights](https://imvision12.github.io/KerasFormers/loading_weights/).
|
| 69 |
+
- Community / upstream weights: See the KerasFormers docs for upstream conversion notes.
|
| 70 |
+
|
| 71 |
+
## Special Thanks
|
| 72 |
+
|
| 73 |
+
A huge thank you to the Facebook AI Research DINO authors for creating and releasing these models.
|
| 74 |
+
|
| 75 |
+
License: Apache 2.0.
|
kf_preprocessor.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"library_name": "kerasformers",
|
| 3 |
+
"kerasformers_version": "1.2.1",
|
| 4 |
+
"preprocessor_module": "kerasformers.models.dino",
|
| 5 |
+
"preprocessor_class": "DinoImageProcessor",
|
| 6 |
+
"variant": "dino_resnet50",
|
| 7 |
+
"image_resolution": 224,
|
| 8 |
+
"model_type": "dino_resnet",
|
| 9 |
+
"resize_size": 256,
|
| 10 |
+
"mean": [
|
| 11 |
+
0.48500001430511475,
|
| 12 |
+
0.4560000002384186,
|
| 13 |
+
0.4059999883174896
|
| 14 |
+
],
|
| 15 |
+
"std": [
|
| 16 |
+
0.2290000021457672,
|
| 17 |
+
0.2240000069141388,
|
| 18 |
+
0.22499999403953552
|
| 19 |
+
],
|
| 20 |
+
"do_normalize": true,
|
| 21 |
+
"do_resize": true,
|
| 22 |
+
"data_format": "channels_last"
|
| 23 |
+
}
|