---
title: "nv-dinov2"
publisher: "nvidia"
type: "endpoint"
updated: "2025-03-25T13:45:06.045Z"
description: "NV-DINOv2 is a visual foundation model that generates vector embeddings for the input image."
canonical: "https://build.nvidia.com/nvidia/nv-dinov2"
---

# TAO Commercial Pretrained NV-Dinov2 Model

## Model Overview <a class="anchor" name="model overview"></a>

This model card contains pretrained weights of NV-Dinov2 model which can be used as a backbone for most of the popular computer vision tasks such as Classification, Segmentation, Detection. This model is ready for commercial use. 

These weights that may be used as a starting point with the classification, segmentation, detection, change detection applications in Train Adapt Optimize (TAO) Toolkit to facilitate transfer learning.

## References

- Oquab, Maxime, et al. "Dinov2: Learning robust visual features without supervision." arXiv preprint arXiv:2304.07193 (2023).

## Model Architecture
**Architecture Type:** Transformer-Based  <br>

NV-Dinov2 is a visual foundational model trained on NVIDIA proprietary large scale dataset. [Dinov2](https://arxiv.org/abs/2304.07193) is a self-supervised learning method that uses a combination of two SSL techniques : DINO and iBOT. These models simplify the use of images in any system by producing all purpose visual features, that is, features that work across image distributions and tasks without finetuning. Trained on large curated datasets, our model has learnt robust fine-grained representation useful for localization and classification tasks. This model can be used as a foundation model for a variety of downstream tasks with few labeled examples. For more details on the method see: Dinov2.

## Input:
**Input Types:** Images <br>
**Input Formats:** Red, Green, Blue (RGB) <br>
**Input Parameters:** Three-Dimensional (3D) <br>
**Other Properties Related to Input:**  <br>
**Minimum Resolution:** 224 x 224 <br>
**Maximum Resolution:** 518 x 518 <br>
**Alpha Channel:** No alpha channel <br>

* Input image format: RGB Image of dimensions: 224 X 224 X 3 (H x W x C)

Note: ViT-G was fine-tuned for high-resolution images. It works for any input resolutions between 224 X 224 X 3 -> 518 x 518 x 3. 
Channel Ordering of the Input: NCHW, where N = Batch Size, C = number of channels (3), H = Height of images (336), W = Width of the images (336)

## Output:
**Output Types:** Embedding - Float tensor <br>
**Output Format:** 3D Vector <br>
**Other Properties Related to Output:** <br> 
**Alpha Channel:** No alpha channel <br>

The output of this model is an embedding of an input image of size 1024 for ViT-L variant and 1536 for ViT-G. 

## Software Integration:
**Runtime Engines:** 
* TAO - 5.2 <br>

**Supported Hardware Architectures:** <br>
* NVIDIA Ampere <br>
* NVIDIA Jetson  <br>
* NVIDIA Hopper <br>
* NVIDIA Lovelace <br>
* NVIDIA Pascal <br>
* NVIDIA Turing <br>
* NVIDIA Volta <br>

**Supported Operating Systems:** <br>
* Linux <br>
* Linux 4 Tegra <br>

## Model Versions: 
- **NV-DinoV2-224-V0** - 130M internal dataset pre-trained model at 224 resolution.
- **NV-DinoV2-518-V0** - 700M internal dataset pre-trained model at 518 resolution.

## Training & Evaluation

This model was trained using our implementation of DINOV2 on NVIDIA-commercial dataset. 

## Using this Model <a class="anchor" name="how_to_use_this_model"></a>

These models need to be used with NVIDIA hardware and software. For hardware, the models can run on any NVIDIA GPU including NVIDIA Jetson devices. These models can only be used with the [Train Adapt Optimize (TAO) Toolkit](https://developer.nvidia.com/tao-toolkit), or [TensorRT](https://developer.nvidia.com/tensorrt).

The primary use case for these models is getting feature embeddings from images. These embeddings can then be used for downstream tasks such as classification, segmentation, and detection by adding relevant heads.

These models are intended for training and fine-tuning using the TAO Toolkit and your datasets for image comparison. High-fidelity models can be trained on new use cases. A Jupyter Notebook is available as a part of the [TAO container](https://ngc.nvidia.com/catalog/containers/nvidia:tao:tao-toolkit) and can be used to re-training.

The models are also intended for edge deployment using TensorRT. 

### Using the Model with TAO

To use these models as pretrained weights for transfer learning, use the snippet below as a template for the `model` and `train` component of the experiment spec file to train a Dinov2 Classification model. For more information on the experiment spec file, see the [TAO Toolkit User Guide](https://docs.nvidia.com/tao/tao-toolkit/index.html).

For ViT-L NV-Dinov2:
```yaml
model:
init_cfg:
checkpoint: None
backbone:
type: vit_large_patch14_dinov2_swiglu
pretrained: /path/to/nvdinov2.pth
freeze: True
head:
type: TAOLinearClsHead
```

## Training Dataset

**Data Collection Method by dataset:** <br>
* Automated <br>

**Labeling Method by dataset:** <br>
* Automated <br>

**Properties:**  <br>

| Dataset | No. of Images |
|--|--|
|NV Internal Data| 130M | 
|NV Internal Data| 700M | 

## Evaluation Dataset:

**Link:** [https://www.image-net.org/](https://www.image-net.org/)

**Data Collection Method by dataset:** <br>
* Unknown <br>

**Labeling Method by dataset:** <br>
* Unknown <br>

**Properties:**  <br>
50,000 validatio images from [ImageNet dataset](https://www.image-net.org/download.php) 

### Methodology and KPI

The key performance indicator is the accuracy, following the standard evaluation protocol for image classification. The KPI for the evaluation data are reported below. 

| model                                 | top-1 accuracy |
|---------------------------------------|----------------|
| ViT-L NV-Dinov2 ImageNet validation   | 79.9           |
| ViT-G NV-Dinov2 ImageNet validation   | 80.4           | 

## Inference:
**Engine:** Tensor(RT) <br>
**Test Hardware:** <br>
- A2
- A30
- DGX H100
- DGX A100
- L4
- L40
- NVIDIA T4
- AGX Orin 64GB
- Orin NX16GB
- T4

The inference is run on the provided unpruned model at FP16 precision. The inference performance is run using [`trtexec`](https://github.com/NVIDIA/TensorRT/tree/main/samples/trtexec) on Orin, Orin NX and NVIDIA T4, and Ampere GPUs. The Jetson devices are running at Max-N configuration for maximum GPU frequency. The performance shown here is the inference only performance. The end-to-end performance with streaming video data might vary depending on other bottlenecks in the hardware and software.

NVDinoV2 (224x224 resolution)

| Platform         | BS  | FPS    |
|------------------|-----|--------|
| Orin NX 16GB     | 16  | 31.55  |
| AGX Orin 64GB    | 16  | 81.41  |
| A2               | 16  | 72.7   |
| T4               | 4   | 110.3  |
| A30              | 16  | 461.0  |
| L4               | 4   | 275.0  |
| L40              | 8   | 579.0  |
| A100             | 32  | 1031.0 |
| H100             | 64  | 2500.6 |

## Technical Blogs <a class="anchor" name="technical_blogs"></a>

- Learn how to transform [Industrial Defect Detection with NVIDIA TAO and Vision AI Models](https://developer.nvidia.com/blog/transforming-industrial-defect-detection-with-nvidia-tao-and-vision-ai-models/).
- Read the 2 part blog on training and optimizing 2D body pose estimation model with TAO - [Part 1](https://developer.nvidia.com/blog/training-optimizing-2d-pose-estimation-model-with-tao-toolkit-part-1)  |  [Part 2](https://developer.nvidia.com/blog/training-optimizing-2d-pose-estimation-model-with-tao-toolkit-part-2).
- Learn how to train [real-time license plate detection and recognition app](https://developer.nvidia.com/blog/creating-a-real-time-license-plate-detection-and-recognition-app) with TAO and DeepStream.
- Model accuracy is extremely important, learn how you can achieve [state of the art accuracy for classification and object detection models](https://developer.nvidia.com/blog/preparing-state-of-the-art-models-for-classification-and-object-detection-with-tao-toolkit/) using TAO.
- Learn how to train the [Instance segmentation model using MaskRCNN with TAO](https://developer.nvidia.com/blog/training-instance-segmentation-models-using-maskrcnn-on-tao-toolkit/).
- Read the technical tutorial on how [PeopleNet model can be trained with custom data using Transfer Learning Toolkit](https://devblogs.nvidia.com/training-custom-pretrained-models-using-tlt/).
- Learn how to [train and deploy real-time intelligent video analytics apps and services using DeepStream SDK](https://developer.nvidia.com/blog/building-iva-apps-using-deepstream-5-0-updated-for-ga/).

## Suggested Reading <a class="anchor" name="suggested_reading"></a>

- More information on about TAO Toolkit and pre-trained models can be found at the [NVIDIA Developer Zone](https://developer.nvidia.com/tao-toolkit).
- Read the [TAO Quick Start](https://docs.nvidia.com/tao/tao-toolkit/text/quick_start_guide/index.html) guide and [release notes](https://docs.nvidia.com/tao/tao-toolkit/text/release_notes.html).
- If you have any questions or feedback, see the discussions on [TAO Toolkit Developer Forums](https://forums.developer.nvidia.com/c/accelerated-computing/intelligent-video-analytics/tao-toolkit/17).
- Deploy your model on the edge using DeepStream. Learn more about [DeepStream SDK](https://developer.nvidia.com/deepstream-sdk).

## Ethical Considerations:

NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications.  When downloaded or used in accordance with our terms of service, developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.  For more detailed information on ethical considerations for this model, please see the Model Card++ Promise and the Explainability, Bias, Safety & Security, and Privacy Subcards.

## Bias

| Field | Response |
| -- | -- |
|Participation considerations from adversely impacted groups [(protected classes)](https://www.senate.ca.gov/content/protected-classes) in model design and testing: | None of the Above |
| Measures taken to mitigate against unwanted bias: | Not Applicable.|

## Explainability

| Field | Response |
| -- | -- |
| Intended Applications & Domains:    | Generating image embedding for image classification, segmentation, and detection tasks. |
| Model Type: | Embedding Generation |
| Intended Users: | This model is intended for developers building search engines and other image-based computer vision tasks. |
| Output: | Embedding Features |
| Describe how the model works: | This model has a vision extractor trained for image embedding generation |
| Technical Limitations: | This model may not perform well with more diverse object classes.  Fine tuning for the target domain is recommended. |
| Verified to have met prescribed NVIDIA standards: | Yes |
| Performance Metrics: | ImageNet Linear Probe Classification Accuracy  |
| Licensing: | [https://creativecommons.org/licenses/by/4.0/](https://creativecommons.org/licenses/by/4.0/) |

## Privacy

| Field | Response |
| -- | -- |
| Generatable or reverse engineerable personally-identifiable information (PII)? | None |
| Protected classes used to create this model? | Not Applicable (No PII) |
| Was consent obtained for any PII used? | Not Applicable (No PII) |
| How often is dataset reviewed? | 	Before Release |
| Is a mechanism in place to honor data subject right of access or deletion of personal data? | Not Applicable |
| If PII collected for the development of the model, was it collected directly by NVIDIA? |Not Applicable |
| If PII collected for the development of the model by NVIDIA, do you maintain or have access to disclosures made to data subjects?	| Not Applicable |
| If PII collected for the development of this AI model, was it minimized to only what was required? | Not Applicable |
| Is there provenance for all datasets used in training? | Yes |
| Does data labeling (annotation, metadata) comply with privacy laws? | Yes |
| Is data compliant with data subject requests for data correction or removal, if such a request was made? | Yes |
| Applicable NVIDIA Privacy Policy	| [https://www.nvidia.com/en-us/data-center/products/nvidia-ai-enterprise/eula/](https://www.nvidia.com/en-us/data-center/products/nvidia-ai-enterprise/eula/) |

## Safety & Security

| Field | Response |
| -- | -- |
| Model Applications:   | Image embedding generation |
| Describe the life-critical application (if present). | None: Not within Operational Design Domain |
| Use Case Restrictions: | Abide by [https://www.nvidia.com/en-us/data-center/products/nvidia-ai-enterprise/eula/"](https://www.nvidia.com/en-us/data-center/products/nvidia-ai-enterprise/eula/)  |
| Describe access restrictions (if any): | The Principle of least privilege (PoLP) is applied limiting access for dataset generation and model development.  |

## Prototype

```python
import os
import sys
import uuid
import base64

import requests

# NVAI endpoint for the NV-DINOv2 NIM
nvai_url="https://ai.api.nvidia.com/v1/cv/nvidia/nv-dinov2"

header_auth = f"Bearer {os.getenv('NVIDIA_API_KEY')}"

def _upload_asset(input, description):
"""
Uploads an asset to the NVCF API.
:param input: The binary asset to upload
:param description: A description of the asset

"""
assets_url = "https://api.nvcf.nvidia.com/v2/nvcf/assets"

headers = {
"Authorization": header_auth,
"Content-Type": "application/json",
"accept": "application/json",
}

s3_headers = {
"x-amz-meta-nvcf-asset-description": description,
"content-type": "image/jpeg",
}

payload = {"contentType": "image/jpeg", "description": description}

response = requests.post(assets_url, headers=headers, json=payload, timeout=30)

response.raise_for_status()

asset_url = response.json()["uploadUrl"]
asset_id = response.json()["assetId"]

response = requests.put(
asset_url,
data=input,
headers=s3_headers,
timeout=300,
)

response.raise_for_status()
return uuid.UUID(asset_id)

if __name__ == "__main__":
"""Uploads an image of your choosing to the NVCF API and sends a
request to the NV-DINOv2 classification model.
The response is written to stdout.

Note: You must set up an environment variable, NVIDIA_API_KEY.
"""

if len(sys.argv) != 2:
print("Usage: python test.py <image>")
sys.exit(1)

with open(sys.argv[1], "rb") as f:
image_b64 = base64.b64encode(f.read()).decode()

if len(image_b64) < 200_000 :
# For images of size less than 200 KB send as base64 string
payload = {
"messages": [
{
"content": {
"type": "image_url",
"image_url": {
"url": f"data:image/jpeg;base64,{image_b64}"
}
}
}
],
}

headers = {
"Content-Type": "application/json",
"Authorization": header_auth,
"Accept": "application/json"
}
else:
# For images of size more than 200 KB use the NVCF assets API
asset_id = _upload_asset(open(sys.argv[1], "rb"), "Input Image")

payload = {"messages": []}

asset_list = f"{asset_id}"

headers = {
"Content-Type": "application/json",
"NVCF-INPUT-ASSET-REFERENCES": asset_list,
"NVCF-FUNCTION-ASSET-IDS": asset_list,
"Authorization": header_auth,
}

response = requests.post(nvai_url, headers=headers, json=payload)

if response.status_code == 200:
print(response.json())
else:
print('Inference failed.')
```

```bash
#!/bin/bash

set -e

# Check arguments
if [ "$#" -ne 1 ]; then
echo "Usage: ./test.sh <image>"
exit 1
fi

header_auth="Bearer ${NVIDIA_API_KEY}"
assets_url="https://api.nvcf.nvidia.com/v2/nvcf/assets"

nvai_url="https://ai.api.nvidia.com/v1/cv/nvidia/nv-dinov2"

function upload_asset {
local input=$1
local description=$2

response=$(curl -s -X POST $assets_url \
-H "Authorization: ${header_auth}" \
-H "Content-Type: application/json" \
-H "accept: application/json" \
-d '{"contentType": "image/jpeg", "description": "'"${description}"'"}')

asset_url=$(echo ${response} | jq -r .uploadUrl)
asset_id=$(echo ${response} | jq -r .assetId)

curl -s -X PUT -H "x-amz-meta-nvcf-asset-description: ${description}" -H "content-type: image/jpeg" \
--data-binary "@${input}" ${asset_url}

echo ${asset_id}
}

image_b64=$(base64 "$1")
length=${#image_b64}

if [ $length -lt 200000 ]; then
# For images of size less than 200 KB send as base64 string
echo '{"messages": [{"content": {"type": "image_url",' \
' "image_url": {"url": "data:image/jpeg;base64,'${image_b64}'" } } } ] }' \
>/tmp/payload.json
inference_command="curl -D - -s -X POST $nvai_url \
-H \"Content-Type: application/json\" \
-H \"Authorization: ${header_auth}\" \
-d@/tmp/payload.json"
else
# For images of size more than 200 KB use the NVCF assets API
asset_id=$(upload_asset "$1" "Input Image")
payload='{"messages": []}'
asset_list="${asset_id}"

inference_command="curl -D - -s -X POST $nvai_url \
-H \"Content-Type: application/json\" \
-H \"NVCF-INPUT-ASSET-REFERENCES: ${asset_list}\" \
-H \"NVCF-FUNCTION-ASSET-IDS: ${asset_list}\" \
-H \"Authorization: ${header_auth}\" \
-d '${payload}'"
fi

echo ${inference_command}
# The response will include a embedding vector representing the input image.
output=$(eval ${inference_command})
echo "\n${output}"
```

```javascript
const fs = require('fs');
const fetch = require('node-fetch');

const nvai_url="https://ai.api.nvidia.com/v1/cv/nvidia/nv-dinov2"
const header_auth = `Bearer ${process.env.NVIDIA_API_KEY}`;

async function _upload_asset(input, description) {
const assets_url = "https://api.nvcf.nvidia.com/v2/nvcf/assets";

const headers = {
"Authorization": header_auth,
"Content-Type": "application/json",
"accept": "application/json",
};

const s3_headers = {
"x-amz-meta-nvcf-asset-description": description,
"content-type": "image/jpeg",
};

const payload = {
"contentType": "image/jpeg",
"description": description
};

const response = await fetch(
assets_url, { method: 'POST', body: JSON.stringify(payload), headers: headers }
);

const data = await response.json();

const asset_url = data["uploadUrl"];
const asset_id = data["assetId"];

const fileData = fs.readFileSync(input);

await fetch(
asset_url,
{ method: 'PUT', body: fileData, headers: s3_headers }
);

return asset_id.toString();
}

(async () => {
if (process.argv.length != 3) {
console.log("Usage: node test.js <image>");
process.exit(1);
}

var payload;
var headers;

const data = fs.readFileSync(`${process.argv[2]}`);
const imageB64 = Buffer.from(data).toString('base64');
if (imageB64.length < 200_000) {
// For images of size less than 200 KB send as base64 string
// Payload for the request
payload = {
"messages": [
{
"content": {
"type": "image_url",
"image_url": {
"url": `data:image/jpeg;base64,${imageB64}`
}
}
}
]
};
headers = {
"Content-Type": "application/json",
"Authorization": header_auth,
"Accept": "application/json"
};
} else {
// For images of size more than 200 KB use the NVCF assets API
// Upload specified user asset
const asset_id = await _upload_asset(`${process.argv[2]}`, "Input Image");

// Payload for the request
payload = { "messages": [] };
const asset_list = asset_id;
headers = {
"Content-Type": "application/json",
"NVCF-INPUT-ASSET-REFERENCES": asset_list,
"NVCF-FUNCTION-ASSET-IDS": asset_list,
"Authorization": header_auth
};
}

// Make the request to nvcf
const response = await fetch(nvai_url, {
method: 'POST', body: JSON.stringify(payload), headers: headers
});

// Get the output JSON message
const output = await response.json();

console.log(JSON.stringify(output));
})();
```