Method, system, device and storage medium for real-time detection of authenticity of traditional Chinese medicine preparations
By improving the YOLOv11n-seg model and building the LEO-YOLO-CM model, the problem of insufficient ability to capture authenticity and false subtle features in Chinese medicinal materials detection is solved, and high-precision and low-complexity automated detection of Chinese medicinal materials is achieved.
Patent Information
- Application Number
- CN202510742571.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2045-06-05
AI Technical Summary
The existing Chinese medicinal materials detection models have shortcomings in capturing the subtle characteristics of authenticity and falsehood and detection accuracy. At the same time, the model is complex and difficult to promote and apply in actual production.
To build the LEO-YOLO-CM model, by introducing ODConv and C2PSA-iEMA Bloc modules in the Backbone of the YOLOv11n-seg model, replacing C3K2 in Neck as ODConv, and using LADH detection head in the head, optimizing the feature extraction and detection process.
It significantly improves the boundary positioning accuracy and segmentation performance of authenticity detection of Chinese medicinal materials, reduces the consumption of computing resources, is suitable for complex backgrounds and diversified adulteration methods, and realizes efficient and stable automated detection.
Smart Images

Figure CN120259686B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image detection, and in particular to a method, system, equipment and storage medium for real-time detection of the authenticity of traditional Chinese medicine preparations. Background Art
[0002] As an important component of traditional Chinese medicine, Chinese medicinal materials (TCMs) not only play a vital role in clinical treatment and preventive health care, but also increasingly demonstrate their unique value in the global health care industry. However, in recent years, issues with the authenticity of TCMs in the market have emerged one after another, resulting in uneven quality of TCMs, a serious threat to medication safety and efficacy, and a hidden danger to consumer health. Traditional TCM quality testing methods rely on manual observation and chemical analysis, which are not only highly subjective, inefficient, and costly to operate, but also often difficult to maintain consistency and objectivity in test results due to the wide variety of TCMs, significant morphological differences, and complex geographical origins. Therefore, how to achieve automation and intelligence while ensuring detection accuracy has become an important technical challenge in promoting the standardization of modern TCMs and industrial upgrading.
[0003] Driven by deep learning frameworks, computer vision technology has experienced rapid development, particularly in tasks such as object detection, semantic segmentation, and image recognition. With the continuous emergence of advanced models such as CNNs (convolutional neural networks), RNNs (recurrent neural networks), and Transformer models (deep learning models based on attention mechanisms), computer vision systems have shifted from traditional feature engineering to end-to-end learning, demonstrating superior performance in processing high-dimensional data, complex backgrounds, and multi-scale objects. For example, the Faster R-CNN model (an object detection model) based on the region proposal algorithm provides strong support for real-time detection. The development of object detection technology has opened up new research directions for the identification of traditional Chinese medicine compounds. In recent years, the YOLO (You Only Look Once) series of models has been widely used in industrial quality inspection and medical image analysis due to its efficient detection capabilities. In the field of traditional Chinese medicine, Li Ming et al. (2022) proposed a TCM identification method based on YOLOv4 (the v4 version of YOLO), achieving high-precision detection of a variety of common TCM materials. Furthermore, Zhao Zhe et al. (2024) improved the model structure based on YOLOv8 (the v8 version of YOLO), enhancing the ability to distinguish morphologically similar medicinal materials and optimizing inference speed, making it suitable for real-time detection scenarios. These studies demonstrate that YOLO technology has great potential for application in the field of traditional Chinese medicine identification. The successful application of deep learning models in medical image analysis, autonomous driving, security monitoring, and other fields has made computer vision an indispensable technical support for realizing intelligent automation.
[0004] In the fields of agriculture and food inspection, computer vision systems are also being applied to tasks such as crop maturity assessment, pest and disease detection, and agricultural product sorting. Improved deep feature extraction methods have been used to increase the accuracy of target segmentation and recognition, providing precise data support for yield prediction and quality control. These technological advances have provided a theoretical foundation and technical inspiration for traditional Chinese medicine (TCM) testing, prompting researchers to incorporate visual recognition and deep segmentation methods into TCM quality monitoring systems to achieve accurate, rapid, and low-cost automated testing.
[0005] In the field of traditional Chinese medicine (TCM) inspection, most research focuses on using deep learning to classify and roughly locate TCM images. For example, Zhang Ming et al. proposed a TCM authenticity detection method based on YOLOv5 (the v5 version of YOLO), which initially achieved rapid target detection. However, its robustness under complex backgrounds and non-ideal lighting conditions needs further improvement. Meanwhile, Li Hong et al., in a review, pointed out that most current TCM identification methods rely primarily on local feature extraction and simple classification algorithms, failing to adequately address the morphological changes and subtle authenticity features of TCMs during collection. Some international research has attempted to combine traditional machine learning algorithms with modern deep learning methods. For example, Nashwa El-Bendary et al. proposed a tomato maturity assessment method, and Xiaoqiang Du et al. used a modified YOLO model to detect partially occluded and small objects, addressing the problem of object detection in complex scenes to some extent. However, when applied to TCM inspection, these methods often struggle to achieve the desired results in feature extraction and fine segmentation due to the complex structure of TCMs, the diverse authenticity patterns, and significant differences between samples. In addition, some quality inspection systems based on deep learning perform well in high-precision inspection, but they also face problems such as large model size, high computing resource consumption, and insufficient real-time performance, which limits their promotion and application in actual production.
[0006] Therefore, how to further reduce the complexity of the model while ensuring high detection accuracy, and achieve efficient capture and precise segmentation of subtle features of Chinese medicinal materials and judgment of the authenticity of prescription formulas, is a key technical problem that needs to be solved urgently. It is also an important research direction to promote the intelligent detection of Chinese medicinal materials quality. Summary of the Invention
[0007] The present invention solves the problem that the existing model has low ability to capture subtle features of the authenticity of traditional Chinese medicine and low detection accuracy, while ensuring low model complexity.
[0008] The method for real-time authenticity detection of traditional Chinese medicine preparations of the present invention comprises the following steps:
[0009] Step S1, constructing a Chinese medicine dispensing image dataset;
[0010] Step S2: Build the LEO-YOLO-CM model, specifically:
[0011] In the Backbone of the YOLOv11n-seg model, the iEMA Bloc module is integrated into the C2PSA module. In the Backbone and Neck of the YOLOv11n-seg model, C3K2 is replaced with ODConv. In the Head of the YOLOv11n-seg model, the detection head is replaced with LADH.
[0012] Step S3: Based on the LEO-YOLO-CM model, the authenticity of the traditional Chinese medicine dispensing image dataset is detected in real time.
[0013] Furthermore, in the embodiment of the present invention, in step S2, the iEMA Bloc module is specifically:
[0014] The Chinese medicine dispensing image dataset is divided into two paths. After one path of the Chinese medicine dispensing image dataset passes through the iEMA attention mechanism module, it is residually connected with the other path of the Chinese medicine dispensing image dataset to output the Chinese medicine dispensing feature image dataset. The Chinese medicine dispensing feature image dataset is divided into two paths. After one path of the Chinese medicine dispensing feature image dataset passes through the multi-level convolutional layer module, it is residually connected with the other path of the Chinese medicine dispensing feature image dataset.
[0015] Furthermore, in an embodiment of the present invention, the iEMA attention mechanism module is specifically:
[0016] The Chinese medicine dispensing image dataset is divided into two paths. One path of the Chinese medicine dispensing image dataset passes through the batch normalization two-dimensional layer, the EMA attention mechanism module and the convolution layer module in sequence, and then starts the jump connection function between the EMA attention mechanism module and the convolution layer module for addition, and then enters the convolution layer module and the discard path in sequence, and is added with the other path of the Chinese medicine dispensing image dataset.
[0017] Furthermore, in the embodiment of the present invention, in step S2, the iEMA Bloc module is integrated into the C2PSA module, specifically:
[0018] The Chinese medicine dispensing image dataset is divided into two paths. One path of the Chinese medicine dispensing image dataset passes through the convolutional layer module and the multi-level iEMA Bloc module in sequence, and then is connected with the other path of the Chinese medicine dispensing image dataset and passes through the convolutional layer module.
[0019] The real-time authenticity detection system for traditional Chinese medicine preparations of the present invention includes the following modules:
[0020] Construction module, builds a dataset of Chinese medicine dispensing images;
[0021] Model module, builds the LEO-YOLO-CM model, specifically:
[0022] In the Backbone of the YOLOv11n-seg model, the iEMA Bloc module is integrated into the C2PSA module. In the Backbone and Neck of the YOLOv11n-seg model, C3K2 is replaced with ODConv. In the Head of the YOLOv11n-seg model, the detection head is replaced with LADH.
[0023] The detection module, based on the LEO-YOLO-CM model, performs real-time authenticity detection on the traditional Chinese medicine dispensing image dataset.
[0024] An electronic device according to the present invention comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0025] Memory for storing computer programs;
[0026] The processor is used to implement the real-time detection method for the authenticity of traditional Chinese medicine preparations described in any of the above methods when executing the program stored in the memory.
[0027] The present invention provides a computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the method for real-time detection of the authenticity of traditional Chinese medicine preparations as described in any of the above methods is implemented.
[0028] This invention solves the problem that existing models have low ability to capture subtle features of the authenticity of traditional Chinese medicines and low detection accuracy, while ensuring low model complexity. Specific beneficial effects include:
[0029] 1. The real-time detection method for the authenticity of traditional Chinese medicine preparations described in the present invention has the problem that the existing model has low ability to capture subtle features of the authenticity of traditional Chinese medicines and low detection accuracy, while ensuring low model complexity. In order to solve the above technical problems, the present invention improves the YOLOv11n-seg model to construct the LEO-YOLO-CM model. The experimental results show that the LEO-YOLO-CM model not only significantly improves the boundary positioning accuracy and segmentation performance while maintaining low computing resource consumption, but also has good generalization capabilities under complex backgrounds, natural light interference and various adulteration methods. It provides a new technology with high efficiency, stability and low cost for the automated quality detection of traditional Chinese medicines, which has important application prospects and industrial promotion value.
[0030] 2. To enhance the model's feature selection capabilities in complex environments, the real-time authenticity detection method for traditional Chinese medicines described in the present invention integrates the iEMA Bloc module into the C2PSA module within the backbone of the YOLOv11n-seg model, achieving comprehensive improvements in feature extraction, feature enhancement, and training stability.
[0031] The real-time authenticity detection method for traditional Chinese medicine (TCM) described in the present invention, the LEO-YOLO-CM model, has higher detection accuracy, lower computing resource usage, and stronger deployment adaptability. It is particularly suitable for industrial scenarios such as TCM quality inspection and authenticity identification, and has broad engineering application value and market potential. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0033] Figure 1 1 is a diagram of the LEO-YOLO-CM model structure described in Implementation Method 1;
[0034] Figure 2 2. This is a performance comparison chart of the LEO-YOLO-CM model described in Implementation 1;
[0035] Figure 3 1. This is a graph showing how the performance indicators of the LEO-YOLO-CM model described in Implementation 1 change with the training process.
[0036] Figure 4 This is a block diagram of the iEMA attention mechanism module described in Implementation 2;
[0037] Figure 5 This is a block diagram of the iEMA Bloc module described in Embodiment 2;
[0038] Figure 6 This is a block diagram of the C2PSA-iEMA Bloc module described in Embodiment 2;
[0039] Figure 7 This is a performance comparison chart of each model described in the second embodiment;
[0040] Figure 8 This is a comparison chart of the detection before and after the improvement of the model described in the second implementation mode. DETAILED DESCRIPTION
[0041] The following will clearly and completely describe various embodiments of the present invention in conjunction with the accompanying drawings. The embodiments described with reference to the accompanying drawings are exemplary and intended to be used to explain the present invention, but should not be understood as limiting the present invention.
[0042] Embodiment 1: The real-time detection method for the authenticity of a Chinese medicine preparation described in this embodiment comprises the following steps:
[0043] Step S1, constructing a Chinese medicine dispensing image dataset;
[0044] Step S2: Build the LEO-YOLO-CM model, specifically:
[0045] In the Backbone of the YOLOv11n-seg model, the iEMA Bloc module is integrated into the C2PSA module. In the Backbone and Neck of the YOLOv11n-seg model, C3K2 is replaced with ODConv. In the Head of the YOLOv11n-seg model, the detection head is replaced with LADH.
[0046] Step S3: Based on the LEO-YOLO-CM model, the authenticity of the traditional Chinese medicine dispensing image dataset is detected in real time.
[0047] When applied to traditional Chinese medicine (TCM) testing, existing models often struggle to achieve the desired results in feature extraction and fine-grained segmentation due to the complex structures of the herbs themselves, the diverse methods of authenticity verification, and significant differences between samples. Furthermore, while some deep learning-based quality inspection systems excel in high-precision testing, they also face challenges such as large model size, high computational resource consumption, and insufficient real-time performance, limiting their widespread application in production.
[0048] To address the above technical issues, this embodiment improves YOLOv11n-seg (YOLO's v11-seg version) and proposes a real-time authenticity detection method for traditional Chinese medicine prescriptions, including the following steps:
[0049] Step S1: Construct a Chinese medicine dispensing image dataset, specifically:
[0050] A representative dataset of Chinese medicine dispensing images was collected, covering a variety of common adulterated types and morphologically similar medicinal materials. Professional annotation tools were used to accurately annotate the Chinese medicine dispensing images, including adulterated area boundaries, category labels, and instance mask information, ultimately forming a high-quality dataset for model training and evaluation.
[0051] Step S2: Build the LEO-YOLO-CM model (an improved version of the YOLOv11n-seg model). Specifically:
[0052] like Figure 1 As shown in the figure, based on the lightweight instance segmentation framework of the YOLOv11n-seg model, the overall network model structure is built to retain its efficient feature extraction capabilities and end-to-end prediction advantages, providing a foundation for subsequent module optimization, specifically:
[0053] To improve the model's detection efficiency and feature representation capabilities when deployed at the edge, the feature extraction component C3K2 is replaced with ODConv (Omni-Dimensional Dynamic Convolution) in the Backbone and Neck layers of the YOLOv11n-seg model. C3K2 represents a 3×3 convolution kernel with a 2×2 stride. However, while this convolution operation is simple and effective, it can encounter trade-offs between efficiency and accuracy when processing complex objects or diverse textures. To further improve the model's computational efficiency and performance, this implementation replaces C3K2 with ODConv, an optimized depthwise separable convolution that significantly reduces computational complexity while maintaining high computational efficiency. Unlike the existing C3K2, ODConv splits the convolution operation into depthwise and pointwise convolutions, reducing the number of parameters and improving feature extraction speed. A dynamic attention mechanism is introduced across the channel, spatial, and kernel dimensions to enhance the model's perception of complex textures, edges, and local structures. This significantly improves the real-time performance of the model in resource-constrained environments, such as edge computing devices, without compromising the model's accuracy and robustness. Therefore, by replacing C3K2 with ODConv, this implementation significantly reduces parameter redundancy and improves computational efficiency, achieving a better balance between efficiency and accuracy.
[0054] In the backbone of the YOLOv11n-seg model, the iEMA Bloc module (efficient inverted attention mechanism module) is integrated into the C2PSA module (enhanced feature extraction module) to form the C2PSA-iEMA Bloc module (improved dual-part spatial attention module). This module enhances the model's focus on key adulteration areas and improves the stability of discrimination, meeting the needs of differential identification of medicinal materials with similar morphologies.
[0055] In the YOLOv11n-seg model's head network, the detection head is replaced with the LADH (Lightweight Adaptive Decoupled Head), a decoupled detection head design. The classification branch and boundary regression branch are independently modeled using 1×1 convolutions and 3×3 convolutions, respectively, effectively reducing feature redundancy. Furthermore, a lightweight attention selection module is introduced to dynamically adjust the weights of different category response channels during training. This enhances the model's ability to locate small-scale adulterated medicinal materials and achieves better boundary accuracy, primarily as shown in the following aspects:
[0056] Decoupled Design: Existing detection heads couple the object classification and regression tasks, potentially leading to interference between them. LADH, on the other hand, adopts a decoupled design, modeling the classification and regression tasks separately. This clarifies the optimization objectives of each task, avoids mutual interference, and improves localization and classification accuracy.
[0057] Anchor-free design: LADH does not rely on traditional anchor mechanisms, but instead employs Point Set Regression. This method directly locates the center point of the object, enabling the model to maintain good performance even with diverse object shapes and uneven distribution. Furthermore, removing the anchor mechanism simplifies the model training process, reducing the complex anchor matching process and improving training efficiency.
[0058] Lightweight Design: LADH uses a lightweight convolutional architecture to reduce computational complexity and the number of parameters. This lightweight design significantly improves detection efficiency while ensuring high accuracy, especially on edge devices.
[0059] Therefore, this embodiment effectively improves the flexibility and robustness of the model by replacing the detection head with LADH. In particular, LADH provides higher detection accuracy and adaptability in complex scenes, dense targets, and occlusion situations.
[0060] In order to verify the recognition degree and segmentation accuracy of the LEO-YOLO-CM model described in this embodiment for the target of traditional Chinese medicine prescription images, this embodiment carried out a series of systematic ablation experiments to verify the impact of each module improvement on the model performance. The results are as follows: Figure 2 shown.
[0061] Traditional Chinese medicine (TCM) prescriptions are often counterfeited and replaced during their distribution. These counterfeit products are characterized by strong camouflage and subtle morphological changes, placing high demands on the detection system's discriminative capabilities. Therefore, achieving high-precision detection and segmentation while ensuring lightweight model deployment is a key goal of this implementation.
[0062] First, this implementation replaces C3K2 in the YOLOv11n-seg model with ODConv. ODConv introduces a dynamic weighting mechanism across spatial, channel, and kernel dimensions, enhancing the model's ability to model and adapt to multi-scale features. This makes it particularly suitable for discriminating against complex backgrounds and subtle structures in scenarios involving adulterated Chinese medicinal materials. Experimental results show that the inclusion of ODConv alone improves mAP@50 (Box) from 0.915% to 0.963% and mAP@50 (Mask) from 0.923% to 0.966%, significantly enhancing the model's feature representation and discrimination accuracy.
[0063] Subsequently, this implementation introduces the C2PSA-iEMA Bloc module, aiming to enhance the model's ability to focus on fine-grained features such as texture boundaries and morphological edges. Building on the ODConv-enhanced backbone network, the C2PSA-iEMA Bloc module further improves the model's performance in both precision (P) and recall (R), achieving particularly superior performance in the mask task, validating the effectiveness of this attention mechanism in extracting details from TCM images.
[0064] Furthermore, this implementation replaces the detection head with LADH. This architecture explicitly decouples the classification and localization tasks and introduces a highly efficient attention module, significantly reducing GFLOPs (computational overhead) while improving detection performance. When ODConv and LADH are combined, the model achieves mAP@50 (Box) and mAP@50 (Mask) improvements of 0.973% and 0.971%, respectively, while maintaining low GFLOPs, demonstrating an excellent balance between accuracy and complexity.
[0065] Ultimately, this implementation integrates the ODConv, C2PSA-iEMA Bloc, and LADH modules to construct a complete LEO-YOLO-CM model. This model achieves optimal performance in both detection and segmentation tasks, achieving a mAP@50 (Box) of 0.978% and a mAP@50 (Mask) of 0.979%. All P and R metrics significantly outperform the baseline models. Furthermore, the model requires only 2.46M params and 7.8s GFLOPs. Compared to the original YOLOv11n-seg model, the LEO-YOLO-CM model achieves improvements of 6.3% and 5.6% in mAP@50 (Box) and mAP@50 (Mask), respectively, fully demonstrating the effectiveness and synergy of the proposed module in the detection of adulterated traditional Chinese medicines.
[0066] Step S3: Training and performance evaluation of the LEO-YOLO-CM model, specifically:
[0067] The LEO-YOLO-CM model was systematically trained and verified using a constructed dataset of traditional Chinese medicine dispensing images. Its performance in terms of accuracy, recall rate, segmentation effect, and inference efficiency was evaluated to ensure that the model has practical deployment and promotion capabilities.
[0068] Overall, the model showed a clear convergence trend and high stability in the early stages of training. Various loss functions showed a smooth decline and eventually stabilized, fully reflecting the model's excellent learning ability in tasks such as feature extraction, object detection, and region segmentation. Figure 3 Specifically, the box_loss (bounding box regression loss) rapidly decreased from its initial high value and stabilized below 0.35, indicating that the model exhibited strong discriminative ability in accurately locating the boundaries of TCM objects. The seg_loss (segmentation loss) gradually decreased to approximately 0.25, demonstrating the model's efficient capture of object edge details when handling semantic-level region segmentation. Furthermore, the cls_loss (classification loss) quickly converged to below 0.1 after initial fluctuations, reflecting the model's continued improvement in identifying adulteration categories such as dyeing, wax coating, and root fractures. Another key metric, the distribution focal loss (dfl_loss), showed a steady downward trend and ultimately stabilized at around 0.02, demonstrating the model's strong ability to capture the internal spatial layout of objects. Notably, the performance of each loss in the training and validation sets was highly consistent, with the validation loss consistently slightly higher than the training loss, without significant fluctuations. This fully demonstrates the model's excellent generalization and resistance to overfitting. In terms of evaluation indicators, the model's P and R in the Mask branch both remained stable above 0.92, and the mAP@50 under the condition of IoU (loss value) = 0.5 reached 97.9%. Under the more stringent mAP@50–95 indicator, it also achieved a score of 72.5%, further verifying the model's excellent segmentation robustness and adaptability under interference conditions such as complex backgrounds, natural light changes and occlusion.
[0069] In summary, the LEO-YOLO-CM model demonstrates significant advantages in the task of authenticity detection for Traditional Chinese Medicine (TCM). The model demonstrates good convergence across all loss models during training, high object detection and segmentation accuracy, and excellent generalization performance on the validation set. This model not only accurately extracts the microstructural features of TCMs but also effectively identifies various types of adulteration, demonstrating broad practical application prospects and potential for widespread adoption.
[0070] Embodiment 2: This embodiment further limits the real-time detection method for the authenticity of traditional Chinese medicine described in embodiment 1. In step S2, the iEMA Bloc module is specifically:
[0071] The Chinese medicine dispensing image dataset is divided into two paths. After one path of the Chinese medicine dispensing image dataset passes through the iEMA attention mechanism module, it is residually connected with the other path of the Chinese medicine dispensing image dataset to output the Chinese medicine dispensing feature image dataset. The Chinese medicine dispensing feature image dataset is divided into two paths. After one path of the Chinese medicine dispensing feature image dataset passes through the multi-level convolutional layer module, it is residually connected with the other path of the Chinese medicine dispensing feature image dataset.
[0072] In this embodiment, the iEMA attention mechanism module is specifically:
[0073] The Chinese medicine dispensing image dataset is divided into two paths. One path of the Chinese medicine dispensing image dataset passes through the batch normalization two-dimensional layer, the EMA attention mechanism module and the convolution layer module in sequence, and then starts the jump connection function between the EMA attention mechanism module and the convolution layer module for addition, and then enters the convolution layer module and the discard path in sequence, and is added with the other path of the Chinese medicine dispensing image dataset.
[0074] In this embodiment, in step S2, the iEMA Bloc module is integrated into the C2PSA module, specifically:
[0075] The Chinese medicine dispensing image dataset is divided into two paths. One path of the Chinese medicine dispensing image dataset passes through the convolutional layer module and the multi-level iEMA Bloc module in sequence, and then is connected with the other path of the Chinese medicine dispensing image dataset and passes through the convolutional layer module.
[0076] The C2PSA module itself combines channel-wise and spatial-attention, aiming to enhance the model's focus on important regions. However, existing channel-wise and spatial-attention mechanisms may still be insufficient in complex scenes. To address these technical challenges, this implementation integrates the iEMA attention mechanism (efficient inverted attention mechanism) into the C2PSA module within the backbone of the YOLOv11n-seg model, further enhancing the model's feature selection capabilities in complex environments. The iEMA attention mechanism is a fusion of the iRMB attention mechanism (efficient multi-scale attention mechanism) and the EMA attention mechanism (efficient multi-scale attention mechanism for cross-spatial learning). The iRMB attention mechanism utilizes a residual module to extract multi-level feature information and weights the channel-wise information based on this information to enhance the response to key features. By adaptively adjusting the channel weights of the feature map, the iRMB attention mechanism can more accurately identify useful information and suppress irrelevant background noise. The EMA attention mechanism module uses exponential weighting to weight input features, enabling effective fusion of feature information at multiple moments, ensuring the stability and consistency of feature map information. The EMA attention mechanism module is better able to capture small but important details in an image, and is particularly advantageous for fine-grained object recognition. By fusing these two attention mechanism modules, the iEMA attention mechanism module, formed by combining the inverted residual structure of the iRMB attention mechanism module with the EMA attention mechanism module, is added to the C2PSA module. This not only improves the ability to capture complex textures, but also strengthens the model's ability to discern details, enabling the model to more accurately handle objects in occlusion, stacking, and complex backgrounds.
[0077] like Figure 4 As shown, the iEMA attention mechanism module is specifically as follows: the Chinese medicine dispensing image dataset is divided into two paths, one path of the Chinese medicine dispensing image dataset is sequentially passed through the batch normalization two-dimensional layer, the EMA attention mechanism module and the convolutional layer module, and then the jump connection function is activated between the EMA attention mechanism module and the convolutional layer module for addition, and then the convolutional layer module and the discard path are sequentially inputted and added to the other path of the Chinese medicine dispensing image dataset.
[0078] However, this embodiment finds that if the iEMA attention mechanism module is directly integrated into the C2PSA module, it will face several technical problems. First, the iEMA attention mechanism module itself contains a complex joint attention mechanism of spatial and channel dimensions and an inverted residual structure. If it is directly embedded into the C2PSA module without distinction, the network structure will become too complex locally, which will lead to feature redundancy and information disorder, affecting the consistency and effectiveness of feature extraction. At the same time, after the iEMA attention mechanism module is directly embedded, it lacks support for progressive modeling of multi-layer features, making it difficult to give full play to the advantages of the iEMA attention mechanism module in long-term and short-term dependency feature extraction. In addition, the design of the C2PSA module itself focuses on spatial attention. If the fusion structure is not optimized, the characteristics of the two may conflict, resulting in problems such as gradient instability and convergence difficulties in the model during training, which ultimately affects the overall detection performance.
[0079] In order to solve the above technical difficulties, this embodiment improves the iEMA attention mechanism module and proposes the iEMA Bloc module. The optimized iEMA Bloc module is introduced into the C2PSA module to form the C2PSA-iEMABloc module, rather than directly embedding a single iEMA attention mechanism module. The iEMA Bloc module is a deep encapsulation and extension of the iEMA attention mechanism module structure. It not only retains the iEMA attention mechanism module's ability to jointly model spatial and channel dimensions, but also maintains consistency and efficiency of features during the flow process through hierarchical convolution modules and residual connections. The iEMA Bloc module effectively alleviates the feature conflicts caused by direct fusion through the coordination of multiple convolution modules, and supports layer-by-layer optimization and progressive enhancement of features.
[0080] like Figure 5 As shown, the iEMA Bloc module is specifically as follows: the Chinese medicine dispensing image dataset is divided into two paths, one path of the Chinese medicine dispensing image dataset is passed through the iEMA attention mechanism module, and then a residual connection is performed with the other path of the Chinese medicine dispensing image dataset to output a Chinese medicine dispensing feature image dataset, and the Chinese medicine dispensing feature image dataset is divided into two paths, one path of the Chinese medicine dispensing feature image dataset is passed through two convolutional layer modules, and then a residual connection is performed with the other path of the Chinese medicine dispensing feature image dataset.
[0081] like Figure 6 As shown, the C2PSA-iEMA Bloc module is specifically as follows: the Chinese medicine dispensing image dataset is divided into two paths, one of which passes through the convolutional layer module and N (N = 1, 2, 3..., a positive integer) layers of iEMA Bloc modules in sequence, and is then connected with the other Chinese medicine dispensing image dataset and passes through the convolutional layer module.
[0082] Based on the C2PSA module structure, the input convolution module is retained for preliminary feature extraction. The ordinary attention structure in the C2PSA module is then replaced with multiple series-connected iEMA Bloc modules. Each iEMA Bloc module contains an inverted residual structure and an iEMA attention mechanism module. Efficient gradient propagation is achieved through the residual path, while joint modeling is performed in the spatial and channel dimensions to more comprehensively capture the long-term and short-term dependency features in the image. Multiple iEMA Bloc modules are connected in series to form a deep feature enhancement pathway. At the end, the enhanced features are fused with the initial features through a feature splicing operation, and the fused features are then re-extracted through a convolution module. This fusion method significantly improves the network's feature expression capabilities and detection accuracy while ensuring computational efficiency.
[0083] Through this optimized fusion approach, the iEMA Bloc module not only resolves the feature redundancy and conflict issues associated with the direct fusion of the iEMA attention mechanism module and the C2PSA module, but also achieves high efficiency and stability in deep feature modeling. Ultimately, the fused module comprehensively improves the performance of the LEO-YOLO-CM model in object detection tasks, particularly in terms of robustness and accuracy in complex scenarios, without significantly increasing computational complexity.
[0084] In order to better illustrate the real-time detection method for the authenticity of traditional Chinese medicine preparations described in this embodiment, the following examples are described in detail:
[0085] In order to comprehensively evaluate the comprehensive performance of each model in the tasks of authenticity detection and semantic segmentation of traditional Chinese medicine, this embodiment selects the Mask R-CNN model (mask region-based convolutional neural network model), YOLOv5-seg model (v5-seg version of YOLO), YOLOv7-seg model (v7-seg version of YOLO), YOLOv8-seg model (v8-seg version of YOLO), YOLOv9-seg model (v9-seg version of YOLO), YOLOv10-seg model (v10-seg version of YOLO), YOLOv11n-seg model, YOLOv12-seg model (v12-seg version of YOLO) and the LEO-YOLO-CM model proposed in this embodiment for comparative analysis under the same data set and experimental environment. Figure 7The figure shows a detailed list of metrics such as P, R, and mAP@50 for each model on the Box and Mask tasks, along with the corresponding Params. Experimental results show that while the Mask R-CNN model performs well in terms of P (for example, P(Box) = 0.907), its R and mAP@50 are slightly lower than those of some lightweight models, and its Params are as high as 4,574,243. In contrast, the YOLO series of models, through continuous iterative optimization and structural innovations and improvements to the attention mechanism, have not only achieved significant improvements in mAP@50 and R, but also maintained a relatively ideal level of Params size. For example, the YOLOv5-seg, YOLOv7-seg, and YOLOv8-seg models all achieved over 95% on key metrics. The LEO-YOLO-CM model proposed in this implementation even achieved leading performance in both detection and segmentation tasks, achieving P(Box) of 0.964, P(Mask) of 0.966, and mAP@50 of 0.979. Furthermore, the model's Params dropped to 2,464,598, representing a 13.4% reduction compared to the baseline model. This data demonstrates that the LEO-YOLO-CM model combines lightweight design with high efficiency while maintaining high precision and recall.
[0086] Judging from the comparative data of various indicators, the LEO-YOLO-CM model has demonstrated significant advantages in many aspects such as P, R, mAP and model scale, and is particularly suitable for the needs of real-time, accurate and efficient online detection in the authenticity detection scenario of traditional Chinese medicine.
[0087] To address the practical application needs of TCM (Traditional Chinese Medicine) authenticity detection and semantic segmentation, this implementation proposes an improved TCM adulteration detection model, the LEO-YOLO-CM model, based on the lightweight YOLOv11n-seg model framework. This model introduces ODConv (ODConv) to the original network, effectively enhancing its ability to capture fine-grained texture and structural features of TCM. Furthermore, by integrating the iEMA Bloc module into the C2PSA module, the model's responsiveness to key adulteration regions is further improved. Furthermore, the use of LADH significantly reduces model params and GFLOPs while maintaining high accuracy and real-time performance. Validation experiments on a constructed dataset demonstrate that the LEO-YOLO-CM model achieves 97.8% and 97.9% mAP@50 for Box and Mask, respectively, representing improvements of 6.3% and 5.6% compared to the original model. Furthermore, the model's params are kept below 2.46M, and GFLOPs are reduced to 7.8 seconds, demonstrating a remarkable balance between accuracy, efficiency, and lightweight design. Further ablation experiments also verified the positive role of each structural module in improving the model detection robustness and segmentation boundary accuracy.
[0088] like Figure 8 Figure 2 shows the detection comparison results of the LEO-YOLO-CM model and the YOLOv11n-seg model proposed in this embodiment on typical images of traditional Chinese medicine preparations. The second column shows the detection output of the YOLOv11n-seg model, while the first column shows the detection output of the LEO-YOLO-CM model. Each medicinal ingredient is presented as a mask, with a bounding box and label used to identify the identification category, authenticity type (T- for authentic medicinal ingredients, F- for adulterated medicinal ingredients), and confidence level. The results show that the YOLOv11n-seg model suffers from issues such as missed detection of counterfeit medicinal ingredients and unclear recognition boundaries. For example, the F-MZC (adulterated horsetail herb) in the YOLOv11n-seg model is only partially detected or misclassified as another category. In contrast, the LEO-YOLO-CM model proposed in this embodiment fully covers the adulterated area in multiple recipe samples, with boundaries closely adhering to the true form, and accurately segmenting some small objects. Furthermore, the LEO-YOLO-CM model significantly improves its ability to distinguish genuine medicinal materials, maintaining good recognition accuracy even in the presence of overlapping occlusions. This graph fully demonstrates the effectiveness of the proposed improvement scheme in improving the ability to identify adulterated medicinal materials, enhancing edge perception capabilities, and overall detection accuracy, providing more reliable technical support for authenticity verification of Traditional Chinese Medicine formula images.
[0089] Implementation method 3: The real-time detection system for the authenticity of traditional Chinese medicine preparations described in this implementation method includes the following modules:
[0090] Construction module, builds a dataset of Chinese medicine dispensing images;
[0091] Model module, builds the LEO-YOLO-CM model, specifically:
[0092] In the Backbone of the YOLOv11n-seg model, the iEMA Bloc module is integrated into the C2PSA module. In the Backbone and Neck of the YOLOv11n-seg model, C3K2 is replaced with ODConv. In the Head of the YOLOv11n-seg model, the detection head is replaced with LADH.
[0093] The detection module, based on the LEO-YOLO-CM model, performs real-time authenticity detection on the traditional Chinese medicine dispensing image dataset.
[0094] Embodiment 4: An electronic device described in this embodiment includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0095] Memory for storing computer programs;
[0096] The processor is used to implement the real-time detection method for the authenticity of traditional Chinese medicine preparations described in any one of implementation modes one and two when executing the program stored in the memory.
[0097] Implementation method five: A computer-readable storage medium described in this implementation method stores a computer program, and when the computer program is executed by a processor, the real-time detection method for the authenticity of traditional Chinese medicine described in any one of implementation methods one to two is implemented.
[0098] The above is a detailed introduction to the real-time detection method, system, device and storage medium for the authenticity of traditional Chinese medicine preparations proposed in the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A real-time detection method for the authenticity of Chinese medicine preparations, characterized in that: The following steps are involved: Step S1, constructing a Chinese medicine dispensing image dataset; Step S2: Build the LEO-YOLO-CM model, specifically: In the Backbone of the YOLOv11n-seg model, the efficient inverted attention mechanism module iEMA Bloc is integrated into the C2PSA module. In the Backbone and Neck of the YOLOv11n-seg model, C3K2 is replaced with ODConv, and in the Head of the YOLOv11n-seg model, the detection head is replaced with LADH. Step S3: Based on the LEO-YOLO-CM model, the authenticity of the traditional Chinese medicine dispensing image dataset is detected in real time. In step S2, the iEMA Bloc module is specifically: The Chinese medicine dispensing image dataset is divided into two paths. After one path of the Chinese medicine dispensing image dataset passes through the iEMA attention mechanism module, it is residually connected with the other path of the Chinese medicine dispensing image dataset to output the Chinese medicine dispensing feature image dataset. The Chinese medicine dispensing feature image dataset is divided into two paths. After one path of the Chinese medicine dispensing feature image dataset passes through the multi-level convolutional layer module, it is residually connected with the other path of the Chinese medicine dispensing feature image dataset.
2. The method for real-time authenticity detection of traditional Chinese medicine according to claim 1, characterized in that: The iEMA attention mechanism module is specifically: The Chinese medicine dispensing image dataset is divided into two paths. One path of the Chinese medicine dispensing image dataset passes through the batch normalization two-dimensional layer, the EMA attention mechanism module and the convolution layer module in sequence, and then starts the jump connection function between the EMA attention mechanism module and the convolution layer module for addition, and then enters the convolution layer module and the discard path in sequence, and is added with the other path of the Chinese medicine dispensing image dataset.
3. The method for real-time authenticity detection of traditional Chinese medicine according to claim 1, characterized in that: In step S2, the iEMA Bloc module is integrated into the C2PSA module, specifically: The Chinese medicine dispensing image dataset is divided into two paths. One path of the Chinese medicine dispensing image dataset passes through the convolutional layer module and the multi-level iEMA Bloc module in sequence, and then is connected with the other path of the Chinese medicine dispensing image dataset and passes through the convolutional layer module.
4. A real-time detection system for the authenticity of Chinese medicine preparations, characterized by: Includes the following modules: Construction module, builds a dataset of Chinese medicine dispensing images; Model module, builds the LEO-YOLO-CM model, specifically: In the Backbone of the YOLOv11n-seg model, the efficient inverted attention mechanism module iEMA Bloc is integrated into the C2PSA module. In the Backbone and Neck of the YOLOv11n-seg model, C3K2 is replaced with ODConv, and in the Head of the YOLOv11n-seg model, the detection head is replaced with LADH. The detection module, based on the LEO-YOLO-CM model, performs real-time authenticity detection on the traditional Chinese medicine dispensing image dataset; In the model module, the iEMA Bloc module is specifically: The Chinese medicine dispensing image dataset is divided into two paths. After one path of the Chinese medicine dispensing image dataset passes through the iEMA attention mechanism module, it is residually connected with the other path of the Chinese medicine dispensing image dataset to output the Chinese medicine dispensing feature image dataset. The Chinese medicine dispensing feature image dataset is divided into two paths. After one path of the Chinese medicine dispensing feature image dataset passes through the multi-level convolutional layer module, it is residually connected with the other path of the Chinese medicine dispensing feature image dataset.
5. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory for storing computer programs; The processor is used to implement the real-time detection method for the authenticity of traditional Chinese medicine preparations according to any one of claims 1 to 3 when executing the program stored in the memory.
6. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the real-time detection method for the authenticity of a traditional Chinese medicine preparation according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Fan surface defect detection method, device and equipment based on lightweight PC-EMA algorithm and storage medium
CN118691573A
Underwater target detection method and system based on improved Yolov11
CN120014235A