Skip to content
All projects

Personal project · public or synthetic data

Visual similarity search

Four image representations on one search engine: pixels, autoencoder, self-supervised SimCLR, ImageNet transfer.

Key results

P@10, pixels + PCA
0.338
P@10, autoencoder
0.349
P@10, SimCLR (no labels)
0.676
P@10, ImageNet transfer
0.766

What does “similar” mean?

"Show me images like this one" depends almost entirely on the image representation. Gallery: CIFAR-10 train (50,000 images); queries: CIFAR-10 test (10,000). Labels are used only to score, never to train the encoders.

Four representations, one search engine

Reconstruction is not similarity: the autoencoder barely beats raw pixels (P@10 0.349 vs 0.338). Self-supervision closes most of the gap: SimCLR learns from unlabelled images in 26 minutes on a laptop GPU and doubles precision (0.676). Transfer still wins here (0.766), because CIFAR objects look like ImageNet; that would not hold for medical or industrial images.

Exact FAISS search takes 0.1–0.3 ms per query over 50k vectors, ~13 ms end to end through the API on CPU.

Precision at 10 and other retrieval metrics for the four representations; SimCLR doubles the autoencoder, ImageNet transfer is highest.
Four representations compared.Figure produced by the project code

The detail that mattered

Per-image augmentation on the GPU. torchvision’s batch transforms draw one random crop per batch, which starves the contrastive task; the project vectorises crop, flip, colour jitter and grayscale with independent parameters per image, checked by a test.

A method, not a product

CIFAR images are 32×32, so this shows the method rather than a product; class membership is only a proxy for "similar", and a real product would also measure clicks.