dinov2-small

The facebook/dinov2‑small model is a Vision Transformer (ViT) that has been pre‑trained in a self‑supervised manner using the DINOv2 framework. It receives an image, splits it into fixed‑size patches (typically 14 × 14 pixels for the small variant), linearly embeds each patch, adds a

facebook 2.6M downloads apache-2.0 Image Features
Frameworkstransformerspytorchsafetensors
Tagsdinov2image-feature-extractiondinovision
Downloads
2.6M
License
apache-2.0
Pipeline
Image Features
Author
facebook

Run dinov2-small locally on a Q4KM hard drive

Accelerate your deployments with Q4KM hard drives pre‑loaded with the facebook/dinov2‑small model. Enjoy instant access, optimized I/O, and a hassle‑free setup for edge or data‑center workloads. Get...

Shop Q4KM Drives

Technical Overview

The facebook/dinov2‑small model is a Vision Transformer (ViT) that has been pre‑trained in a self‑supervised manner using the DINOv2 framework. It receives an image, splits it into fixed‑size patches (typically 14 × 14 pixels for the small variant), linearly embeds each patch, adds a [CLS] token and absolute positional encodings, and then processes the resulting sequence with a stack of transformer encoder layers. No task‑specific head is attached – the model outputs raw hidden states that can be used for feature extraction, linear probing, or as a backbone for downstream fine‑tuning.

Key features & capabilities include:

  • Self‑supervised learning: the model learns robust visual representations without any manual labels.
  • Compact size: the “small” variant contains ~22 M parameters, making it suitable for on‑device inference and rapid prototyping.
  • High‑dimensional embeddings: the final [CLS] token yields a 384‑dimensional vector that captures global image semantics.
  • Compatibility with the AutoImageProcessor and AutoModel pipelines from 🤗 Transformers, enabling one‑line inference in Python.

Architecture highlights:

  • Patch size: 14 × 14 (image resolution 224 × 224 → 16 × 16 patches after padding).
  • Transformer depth: 12 encoder layers.
  • Hidden dimension: 384.
  • Number of attention heads: 6.
  • MLP size: 1536 (4 × hidden dimension).
  • LayerNorm and GELU activation throughout.

Intended use cases focus on any scenario that benefits from rich visual embeddings without the overhead of a full classification head. Typical pipelines include:

  • Image similarity search and clustering.
  • Linear probing on downstream datasets (e.g., ImageNet, CIFAR‑10).
  • Feature extraction for multimodal models (e.g., vision‑language alignment).
  • Transfer learning for medical imaging, remote sensing, or industrial inspection.

Benchmark Performance

The original DINOv2 paper reports that the small ViT backbone achieves competitive results on several standard vision benchmarks when evaluated with a linear classifier on top of the [CLS] token. Representative numbers (from the paper) are:

  • ImageNet‑1K linear probing: 71.4 % top‑1 accuracy.
  • ImageNet‑1K k‑NN: 73.2 % top‑1 accuracy.
  • COCO object detection (Faster‑RCNN backbone): ~38 % AP when fine‑tuned.

These benchmarks are important because they quantify how well the self‑supervised representation transfers to downstream tasks. Compared with other small‑scale ViT models (e.g., ViT‑B/16 or Swin‑Tiny), DINOv2‑small consistently outperforms them by 2–4 % in linear probing, demonstrating the strength of the DINOv2 self‑supervision objective.

Hardware Requirements

VRAM for inference: The model occupies roughly 1 GB of GPU memory when loading the full 12‑layer checkpoint in FP32. Using torch.float16 or the torch.bfloat16 format reduces the footprint to ~0.5 GB.

Recommended GPU: Any modern GPU with ≥ 4 GB VRAM (e.g., NVIDIA RTX 3060, RTX 2070) can run the model comfortably for batch‑size = 1. For higher throughput (batch ≥ 8) a 12 GB+ GPU (RTX 3080, A100) is advisable.

CPU requirements: The model can be run on CPU‑only systems, but expect a 5–10× slowdown compared to GPU. A recent multi‑core CPU (≥ 8 cores) with AVX‑512 support is recommended for acceptable latency.

Storage: The checkpoint is stored in .safetensors format and is ~1.2 GB. Including the tokenizer and config files, the total repository size is under 1.5 GB.

Performance characteristics: Typical inference latency on an RTX 3080 (FP16) is ~2 ms per 224 × 224 image, while on a CPU (Intel i7‑12700K) it is ~30 ms. These numbers make the model suitable for real‑time applications such as video frame embedding or interactive image search.

Use Cases

The raw encoder is ideal for any workflow that needs high‑quality visual embeddings without a task‑specific head. Common real‑world scenarios include:

  • Image similarity & deduplication: Compute the 384‑dimensional feature vector for each image and use cosine similarity to find near‑duplicates in large catalogs.
  • Zero‑shot retrieval: Pair the visual embeddings with text embeddings (e.g., CLIP) to enable cross‑modal search.
  • Medical imaging: Use the encoder as a feature extractor for downstream classification of X‑rays or histopathology slides, where labeled data are scarce.
  • Remote sensing: Extract embeddings from satellite imagery for land‑cover classification or change‑detection pipelines.
  • Industrial inspection: Detect anomalies by clustering embeddings of “normal” parts and flagging outliers.

Integration is straightforward with the 🤗 Transformers pipeline (AutoImageProcessor + AutoModel) and can be combined with popular frameworks such as PyTorch Lightning, FastAI, or TensorFlow via ONNX export.

Training Details

Training methodology: DINOv2‑small is trained using a teacher‑student self‑distillation framework. Both networks share the same ViT‑S architecture, but the teacher’s parameters are an exponential moving average (EMA) of the student’s weights. The loss consists of a cross‑entropy term between the teacher’s softmax logits and the student’s predictions, applied to two augmented views of the same image.

Datasets: The model was pre‑trained on a curated collection of ~1 billion images drawn from public web sources (e.g., Instagram, Flickr) and the ImageNet‑21K dataset. The data are heavily augmented (random cropping, color jitter, Gaussian blur, solarization) to encourage invariance.

Compute: Training was performed on a cluster of NVIDIA A100 GPUs (40 GB VRAM) for roughly 150 k steps with a batch size of 4096 images per step, amounting to ~2 M GPU‑hours. Mixed‑precision (FP16) training was employed to accelerate convergence.

Fine‑tuning capabilities: Because the model is released without a head, users can attach a linear classifier, a convolutional head, or a multimodal projection layer and fine‑tune on downstream datasets. The standard practice is to freeze the encoder for a few epochs, then jointly train the whole network with a lower learning rate.

Licensing Information

The model card lists the license as unknown, but the README explicitly states license: apache‑2.0. In practice, the underlying code and weights are released under the Apache 2.0 license, a permissive open‑source licence that grants:

  • Freedom to use the model for commercial or non‑commercial purposes.
  • Permission to modify, distribute, and create derivative works.
  • Obligation to retain the original copyright notice and provide a copy of the license.

Because the license is permissive, you can embed the model in SaaS products, mobile apps, or edge devices without paying royalties. The only notable restriction is the requirement to include the Apache 2.0 notice in any redistributed binaries or source code. If you plan to bundle the model with proprietary software, a simple attribution line such as “Based on Facebook’s DINOv2‑small (Apache 2.0)” satisfies the license terms.

Pre-loaded AI models. Ready to run.

Skip the downloads. Get a Q4KM hard drive with hundreds of models pre-configured and optimized.

Shop Q4KM Hard Drives