Downloads · 30 days
9
10% of all-time downloads
fathindifa/food-caption-blip2
food-caption-blip2 is a machine learning model from fathindifa. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This is a fine-tuned version of the BLIP2 model for food image captioning.
Downloads · 30 days
9
10% of all-time downloads
All-time downloads
94
Public
Parameters
3.7B
15 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors15 GB · 100%
From the Hugging Face model README
This is a fine-tuned version of the BLIP2 model for food image captioning.
from transformers import Blip2Processor, Blip2ForConditionalGeneration
from PIL import Image
processor = Blip2Processor.from_pretrained("fathindifa/food-caption-blip2")
model = Blip2ForConditionalGeneration.from_pretrained("fathindifa/food-caption-blip2")
# Load and preprocess image
image = Image.open("food_image.jpg").convert('RGB')
inputs = processor(images=image, return_tensors="pt")
# Generate caption
outputs = model.generate(**inputs, max_new_tokens=32)
caption = processor.batch_decode(outputs, skip_special_tokens=True)[0]
print(caption)