RuntimeError: shape mismatch:

#39
by ROSCOSMOS - opened

\blip_2\modeling_blip_2.py", line 2316, in generate
inputs_embeds[special_image_mask] = language_model_inputs.flatten()
RuntimeError: shape mismatch: value tensor of shape [81920] cannot be broadcast to indexing result of shape [0]

I am now seeing this error being returned when captioning and have no idea how to resolve it, the model had been working previously(a couple of weeks ago) now returning to it when using for captioning I see this. Has anything changed?

I have the same issue too.

same for me

same for me

Not same, but recently started getting data match errors as well out of the blue
fast_tokenizer = TokenizerFast.from_file(fast_tokenizer_file)
Exception: data did not match any variant of untagged enum ModelWrapper at line 250373 column 3

Hey everyone! The error with shape mismatch will be solved by PR https://github.com/huggingface/transformers/pull/34876, in the meanwhile feel free to indicate the revision when modeling model/processor from pretrained, so it doesn't get the latest commit from the hub

For the tokenizer error, transformers latest versions now use tokenizers==0.20 by default and thus you would need to upgrade transformers version. The file on the hub was saved with latest transformers, and cannot be loaded with old versions, which was made for forward compatibility

same error for me, really looking forward for the solutions.
thanks devs

The PR is merged into main branch. For anyone who stumbles upon the same error, you should be able to resolve it by updating transformers to v4.47 and higher. The release for v4.47 is planned around today

Isn't the last transformers update 4.46.3 according to https://pypi.org/project/transformers/#history ?

Update, the release on PyPi got delayed for a week. So for now the workaround is to use the commit hash just before the model repo was updated:

.from_pretrained("Salesforce/blip2-opt-2.7b", revision="51572668da0eb669e01a189dc22abe6088589a24")

Sign up or log in to comment