Instructions to use fatehmujtaba/BLIP-Image-to-recipe with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use fatehmujtaba/BLIP-Image-to-recipe with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("image-to-text", model="fatehmujtaba/BLIP-Image-to-recipe")# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("fatehmujtaba/BLIP-Image-to-recipe") model = AutoModelForMultimodalLM.from_pretrained("fatehmujtaba/BLIP-Image-to-recipe") - Notebooks
- Google Colab
- Kaggle
BLIP-Image-to-recip
Inference code
import requests from PIL import Image
from transformers import BlipForConditionalGeneration, AutoProcessor
img_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSQuFg4LTHUattLGPU0kLzYpBGHRtuqgJY8Gho3uZe_cg&s' image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB')
model = BlipForConditionalGeneration.from_pretrained("Fatehmujtaba/BLIP-Image-to-recipe").to(device) processor = AutoProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
inputs = processor(images=image, return_tensors="pt").to(device) pixel_values = inputs.pixel_values generated_ids = model.generate(pixel_values=pixel_values, max_length=50) generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
- Downloads last month
- 6