Introduction: Automated visual inspection is increasingly important in pharmaceutical production, where capsule presence verification, localization, and counting must be performed consistently to reduce manual inspection errors. Real-time object detection models offer a practical solution for integrating image-based quality control into production-line monitoring. This work investigates the use of Ultralytics YOLO26 for capsule detection in pharmaceutical images.
Methods: A YOLO26 nano model was trained for capsule detection using an open-access capsule image dataset containing 314 images. The model was trained for 20 epochs with a batch size of 15 using the Ultralytics framework on a Tesla T4 GPU. The dataset was configured as a single-class object detection problem where capsules were annotated using bounding boxes. Model performance was evaluated using standard object detection metrics, including precision, recall, mean average precision at 50% IoU, and mean average precision from 50% to 95% IoU.
Results: The trained model achieved a precision of 0.862, a recall of 0.822, an mAP50 of 0.887and an mAP50–95 of 0.670 on the validation set, which included 31 images and 318 capsule instances. These results indicate that the model can reliably localize capsules under varying image conditions while maintaining fast inference performance.
Conclusions: The proposed YOLO26-based approach demonstrates the potential of deep learning for automated capsule detection in pharmaceutical imaging. The system can support preliminary visual inspection tasks such as capsule presence verification, localization, and counting. Future work will extend the dataset, include real production-line images, and investigate defect-specific capsule classification.