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 med/coco caption #252

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lavis/models/med.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,11 @@ def generate_from_encoder(
num_beams = num_beams
visual_embeds = visual_embeds.repeat_interleave(num_beams, dim=0)

if visual_embeds.size(0) != tokenized_prompt.input_ids.size(0):
tokenized_prompt.input_ids = tokenized_prompt.input_ids.repeat_interleave(num_beams, dim=0)
# Make sure that the prompt is repeated same number of times as the visual_embeds
assert visual_embeds.size(0) == tokenized_prompt.input_ids.size(0)

image_atts = torch.ones(visual_embeds.size()[:-1], dtype=torch.long).to(
self.device
)
Expand Down