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

Handle image_embeds in ViltModel #16696

Merged
merged 2 commits into from
Apr 11, 2022
Merged

Conversation

ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Apr 11, 2022

What does this PR do?

Handle image_embeds in ViltModel / ViltForImagesAndTextClassification.

(looks like Vilt is the first model introducing image_embeds argument.)

More Info

The image_embeds in ViltForImagesAndTextClassification should have num_images dimension as pixel_values has, as far as I understand.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 11, 2022

The documentation is not available anymore as the PR was closed or merged.

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, but let's wait for @NielsRogge final review before merging!

Comment on lines 819 to 821
image_batch_size = pixel_values.shape[0] if pixel_values is not None else image_embeds.shape[0]
if image_batch_size != batch_size:
raise ValueError("The text inputs and image inputs need to have the same batch size")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe for consistency, we can call the other one text_batch_size (instead of batch_size).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done :-) & wait for green CI

Copy link
Contributor

@NielsRogge NielsRogge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving this!

Out of interest: were you experimenting with ViLT?

@ydshieh
Copy link
Collaborator Author

ydshieh commented Apr 11, 2022

Thanks for improving this!

Out of interest: were you experimenting with ViLT?

Not for this PR. I tried to fix a CI (vit-mae), which was about test_torchscript.
It turns out to be related to model main input -> I worked/improved on it -> more models involved including ViLT -> I just took this chance to work on this PR (otherwise I would forget it very quickly)

@ydshieh ydshieh merged commit 7f73008 into huggingface:main Apr 11, 2022
@ydshieh ydshieh deleted the update_vilt_model branch April 11, 2022 20:16
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
* update

* batch_size -> text_batch_size

Co-authored-by: ydshieh <[email protected]>
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.

4 participants