apparel-image-caption
clothing description generation from photos
2 min readupdated
The model generates short and accurate clothing descriptions from photographs, suitable for screen readers or online store catalogs. It is based on the Florence-2-base architecture (0.23B parameters) and fine-tuned on an H&M product photo dataset. Unlike the base model, it outputs structured sentences with proper punctuation instead of raw text. Useful for marketplace developers and clothing catalog creators.
Key features
- Based on the lightweight and fast Florence-2-base architecture (231M parameters)
- Fine-tuned on a dataset of over 20,000 cleaned image-caption pairs
- Outputs concise sentences starting with a capital letter and ending with a period
- Shows high results on test datasets using CLIPScore and CIDEr metrics
What you can do
- Automatically generate alternative text (alt-text) for product photos in an online store
- Use in projects to assist visually impaired people via clothing description audio playback
- Integrate the model into a content processing pipeline for clothing catalogs using the transformers library
Example
from PIL import Image
from transformers import AutoProcessor, Florence2ForConditionalGeneration
repo = "MeghanaNanuvala/apparel-image-caption"
processor = AutoProcessor.from_pretrained(repo)
model = Florence2ForConditionalGeneration.from_pretrained(repo).eval()
image = Image.open("shirt.jpg").convert("RGB")
inputs = processor(text=[""], images=[image], return_tensors="pt")
ids = model.generate(**inputs, max_new_tokens=96, num_beams=3, do_sample=False)
print(processor.batch_decode(ids, skip_special_tokens=True)[0].strip())Read more
DetailsTest metrics: CIDEr 281.6, CLIPScore 80.5, BLEU-4 37.3.
Training: 5 epochs, batch size 16, bf16, 32 minutes on a single H100.
Limitations: trained exclusively on studio photos of single H&M items; colors and patterns on complex prints may be detected with errors.










Comments