Created
February 4, 2024 14:32
-
-
Save codezakh/47716b6bbfd33ca3f99629c1b0843b4c to your computer and use it in GitHub Desktop.
Get the answers+confidence from a BLIP-2 model for a VQA task.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
outputs = blip2.generate( | |
pixel_values=pixel_values, | |
input_ids=input_ids, | |
attention_mask=attention_mask, | |
do_sample=False, | |
num_beams=5, | |
max_new_tokens=10, | |
min_length=1, | |
length_penalty=-1, | |
return_dict_in_generate=True, | |
output_scores=True, | |
) | |
output_text = blip2_tokenizer.batch_decode( | |
outputs.sequences, skip_special_tokens=True | |
) | |
output_scores = torch.exp(outputs.sequences_scores) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment