Few-Shot Pill Detectors Collapse 87% When Real Clutter Hits
A new study shows one labeled example is enough for pill classification, but overlapping pills expose a hidden localization failure mode.
ProTakeaways
- Few-shot pill classification saturates at ~99% accuracy with a single labeled example under cross-dataset shift.
- Under overlap stress testing, CURE-trained models collapse to 13% accuracy while MEDISEG-trained models hold 41%.
- Base-training on realistic multi-pill scenes beats extra shots for handling clutter and occlusion.
- Semantic classification decouples from localization: detected pills are named correctly, but many are missed entirely.
- Pipeline built on FsDet and Detectron2 with a frozen ResNet+FPN backbone.
- Full paper available on arXiv.
Pill recognition sounds like a solved problem until you point a camera at a real dosette box. A recent arXiv preprint takes a hard look at what happens when few-shot pill detectors leave the clean lab and meet the mess of actual medication handling, and the results are unflattering in ways that matter for anyone building healthcare vision systems.
The paper investigates few-shot object detection for pills under realistic cross-dataset domain shift. Instead of chasing new architectures, the authors probe an existing detector and ask a deployment question: how many labeled examples do you actually need, and where does the pipeline break?
Why pill recognition keeps failing in the wild
Adverse drug events remain a significant source of preventable patient harm, particularly when patients manage complex medication regimens involving multiple concurrent prescriptions. The visual side of the problem is nastier than typical object detection: pills are often stored together in dosette boxes or pill organizers, resulting in cluttered scenes with overlapping objects and reflective surfaces.
Pill images are also a fine-grained classification task. Many pills share similar shapes, colors, and surface textures, making their distinction challenging even under controlled imaging conditions. Collecting big labeled datasets in healthcare is expensive, which is why few-shot learning, adapting to a new class from a handful of labeled examples, is the natural fit. The catch: most prior few-shot pill work trains and tests on similar distributions, so reported numbers do not tell you how the model behaves on a cluttered pill tray.
The setup: two base datasets, one messy test
The team uses a two-stage Faster R-CNN pipeline via the FsDet library. The workflow is straightforward:
- Base training on either CURE or MEDISEG.
- Few-shot fine-tuning on novel classes with 1, 5, or 10 labeled examples per class (a 5-way K-shot setup).
- Evaluation on a disjoint deployment set with multi-pill, cluttered scenes.
The two base datasets are deliberately mismatched in realism. CURE is a large-scale pill recognition dataset comprising 8,973 images across 196 pill classes. Each image depicts a single pill instance photographed under controlled conditions, with minimal background clutter and no object overlap. MEDISEG is the opposite: 8,262 images spanning 32 pill classes designed to reflect realistic medication-handling scenarios. Images often contain multiple pill instances per frame, with pills placed in dosette boxes or on varied backgrounds.
During fine-tuning the ResNet+FPN backbone is frozen, the region proposal network is lightly trainable, and the ROI heads are fully fine-tuned with the classification layer re-initialized. Because CURE uses full-image boxes and MEDISEG uses instance-level boxes, mean average precision is not directly comparable across configurations, so the analysis focuses on foreground classification accuracy, false negative rate, and loss curves from the ROI head.
Classification saturates almost immediately
The first finding is that one labeled example is enough for the semantic part of the job. In the 1-shot regime, models base-trained on CURE achieve a mean foreground classification accuracy of 0.989, while MEDISEG-trained models reach 0.994. Adding more shots barely nudges the mean but does reduce variance. For MEDISEG-trained models, increasing supervision from 1-shot to 5-shot reduces the standard deviation of foreground classification accuracy by 60%, so 5-shot is the practical sweet spot between annotation effort and stability.
Overlap breaks everything the clean benchmark hid
The interesting result comes from an overlap-only stress test built from 133 heavily cluttered images. Here the numbers fall off a cliff, and the two base datasets diverge sharply. For models base-trained on CURE, foreground classification accuracy collapses from 0.989 under standard evaluation to 0.131 in the 1-shot overlap setting, representing an 87% relative decrease. Meanwhile MEDISEG-trained models retain a foreground classification accuracy of 0.406 under identical conditions, yielding a 210% relative improvement over CURE-trained models.
The MEDISEG advantage holds across shot counts:
| Shot | CURE fg-acc | MEDISEG fg-acc | MEDISEG false-neg |
|---|---|---|---|
| 1 | 0.131 | 0.406 | 0.513 |
| 5 | 0.372 | 0.625 | 0.246 |
| 10 | 0.558 | 0.740 | 0.210 |
The takeaway is that base-training realism, not shot count, drives generalization under clutter. A detector that has never seen two pills touching during pretraining does not learn to disentangle them from five extra labels.
The failure mode nobody was measuring
Beyond the headline numbers, the paper flags a decoupling that matters for practitioners. Semantic classification stays strong even when localization and recall crater under occlusion. In other words, if a pill gets detected the model usually names it correctly, but proposals go missing in overlap regions. This is exactly the kind of failure that aggregate average precision hides and that a real dispensing system would surface as silent errors.
Should you use this?
The pipeline itself is stock Detectron2 plus FsDet, so nothing new to install. The useful contributions are methodological:
- Use classification-centric and error-based metrics, not just AP, when annotation granularity differs between train and test.
- Invest annotation budget in realistic multi-object base data before chasing more shots per novel class.
- Treat few-shot fine-tuning as a diagnostic probe for deployment readiness, sweeping 1, 5, and 10 shots to expose stability-robustness trade-offs.
The obvious limits: only 5 novel classes were tested, CURE's coarse boxes constrain what can be reported, and the study is not trying to push state of the art. But for teams building any fine-grained detector for a safety-critical setting, the message lands. Semantic recognition is cheap; robust localization under occlusion is where the engineering actually starts.