Preamble

I uploaded a phone photo of cosmetic products spread across a table and asked Gemini what the lot was worth. The reply named most of the bottles and came back with a total that was close to what I would have added up by hand. That is a strange result if you picture the model as a captioner. A captioner says “several skincare bottles on a wood table.” It does not say “this is the 50 ml serum, this is the tinted moisturizer, and the shelf price of the set is about this.”

The tempting reconstruction is a classical vision pipeline: draw a box around each product, OCR the label, look every name up in parallel, add the prices. Parts of that reconstruction are real. Parts of it are a diagram we invent because the chat UI never shows its work. This post separates the two, using Google’s own descriptions of Gemini image understanding and of AI Mode, plus the failure modes that make a “close” total still the wrong thing to wire into a checkout.

The follow-up, Prompt Injection: Detect What You Can, Contain What You Cannot, matters here for a dull reason. Text on a bottle, a sticker, or a screenshot is data. A model that can read it can also follow it.


Two products, two pipelines

“Gemini” is doing different jobs depending on which surface you typed into.

The Gemini API, given only an image and a question, runs a multimodal model. The image becomes visual tokens. The tokens sit in the same context as your text. One generation can name objects, read printed text, and talk about how the objects are arranged. Google’s image-understanding guide is explicit that this covers captioning, classification, visual question answering, object detection, and segmentation without a separate detector you trained yourself. Detection is extra training on top of that general ability, and it shows up when you ask for coordinates.

The consumer surfaces Google has actually described for “what is everything in this photo, and what does it cost” add tools. In the March 2026 “Ask a Techspert” note on visual search, Google’s account is: Gemini looks at the image and the question and decides which tools to call. Lens is the visual library. A fan-out then fires multiple searches at once, for the scene and for the individual objects, and the model writes one answer over those results. The same pattern is in the AI Mode multimodal post: Gemini understands the scene, Lens identifies each object, fan-out issues the queries. Shopping queries can land on the Shopping Graph, which Google describes as more than 50 billion listings, with more than 2 billion of them refreshed every hour. Those are Google’s published figures.

So the accurate answer to “did it box every product, read the names, and look them up concurrently?” is:

  • Names. Yes, that is the part the model is built to do, from packaging appearance and from the words printed on the packaging.
  • Boxes. The model can emit them. Lens localizes objects in the search product. A chat reply that never drew a rectangle still may have localized internally. You do not get to treat an undrawn box as a step you observed.
  • Concurrent lookups. That is the published shape of AI Mode and of the multi-object Lens path: many queries in one turn, then a synthesis. A Gemini transcript with shopping cards or source links is evidence the tool path ran. A bare paragraph with no sources is compatible with the model remembering typical prices and never leaving the weights.

The Vertex AI image console, as documented, still says grounding is not supported for multimodal prompts on that screen. An API call that only attaches a JPEG does not, by itself, hit the Shopping Graph. If you are rebuilding this, you turn search on deliberately, or you look prices up in your own code.


What the model actually receives

The image is not fed to the transformer as pixels one-for-one. It is reduced to a budget of visual tokens. Two accountings are in the current docs, and they belong to different controls:

  • The API guide’s tile estimate: an image whose sides are both at most 384 pixels costs 258 tokens. Larger images are cut into tiles. The worked example is a 960×540 image becoming 6 tiles at 258 tokens each.
  • Gemini 3’s media_resolution cap, per image: low 280, medium 560, high 1120, ultra-high 2240. The documented default for an unspecified Gemini 3 image is 1120 tokens. The same page lists Gemini 3.1 Pro preview and Gemini 3 Flash preview as the image models, with a default of 1120.

Label text is the first casualty of a tight budget. A wide shot of a table makes each bottle a small fraction of the frame. At low resolution the silhouette and the brand color can still be recognizable, and the shade name or the “50 ml” can be mush. Turning resolution up is how you buy back small text. You pay for it in tokens, latency, and money, which is the same budget fight as Token Budgets: Enforcing Limits at the API Layer. Rotate the photo so the labels are upright before you spend that budget. The guide calls rotation out because the model will not reliably fix it for you.

Identification then has three sources, and a close total usually mixes them:

  1. Text on the object. Brand, line, size, shade. This is the model reading, in the same forward pass as the rest of the scene. It is the same family of skill as OCR, and it fails when the type is small, reflective, or partly occluded.
  2. Appearance. Shape, cap color, layout of the label. Useful when the text is unreadable, and also how a dupe or a counterfeit gets the real product’s name.
  3. Memory of prices. Popular SKUs have prices in the training mixture. Those prices have a region, a year, and a size. They are not a quote.

A fourth source appears only when a tool runs: a search snippet, a Lens near-duplicate, or a Shopping Graph row with a current price. That source is the one that can make an obscure SKU come out right. Memory cannot do that for a product the model barely saw.


Boxes, when you actually ask for them

Object detection in the Gemini API is a prompted, structured output. You ask for items. The model returns JSON. Each box is [ymin, xmin, ymax, xmax], origin at the top left, each value an integer from 0 to 1000. You scale by the real image width and height. The same response can carry a label and, if you asked, a segmentation polygon in the same 0–1000 space. AI Studio will draw the boxes. On Vertex you draw them yourself.

That is a detector you did not train. It is also a generative detector. It can miss a bottle at the edge, merge two overlapping compacts, or invent a box around a shadow. Custom instructions work (“only the bottles, not the tissue box”), which is the useful part, and they work without a fine-tune, which is also how a sloppy prompt localizes the wrong thing with confidence.

A minimal request, pinned to whatever Gemini 3 model id you actually evaluated:

from pydantic import BaseModel, Field
from typing import List

class Item(BaseModel):
    box_2d: List[int] = Field(description="[ymin, xmin, ymax, xmax] in 0..1000")
    label: str
    printed_text: str = Field(description="Words read off the package. Empty if illegible.")
    size: str | None = None

class TableScan(BaseModel):
    items: List[Item]

prompt = (
    "List each distinct cosmetic product on the table. "
    "box_2d is [ymin, xmin, ymax, xmax] normalized to 0-1000. "
    "printed_text must be words you can read, not a guess from the shape. "
    "If two items are the same SKU, return both."
)

Send prompt plus the image, and require JSON matching TableScan. Keep the raw image size next to the response so you can descale:

def to_pixels(box: list[int], width: int, height: int) -> tuple[int, int, int, int]:
    ymin, xmin, ymax, xmax = box
    return (
        round(xmin / 1000 * width),
        round(ymin / 1000 * height),
        round(xmax / 1000 * width),
        round(ymax / 1000 * height),
    )

I would log every box and the printed_text beside the final prices. When the total is wrong, the usual bug is a name that never appeared on the package.


The lookup, and who is allowed to add

Google’s fan-out is concurrent search: the model proposes several queries, the search systems run them together, the model reads the pile and writes the answer. Inside AI Mode that is one product. Inside an application you should split it, for the same reason the financial graph post refuses to let the model do the arithmetic. See GraphRAG for Financial Filings: growth rates belong in the query, and the model interprets the rows.

The split that matches the cosmetic photo:

  1. Perceive. One multimodal call returns items, boxes, and the text actually printed. No prices in this call. A model that is allowed to “helpfully” fill in a price will do it from memory and you will not know.
  2. Resolve. Map (brand, line, size) to a catalog id. This is entity resolution again. “The ordinary niacinamide” and “The Ordinary Niacinamide 10% + Zinc 1%, 30 ml” must collapse, and the 30 ml must not collapse into the 60 ml.
  3. Price in your system. Concurrent lookups against a catalog or a shopping API you are allowed to call. One query per resolved id. Record the currency, the retailer, and whether the number is a shelf price or a sale.
  4. Add in code. sum(unit_price * count). The model can explain the table. It does not get to be the source of the total.
  5. Cite. Each line carries the catalog row id. A line with no row is “unpriced,” and it stays out of the total.
import asyncio

async def price_table(items: list[dict]) -> dict:
    resolved = [catalog.resolve(it) for it in items]
    quotes = await asyncio.gather(*(catalog.quote(r) for r in resolved))
    lines = []
    total = 0
    currency = None
    for item, sku, quote in zip(items, resolved, quotes):
        if quote is None:
            lines.append({**item, "sku": None, "price": None})
            continue
        count = int(item.get("count", 1))
        total += quote.price * count
        currency = currency or quote.currency
        lines.append({
            **item,
            "sku": sku.id,
            "price": quote.price,
            "count": count,
            "currency": quote.currency,
        })
    return {"lines": lines, "total": total, "currency": currency}

Concurrency here is ordinary fan-out of I/O. It is the right shape, and it is auditable. The model’s private fan-out, if the product did one, is the same shape with none of the logs unless the UI showed sources.


Why a close total can still be the wrong total

Cosmetics are a nasty catalog. The photo under-specifies the SKU in ways a fluent answer hides.

  • Size. The 30 ml and the 50 ml share a label design. The price ratio is not the volume ratio.
  • Shade. Two foundations in the same carton differ by a number the model smoothed over.
  • Channel. Boutique list price, drugstore, grey-market seller, travel size. “Close” often means the right order of magnitude for the hero SKU in the US.
  • Doubles. Two of the same bottle, one counted. Or one bottle counted twice because the box and the bottle were both localized.
  • Lookalikes. A dupe photographed next to the real bottle inherits the real price if appearance outruns the printed text.
  • Region and date. A remembered 2024 USD price is not today’s price in another currency. Shopping Graph freshness is why the tool path exists. Memory does not refresh 2 billion listings an hour.
  • The sum. Even a perfect list of prices gets a wrong total when the model adds them. This is the bug I would bet on once the names are mostly right.

The honest evaluation is per line, not on the total. Hold out a photo, write down the SKU and the price you consider correct, and score name match, size match, and price error separately. A total that is accidentally close because two errors cancelled is a failure. That is the same instinct as retrieval recall in RAG in Production: Re-ranking, HyDE, and Simple Evals: score the step that can be wrong, before you score the prose.


What I would ship

For a one-off chat, Gemini’s scene understanding plus Lens and fan-out is a remarkable demo, and a close cosmetic total is what that demo looks like when the products are famous and the labels are legible.

For anything that charges a card, quotes a client, or writes a number into a database:

  • Ask for boxes and printed text, and store both.
  • Resolve names in a catalog. Leave unmatched rows unmatched.
  • Fetch prices concurrently from a source you trust, and add them in code.
  • Show the line items. The total is a consequence.
  • Treat every string read off the image as untrusted data. A label can say something other than a product name, which is the subject of Prompt Injection: Detect What You Can, Contain What You Cannot.

I still cannot see the tool trace from that one upload. I can see which of these steps the product is capable of, which ones Google has said the visual-search path runs, and which ones a bare answer does not prove. The names are the model’s. The boxes are available when requested. The live prices, if they were live, came from a lookup. The total should have been a sum in ordinary code.