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

chore: add expected output to the sample code. #19183

Merged
merged 4 commits into from Sep 30, 2022
Merged

chore: add expected output to the sample code. #19183

merged 4 commits into from Sep 30, 2022

Conversation

sayakpaul
Copy link
Member

Fixes the issue as described here: #18815 (comment)

@ydshieh FYI.

@@ -632,6 +632,8 @@ def forward(
>>> from PIL import Image
>>> import requests

>>> torch.manual_seed(2)
Copy link
Member Author

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])).

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Sep 25, 2022

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
Copy link
Collaborator

@ydshieh ydshieh Sep 26, 2022

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?

Copy link
Member Author

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?

Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Collaborator

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?

Copy link
Member Author

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.

@sayakpaul
Copy link
Member Author

@ydshieh here's what I have done so far:

  • Update the weight conversion script, so we have the ImageNet-1k label mapping in the model config.
  • Update the modeling_vit_msn.py script with the expected output (which is basically an ImageNet-1k class).

I also pushed the model classes with the updated configs. I realized if I only updated the config.json in the respective Hub repositories, the member config associated with the model classes may not get appropriately updated. So, I pushed everything updated with the new config to my HF account.

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 facebook and another one is hosted from sayakpaul. I need someone from the HF team to transfer the updated model repositories to facebook.

Let me know if anything here is unclear.

Copy link
Collaborator

@ydshieh ydshieh left a 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 :-)

@ydshieh
Copy link
Collaborator

ydshieh commented Sep 29, 2022

I realized if I only updated the config.json in the respective Hub repositories, the member config associated with the model classes may not get appropriately updated.

Could you explain a bit more about the member config associated with the model classes may not get appropriately updated. ?

@sayakpaul
Copy link
Member Author

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 sayakpaul do. They need to be transferred to the facebook org.

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.

@ydshieh
Copy link
Collaborator

ydshieh commented Sep 29, 2022

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.

@sayakpaul
Copy link
Member Author

Okay, let me verify a few things and get back to you.

Copy link
Collaborator

@sgugger sgugger left a 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!

@sayakpaul
Copy link
Member Author

@ydshieh
Copy link
Collaborator

ydshieh commented Sep 30, 2022

Hub PRs all merged, thank you @sayakpaul (also for checking)

@ydshieh ydshieh merged commit 582d085 into huggingface:main Sep 30, 2022
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.

None yet

4 participants