← All models

zero-shot-image-classification · text→image retrieval · WASM · ~606 MB

Fashion-CLIP — describe it, find it

CLIP learns a shared space for images and text, so you can search a collection of pictures with a sentence. Fashion-CLIP is a CLIP model fine-tuned on fashion pairs. This demo embeds a small catalog once, then ranks it against your free-text query — every score is a real cosine similarity, computed on your device.

At a glance

Modelpatrickjohncyh/fashion-clip
Taskzero-shot-image-classification — used here as text→image retrieval (CLIP)
ArchitectureCLIP — BERT-style text encoder (512-d) + ViT-style vision encoder (768-d) with projection heads, fine-tuned on fashion pairs
Artifact / revisiononnx/model.onnx · fp32 · exactly 605,804,513 bytes (578 MiB) · immutable revision 7e3ba62ce16b… — pinned to the same revision as the FashionCLIP classification demo, so one download serves both
BackendWebAssembly (CPU) — no GPU required
Download~578 MiB, cached after first load
LicenseMIT
Web APIsWeb Workers, Cache Storage (via Transformers.js), WebAssembly
Large local resource: FashionCLIP downloads 605,804,513 bytes (578 MiB) plus small tokenizer/config files. Allow roughly 1.2 GiB free memory during WASM initialisation. Mobile browsers may evict the cache or terminate the tab; no absent model is auto-downloaded. Use desktop-class hardware when possible. Because this demo pins the same immutable revision as the FashionCLIP classification demo, a visitor who already loaded that model gets this one instantly from the shared cache — the 578 MiB downloads once per origin, not once per demo.

Run it

See inside — the shared embedding space

Every image and every query becomes a vector (512-dim after projection). The rank is the cosine similarity between the query vector and each image vector — 1.0 means identical direction, 0 means unrelated. The scores below each card are that real number; nothing is faked. Because Fashion-CLIP was tuned on clothing pairs, fashion-y queries are its specialty — try "a formal outfit" and see what it does with this catalog.

Why it matters

Text→image retrieval is the engine behind visual search and media library tools. Running it on-device means a photo collection is searchable by description without uploading a single image.

Use cases

Basics

Search the catalog — the core retrieval move with real similarity scores.

Practical

Zero-shot tagging: score the whole catalog against several labels at once.

Wild

Absurd queries — describe something that isn't in the catalog and watch CLIP reach anyway.

How the API works

import { AutoTokenizer, AutoProcessor, CLIPModel } from "@huggingface/transformers";

const tokenizer = await AutoTokenizer.from_pretrained(MODEL, { subfolder: "onnx" });
const processor = await AutoProcessor.from_pretrained(MODEL, { subfolder: "onnx" });
const model = await CLIPModel.from_pretrained(MODEL, { subfolder: "onnx", dtype: "fp32" });

const imageInputs = await processor(await Promise.all(urls.map(RawImage.read)));
const textInputs = await tokenizer([query], { padding: true, truncation: true });
const { image_embeds, text_embeds } = await model({ ...textInputs, ...imageInputs });
// rank = cosine(text_embeds[0], image_embeds[i]) for each catalog image

We embed the catalog once (it's cached in the worker), then each query is a single text pass + a cosine sweep — fast enough for interactive search. All of it runs in a Web Worker.

References