In the past three years,traditional Chinese medicine(TCM)decoction pieces have played a crucial role in the prevention and control of the pandemic.In fact,TCM decoction pieces were widely used for disease prevention and treatment even before the outbreak.However,during the production process of decoction pieces,bundles of the same type may be mixed with other types,which is unfavorable for the subsequent quality control.To provide a foundation for quality control of TCM decoction pieces,this paper employs the YOLOv5 s object detection algorithm for classification and recognition to avoid the occurrence of decoction piece adulteration during the actual production process.The main research in this paper is as follows:(1)Dataset.There is currently no public dataset for TCM decoction pieces.To meet the needs of practical scene detection,commonly used TCM decoction pieces including Atractylodes macrocephala,Paeonia lactiflora,Poria cocos and Licorice were purchased online.The approach used to collect the data on the medicinal herbs was by recording videos,and then using video stream segmentation techniques to extract images of the TCM decoction pieces.To improve the algorithm’s generalization ability to the herbal medicine slices,data augmentation techniques such as contrast enhancement,brightness enhancement,and adding Gaussian noise were applied to the dataset of TCM decoction pieces.(2)Model optimization.Due to the characteristics of small targets in TCM decoction pieces,this study chose the YOLOv5 s algorithm,which performs well on small target objects,for the detection and classification of TCM decoction pieces.The CA attention mechanism was applied to the model structure to improve the feature representation ability of the model and reduce the interference of herbal medicine background.Secondly,in order to improve the efficiency of model detection,the KMeans++ algorithm was applied to the model to speed up the generation of preset anchor boxes.(3)Test results and model comparison.The model was tested on the dataset of TCM decoction pieces images and video streams.The model accurately classified the drink pieces and had fast inference speed,which meets the real-time detection requirements of the pharmaceutical factory.Finally,the improved model is compared with other models such as Faster-RCNN in terms of performance.The detection accuracy of the improved model reaches 91.1%,and the parameter size and inference time of the improved model are lower than other models.The optimization improvement effect of the model is significant. |