DINOv2 ViT-B/14 Slim FP16 ONNX
This repository contains a deployment-oriented ONNX export of the standard
dinov2_vitb14 backbone from
facebookresearch/dinov2.
Artifact
| Property | Value |
|---|---|
| File | dinov2_vitb14_opset18_slim_fp16.onnx |
| Architecture | DINOv2 ViT-B/14 |
| ONNX opset | 18 |
| Precision | FP16 |
| Input shape | 1 x 3 x 224 x 224 |
| Output shape | 1 x 768 |
| SHA-256 | d0737e9262093604e0b847e4388dfaca6e21b6c35663a81bc6f7f1085a56ffba |
The graph was optimized with onnxslim and is intended for single-image
inference with ONNX Runtime DirectML, with CPU execution as a fallback.
Inputs
The exported graph has two inputs:
pixel_values: FP16 tensor with shape[1, 3, 224, 224].masks: scalar boolean set tofalse.
Benchmark preprocessing:
- Convert the image to RGB.
- Resize with bicubic interpolation so the shortest side is 224.
- Take a centered 224 x 224 crop.
- Convert to CHW and scale pixels to 0 through 1.
- Normalize with ImageNet mean
[0.485, 0.456, 0.406]and standard deviation[0.229, 0.224, 0.225]. - Cast
pixel_valuesto FP16.
The EStock catalog uses a compatibility profile that first resizes the shortest side to 256 and then takes the same 224 x 224 center crop. The ONNX graph itself is identical for both profiles.
For similarity search, cast the output to FP32 and L2-normalize it before storage or comparison.
Runtime
Tested on Windows with:
- Python 3.14.5, 64-bit
onnxruntime-directml==1.24.4numpy==2.5.2pillow==12.3.0
Provider preference:
DmlExecutionProviderCPUExecutionProvider
Verification
Verify the downloaded artifact before loading it:
(Get-FileHash .\dinov2_vitb14_opset18_slim_fp16.onnx -Algorithm SHA256).Hash.ToLowerInvariant()
Expected value:
d0737e9262093604e0b847e4388dfaca6e21b6c35663a81bc6f7f1085a56ffba
License and attribution
The source DINOv2 code and standard S/B/L/g model weights are distributed by Meta under the Apache License 2.0. This optimized export retains that license; see the upstream repository and model card for attribution and usage details.