Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update model-card for DINOv2 #37104

Merged
merged 1 commit into from
Apr 7, 2025

Conversation

shubham0204
Copy link
Contributor

What does this PR do?

This PR updates the model-card for the dinov2 model, as described in #36979, in an attempt to standardize all model-cards.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@stevhliu

Copy link

Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the Ready for review button (at the bottom of the PR page). This will assign reviewers and trigger CI.

@github-actions github-actions bot marked this pull request as draft March 29, 2025 13:23
@shubham0204 shubham0204 marked this pull request as ready for review March 29, 2025 13:23
@github-actions github-actions bot requested a review from stevhliu March 29, 2025 13:23
Copy link
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

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

Nice work, thanks! I think an image classification example would be more impactful since that is something users can immediately and visually grasp versus an embedding.

@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.

@shubham0204 shubham0204 force-pushed the update-dinov2-model-card branch 2 times, most recently from f26fe15 to 6522e9b Compare April 1, 2025 14:47
Copy link
Member

@stevhliu stevhliu 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 your changes, just a few more and then we're ready!

@shubham0204 shubham0204 force-pushed the update-dinov2-model-card branch from 6522e9b to fe5e8ca Compare April 4, 2025 14:13
@shubham0204
Copy link
Contributor Author

@stevhliu All requested changes have been made in the latest commit 👍🏻

@shubham0204 shubham0204 requested a review from stevhliu April 5, 2025 00:24
@shubham0204 shubham0204 force-pushed the update-dinov2-model-card branch from fe5e8ca to dffd8c4 Compare April 5, 2025 15:45
@shubham0204
Copy link
Contributor Author

@stevhliu I have added a quantization example as requested 👍🏻

Copy link
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

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

Awesome, thanks again for your changes! 🤗

@stevhliu stevhliu merged commit 416b5a8 into huggingface:main Apr 7, 2025
10 checks passed
vasqu pushed a commit to vasqu/transformers that referenced this pull request Apr 7, 2025
[docs] Update model-card for DINOv2
Comment on lines -66 to -77
## Resources
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)

A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with DINOv2.
processor = AutoImageProcessor.from_pretrained('facebook/dinov2-base')
model = AutoModel.from_pretrained('facebook/dinov2-base')

- Demo notebooks for DINOv2 can be found [here](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/DINOv2). 🌎
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
last_hidden_states = outputs[0]

<PipelineTag pipeline="image-classification"/>
# We have to force return_dict=False for tracing
model.config.return_dict = False

- [`Dinov2ForImageClassification`] is supported by this [example script](https://github.com/huggingface/transformers/tree/main/examples/pytorch/image-classification) and [notebook](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/image_classification.ipynb).
- See also: [Image classification task guide](../tasks/image_classification)
with torch.no_grad():
traced_model = torch.jit.trace(model, [inputs.pixel_values])
traced_outputs = traced_model(inputs.pixel_values)

If you're interested in submitting a resource to be included here, please feel free to open a Pull Request and we'll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource.
Copy link
Member

Choose a reason for hiding this comment

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

Providing code snippets is great, however it would be super nice to keep resources within docs, they usually provide more in-depth view of the model, e.g. finetuning 🤗

cc @stevhliu

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.

4 participants