YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Install the transformers library
!pip install transformers Pillow torch torchvision torchaudio from transformers import BlipProcessor, BlipForConditionalGeneration from PIL import Image
Initialize the processor and model from Hugging Face
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base") model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
Load an image
image = Image.open("path_to_your_image.jpg")
Prepare the image
inputs = processor(image, return_tensors="pt")
Generate captions
outputs = model.generate(**inputs) caption = processor.decode(outputs[0],skip_special_tokens=True)
print("Generated Caption:", caption)
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support