Naveed Ali
‹ All blogs

Architecture · Mar 2026 · 2 min read

Stop classifying products. Retrieve them.

A store shelf holds thousands of products, and the catalogue changes constantly. New products arrive, packaging gets redesigned and seasonal lines come and go. A system that identifies products on a shelf has to keep up with all of it.

Why a classifier struggles

The first instinct is a classifier: one output per product, trained on labelled images. It works well on the day it is trained.

Then a new product arrives. A classifier has no slot for it, so it needs new training data, a new training run, a new evaluation and a new release. At catalogue scale that cycle never stops, and the model is always slightly behind the shelf.

The alternative is to treat identification as search.

  1. A detector finds each product on the shelf and crops it.
  2. An image model turns each crop into an embedding, a list of numbers that describes how it looks.
  3. That embedding is compared against a gallery: reference embeddings for every known product.
  4. The closest matches form a shortlist, and a second model looks at the shortlist and picks the winner.

A new product needs a few reference photos added to the gallery. The model itself stays the same, so there are zero retraining runs for a catalogue change.

The detail that quietly breaks it

Search only works if the query and the gallery are made the same way. If gallery crops are padded, resized or normalised differently from the crops taken at scan time, the embeddings drift apart. Nothing errors. The matches just get gradually worse, and the cause is hard to find.

The fix is a fixed preprocessing contract: one function that prepares every crop, used both when building the gallery and when scanning a shelf, and tested so it can't change without anyone noticing.

Combining two kinds of evidence

Visual similarity alone confuses products that look nearly identical, such as two sizes of the same brand. Adding a text signal, matching against product names, helps separate them. The shortlist combines both, and the final pick is made by a model that sees the candidates side by side.

When to use this pattern

Use retrieval when the set of things you recognise keeps changing, when you can't afford a training run for every change, or when new items arrive with only a handful of example images. Keep a classifier when the label set is small and stable.

Have a project in mind? Let’s talk.

Open to contract and full-time work. Based in Lahore, working with teams in the UK, EU and US.