TL;DR
This paper tackles the critical challenge of accurately identifying pills in hospital pharmacies, especially when original packaging is removed and pills lack unique markings. By comparing three leading object detection models (RetinaNet, SSD, and YOLO v3) on a custom pill dataset, they found YOLO v3 offers the best balance of speed and accuracy for real-time applications, making it a promising tool for improving medication safety.
What Problem Does This Paper Address?
In hospital pharmacies, particularly in China, pharmacists often have to dispense individual oral pills from their original packaging. This process is complicated by the fact that many pills lack unique imprint codes, making them visually indistinguishable by size, shape, or color. This ambiguity can lead to dispensing errors, wasting valuable medical resources, and placing a significant burden on pharmacists who need extensive knowledge and intense focus. While automated dispensing machines exist, they are expensive and not error-proof. This paper aims to address the need for an automated, accurate, and real-time pill identification system to assist pharmacists and enhance patient safety.
Methods
The researchers compared three popular one-stage object detection models: RetinaNet, SSD (Single Shot Multi-Box Detector), and YOLO v3 (You Only Look Once v3).
- RetinaNet: Utilizes a ResNet backbone with a Feature Pyramid Network (FPN) and introduces "Focal Loss" to address class imbalance, improving accuracy by down-weighting easy examples and focusing on hard ones.
- SSD: Employs a VGG-16 backbone and uses multiple convolutional layers to predict bounding boxes and class scores directly from feature maps at different scales.
- YOLO v3: Uses the Darknet-53 backbone, which incorporates residual connections (similar to ResNet) to enable deeper networks and better feature extraction. It predicts bounding boxes and class probabilities in a single pass.
All models were trained on a custom pill dataset and evaluated based on their Mean Average Precision (MAP) for accuracy and Frames Per Second (FPS) for detection speed.
Datasets
- Custom Pill Dataset: The authors created their own dataset due to the unsuitability of existing public datasets (like the NLM pill image dataset) for their specific problem, particularly regarding pills without imprint codes.
- The dataset consists of 5,131 images of oral solid dosage forms, covering 261 varieties.
- Images were captured using a high-speed photographic apparatus.
- The dataset was augmented to 51,310 images through various transformations (horizontal/vertical flips, mirror symmetry, affine changes, rotation, Gaussian noise, scale transformation).
- Annotation was performed using LabelImg, saving labels in PASCAL VOC XML format.
Key Insights and Ideas
- Real-time performance is crucial: Unlike many object detection studies, this paper explicitly prioritizes real-time performance (FPS > 30) for practical deployment in a busy pharmacy setting.
- Trade-off between accuracy and speed: The study highlights the inherent trade-off between detection accuracy (MAP) and speed (FPS) among the evaluated models.
- YOLO v3's speed advantage: YOLO v3 significantly outperforms RetinaNet and SSD in detection speed, making it more suitable for real-time applications.
- RetinaNet's accuracy edge: RetinaNet achieves the highest MAP, indicating superior accuracy, but at the cost of much slower inference.
- SSD as a middle ground: SSD offers a balance between RetinaNet and YOLO v3 in terms of both MAP and FPS.
- "Hard samples" reveal model nuances: The comparison on difficult-to-distinguish pills shows that while MAP is similar across models, YOLO v3 still maintains an advantage in speed and model size, suggesting its robustness.
Key Results
- MAP: RetinaNet achieved the highest MAP (82.89%), followed closely by SSD (82.71%), and then YOLO v3 (80.69%).
- FPS: YOLO v3 demonstrated the fastest detection speed at 51 FPS, significantly exceeding RetinaNet (17 FPS) and SSD (32 FPS). This means YOLO v3 meets the real-time requirement.
- Model Size: YOLO v3 also had the smallest model size (89M) compared to RetinaNet (157M) and SSD (149M), making it more suitable for deployment on less powerful hardware.
- Hard Sample Detection: For challenging cases, YOLO v3 maintained a competitive MAP (79.02%) while offering superior FPS (69) and model size (89M) compared to RetinaNet (MAP: 79.61%, FPS: 22) and SSD (MAP: 79.03%, FPS: 41).
Limitations and Future Work
- Dataset Limitations: The study acknowledges that the experimental dataset was limited to pills from a single hospital. A larger, more diverse dataset would improve model robustness.
- Visual Similarity: The inherent visual similarity of some oral solid dosage forms, even with advanced models, can reduce MAP.
- Future Work: The authors suggest building larger datasets and exploring new algorithms to further optimize both the MAP and detection speed of pill identification models. They also propose using confidence thresholds to allow pharmacists to manually intervene when the model is uncertain, ensuring correctness.
Summary updated