Automated Inventory Counting with Multimodal LLMs in Grocery Fulfillment

picnic · E-commerce · 2025 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.4 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: E-commerce fulfillment

Picnic needed to automate stock counting in an automated grocery warehouse so inventory promises stayed accurate without repeatedly asking shoppers to manually count products in totes.

Constraints:

Architecture

Picnic deploys 16 camera setups in its automated fulfillment center, each with camera, flashlight, laser, and barcode scanner to capture tote images and link them to expected products. A FastAPI service unlocks the camera immediately, then processes the image asynchronously with prompt template, tote image, and a supply-chain reference image. Requests flow through LiteLLM to Gemini, with a fine-tuned Gemini 2.5 Flash model chosen to reach Pro-level performance at Flash-tier economics. A rule-based accountability check filters uncountable images before counting, predictions go to warehouse control software and Snowflake, and a small percentage still receive manual shopper validation for continuous monitoring.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  camera-setup[Camera setup] --> fastapi-service[FastAPI service]
  fastapi-service --> context-assembler[Context assembler]
  context-assembler --> supply-chain-reference-images[Supply-chain reference images]
  context-assembler --> accountability-check[Accountability check]
  accountability-check --> litellm-proxy[LiteLLM proxy]
  litellm-proxy --> gemini-counting-model[Gemini counting model]
  gemini-counting-model --> warehouse-control-software[Warehouse control software]
  gemini-counting-model --> snowflake-monitoring[Snowflake monitoring]
  manual-validation-flow[Manual validation flow] --> snowflake-monitoring
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Camera setup Captures tote images and scans barcodes to link the tote to the expected product. FastAPI service
FastAPI service Receives camera images, immediately unlocks the camera response path, and launches asynchronous counting work. Camera setup, Context assembler, Warehouse control software
Context assembler Collects prompt template, captured tote image, and supply-chain reference image for model input. FastAPI service, Supply-chain reference images, Accountability check, LiteLLM proxy
Supply-chain reference images Domain-specific product images showing how products look in Picnic's supply chain. Context assembler
Accountability check Rule-based precheck that decides whether an image is countable before invoking the counting model. Context assembler, LiteLLM proxy
LiteLLM proxy Provider abstraction that forwards counting requests to the selected multimodal model and keeps model switching easy. Context assembler, Gemini counting model
Gemini counting model Fine-tuned multimodal Gemini model that counts products in tote images using reference-image context. LiteLLM proxy, Warehouse control software, Snowflake monitoring
Warehouse control software Consumes predictions for operational decisions such as rerouting empty totes. FastAPI service, Gemini counting model
Snowflake monitoring Stores model predictions and manual validation events for ongoing performance tracking. Gemini counting model, Manual validation flow
Manual validation flow Asks shoppers to recount a small percentage of cases for continuous production validation. Snowflake monitoring

Data flow

A tote passes a camera setup, where the barcode scanner identifies the expected product and the camera captures the tote image. The FastAPI service acknowledges the camera immediately, then assembles the prompt, supply-chain reference image, and captured tote image. An accountability check determines whether the image is countable; countable images are sent through LiteLLM to Gemini for prediction. The prediction is sent to warehouse control software for operational decisions and to Snowflake for monitoring, while a small validation sample is also manually recounted by shoppers and published to Snowflake.

4 supporting quotes
“we have a quite relatively small camera. It has a um a flashlight. It has a laser. It has a barcode scanner. So we”transcript, stated
“we bought 16 uh uh camera setups that are all spread now to FCA. We created a fast API web service that when it gets”transcript, stated
“We created a fast API web service that when it gets an image, it immediately actually sends a request back with a background task.”transcript, stated
“Then we make our predictions. We um well send that to our control software but we also publish that to to snowflake.”transcript, stated

Why this architecture

Picnic's architecture is deliberately pragmatic. Weighing scales could not count individual items, and traditional CV models underperformed out of the box, so multimodal LLMs were selected for visual reasoning. But the team did not force LLMs everywhere: clustering failure cases showed a simple rule-based accountability check beat the model for countability. Supply-chain reference images supplied unique visual context that prompt optimization could not. Fine-tuning a Flash-tier model bridged the cost-performance gap, while LiteLLM preserved the ability to swap providers as model prices and quality changed.

4 supporting quotes
“the skills uh that are installed they have too much deviation in well in what they report that we absolutely cannot get on the individual product level”transcript, stated
“Even the ones that well, if you would look at the paper, you would think, well, counting a few apples in a toad would definitely be possible was actually uh yeah, very hard for these models.”transcript, stated
“So we made a few rules and actually it outperformed the model the models way better which was again of course a good”transcript, stated
“the moment we added that one it all of a sudden shot up in uh accuracy and also all the autometrics went down in the right approach uh right direction”transcript, stated

Models used: Google Gemini 2.0 Flash · Google Gemini 2.5 Flash · Google Gemini 2.5 Pro · fine-tuned Gemini 2.5 Flash · multimodal LLMs

Scale

Alternatives considered (roads not taken)

Weigh totes with installed scales

Rejected because: The scales had too much measurement deviation to infer individual product counts.

“of the things we immediately thought was maybe using scales right so to weigh the toad maybe before and after pick and to”transcript, stated
“they have too much deviation in well in what they report that we absolutely cannot get on the individual product level”transcript, stated

Traditional computer vision models

Rejected because: Out-of-box traditional CV models struggled with Picnic's specific grocery tote images despite the apparent simplicity of the task.

“We tried a couple of models, right? Just uh Python packages tried it on our data set. Even the ones that well, if you would look at the paper,”transcript, stated
“possible was actually uh yeah, very hard for these models. Well, latency wise, um we going to do we're going to reroute toads if we think”transcript, stated

LLM-based accountability check

Rejected because: Prompting and prompt optimization performed poorly, while simple rules from clustered mistakes worked better.

“we thought well let's also apply it here it was actually horrible and and then we tried a more prompts because we got a bit better and we tried prompt optimization and it was still horrible.”transcript, stated
“So we made a few rules and actually it outperformed the model the models way better which was again of course a good”transcript, stated

Use Gemini 2.5 Pro for every count

Rejected because: It solved the problem but did not satisfy the cost side of the business case, so the team fine-tuned 2.5 Flash instead.

“2.5 Pro to see would it then solve this problem even and for us that that 14 year would would definitely solve the problem.”transcript, stated
“gap right how how do we get from 2.5 flesh to 2.5 pro with with the cost benefit of 2.5 flash and that's well we”transcript, stated

Patterns

fine-tuning-adaptation (model-optimization)

Picnic fine-tuned Gemini 2.5 Flash to outperform base 2.5 Pro while keeping Flash-tier economics.

“basically apply some finetuning and all of a sudden our 2.5 flash was outperforming the base uh 2.5 pro.”transcript, stated

model-routing (model-operations)

LiteLLM sits between Picnic's service and Gemini so the team can switch models as quality and prices change.

“we put a lightm in front of it because like we we already saw during the development we were switching quite often between models”transcript, stated

eval-driven-development (evaluation)

The team built labeled datasets, metrics, validation samples, and mistake analysis before choosing and operating the model.

“we're going to do some eval development uh as that is now the hype but it's also just yeah very logical to do of course.”transcript, stated
“we got the pictures, we got the screw that's in the picture, the number of products we think is in the picture.”transcript, stated

observability-tracing (monitoring)

Predictions and sampled manual validation counts are published to Snowflake for continuous production monitoring.

“we also publish that to to snowflake. And in those small cases where we ask for validation count, we uh put WCS actually puts uh also that information to as an event to to Snowflake.”transcript, stated

Tradeoffs

Multimodal LLM over traditional CV

Chose Gemini multimodal models over YOLO/DETR/vision-transformer-style models out of the box.

Rationale: Traditional models offered lower latency and easier hosting, but Picnic's tested models performed poorly on the specific tote-counting problem.

“latency wise, um we going to do we're going to reroute toads if we think that they're empty.”transcript, stated
“Even the ones that well, if you would look at the paper, you would think, well, counting a few apples in a toad would definitely be possible was actually uh yeah, very hard for these models.”transcript, stated

Fine-tuned Flash model

Chose fine-tuned Gemini 2.5 Flash over base Gemini 2.5 Pro.

Rationale: The Pro model solved the task but was too costly for the business case; fine-tuning Flash reached sufficient performance at lower cost.

“how how do we get from 2.5 flesh to 2.5 pro with with the cost benefit of 2.5 flash”transcript, stated
“basically apply some finetuning and all of a sudden our 2.5 flash was outperforming the base uh 2.5 pro.”transcript, stated

Model abstraction layer

Chose LiteLLM proxy in front of Gemini over hardcoding directly to one provider API.

Rationale: The team expected model quality and price to change quickly and wanted to capture improvements with minimal rework.

“every week new models come out. Um, they get either better or maybe in the case of Grock this week, it gets 47 times cheaper”transcript, stated
“we planned for this yeah interchangeability from the start by already having a lightm proxy in front of it.”transcript, stated

Gotchas (what bit them)

Some tote images are not countable even by humans.

Root cause: Cardboard, stacking, loose inner packaging, and occlusion can hide products from view.

Resolution: Picnic added an accountability check that routes uncountable cases away from model counting.

“products that are completely blocked by carton that are completely stacked on top of each other”transcript, stated
“we first want to check is this even an image that the uh even a human can count or not.”transcript, stated

The LLM was the wrong tool for the countability precheck.

Root cause: The accountability failures clustered around simple visual/business-rule patterns.

Resolution: Embedding and clustering mistakes revealed groups that simple rules handled better than the model.

“we tried prompt optimization and it was still horrible. So we went back to the drawing board”transcript, stated
“based on this we actually found these nice groups uh that for instance said that the word carton because yeah the the carton was blocking”transcript, stated

The counting model was distracted by warehouse-image artifacts.

Root cause: Stickers, reflections, upside-down products, and similar tote conditions confused the visual model.

Resolution: Adding supply-chain reference images as context dramatically improved accuracy and other metrics.

“The the model was often being distracted by um by having stickers in the toad and by having uh yeah some reflections in the toad.”transcript, stated
“the moment we added that one it all of a sudden shot up in uh accuracy”transcript, stated

Evaluation

Picnic evaluates with exact count accuracy as the primary metric, MAPE for low-stock sensitivity, RMSE for larger errors, MSD for over/under-prediction bias, precision/recall for the accountability check, MMMU for model selection, and ongoing sampled manual recounts in production.

Metrics: exact count accuracy · mean average percentage error · root mean squared error · mean signed deviation · accountability precision and recall · manual validation sample in production

3 supporting quotes
“accuracy is the most important, right? We want the exact number that is in the toad to be exactly predicted by the model.”transcript, stated
“we use precision and recall in this case where for the precision of all the images the model set were countable how many were actually countable”transcript, stated
“for almost 100% do it automatic but then for a very small percentage we would also still ask the shopper to recount it as well.”transcript, stated

Outcomes

The deployment runs in a highly automated fulfillment center with 16 camera setups and uses sampled manual validation rather than full manual counting.

3 supporting quotes
“the moment we added that one it all of a sudden shot up in uh accuracy and also all the autometrics went down in the right approach uh right direction”transcript, stated
“basically apply some finetuning and all of a sudden our 2.5 flash was outperforming the base uh 2.5 pro.”transcript, stated
“we bought 16 uh uh camera setups that are all spread now to FCA.”transcript, stated