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

Error happens when using SiglipVisionModel.forward with interpolate_pos_encoding=True #33993

Closed
2 of 4 tasks
kaitolucifer opened this issue Oct 6, 2024 · 2 comments · Fixed by #33994
Closed
2 of 4 tasks
Labels

Comments

@kaitolucifer
Copy link
Contributor

kaitolucifer commented Oct 6, 2024

System Info

transformers==4.46.0.dev0

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

If the size of pixel_values is 384 x 384, below will throw an error.

vision_tower =  SiglipVisionModel.from_pretrained("google/siglip-so400m-patch14-384")
image_outputs = vision_tower(pixel_values, interpolate_pos_encoding=True)

Error:

embeddings = embeddings + self.interpolate_pos_encoding(embeddings, height, width)
                         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for +: 'Tensor' and 'Embedding'

Expected behavior

Shouldn't raise an error even though pos_encoding doesn't need to be interpolated when interpolate_pos_encoding=True

@ArthurZucker
Copy link
Collaborator

Hey! I think this is also related to #33965

@ArthurZucker
Copy link
Collaborator

Thanks for opening a PR seems right indeed! 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants