﻿# DINOv2 features: choose a global vector or a spatial patch map

Choose the DINOv2 output that matches image retrieval or dense prediction, preserving processor geometry and excluding non-spatial tokens from patch maps.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-dinov2-global-local-feature-contract/
Language: en

## Start with the output's intended use

A visual inspection application may need to find similar photographs, while another application must mark a defective region. Both can use a DINOv2 backbone, but they need different outputs. The [original paper](https://arxiv.org/abs/2304.07193) studies transferable visual representations rather than promising a finished detector for every domain. Decide whether the downstream consumer expects an image-level representation or a spatial grid before selecting a pooling operation.

## Separate image and patch representations

The [Transformers integration](https://huggingface.co/docs/transformers/model_doc/dinov2) distinguishes the whole-image classification token from local patch embeddings. Flattening every token into an arbitrary vector removes this distinction. Conversely, reshaping a global token as if it described an image position creates a false spatial interpretation. Read the selected model's output structure, including whether a wrapper has already pooled or reshaped its hidden states. Register-token variants additionally contain non-spatial register tokens; exclude these from image patch grids according to the selected variant's documented output convention.

## Preserve the processor's geometry

The patch grid corresponds to the image delivered to the encoder after resizing and cropping, not automatically to the original photograph. Store the processor configuration with cached features. To overlay a dense prediction, reconstruct the relevant transformation back to the original canvas. The [official implementation](https://github.com/facebookresearch/dinov2) provides the reference model variants and extraction utilities; a similarly named third-party wrapper can still expose a different output convention.

## Keep feature comparison internally consistent

For a retrieval experiment, extract the query and reference vectors with the same checkpoint, processor and feature-selection rule. Specify normalization and similarity separately. For a dense task, train or evaluate the downstream head using the same patch convention used at inference. A plausible nearest neighbor or colorful feature visualization does not independently establish that the representation captures the operational distinction the application needs.

## Inspect a representative failure

Consider a defect that occupies a small part of a product photograph. A global representation can preserve overall product similarity while underweighting the defect, whereas a local map retains positions but still requires an appropriate decision rule. Compare both against labeled examples instead of choosing by embedding size. The guides to [image patch tokens](/journal/vit-image-patches-token-sequence/) and [contrastive image-text spaces](/journal/clip-image-text-contrastive-space/) explain related mechanisms, but DINOv2 feature selection remains a separate application decision.
