As a common type of medication,pills require supervision and inspection at various stages,including production,packaging,identification,and verification,with quality identification and prescription verification being particularly important.With the development of image recognition technology,some deep learning-based pill identification and detection models have achieved excellent results.However,these models suffer from problems such as a large number of parameters and high computational complexity,making it difficult to deploy and apply in practical environments.Therefore,this paper mainly focuses on the essential principles of image classification and object detection and explores the construction method of lightweight pill identification and detection models to improve their application performance on computing devices.The main research work and conclusions of this paper are:(1)Two different datasets were constructed for the requirements of pill recognition and detection: a dataset for pill defect recognition and another for multi-object detection.Firstly,the selection of data acquisition equipment was carried out,and preliminary pill image data was collected.Next,data cleaning was performed to select usable image data.Finally,data augmentation was performed on defective pill images,and data annotation was carried out for multi-object pill detection images.(2)A pill defect recognition method,SKPE-Shuffle Netv2,is proposed to address the problem of high similarity between different defect categories in the same type of pill.First,the Shuffle Netv2 lightweight network is used as the base model,and the SK-Net attention mechanism is integrated with the Shuffle Netv2 unit module to enhance the model’s ability to extract defect features of pills of different scales.Second,the MPECA mixed pooling channel attention is introduced to enable the model to extract more diverse defect features of the pill,resulting in more accurate identification of defective pills.Finally,the number of repetitions of the Shuffle-SK Unit1 module is reduced to improve the network model’s performance without compromising accuracy.Experimental results show that the improved SKPEShuffle Netv2 0.5× and 1.0× network models achieve average accuracy rates of 97.70% and98.37%,respectively,on the PDIAD dataset.Compared to the original Shuffle Netv2 0.5× and1.0× network models,there is an increase of 5.05% and 3.19%,respectively.(3)A multi-target pill detection method,CB-Efficient Det,is proposed to address the conflict between detection accuracy and model lightweighting in multi-target pill detection.First,the Efficient Det lightweight network model is used as the basis,and the Mosaic data enhancement technique is introduced to increase the complexity of the sampling data.Second,the main network Efficient Net is improved and optimized,with a feature fusion layer embedded with a CBAM attention module to enhance the extraction of key pill features through enhanced learning features.Finally,cross-level data flow from the lower level to the upper level is added to the Bi FPN feature fusion section,improving the efficiency of multiscale feature fusion at different levels.Experimental results show that the improved CBEfficient Det pill detection algorithm achieves an m AP value of 99.84% in testing,an improvement of 0.65% compared to the original Efficient Det algorithm,and higher accuracy and better performance than other detection networks.(4)A pill recognition and verification system was designed and implemented for two identification and detection scenarios.Based on the constructed pill defect recognition model and multi-objective pill detection model,the pill recognition and verification system was designed and developed using tools such as Py Charm,Qt Designer,Py QT5,and database technology.The system mainly realizes multiple functions,such as pill defect recognition,pill information management,prescription information management,pill target detection,and prescription medication verification,providing a scientific basis for pill production quality and patient medication safety.The results showed that the system achieved a testing accuracy of 97.12% and 96.30% for defect recognition and prescription verification in practical scenarios. |