Fashion CLIP (ViT-B-32)

This model is a fine-tuned version of OpenAI's ViT-B-32 on a fashion and apparel e-commerce catalog for Visual Product Search ("Shop the Look").

Model Details

  • Base Architecture: ViT-B-32 (Vision Transformer Base, 32x32 patch size)
  • Embedding Dimension: 512
  • Image Input Size: 224x224
  • Framework: OpenCLIP / PyTorch

How to Use with OpenCLIP

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(['blue denim button-down shirt', 'formal dress pants'])
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)
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support