-
Notifications
You must be signed in to change notification settings - Fork 25.2k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -632,6 +632,8 @@ def forward( | |
>>> from PIL import Image | ||
>>> import requests | ||
|
||
>>> torch.manual_seed(2) | ||
|
||
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg" | ||
>>> image = Image.open(requests.get(url, stream=True).raw) | ||
|
||
|
@@ -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 commentThe 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 commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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. |
||
```""" | ||
return_dict = return_dict if return_dict is not None else self.config.use_return_dict | ||
|
||
|
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])
).