Skip to content

Conversation

@openvino-dev-samples
Copy link
Contributor

@openvino-dev-samples openvino-dev-samples commented Aug 21, 2025

What does this PR do?

Conversion cmd-line for DINOv3:

optimum-cli export openvino --task feature-extraction --model facebook/dinov3-convnext-tiny-pretrain-lvd1689m dinov3-convnext-tiny-pretrain-lvd1689m-ov

Inference of DINOv3 using OpenVINO backend:

from optimum.intel import OVModelForCustomTasks
import torch
from transformers import AutoImageProcessor
from transformers.image_utils import load_image

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = load_image(url)

pretrained_model_name = "dinov3-convnext-tiny-pretrain-lvd1689m-ov"
processor = AutoImageProcessor.from_pretrained(pretrained_model_name)
model = OVModelForCustomTasks.from_pretrained(
    pretrained_model_name, 
    device_map="cpu", 
)

inputs = processor(images=image, return_tensors="pt").to(model.device)
print(inputs)
with torch.inference_mode():
    outputs = model(**inputs)

pooled_output = outputs.pooler_output
print("Pooled output shape:", pooled_output.shape)

Before submitting

  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@openvino-dev-samples openvino-dev-samples changed the title [OpenVINO][Dratf]add support for dinov3 [OpenVINO][Draft]add support for dinov3 Aug 21, 2025
Copy link
Collaborator

@echarlaix echarlaix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the addition @openvino-dev-samples, transformers v4.55 will soon be supported (once #1406 is merged), would you mind adding tests with tiny models ?

Copy link
Collaborator

@rkazants rkazants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add tests to check inference. Now it is tests only export

Copy link
Collaborator

@echarlaix echarlaix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @openvino-dev-samples

Comment on lines 4542 to 4543
@register_in_tasks_manager("dinov3_vit", *["feature-extraction"], library_name="transformers")
@register_in_tasks_manager("dinov3_convnext", *["feature-extraction"], library_name="transformers")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding a tests for dinov3_vit! Would you mind adding a test for dinov3_convnext as well ? (to make sure support is not broken in the future)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also why not add the "image-classification" task ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dinov3 is not included in AutoModelForImageClassification.
Any suggestion ?

@echarlaix
Copy link
Collaborator

the PR #1406 is now merged !

Co-authored-by: Ella Charlaix <80481427+echarlaix@users.noreply.github.com>
Co-authored-by: Ella Charlaix <80481427+echarlaix@users.noreply.github.com>
Co-authored-by: Ella Charlaix <80481427+echarlaix@users.noreply.github.com>
Co-authored-by: Ella Charlaix <80481427+echarlaix@users.noreply.github.com>
]
)

if is_transformers_version(">=", "4.56"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's wait for us to support transformers v4.56 before merging so that we are sure all tests are triggered and pass

@echarlaix
Copy link
Collaborator

Hi @openvino-dev-samples #1529 adds support for transformers v4.56!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

class OVModelForCustomTasksIntegrationTest(unittest.TestCase):
SUPPORTED_ARCHITECTURES_WITH_ATTENTION = ["vit-with-attentions"]
SUPPORTED_ARCHITECTURES_WITH_HIDDEN_STATES = ["vit-with-hidden-states"]
SUPPORTED_ARCHITECTURES_WITH_HIDDEN_STATES = ["dinov3_vit"]
Copy link
Collaborator

@echarlaix echarlaix Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not add a test directly under

SUPPORTED_ARCHITECTURES = (
and
SUPPORTED_ARCHITECTURES = (

instead

openvino-dev-samples and others added 2 commits December 3, 2025 10:24
Co-authored-by: Ella Charlaix <80481427+echarlaix@users.noreply.github.com>
@rkazants rkazants requested a review from popovaan December 15, 2025 19:18
Copy link
Collaborator

@popovaan popovaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests which check inference results comparing with transformers and add quantization tests.

@popovaan
Copy link
Collaborator

Please update docs/source/openvino/models.mdx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants