A tongue image detection and positioning algorithm based on lightweight cascade neural network
Through a tongue image detection algorithm based on a lightweight cascaded neural network, three small convolutional neural network cascades are used for training and screening, which solves the problems of inaccurate tongue image positioning and algorithm complexity in the existing technology, and achieves high Accurate tongue image detection and positioning, suitable for applications in diverse backgrounds and Internet platforms.
Patent Information
- Application Number
- CN201910789517.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-08-26
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2039-08-26
AI Technical Summary
The algorithm collected by the existing computer tongue diagnosis system in fixed tongue diagnosis instruments is difficult to achieve accurate positioning of tongue images in diverse backgrounds, and the detection algorithm with complex network structure is not conducive to the transplantation of actual algorithms and application on the Internet platform.
A tongue image detection and positioning algorithm based on a lightweight cascaded neural network is used. By marking the target area of the tongue image sample picture, positive and negative samples are randomly cropped to perform feature extraction and classification judgment. Three small convolutional neural network cascades are used to perform Training to eliminate low-confidence candidate frames and achieve precise positioning of the tongue image.
It achieves tongue image detection and positioning in complex backgrounds, with detection accuracy higher than 90% and accurate positioning higher than 80%. It also reduces the complexity of the algorithm and model size, making it suitable for Internet platform applications.
Smart Images

Figure CN110599463B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image detection algorithms, and in particular to a tongue image detection and positioning algorithm based on a lightweight cascade neural network. Background Art
[0002] Tongue diagnosis is one of the important diagnostic methods in traditional Chinese medicine. In recent years, with the development of image processing and machine learning technology, the research on computer tongue diagnosis system has received more and more attention. The complete computer tongue diagnosis system is divided into three parts: tongue image acquisition, tongue segmentation and tongue image recognition and analysis. It uses image processing and machine learning related technologies to complete the recognition and classification of tongue image information and finally obtain the diagnosis result.
[0003] A complete computer tongue diagnosis system is generally divided into three parts: tongue image acquisition, tongue image segmentation, and tongue image feature recognition and analysis. Image processing and pattern recognition technology are used to complete the recognition and analysis of tongue image information. Researchers focus on the quantification and standardization of tongue diagnosis. They suggest using standard tongue image equipment to capture standardized tongue images to reduce the impact of environmental factors, such as differences in lighting conditions, tongue position, and image size. Although constant lighting and fixed position can reduce the difficulty of subsequent tongue segmentation and tongue image recognition. However, considering that the computer tongue diagnosis system should be able to play a role on more platforms represented by the Internet, the algorithms proposed in the past for standard tongue diagnosis images collected in fixed tongue diagnosis instruments may face considerable challenges. Existing detection algorithms such as vgg and faster_rcnn have complex network structures and large models, which are not conducive to the transplantation of actual algorithms.
[0004] As the scenarios of TCM diagnosis and treatment become more complex and the backgrounds of images to be analyzed become more diverse, the premise of tongue image analysis is to accurately locate the position of the tongue in an image. The current fixed coordinate tongue image positioning can no longer meet the requirement of accurately locating the tongue area. Detecting whether there is a tongue image in the image and accurately locating the tongue image are the practical functions that this algorithm proposes to meet. Summary of the invention
[0005] In view of this, the problem to be solved by the present invention is to provide a tongue image detection and positioning algorithm based on a lightweight cascade neural network.
[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is: a tongue image detection and positioning algorithm based on a lightweight cascade neural network, comprising the steps of 1) marking the coordinate position of the target area of the tongue image sample picture;
[0007] Step 2) randomly crop the tongue image sample images to obtain positive and negative samples with classification labels, and input them into the first layer of the network;
[0008] Step 3) extracting features and classifying the sample images in step 2), outputting the coordinate information of the candidate boxes classified as positive, cropping the original images to obtain selected samples, scaling them to a specified size and feeding them into the second layer network;
[0009] Step 4) trains the sample image in step 3) to obtain the classified candidate boxes, outputs the coordinate information of the candidate boxes classified as positive, crops the original image to obtain the selected samples, scales them to a specified size (larger than the size in step 3) and puts them into the third layer network;
[0010] Step 5) The sample images in step 4) are trained, and after the training is completed, the classification labels and the coordinate information of the candidate boxes are obtained.
[0011] In the present invention, preferably, the candidate boxes are screened and bounding box regression is performed before the step 3) is put into the second layer network and the step 4) is put into the third layer network to eliminate the candidate boxes with low confidence.
[0012] In the present invention, preferably, the step 2) realizes classification of positive and negative local samples by distinguishing through iou values.
[0013] In the present invention, preferably, the training algorithm steps of step 4) and step 5) include:
[0014] Step S1) preparing a tongue image sample image scaled to the window size as a positive sample;
[0015] Step S2) sampling negative samples from tongue image sample pictures without positive samples (without tongue images);
[0016] Step S3) Calculate the values of 10 integral channels of positive and negative samples;
[0017] Step S4) randomly generates a feature pool F and calculates the error rate of the sampled samples;
[0018] Step S5) Initialize the sample set D, the maximum number of iterations k max ;
[0019] Step S6) Initialize the iterative weight W k (i) = 1 / n, i = 1…n, from 1 to k max Perform cumulative summation;
[0020] Step S7) According to the weight W of sample set D k (i) Select the feature pool to construct a two-layer decision tree C k ;
[0021] Step S8) Calculate the training error, C k The weight W in the sample set D k(i) The error in
[0022] Step S9) Calculate the weak classifier weights and update the sample weights;
[0023] Step S10) Return weak classifier C k And their corresponding weights, the weak classifiers are combined into a strong classifier.
[0024] In the present invention, preferably, the method for screening candidate boxes includes:
[0025] Step T1) extracting a list of candidate boxes W and sorting the list of candidate boxes W according to the scores;
[0026] Step T2) Initialize the filtered candidate box list W l is empty;
[0027] Step T3) determines whether l(W)>0 is established. If yes, executes the nms algorithm to screen the candidate boxes; if no, returns to step T2).
[0028] In the present invention, preferably, the nms algorithm includes:
[0029] Step U1) Select the first candidate box w in the candidate box list W, score s, and add it to W l , remove it from the candidate box list W;
[0030] Step U2) Calculate the first candidate box w and the first candidate box w i The degree of overlap;
[0031] Step U3) remove all candidate boxes in the candidate box list W that overlap with the first candidate box w by more than a degree threshold of 0.3.
[0032] In the present invention, preferably, after removing the candidate boxes with low confidence, the coordinate information of the candidate boxes is corrected. The method for correcting the coordinate information of the candidate boxes includes: defining a three-dimensional coordinate correction vector Given the candidate box (x, y, w, h), the coordinates of the upper left corner (x, y), and the length and width of the candidate box (w, h), the candidate box after coordinate correction is:
[0033] The confidence vector {c1,c2,...,c n}I(c n >t), when (c n >t), it takes 1, otherwise it takes 0: The mean of the correction methods that are greater than the threshold t is taken as the coordinate information of the corrected candidate box.
[0034] In the present invention, preferably, in the step 2), the same character is sent to the classification network for classification multiple times by random cropping.
[0035] In the present invention, preferably, the sample size of the second layer network is larger than the sample size of the first layer network, and the sample size of the third layer network is larger than the sample size of the second layer network.
[0036] In the present invention, preferably, the size of the input tongue image sample picture needs to be scaled to multiple scales, and the multi-scale sample test can effectively improve the robustness and accuracy of the classifier.
[0037] The advantages and positive effects of the present invention are as follows: the deep learning network in the algorithm is composed of three small convolutional neural networks connected in series, and a classifier with better classification effect is obtained by cascading weak classifiers to perform tongue image detection. First, the labeled tongue image sample pictures are randomly cropped to obtain positive and negative samples with classification labels, and are put into the first layer of network. By extracting and classifying the input samples, the coordinate information of the samples identified as positive in the original image is saved as candidate frame information, and through the difficult example recognition operation, the candidate frames with low confidence are eliminated and put into the second layer of network for further training. The second layer sample size is larger than the first layer sample, and more picture information is carried for training to obtain more accurate candidate frames. Similarly, the number of candidate frames is reduced by confidence screening and put into the third layer. The sample size is larger than the second layer. After training, the model can obtain the classification label and the coordinate information of the frame at the same time, thereby realizing the function of detecting tongue images and accurately positioning; it can realize the judgment of whether there is tongue image and the framing of the tongue image interest area for samples with complex background and complex picture structure. In actual detection, the accuracy of color tongue image detection is higher than 90%, and the accurate positioning is higher than 80%. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0039] Figure 1 It is a schematic diagram of a sample picture of a tongue image detection and positioning algorithm based on a lightweight cascade neural network of the present invention;
[0040] Figure 2 It is a schematic diagram of feature extraction, classification and judgment of a tongue image detection and positioning algorithm based on a lightweight cascade neural network of the present invention. DETAILED DESCRIPTION
[0041] 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.
[0042] It should be noted that when a component is referred to as being "fixed to" another component, it may be directly on the other component or there may also be a component centered. When a component is considered to be "connected to" another component, it may be directly connected to the other component or there may also be a component centered. When a component is considered to be "set on" another component, it may be directly set on the other component or there may also be a component centered. The terms "vertical", "horizontal", "left", "right" and similar expressions used herein are for illustrative purposes only.
[0043] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more related listed items.
[0044] like Figure 1 and Figure 2 As shown, the present invention provides a tongue image detection and positioning algorithm based on a lightweight cascade neural network, comprising:
[0045] Step 1) marking the coordinate position of the target area of the tongue image sample picture;
[0046] Step 2) randomly crop the tongue image sample images to obtain positive and negative samples with classification labels, and input them into the first layer of the network;
[0047] Step 3) extracting features and classifying the sample images in step 2), outputting the coordinate information of the candidate boxes classified as positive, cropping the original images to obtain selected samples, scaling them to a specified size and feeding them into the second layer network;
[0048] Step 4) trains the sample image in step 3) to obtain the classified candidate boxes, outputs the coordinate information of the candidate boxes classified as positive, crops the original image to obtain the selected samples, scales them to a specified size (larger than the size in step 3) and puts them into the third layer network;
[0049] Step 5) The sample images in step 4) are trained, and after the training is completed, the classification labels and the coordinate information of the candidate boxes are obtained.
[0050] In this embodiment, further, before the step 3) is put into the second layer network and the step 4) is put into the third layer network, the candidate boxes are screened and bounding box regression is performed to eliminate the candidate boxes with low confidence.
[0051] In this embodiment, further, the step 2) realizes the classification of positive and negative local samples by distinguishing through the iou value, wherein the iou value is defined as the ratio of the area of the intersection of the segmented area and the target area to the area of the union area, and a larger iou value corresponds to a better object segmentation. For a group of tongue image sample pictures, the mean of the iou value of each tongue image sample picture is used as the iou segmentation result of the group. Given a group of tongue image sample pictures, the experiment uses the iou mean of all tongue image sample pictures to represent the iou value of the group of tongue image sample pictures. Successful segmentation corresponds to a larger iou value, and vice versa.
[0052] In this embodiment, further, the training algorithm steps of step 4) and step 5) include:
[0053] Step S1) preparing a tongue image sample image scaled to the window size as a positive sample;
[0054] Step S2) sampling negative samples on tongue image sample pictures without positive samples (without tongue images);
[0055] Step S3) Calculate the values of 10 integral channels of positive and negative samples;
[0056] Step S4) randomly generates a feature pool F and calculates the error rate of the sampled samples;
[0057] Step S5) Initialize the sample set D, the maximum number of iterations k max ;
[0058] Step S6) Initialize the iterative weight W k (i) = 1 / n, i = 1…n, from 1 to k max Perform cumulative summation;
[0059] Step S7) According to the weight W of sample set D k (i) Select the feature pool to construct a two-layer decision tree C k ;
[0060] Step S8) Calculate the training error, C k The weight W in the sample set D k (i) The error in
[0061] Step S9) Calculate the weak classifier weights and update the sample weights;
[0062] Step S10) Return weak classifier Ck And their corresponding weights, the weak classifiers are combined into a strong classifier.
[0063] In this embodiment, further, the method for screening candidate boxes includes:
[0064] Step T1) extracting a list of candidate boxes W and sorting the list of candidate boxes W according to the scores;
[0065] Step T2) Initialize the filtered candidate box list W l is empty;
[0066] Step T3) determines whether l(W)>0 is established. If yes, executes the nms algorithm to screen the candidate boxes; if no, returns to step T2).
[0067] In this embodiment, further, the nms algorithm includes:
[0068] Step U1) Select the first candidate box w in the candidate box list W, score s, and add it to W l , remove it from the candidate box list W;
[0069] Step U2) Calculate the first candidate box w and the first candidate box w i The degree of overlap;
[0070] Step U3) remove all candidate boxes in the candidate box list W that overlap with the first candidate box w by more than a degree threshold of 0.3.
[0071] In this embodiment, after removing the candidate boxes with low confidence, the coordinate information of the candidate boxes is corrected. The method for correcting the coordinate information of the candidate boxes includes: defining a three-dimensional coordinate correction vector Given the candidate box (x, y, w, h), the coordinates of the upper left corner (x, y), and the length and width of the candidate box (w, h), the candidate box after coordinate correction is:
[0072]
[0073] The confidence vector {c1,c2,...,cn}I(cn>t) takes 1 when (cn>t) and takes 0 otherwise: The mean of the correction methods that are greater than the threshold t is taken as the coordinate information of the corrected candidate box.
[0074] In this embodiment, further, in step 2), the same character is sent to the classification network for classification multiple times by random cropping. This random cropping method can effectively improve the classification effect of difficult tongue image sample pictures. For some difficult tongue image sample pictures, that is, tongue image sample pictures that are partially similar, they can be distinguished by focusing on local information. Therefore, this random cropping method enables the classifier to not only learn global information, but also focus on local information, which is conducive to improving the effect of the classifier.
[0075] In this embodiment, further, the sample size of the second layer network is larger than the sample size of the first layer network, and the sample size of the third layer network is larger than the sample size of the second layer network.
[0076] In this embodiment, further, the size of the input tongue image sample picture needs to be scaled to multiple scales, and the multi-scale sample test can effectively improve the robustness and accuracy of the classifier.
[0077] The working principle and working process of the present invention are as follows: In this algorithm, the deep learning network is a cascade of weak classifiers obtained by three small convolutional neural networks to obtain a classifier with better classification effect. First, the labeled tongue image sample pictures are randomly cropped to obtain positive and negative samples with classification labels, and are put into the first layer of the network. Through feature extraction and classification judgment of the input samples, the coordinate information of the samples identified as positive in the original image is saved as candidate frame information, and through the difficult example recognition operation, the candidate frames with low confidence are eliminated and put into the second layer of the network for further training. The second layer sample size is larger than the first layer sample, and more image information is carried for training to obtain candidate frames with more accurate classification. Similarly, the number of candidate frames is reduced through confidence screening and put into the third layer. The sample size is larger than the second layer. After the training is completed, the model can obtain the classification label and the coordinate information of the frame at the same time, realizing the function of detecting tongue images and accurately positioning.
[0078] The idea of the feature selection algorithm is to obtain a stronger classifier with better effect by combining weak classifiers. The training is iterative during training. Each round can be adaptive. The weight of the samples that were misclassified by the classifier in the previous iteration is increased. A new weak classifier is trained based on this benchmark and added to the set of weak classifiers. During testing, g(x) is calculated to determine whether it is greater than a given threshold θ, and positive and negative samples are classified. The specific training steps are as follows: prepare tongue image sample images scaled to the window size as positive samples; sample negative samples on tongue image sample images without positive samples (no tongue images) to calculate the values of 10 integral channels of positive and negative samples; randomly generate a feature pool F and calculate the error rate of the sampled samples; initialize the sample set D, and the maximum number of iterations k max ; Initialize the iterative weight W k (i) = 1 / n, i = 1…n, from 1 to k max Perform cumulative summation; according to the weight W of sample set Dk (i) Select the feature pool to construct a two-layer decision tree C k ; Calculate the training error, C k The weight W in the sample set D k (i); calculate the weak classifier weights and update the sample weights; return the weak classifier C k And its corresponding weight, the weak classifier is combined into a strong classifier. This algorithm is very sensitive to anomalies and noise. If there is an error in the labeled data, it is easy to affect the training model. To reduce this impact, the labeling of the entire data set is rechecked and the labeled data is corrected; in addition, the weak classifiers obtained by cascading three small convolutional neural networks are used to obtain a classifier with better classification effect. This algorithm uses a relatively small convolutional neural network and filters the candidate boxes layer by layer in a cascade manner through three series of networks of different sizes, ensuring speed while also ensuring high model accuracy.
[0079] The embodiments of the present invention are described in detail above, but the contents described are only preferred embodiments of the present invention and cannot be considered to limit the scope of implementation of the present invention. All equivalent changes and improvements made within the scope of the present invention should still fall within the scope of this patent.
Claims
1. A tongue image detection and positioning algorithm based on a lightweight cascade neural network, characterized in that: The following steps are involved: Step 1) marking the coordinate position of the target area of the tongue image sample picture; Step 2) randomly crop the tongue image sample images to obtain positive and negative samples with classification labels, and input them into the first layer of the network; Step 3) extracting features and classifying the sample images in step 2), outputting the coordinate information of the candidate boxes classified as positive, cropping the original images to obtain selected samples, scaling them to a specified size and feeding them into the second layer network; Step 4) trains the sample image in step 3) to obtain the classified candidate boxes, outputs the coordinate information of the candidate boxes classified as positive, crops the original image to obtain the selected samples, scales them to a specified size larger than the size in step 3) and puts them into the third layer network; wherein the sample size of the second layer network is larger than the sample size of the first layer network, and the sample size of the third layer network is larger than the sample size of the second layer network; Step 5) training the sample images in step 4) to obtain the classification labels and coordinate information of the candidate boxes after the training is completed; The training algorithm steps of step 4) and step 5) include: Step S1) preparing a tongue image sample image scaled to the window size as a positive sample; Step S2) sampling negative samples from tongue image sample pictures without positive samples and tongue images; Step S3) Calculate the values of 10 integral channels of positive and negative samples; Step S4) randomly generates a feature pool F and calculates the error rate of the sampled samples; Step S5) Initialize the sample set D, the maximum number of iterations k max ; Step S6) Initialize the iterative weight W k (i) = 1 / n, i = 1…n, from 1 to k max Perform cumulative summation; Step S7) According to the weight W of sample set D k (i) Select the feature pool to construct a two-layer decision tree C k ; Step S8) Calculate the training error, C k The weight W in the sample set D k (i) The error in Step S9) Calculate the weak classifier weights and update the sample weights; Step S10) Return weak classifier C k And their corresponding weights, the weak classifiers are combined into a strong classifier.
2. The tongue image detection and positioning algorithm based on lightweight cascade neural network according to claim 1 is characterized in that: Before the step 3) is put into the second layer network and the step 4) is put into the third layer network, the candidate boxes are screened and the frame regression is performed to eliminate the candidate boxes with low confidence.
3. The tongue image detection and positioning algorithm based on lightweight cascade neural network according to claim 1 is characterized in that: The step 2) classifies positive and negative local samples by distinguishing them through the iou values.
4. The tongue image detection and positioning algorithm based on lightweight cascade neural network according to claim 2 is characterized in that: The method for selecting candidate frames includes: Step T1) extracting a list of candidate boxes W and sorting the list of candidate boxes W according to the scores; Step T2) Initialize the filtered candidate box list W l is empty; Step T3) determines whether l(W)>0 is established. If yes, executes the nms algorithm to screen the candidate boxes; if no, returns to step T2).
5. The tongue image detection and positioning algorithm based on lightweight cascade neural network according to claim 4 is characterized in that: The nms algorithm includes: Step U1) Select the first candidate box w in the candidate box list W, score s, and add it to W l , remove it from the candidate box list W; Step U2) Calculate the first candidate box w and the first candidate box w i The degree of overlap; Step U3) remove all candidate boxes in the candidate box list W that overlap with the first candidate box w by more than a degree threshold of 0.
3.
6. The tongue image detection and positioning algorithm based on lightweight cascade neural network according to claim 1, characterized in that: In the step 2), the same character is sent to the classification network for classification multiple times by random cropping.
7. The tongue image detection and positioning algorithm based on lightweight cascade neural network according to claim 1, characterized in that: The size of the input tongue image sample needs to be scaled to multiple scales. Multi-scale sample testing can effectively improve the robustness and accuracy of the classifier.
