AI Hints
Home›Computer Vision Tutorial›Myths and Design Interviews
Computer Vision · Lesson 104 of 111

Designing Visual Search

A second worked answer.

⏱ 2 min read▶ Video at 2:54:21🎓 Free
Watch this lesson in the Computer Vision courseWatch on YouTube ↗Full Computer Vision course

Here's another classic. Design a system where someone can photograph a product, and find it in a shop of ten million items. It's the sort of feature that you've seen in shopping apps. Let's work it through.

Designing Visual Search
From the video: Designing Visual Search
  • Photograph a product
  • Find it among ten million
  • A classic question

The pipeline

First, detect the main object, and crop it, as phone photos are messy. Then embed the crop with a network. Search a vector index for the nearest neighbours. Rerank the top hundred, with a stronger model. Then show the results. Each step is simple, and you've built nearly all of them.

  1. Detect and cropfind the product
  2. Embeda vector
  3. Vector searchten million items
  4. Reranktop hundred
  5. Showresults
The pipeline
From the video: The pipeline

The hard parts

The hard part is the gap between domains. Catalogue photos are clean studio shots, and customer photos are dark and blurry. So you train with pairs of photos, one from each, using contrastive learning. Then there's scale. Ten million vectors need an approximate index, which trades a little accuracy for a lot of speed. New products need embedding the same day.

Domain gapstudio versus phone
Train in pairscontrastive learning
Approximate indexfast at scale
Fresh itemsembed same day

Measuring success

Offline, measure how often the right product is in the top ten. Online, measure clicks and purchases. Test on real customer photos, rather than on catalogue images. Log searches with no clicks, as those are your failures. And plan for a language model option too, for describing what's in a photo in words.

Recall at 10offline
Clicks and salesonline
Real photosin testing
Failed searcheslog them

Summary

Detect, embed, search, rerank. You've got every piece. Next, how to read research, so that you never fall behind.

Key takeaways
  • Cut the problem into stages
  • Bridge the domain gap
  • Measure on real photos
Next up: Reading Vision Papers — keeping up with the field