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 on blip_caption.py: prepare prompt for beam search, aovid tensor … #251

Open
wants to merge 1 commit 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lavis/models/blip_models/blip_caption.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ def generate(
prompt = self.tokenizer(prompt, return_tensors="pt").to(self.device)
prompt.input_ids[:, 0] = self.tokenizer.bos_token_id
prompt.input_ids = prompt.input_ids[:, :-1]

# prepare prompt for beam search
if not use_nucleus_sampling:
prompt.input_ids = torch.repeat_interleave(prompt.input_ids, num_beams, dim=0)

# get decoded text
decoder_out = self.text_decoder.generate_from_encoder(
Expand Down