Improving Pill Detection in YOLOv8 Using Learnable Multi-Scale Feature Fusion
Abstract
Accurate recognition of pharmaceutical pills is essential in various healthcare applications, ranging from automated medication dispensing to mobile health diagnostics. Despite the architectural strengths of YOLOv8 in lightweight and real-time object detection, its use of fixed aggregation mechanisms in multi-scale feature fusion may limit adaptability in visually complex scenarios. In this study, we propose a Learnable Fusion (LF) enhancement to the YOLOv8 framework, introducing two variants, scalar and spatial, capable of dynamically weighting multi-resolution features in the model’s neck. The scalar variant applies global softmax-normalized weights to fuse feature maps, while the spatial variant generates per-pixel adaptive attention maps via a 1×1 convolution followed by channel-wise softmax. Evaluated on a publicly available pill detection dataset, our approach demonstrates notable improvements in localization and classification performance. The YOLOv8s-LF-spatial model achieved the best generalization on the test set, attaining an F1-score of 0.703 and mAP50-95 of 0.379, surpassing all baselines. These results confirm that adaptive, learnable fusion mechanisms can substantially enhance feature representation in object detection models, particularly in visually ambiguous medical imaging tasks.
Fields of Study & Subjects
Advanced Neural Network Applications
Industrial Vision Systems and Defect Detection
Smart Agriculture and AI
Publication details
- Journal / source
- Frontiers in artificial intelligence and applications
- Publication date
- 27 January 2026
- Document type
- Book chapter