Traditional Chinese medicine decoction piece detection method based on real-time object detection deep learning model

By improving and optimizing the YOLOv8 model, combining data set construction and model deployment, the problems of low efficiency and poor accuracy of traditional Chinese herbal medicines are solved, and high-precision and high-speed Chinese herbal medicine detection are achieved, which promotes the automation and intelligence of the industry.

CN119723541APending Publication Date: 2025-03-28BEIJING UNIV OF CHINESE MEDICINE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411784489.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The recognition of traditional Chinese herbal medicines relies on manual labor, with subjective differences, time-consuming, low efficiency, difficult to meet real-time needs, and a wide variety and fake products, making it difficult to guarantee the accuracy and consistency of identification.

Method used

The Chinese herbal medicine detection method based on real-time object detection deep learning model is adopted. Through the improvement and optimization of the YOLOv8 model, including data set construction, model improvement, pre-training, constraint training, model pruning, model fine-tuning and model deployment, the detection accuracy and speed are improved and the small object detection capability is enhanced.

Benefits of technology

It significantly improves the accuracy and speed of Chinese herbal medicine detection, meets the needs of real-time application, enhances the ability to detect small targets, and promotes the automation and intelligent development of the traditional Chinese medicine industry.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119723541A_ABST
    Figure CN119723541A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of traditional Chinese medicine decoction piece detection, in particular to a traditional Chinese medicine decoction piece detection method based on a real-time object detection deep learning model. According to the technical scheme, the method comprises the steps of data set construction, model improvement, pre-training, constraint training, model pruning, model fine adjustment and model deployment, in the model improvement, a C2f module of a YOLOv8 model is replaced with a VoVGSCSP module, the model is pre-trained by using the data set, performance evaluation and adjustment are performed on the model, and the model deployment efficiency is improved. A channel, suitable for pruning, of the model is recognized through constraint training to achieve compression and optimization of the model, pruning is conducted on the model through the pruning method to improve the operation speed of the model, the optimal result of model pruning is explored through model fine adjustment, and finally the model is deployed. Through cooperation of the structures, the detection precision and the detection speed are remarkably improved, the small target detection capability is enhanced, and the industry automation process is promoted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of Chinese herbal medicine slice detection, and in particular to a Chinese herbal medicine slice detection method based on a real-time object detection deep learning model. Background Art

[0002] Traditionally, the identification of Chinese herbal medicines mainly relies on experienced pharmacists or Chinese medicine practitioners to do it manually, but this method has many disadvantages. First, manual identification is highly subjective, and different pharmacists have different levels of experience and knowledge, resulting in differences in identification results, especially the accuracy of identification by novice pharmacists is difficult to guarantee. Second, the manual identification process is complicated and time-consuming, which is difficult to meet the growing demand for Chinese medicine, and the workload is huge and inefficient. In addition, long-term identification work can easily lead to pharmacist fatigue, which in turn affects the accuracy of identification, and visual fatigue and decreased attention may lead to misjudgment. In addition, there are many types of Chinese herbal medicines, and new medicinal materials and counterfeits continue to appear. Pharmacists need to continue to learn and accumulate new knowledge, but the speed of personal learning and updating is limited, and it is difficult to fully grasp the latest information. At the same time, the process and standards of manual identification are difficult to fully unify, and there may be differences between different regions and institutions, which affects the consistency and reliability of identification. Finally, there is a contradiction between the market demand and supply of high-quality pharmacists. The training cycle is long and human resources are scarce, which makes it difficult to meet actual needs. With the development of science and technology, the use of technologies such as computer vision and deep learning to achieve automatic identification of Chinese herbal medicines can effectively make up for the shortcomings of manual identification, improve identification efficiency and accuracy, and provide technical support for the modernization and standardization of the Chinese medicine industry.

[0003] You Only Look Once (YOLO) is a deep learning model widely used in real-time object detection. Its latest version, YOLOv8, further improves the accuracy and efficiency of detection. The improvements of YOLOv8 include a deeper network structure, an optimized loss function, and a more efficient feature extraction method, which enables it to perform well when processing complex images. Applying YOLOv8 to the detection of Chinese herbal medicines can make full use of its fast and efficient characteristics, providing strong support for automated detection in the Chinese medicine industry.

[0004] The problems that need to be solved at present include the diversity and complexity of Chinese herbal medicines: Chinese herbal medicines are of various types and in various forms, and traditional detection methods are difficult to cope with this complexity. Balance between detection accuracy and speed: While ensuring high detection accuracy, it is necessary to ensure that the detection speed is fast enough to meet the real-time requirements in practical applications. The problem of small target detection: Chinese herbal medicines often contain small-sized targets, and traditional detection methods are prone to missed detection or false detection when dealing with these small targets.

[0005] To this end, we propose a Chinese herbal medicine detection method based on a real-time object detection deep learning model to solve the existing problems. Summary of the invention

[0006] The purpose of the present invention is to address the problems existing in the background technology and to propose a method for detecting Chinese herbal medicine slices based on a real-time object detection deep learning model.

[0007] To achieve the above-mentioned purpose, the present invention provides the following technical solutions: a method for detecting Chinese herbal medicine slices based on a real-time object detection deep learning model, comprising data set construction, model improvement, pre-training, constraint training, model pruning, model fine-tuning and model deployment, wherein the model improvement replaces the C2f module of the YOLOv8 model with the VoVGSCSP module, pre-trains the model using the data set, evaluates and adjusts the model performance, identifies the channels of the model suitable for pruning through the constraint training to achieve model compression and optimization, prunes the model through the pruning method to improve the model's computing speed, explores the best results of model pruning through the model fine-tuning, and finally deploys the model.

[0008] Preferably, the data set construction includes sample collection and data annotation, collecting representative samples of Chinese herbal medicines from markets, production enterprises or hospitals and other channels, performing image acquisition and fine annotation on the collected samples, and marking information such as the type and location of the Chinese herbal medicines.

[0009] Preferably, the model improvement includes replacing the C2f module with the VoVGSCSP module in the YOLOv8 model and using the Focal-CIOU loss function. The VoVGSCSP module adopts a dual-branch design, in which one branch performs a standard convolution operation on the input feature matrix to adjust the number of channels, and then uses the GSBottleneck module to further extract features; the other branch performs only one standard convolution operation, thereby ensuring similar accuracy to traditional convolution modules of the same depth while greatly reducing the number of parameters.

[0010] Preferably, the pre-training includes using the YOLOv8+VoVGSCSP+Focal-CIOU model training result weights as the pre-training result weights, and the subsequent experiments will be carried out on the YOLOv8+VoVGSCSP+Focal-CIOU model, and the constrained training includes constraining the BN layer by adding an L1 regularizer.

[0011] Preferably, the model pruning adopts global pruning with a retention rate of factor, setting each BN layer to retain at least 8 channels (due to NVIDIA's hardware acceleration, the number of channels we retain should be greater than or equal to 8), extracting the weights of all batch normalization layers (BN) and sorting them in descending order, calculating the weight length and multiplying it by the retention rate factor, and obtaining the position of the threshold threshold in the weights after descending order. Weights less than the threshold will be removed in subsequent pruning.

[0012] Preferably, the model fine-tuning includes fine-tuning the model after pruning on the Chinese herbal medicine data set by selecting different factor values ​​to explore the best result of model pruning.

[0013] Preferably, the model deployment includes Docker-based model deployment steps: selecting a base image, writing a Dockerfile, building an image, and running a Docker container. Through the above steps, the model can be successfully deployed into a Docker container and easily run and managed in different environments.

[0014] Compared with the prior art, the present invention has the following beneficial effects:

[0015] During use of the present invention,

[0016] Significantly improve detection accuracy: The improved YOLOv8 model can more accurately identify and classify different types of Chinese herbal medicines, significantly improving the detection accuracy.

[0017] Improve detection speed: By optimizing the model structure and algorithm, YOLOv8 achieves fast detection while ensuring high accuracy, meeting the needs of real-time applications.

[0018] Enhanced small target detection capabilities: Improved feature extraction and multi-scale detection methods enable YOLOv8 to show higher detection performance when facing small-sized Chinese herbal medicine pieces.

[0019] Promote the automation process of the industry: The Chinese herbal medicine detection system based on YOLOv8 can significantly reduce the cost of manual detection, improve the efficiency of Chinese medicine production and inspection, and promote the automation and intelligent development of the Chinese medicine industry. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 It is a flow chart of the present invention. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0022] Embodiment 1

[0023] like Figure 1 As shown, the present invention proposes a method for detecting Chinese herbal medicine slices based on a real-time object detection deep learning model, including data set construction, model improvement, pre-training, constraint training, model pruning, model fine-tuning and model deployment. The model improvement replaces the C2f module of the YOLOv8 model with the VoVGSCSP module, pre-trains the model by using a data set, evaluates and adjusts the model performance, compresses and optimizes the model by identifying the channels suitable for pruning through constraint training, prunes the model through a pruning method to improve the model's computing speed, explores the best result of model pruning through model fine-tuning, and finally deploys the model to improve the detection accuracy and detection speed of the model and enhance the small target detection capability.

[0024] Embodiment 2

[0025] like Figure 1 As shown, the present invention proposes a method for detecting Chinese herbal medicines based on a real-time object detection deep learning model. Compared with the first embodiment, this embodiment also includes: data set construction including sample collection and data annotation, collecting representative Chinese herbal medicine samples from markets, production enterprises or hospitals and other channels, performing image acquisition and fine annotation on the collected samples, and marking the type, location and other information of the Chinese herbal medicines.

[0026] Embodiment 3

[0027] like Figure 1As shown, the present invention proposes a method for detecting Chinese herbal medicine pieces based on a real-time object detection deep learning model. Compared with the first embodiment, this embodiment also includes: model improvements include replacing the C2f module with the VoVGSCSP module in the YOLOv8 model, using the Focal-CIOU loss function, and the VoVGSCSP module adopts a dual-branch design, one branch performs a standard convolution operation on the input feature matrix to adjust the number of channels, and then uses the GSBottleneck module to further extract features; the other branch only performs a standard convolution operation, and the outputs of the two branches are then spliced ​​together, and the feature information is fused through another standard convolution operation. The subtlety of the VoVGSCSP module is that it greatly reduces the number of parameters while ensuring similar accuracy to traditional convolution modules of the same depth, which makes the model more lightweight and suitable for application scenarios that require lightweight models.

[0028] By using the data set to pre-train the model, the YOLOv8+VoVGSCSP+Focal-CIOU model training result weights are used as the pre-training result weights. The following experiments will be conducted on YOLOv8+

[0029] The VoVGSCSP+Focal-CIOU model is expanded and the BN layer is constrained by adding an L1 regularizer. In the experimental part, the model weights for the next experiment are determined by setting 100 training cycles and observing the stability of different evaluation indicators. In this way, we can more accurately identify channels that contain less information and are suitable for pruning in the experiment, thereby achieving model compression and optimization with minimal loss of accuracy.

[0030] Pruning method

[0031] Use global pruning with a retention rate of factor. Set each BN layer to retain at least 8 channels (due to NVIDIA's hardware acceleration, the number of channels we retain should be greater than or equal to 8). Extract the weights of all batch normalization layers (BN) and sort them in descending order. Calculate the weight length and multiply it by the retention rate factor to get the position of the threshold threshold in the weights after descending order. Weights less than the threshold will be removed in subsequent pruning.

[0032] Bottleneck module pruning

[0033] In the VoVGSCSP network architecture, the Bottleneck module is a key component, and its structure consists of two sequentially arranged convolutional modules, called ConvModule. To improve the efficiency of this module, we performed a pruning process.

[0034] Through this series of pruning operations, the Bottleneck module is optimized to be lighter while maintaining the original performance level as much as possible. This process optimizes the computational efficiency of the module and reduces the demand for computing resources.

[0035] In the network structure, we can observe four main module combinations: ConvModule->ConvModule, ConvModule->VoVGSCSP, VoVGSCSP->ConvModule, and VoVGSCSP->SPPF. Here, '->' represents the sequential concatenation of modules. When analyzing the structure in depth, we found that both VoVGSCSP and SPPF modules use ConvModule at the beginning and end of their sequence, that is, there are two sequentially arranged convolutional modules (ConvModule) in each combination. This discovery allows us to unify the complex pruning strategies into a simplified process that is applicable to all the above module combinations.

[0036] The process involves the following detailed steps:

[0037] ① Weight extraction and threshold screening: First, we extract all weights and bias parameters from the batch normalization (BN) layer in the first ConvModule. Next, we set a predefined threshold and screen the weights of the BN layer. Specifically, we build an index list that contains only those neurons whose absolute weights are greater than the threshold.

[0038] ②BN layer parameter update: Using the filtered index, we update the parameters in the BN layer. Only those weights and biases whose absolute values ​​are higher than the threshold are retained, which means removing those less important weights - that is, those that have little effect on the model output.

[0039] ③ Pruning of convolutional layers: Next, we prune the convolutional layers of the first ConvModule according to the indices obtained in the previous step. This step involves retaining the output feature channels corresponding to the retained weights in the BN layer.

[0040] ④ Channel consistency preservation: Finally, in order to maintain the continuity of the network, we retain the input channels in the convolution layer of the second ConvModule according to the feature channel index retained in the first ConvModule. This ensures the match between input and output and avoids the dimension mismatch problem caused by pruning.

[0041] Through this pruning process, we can simplify the pruning work between modules to the greatest extent possible while ensuring that the pruned structure can maintain its original functionality and efficiency. This method not only improves the model's computing speed, but also maintains or even improves the model's accuracy to a certain extent.

[0042] Then, by selecting different factor values, we fine-tune the model after pruning on the Chinese herbal medicine dataset to explore the best results of model pruning.

[0043] According to the environment required for the model to run, select a suitable base image, then in the Dockerfile, specify the base image, set the working directory, copy the model file to the container, install necessary dependencies, set environment variables, expose ports, and define the commands to be executed when the container is started. Use the instructions in the Dockerfile to build the Docker image through the docker build command, where docker build -t my-model-image. (where my-model-image is the image name, and . represents the current directory where the Dockerfile is located). Use the docker run command to start the Docker container based on the built image docker run -dp 5000:5000my-model-image (-d means background running, -p 5000:5000 means mapping port 5000 of the container to port 5000 of the host). Through the above steps, the model is successfully deployed to the Docker container.

[0044] The above-mentioned specific embodiments are only several preferred embodiments of the present invention. Based on the technical solutions of the present invention and the relevant inspirations of the above-mentioned embodiments, those skilled in the art can make various alternative improvements and combinations to the above-mentioned specific embodiments.

[0045] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.

Claims

1. A method for detecting Chinese herbal medicine pieces based on a real-time object detection deep learning model, including data set construction, model improvement, pre-training, constraint training, model pruning, model fine-tuning and model deployment, characterized in that: The model improvement replaces the C2f module of the YOLOv8 model with the VoVGSCSP module, pre-trains the model by using the data set, evaluates and adjusts the performance of the model, compresses and optimizes the model by identifying the channels of the model suitable for pruning through the constraint training, prunes the model through the pruning method to improve the operation speed of the model, explores the best result of model pruning through model fine-tuning, and finally deploys the model to improve the detection accuracy and detection speed of the model and enhance the small target detection capability.

2. According to claim 1, a method for detecting Chinese herbal medicine pieces based on a real-time object detection deep learning model is characterized in that: The dataset construction includes sample collection and data annotation. Representative samples of Chinese herbal medicines are collected from markets, production enterprises or hospitals and other channels. Images of the collected samples are captured and finely annotated to mark out information such as the types and locations of the Chinese herbal medicines.

3. According to claim 1, a method for detecting Chinese herbal medicine pieces based on a real-time object detection deep learning model is characterized in that: The model improvements include replacing the C2f module with the VoVGSCSP module in the YOLOv8 model and using the Focal-CIOU loss function. The VoVGSCSP module adopts a dual-branch design, which ensures similar accuracy to traditional convolution modules of the same depth while greatly reducing the number of parameters.

4. According to claim 1, a method for detecting Chinese herbal medicine pieces based on a real-time object detection deep learning model is characterized in that: The pre-training includes using the YOLOv8+VoVGSCSP+Focal-CIOU model training result weights as the pre-training result weights. The following experiments will be carried out on the YOLOv8+VoVGSCSP+Focal-CIOU model. The constrained training includes constraining the BN layer by adding an L1 regularizer.

5. The method for detecting Chinese herbal medicine pieces based on a real-time object detection deep learning model according to claim 1, characterized in that: The model pruning adopts global pruning with a retention rate of factor. Each BN layer is set to retain at least 8 channels (due to NVIDIA's hardware acceleration, the number of channels we retain should be greater than or equal to 8). The weights of all batch normalization layers (BN) are extracted and sorted in descending order. The weight length is calculated and multiplied by the retention rate factor to obtain the position of the threshold threshold in the weights after descending order. Weights less than the threshold will be removed in subsequent pruning.

6. The method for detecting Chinese herbal medicine pieces based on a real-time object detection deep learning model according to claim 1, characterized in that: The model fine-tuning includes fine-tuning the model after pruning on the Chinese herbal medicine dataset by selecting different factor values ​​to explore the best result of model pruning.

7. The method for detecting Chinese herbal medicine pieces based on a real-time object detection deep learning model according to claim 1, characterized in that: The model deployment includes Docker-based model deployment steps: selecting a base image, writing a Dockerfile, building an image, and running a Docker container. Through the above steps, the model can be successfully deployed into a Docker container and easily run and managed in different environments.