Downloads · 30 days
0
SowmyaAndela/Image_Captioner
Image_Captioner is a machine learning model from SowmyaAndela. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
!pip install transformers Pillow torch torchvision torchaudio from transformers import BlipProcessor, BlipForConditionalGeneration from PIL import Image processor = BlipProcessor.frompretrained("Salesforce/blip-image-…
Downloads · 30 days
0
Access
Public
Updated Sep 1, 2024
Repo size
—
Likes
0
Public
Click a slice to open those files.
Other1.5 KB · 68%
From the Hugging Face model README
!pip install transformers Pillow torch torchvision torchaudio from transformers import BlipProcessor, BlipForConditionalGeneration from PIL import Image
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base") model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
image = Image.open("path_to_your_image.jpg")
inputs = processor(image, return_tensors="pt")
outputs = model.generate(**inputs) caption = processor.decode(outputs[0],skip_special_tokens=True)
print("Generated Caption:", caption)