Downloads · 30 days
58
1% of all-time downloads
dblasko/blip-dalle3-img2prompt
blip-dalle3-img2prompt is a image-to-text model from dblasko. Use it when you need a caption or text from an image. It is set up for transformers.
Pre-trained image-captioning model BLIP fine-tuned on a mixture of laion/dalle-3-dataset and semi-automatically gathered (image, prompt) data from DALLE·E 3. It takes a generated image as an input and outputs a potent…
Downloads · 30 days
58
1% of all-time downloads
All-time downloads
5.2K
Public
Parameters
247M
5.9 GB on disk
Likes
36
Public
Click a slice to open those files.
.bin990 MB · 50%
From the Hugging Face model README
Pre-trained image-captioning model BLIP fine-tuned on a mixture of laion/dalle-3-dataset and semi-automatically gathered (image, prompt) data from DALLE·E 3.
It takes a generated image as an input and outputs a potential prompt to generate such an image, which can then be used as a base to generate similar images.
⚠️ Disclaimer: This model is not intended for commercial use as the data it was trained on includes images generated by DALLE·E 3. This is for educational purposes only.
Loading the model and preprocessor:
from transformers import BlipForConditionalGeneration, AutoProcessor
model = BlipForConditionalGeneration.from_pretrained("dblasko/blip-dalle3-img2prompt").to(device)
processor = AutoProcessor.from_pretrained("dblasko/blip-dalle3-img2prompt")
Inference example on an image from laion/dalle-3-dataset:
from datasets import load_dataset
dataset = load_dataset("laion/dalle-3-dataset", split=f'train[0%:1%]') # for fast download time in the toy example
example = dataset[img_index][0]
image = example["image"]
caption = example["caption"]
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]
print(f"Generated caption: {generated_caption}\nReal caption: {caption}")