BLIP icon indicating copy to clipboard operation
BLIP copied to clipboard

retrieve output not fix

Open ltm920716 opened this issue 2 years ago • 0 comments

hello,

bellow is the sample before huggingface https://huggingface.co/docs/transformers/main/en/model_doc/blip#transformers.BlipConfig

from PIL import Image
import requests
from transformers import AutoProcessor, BlipModel

model = BlipModel.from_pretrained("Salesforce/blip-image-captioning-base")
processor = AutoProcessor.from_pretrained("Salesforce/blip-image-captioning-base")

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

inputs = processor(
    text=["a photo of a cat", "a photo of a dog"], images=image, return_tensors="pt", padding=True
)

outputs = model(**inputs)
logits_per_image = outputs.logits_per_image  # this is the image-text similarity score
probs = logits_per_image.softmax(dim=1)  # we can take the softmax to get the label probabilities

probs will change everytime

ltm920716 avatar Aug 15 '23 07:08 ltm920716