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
chore: add expected output to the sample code. #19183
Conversation
@@ -632,6 +632,8 @@ def forward( | |||
>>> from PIL import Image | |||
>>> import requests | |||
|
|||
>>> torch.manual_seed(2) |
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.
Since the classification head of ViT MSN is randomly initialized we need this for a consistent output (print(model.config.id2label[predicted_label])
).
The documentation is not available anymore as the PR was closed or merged. |
@@ -644,6 +646,7 @@ def forward( | |||
>>> # model predicts one of the 1000 ImageNet classes | |||
>>> predicted_label = logits.argmax(-1).item() | |||
>>> print(model.config.id2label[predicted_label]) | |||
LABEL_183 |
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.
Thank you @sayakpaul . Just wondering, if there is any plan to update the config on the Hub for this checkpoint, then update this value here?
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.
How the config should be updated? Updated with the ImageNet-1k labels?
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.
Sorry @sayakpaul , I should ask this question internally, as it is a checkpoint from fackebook facebook/vit-msn-small
.
But yes, I think it should be updated with ImageNet-1k labels.
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.
Sure. When the classification head is updated with the pretrained params, I think we could revisit it.
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.
Or maybe you would like to open a Hub PR for that checkpoint?
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.
Yeah that is what my plan is i.e., open a PR to the MSN checkpoints on Hub to update the config.
@ydshieh here's what I have done so far:
I also pushed the model classes with the updated configs. I realized if I only updated the So, if you go to https://huggingface.co/models?filter=vit_msn now, you'd notice two versions of the same model checkpoint: one is hosted from Let me know if anything here is unclear. |
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.
Thank you @sayakpaul , nice we hvae labels now :-)
Could you explain a bit more about |
The current model classes living under the Facebook org don't have the updated configs that have the ImageNet-1k labels. The model classes residing under If you search with https://huggingface.co/models?filter=vit_msn then you will get the complete list. Let me know if anything is unclear now. |
My question is about why uploading the new config.json is not enough - this is what I understand from your comments. I think simply updating the config.json on the facebook model Hub repo. would be enough. |
Okay, let me verify a few things and get back to you. |
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.
LGTM for the changes in Transformers! For configs already on the Hub, a PR to update them will be needed indeed.
Thanks!
@ydshieh @sgugger the PRs to the Hub repos are up:
Indeed, just updating the config.json made it work. I have verified it locally. |
Hub PRs all merged, thank you @sayakpaul (also for checking) |
Fixes the issue as described here: #18815 (comment)
@ydshieh FYI.