Abstract
Medication errors represent a critical global health challenge, contributing to nearly one-third of deaths worldwide. While automated pill identification systems offer a potential solution, they often fail in real-world scenarios due to the "look-alike" problem—where different medications share identical visual characteristics—and the complexities of unconstrained environments. This paper introduces PGPNet (Priori Graph-assisted Pill detection Network), a novel framework that enhances standard object detection with Graph Neural Networks (GNNs). By fusing visual features with relational "a priori" knowledge—including prescription co-occurrence and relative physical sizes—PGPNet significantly improves detection accuracy and provides explainable insights into its decision-making process. Evaluated on the large-scale VAIPE dataset, PGPNet outperforms baseline models like Faster R-CNN and YOLOv5 by 9.4% and 12.0% in mAP, respectively.
Introduction
Automated pill identification is a high-stakes application of computer vision. However, moving from laboratory settings to "in the wild" detection presents two major hurdles. First, many pills are visually indistinguishable (the look-alike problem). Second, real-world images taken by patients often feature overlapping pills, messy backgrounds, and inconsistent lighting. Standard deep learning models, which rely solely on pixel data from individual objects, struggle to resolve these ambiguities.
This research proposes that a pill’s identity is defined not just by its own appearance, but by its context. By modeling the relationships between pills in a handful, PGPNet mimics the cognitive process of a pharmacist who uses prescription knowledge and relative comparisons to verify medication.
Methods: The PGPNet Framework
PGPNet integrates visual detection with three distinct relational graphs to assist in identification:
- Co-occurrence Graph: Built from a database of 1,527 prescriptions, this graph models the statistical likelihood of specific drugs appearing together (e.g., medications frequently prescribed for the same chronic condition).
- Relative Size Graph: Because absolute size is difficult to determine from a single smartphone image without a reference object, this directed graph models the size ratios between pill categories. This allows the model to distinguish between two identical-looking pills if one is known to be consistently larger than the other.
- Visual Semantic Graph: This graph captures latent correlations between pills based on their extracted visual features during the learning process.
The Workflow
The system begins with a visual backbone (such as Faster R-CNN) to identify Regions of Interest (RoIs). A "Pseudo Classifier" then generates a preliminary estimate of the pills present to condense the global relational graphs into a relevant sub-graph. These features are processed through a Graph Transformer Network (GTN) to create "context vectors." Finally, these vectors are concatenated with raw visual features to produce the final classification and bounding box regression.
Datasets
The study introduces and utilizes VAIPE, a new large-scale, open-source dataset designed for real-world medicine inspection. VAIPE contains 9,426 images of 96 pill categories captured via smartphones in unconstrained settings, accompanied by 1,527 associated prescriptions. This dataset provides significantly more diversity in lighting, background, and occlusion compared to traditional benchmarks like the NIH Pill Image Dataset.
Key Insights and Results
Performance Gains
PGPNet demonstrated a substantial performance leap over "vanilla" object detectors. On the VAIPE dataset, it achieved a 9.4% improvement in Mean Average Precision (mAP) over Faster R-CNN and a 12.0% improvement over YOLOv5.
Robustness to Occlusion
In real-world scenarios, pills are rarely laid out perfectly. In a custom sub-dataset where pills overlapped by more than 30%, PGPNet maintained a high mAP of 67.5%, whereas the baseline model dropped to 59.2%. This suggests that the relational graphs provide the necessary context to identify a pill even when its visual features are partially obscured.
Explainability and Reliability
Beyond accuracy, PGPNet offers improved reliability. Reliability plots indicate that the model's confidence scores are closely aligned with its actual accuracy, reducing the "over-confidence" often seen in standard deep learning models. Furthermore, by using GNNExplainer, the researchers showed that for "hard samples," the model actively "looks" at neighboring pills to confirm its choice, providing a transparent reasoning path that builds clinical trust.
Conclusion
PGPNet represents a significant step forward in making automated pill detection viable for home healthcare. By moving beyond simple image classification to a multimodal, graph-based approach, the framework successfully addresses the visual ambiguities of medication. Future work will focus on scaling the system to handle a wider variety of pill classes and exploring federated learning to enhance model training while maintaining patient privacy across different healthcare providers.
Summary updated