Page cover

Search 192K artworks with CLIP

In this example we:

  • Fetch every Met Open Access artwork with a usable image.

  • Embed about 192,000 images with CLIP.

  • Use FAISS to find visual twins across time, culture, and department.

The question is deliberately weird: which artworks look alike even though the metadata says they should not?

Dataset: Met Open Access images

Discovery joins Met object metadata to CRDImages paths. After that, workers can fetch deterministic CDN URLs instead of hammering the API.

import json
import random
from pathlib import Path

import numpy as np
import pandas as pd
from burla import remote_parallel_map
from sentence_transformers import SentenceTransformer

CRD_IMAGE_BASE = "https://images.metmuseum.org/CRDImages/"
OBJECTS_PATH = Path("/workspace/shared/met-weirdest/objects.parquet")
VEC_DIR = Path("/workspace/shared/met-weirdest/vectors")
FINAL_DIR = Path("/workspace/shared/met-weirdest/final")
HTTP_THREADS = 16
CLIP_BATCH = 64
BATCH_SIZE = 512
MODEL_NAME = "clip-ViT-B-32"

Step 1: Build the image queue

The client loads object metadata, keeps rows with an image path, shuffles them, and builds batches.

Step 2: Fetch and embed

Each worker fetches images with a thread pool, thumbnails them, embeds with CLIP, and writes a vector shard.

Step 3: Run the image batches

Run one batch first. Broken image URLs and PIL mode surprises show up here.

Then run the full museum.

Step 4: Search the museum

The reducer loads vector shards, builds a FAISS cosine index, and filters out boring matches.

The filter matters. Raw nearest neighbors mostly find same-period, same-object-type matches. The fun pairs are the ones that cross boundaries.

What's the point?

I would not call this art history truth. It is visual coincidence at scale, and that is exactly why it is fun.

A small gallery sample finds bowls next to bowls. The full run can find a 19th-century silverware case that looks weirdly like a Bronze Age Cypriot dagger blade. I would never trust that result from a tiny sample, because nearest-neighbor search is competitive. The candidate has to compete against the whole museum.

Last updated