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

Fix TFViT #14399

Merged
merged 1 commit into from
Nov 15, 2021
Merged

Fix TFViT #14399

merged 1 commit into from
Nov 15, 2021

Conversation

NielsRogge
Copy link
Contributor

@NielsRogge NielsRogge commented Nov 15, 2021

What does this PR do?

Fix the code example of TFViTForImageClassification + fix the integration test.

cc @ydshieh

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.

Looks good, thanks for uploading the checkpoint!

@ydshieh
Copy link
Collaborator

ydshieh commented Nov 15, 2021

LGTM, thanks!

@ydshieh
Copy link
Collaborator

ydshieh commented Nov 15, 2021

I open an issue #14403 for the following.


Hi, I found that there is something wrong (not introduced in this PR).

model.save_pretrained("tmp", saved_model=True) will give an error AttributeError: 'ViTConfig' object has no attribute 'items'.
(I found this when running test_saved_model_creation_extended in TF ViT test script)

Maybe it's better to open a new issue for this.

Update
Not specific to TFViT, even occurs for TFBert

from transformers import TFBertModel
model = TFBertModel.from_pretrained("bert-base-uncased")

# failed
for x in model.config.items():
    print(x)

# failed
model.save_pretrained("tmp", saved_model=True)

This probably suggests that test_saved_model_creation_extended (@tooslow) in test_modeling_tf_common.py will fail for all TF models.

Full example:

from transformers import TFViTForImageClassification
model = TFViTForImageClassification.from_pretrained('google/vit-base-patch16-224')
model.save_pretrained("tmp", saved_model=True)

@NielsRogge NielsRogge merged commit 74e6111 into huggingface:master Nov 15, 2021
@NielsRogge NielsRogge deleted the fix_tf_vit branch November 19, 2021 10:49
Albertobegue pushed a commit to Albertobegue/transformers that referenced this pull request Jan 27, 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.

3 participants