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

How to retrive the raw attention scores or logits from blip model ( image captioning) #206

Open
umme17 opened this issue Apr 11, 2024 · 0 comments

Comments

@umme17
Copy link

umme17 commented Apr 11, 2024

from PIL import Image
import requests
url = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTrp7yKuY1NxcXlHQX10JtTlECuna-xWv-jetxnv73WBw&s"
image = Image.open(requests.get(url, stream=True).raw)

prepare image for the model

inputs_base= processor_base(images=image, return_tensors="pt")
pixel_values = inputs_base.pixel_values
outputs_base = model_base.generate(**inputs_base, renormalize_logits=True, max_length=50 )
generated_caption_base = processor_base.batch_decode(outputs_base[0], skip_special_tokens=True)[0]
print(f"Generated caption: {generated_caption_base}")

I want to retrive the raw attention scores or logits from outputs_base. then make some change to the logits and then generate the new caption for new logits. how to do that?

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

1 participant