Practical ยท Few-Shot k-NN & Visual Deduplication ยท 87.45 MB WASM q8

768-d Few-Shot k-NN Retrieval & Near-Duplicate Clustering

Because google/vit-base-patch16-224-in21k omits the fixed ImageNet-1k head, teams use its 768-d embeddings directly as a zero-training few-shot k-NN classifier and visual deduplicator. Index the gallery sequentially off-main-thread, cancel cleanly mid-batch, inspect Leave-One-Out category accuracy, and export formula-safe CSV/JSON.

1. Album Indexer & Multi-Photo Upload

Drop multiple photos here or paste from clipboard (Ctrl/โŒ˜+V). Click any thumbnail to query its nearest neighbors.

Initialise ViT-Base IN21k above to index the 10-photo starter gallery.

Indexed Photos0 / 10
Mean Latencyโ€“
LOO 1-NN Accuracyโ€“
Duplicate Groupsโ€“
Top Match Cosโ€“
Tensor NaN Totalโ€“

Nearest Neighbors

Index the album, then click any thumbnail above to rank cosine neighbors.

Near-Duplicate Clusters (≥ 0.54 cos)

Pairwise Cosine Similarity Matrix (768-d ViT-Base IN21k)
Index at least 2 photos to compute the pairwise cosine matrix.

Show the code

Show the code โ€” vit21k-core.mjs: evaluateLooKnn() (zero-training few-shot k-NN probe)