-
Notifications
You must be signed in to change notification settings - Fork 28.6k
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
Update model-card for DINOv2 #37104
Conversation
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 |
There was a problem hiding this 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.
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. |
f26fe15
to
6522e9b
Compare
There was a problem hiding this 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!
6522e9b
to
fe5e8ca
Compare
@stevhliu All requested changes have been made in the latest commit 👍🏻 |
fe5e8ca
to
dffd8c4
Compare
@stevhliu I have added a quantization example as requested 👍🏻 |
There was a problem hiding this 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! 🤗
[docs] Update model-card for DINOv2
## 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. |
There was a problem hiding this comment.
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
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
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