From zero labels to production: a detector for small objects that touch
Every zero-shot model we tried merged touching objects into one. How we bootstrapped a production detector from about 1,250 corrected images, and why the last real gain came from fixing the labels, not the model.

We recently built an object detector for images where each image holds a handful of small, nearly identical objects, often packed right next to each other. The goal was easy to state: one box per object. The starting point was less friendly: about 44,000 images, no labels at all, and data that had to stay on our own machines, which ruled out cloud labeling tools. Natali, our CTO, led the project. These are the lessons that carry over to other projects.
Foundation models hit the same wall
Before committing to a plan, we checked whether an off-the-shelf model could label the data for us. On a pilot set of 100 images we tried six approaches: classical thresholding with watershed, SAM in automatic mode, FastSAM, SAM 2.1 with point prompts, SAM 3 with text prompts, and a local vision-language model (Qwen2.5-VL) asked to return bounding boxes.
They all failed in the same place. Where the objects had clear gaps between them, most methods did fine. Where the objects touched, which was most of the data, the segmenters merged a whole cluster into one box or returned nothing. SAM 3 found nothing for any text prompt we tried. The vision-language model skipped dense clusters entirely. Classical CV failed in the opposite direction and split single objects into three to five boxes.
The reason is structural. Segmenters look for visually continuous regions, and a cluster of identical touching objects is one continuous region. No prompt changes that. Where one object ends and the next begins is a rule specific to this data, and the way to teach a model a rule is to show it examples.
Empty beats messy
We still wanted something to pre-label the first batch, so a person would correct boxes instead of drawing every one. We didn't pick the method with the best score. We picked the one that was cheapest to correct. Classical CV produced plenty of boxes, most of them wrong, and every wrong box costs a deletion plus a redraw. FastSAM returned nothing on about a fifth of the images, but when it did fire, its boxes were tight. An empty image is a clean canvas. A messy one is extra work.
The model labels its own next batch
From there we ran a model-in-the-loop cycle: label a batch, train a detector on everything labeled so far, let it pre-label the next batch, correct, repeat. Each round's pre-labels were better than the last, so each round took less human time.
| Round | Labeled images | mAP@50 (validation) |
|---|---|---|
| 1 | ~200 | 0.87 |
| 2 | ~390 | 0.91 |
| 3 | ~780 | 0.95 |
| 4 | ~1,080 | 0.96 |
Already after the first round, the model separated touching objects, the one thing no zero-shot method could do. We also set aside a fixed test set of 100 images that never entered training, so every later comparison used the same yardstick. In the end, about 1,250 corrected images, under 3% of the pool, were enough.
One small addition saved a lot of time. The most common manual fix was deleting a box nested inside another box. Standard non-maximum suppression misses these, because a small box inside a large one has a low overlap score. A simple containment filter, which drops a box when most of it sits inside a higher-confidence box, removed about 80% of those deletions automatically.
Label with one model, ship another
We ran the labeling loop with Ultralytics YOLO because it's quick to iterate with. But it's AGPL-licensed, which is a problem inside a closed commercial product. So the detector we shipped is YOLOX, which is Apache-licensed, trained on the same data and scored on the same test set: 0.986 mAP@50, against 0.987 for the labeling model. The labeling model stayed an internal tool.
Measure what you ship
Up to that point we tracked mAP. But mAP averages over every confidence threshold, and we were computing it on the raw model output, before the cleanup filters the product actually runs. The product runs at one threshold, with cleanup. So we built an evaluation that runs exactly that pipeline and labels every error by type: a duplicate box, a loose box, a false alarm on background, an object the threshold dropped, an object the model missed completely.
It changed our conclusions. A retraining round with hard negatives had raised mAP@50-95 from 0.884 to 0.895, which looked like progress. At the operating point it bought nothing: F1 went from 0.967 to 0.965. The gain was slightly sharper box edges, which the downstream system doesn't need. It was also the signal to stop labeling new data.
The last gain came from the labels
The errors weren't spread evenly. On the validation set, 3 images out of 231 held 40% of all errors, and 10 images held 70%. We sent the 40 worst images in the dataset back for review, pre-filled with their existing labels rather than the model's predictions, so a weak prediction couldn't overwrite a good label.
Only 18 of the 40 needed fixing. In the other 22 the labels were right and the model was wrong. The root cause was our own loop: low-confidence pre-labels from earlier rounds that nobody deleted during review, and that quietly became ground truth. After the fix, recall on the test set went from 0.962 to 0.976, and the number of objects the model "missed completely" dropped from 6 to 0.
Same model, same weights. The model didn't get better, the measurement got honest. To check we hadn't just bent the labels toward the model, we compared the false alarms before and after: they were identical.
Takeaways
- Try zero-shot first, but know where it breaks. Small, touching, look-alike objects are exactly where segmenters merge.
- For pre-labeling, choose what's cheapest to correct, not what scores best.
- A model-in-the-loop cycle gets you to production with a small share of the data labeled.
- Evaluate the pipeline you ship, at the threshold you ship, and sort the errors by type.
- When errors cluster in a few images, look at the labels before you touch the model.
- Check licenses before you ship, not after.
What's still open: about 11 false alarms remain on the 100 test images, mostly markings and specks of background that look like objects but aren't. Nothing above touched them, and that's where the next round of work goes.