Find similar images with CLIP

Build visual similarity search to find images that look alike using OpenAI's CLIP model.

Search & Embeddings · Notebook · Updated

Colab runs it in your browser. If it calls a model provider, it asks for that provider's API key in a cell.

How it works

You add an embedding index using CLIP, which understands both images and text. This enables finding similar images or searching images by text description.

What it covers

  • Create image embeddings with CLIP
  • Search by image similarity
  • Search by text description (cross-modal)

What it uses

Install
terminal
pip install pixeltable sentence-transformers torch
Pixeltable calls
pxt.create_table()insert()add_embedding_index()similarity()

A look at the code

search-similar-images.ipynb
# Add CLIP embedding index (supports both image and text queries)
images.add_embedding_index(
'image', embedding=clip.using(model_id='openai/clip-vit-base-patch32')
)

One cell of the notebook, copied as it is. Open it in Colab for the rest.

Browse all 103