This model is a fine-tuned version of OpenAI's ViT-B-32 on an e-commerce fashion catalog containing 14,833 products across 23 categories for Visual Product Search, "Shop the Look", and Cross-Modal Semantic Retrieval.
ViT-B-32 (Vision Transformer Base, 32x32 patch size)openaiCasual Shirts, Formal Shirts, Formal Pants, Jeans, Men Cargos, Printed Hoodies, Printed T-shirts, Solid T-shirts, Blazers, Jackets, Denim Jackets, Sports Jackets, Long Pants, Short Pants, Dresses (Gaun), Sweaters, Polo Shirts, Skirts (Rok), Coats (Mantel), etc.
import torch
import open_clip
from PIL import Image
# 1. Load model and preprocessing transforms directly from Hugging Face Hub
model, _, preprocess = open_clip.create_model_and_transforms('hf-hub:Panavath/fashion-clip-b32')
tokenizer = open_clip.get_tokenizer('ViT-B-32')
model.eval()
# 2. Embed an image
image = preprocess(Image.open('path_to_clothing.jpg')).unsqueeze(0)
with torch.no_grad():
image_features = model.encode_image(image)
image_features /= image_features.norm(dim=-1, keepdim=True)
# 3. Embed a text query
text = tokenizer(['black tactical cargo pants', 'formal striped button down shirt'])
with torch.no_grad():
text_features = model.encode_text(text)
text_features /= text_features.norm(dim=-1, keepdim=True)
# 4. Compute cosine similarity
similarity = (image_features @ text_features.T).squeeze(0)
print('Similarity scores:', similarity)
open_clip_pytorch_model.bin 577 MiBopen_clip_model.safetensors 577 MiB