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

UDOP Demo notebooks #396

Open
AurelienVaudois opened this issue Mar 6, 2024 · 2 comments
Open

UDOP Demo notebooks #396

AurelienVaudois opened this issue Mar 6, 2024 · 2 comments

Comments

@AurelienVaudois
Copy link

AurelienVaudois commented Mar 6, 2024

There seems to be a problem with the demo notebook for udop, I can't launch a training of the model I have the following error message :

IndexError Traceback (most recent call last)

in <cell line: 20>()
33
34 # forward pass
---> 35 outputs = model(
36 input_ids=input_ids,
37 attention_mask=attention_mask,

6 frames

/usr/local/lib/python3.10/dist-packages/transformers/models/udop/modeling_udop.py in combine_image_text_embeddings(image_embeddings, inputs_embeds, bbox, visual_bbox, attention_mask, num_patches, max_len, image_size, patch_size)
318 sequence_length = num_patches
319 ocr_points_x = torch.clip(
--> 320 torch.floor((bbox[:, :, 0] + bbox[:, :, 2]) / 2.0 * sequence_length).long(), 0, sequence_length - 1
321 )
322 ocr_points_y = (

IndexError: too many indices for tensor of dimension 2

@NielsRogge
Copy link
Owner

Hi,

Make sure that the bounding boxes have the appropriate shape: (batch_size, seq_len, 4) - as we need 4 coordinates per token.

@AurelienVaudois
Copy link
Author

Hi Niels,

Thank you for your answer. I have inspected the bboxes of the train_dataloader and they are all in the form [1, seq_len, 4] except for some which are in the form [1, 4]. (See second screen). Is this the cause of the issue?

Screenshot_2024-03-11-00-19-31-09_40deb401b9ffe8e1df2f1cc5ba480b12
Screenshot_2024-03-11-00-19-04-22_40deb401b9ffe8e1df2f1cc5ba480b12

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

No branches or pull requests

2 participants