Traditional Chinese medicinal material identification model training method and traditional Chinese medicinal material type identification method and device
By combining the comparison learning and recognition model in self-supervised learning for alternating training, a Chinese medicinal material recognition model is constructed, which solves the problems of a wide variety of Chinese medicinal materials and is difficult to identify, and improves the recognition accuracy and efficiency.
Patent Information
- Application Number
- CN202411939961.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-05-16
AI Technical Summary
There are many types of Chinese medicinal materials and are difficult to identify, which leads to non-professionals who are prone to misuse and misuse when using Chinese medicine, and the manual identification efficiency is low and it is easy to cause misjudgment.
By combining contrast learning in self-supervised learning with recognition models, alternate training is carried out to build a Chinese medicinal material recognition model to improve the recognition accuracy of similar types of Chinese medicinal materials.
It improves the accuracy of Chinese medicinal materials recognition, reduces the rate of misjudgment, improves the recognition efficiency, and reduces the difficulty of manual recognition.
Smart Images

Figure CN120014403A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a training method for a Chinese medicinal material identification model, a method for identifying Chinese medicinal material types, a training device for a Chinese medicinal material identification model, a computer-readable storage medium, and a computer device. Background Art
[0002] Chinese herbal medicines are widely distributed and come in many varieties, so it is difficult to identify the types of Chinese herbal medicines. In particular, non-professionals with very limited knowledge and experience in Chinese medicines who use Chinese medicines without detailed technical guidance are prone to accidental ingestion and misuse. At present, the classification and identification of Chinese herbal medicines during production and preparation are done manually, which requires extensive knowledge of type and shape identification. In addition, long-term manual operation results in low work efficiency, visual fatigue, and the possibility of misjudgment. Therefore, it is very necessary to use intelligent technology to identify Chinese herbal medicines. Summary of the invention
[0003] The present application aims to solve at least one of the technical problems in the above-mentioned technology to a certain extent. To this end, one purpose of the present application is to propose a training method for a Chinese herbal medicine recognition model, which combines contrast learning in self-supervised learning with a recognition model for alternating training to improve the recognition accuracy of similar types of Chinese herbal medicines.
[0004] The second purpose of this application is to provide a method for identifying the types of Chinese medicinal materials.
[0005] The third objective of the present application is to provide a training device for a Chinese medicinal material identification model.
[0006] A fourth objective of the present application is to provide a computer-readable storage medium.
[0007] A fifth objective of the present application is to provide a computer device.
[0008] To achieve the above-mentioned purpose, the first aspect embodiment of the present application proposes a training method for a Chinese medicinal material recognition model, comprising the following steps: obtaining a training data set, the training data set comprising a first training data set and a second training data set; constructing a Chinese medicinal material recognition model, the Chinese medicinal material recognition model comprising a backbone network and a contrast learning module; inputting the training data set into the Chinese medicinal material recognition model to obtain the detection loss corresponding to the first training data set through the backbone network, and to obtain the contrast loss corresponding to the second training data set through the contrast learning module; alternately using the detection loss and the contrast loss to train the Chinese medicinal material recognition model until a preset convergence condition is met to obtain a trained Chinese medicinal material recognition model.
[0009] According to the training method of the Chinese medicinal material recognition model in the embodiment of the present application, the recognition accuracy of similar types of Chinese medicinal materials is improved by combining contrast learning in self-supervised learning with the recognition model for alternating training.
[0010] In addition, the training method of the Chinese medicinal material recognition model proposed in the above embodiment of the present application may also have the following additional technical features:
[0011] Optionally, obtaining a training data set includes: photographing each type of Chinese medicinal materials under specified conditions using a photographing device; preprocessing the photographed photos to obtain processed images corresponding to each type of Chinese medicinal materials; randomly extracting n types from the processed images, extracting m quantities from each type, and performing image synthesis to form the first training data set through multiple synthesized images.
[0012] Optionally, the captured photos are preprocessed, including: uniformly cropping the captured photos; determining the upper and lower limits of each color component of the Chinese medicinal material sample according to the histogram of the color components of the cropped photos, segmenting the Chinese medicinal material sample from the photo using a threshold method, and setting the pixel value of the background to 0; cropping the rectangular area where the segmented Chinese medicinal material sample is located to obtain a cropped image, and generating a sample mask corresponding to the cropped image, wherein the pixel value of the sample position in the sample mask is set to 255, and the pixel values of other positions are still 0.
[0013] Optionally, image synthesis is performed, including: setting the background of the synthetic image to white; randomly extracting a Chinese medicinal material sample, and generating the position of the upper left corner of the Chinese medicinal material sample in the synthetic image; embedding the sample image into the synthetic image, wherein the position where the sample mask is 255 in the synthetic image is replaced with the pixel value of the sample, and the position where the sample mask is 0 keeps the original pixel value unchanged; writing the annotation information of the sample image into an annotation file, wherein the annotation information includes the sample category, the normalized center point x coordinate, the normalized center point y coordinate, the normalized target frame width, the normalized target frame height, and the annotation information of each sample occupies one line; according to the sample type and quantity requirements of the synthetic image, a synthetic image is obtained.
[0014] Optionally, the second training data set includes similar N / 2 first-category Chinese medicinal material samples and N / 2 second-category Chinese medicinal material samples.
[0015] Optionally, the contrast loss corresponding to the second training data set is obtained by the following formula:
[0016]
[0017] Among them, the feature vectors of N images are recorded as v1, v2, ..., v N , μ +represents the mean of the eigenvectors of the first category of Chinese medicinal materials samples, μ - represents the mean of the feature vector of the second category of Chinese medicinal materials samples, τ represents the hyperparameter, and sim represents the similarity function.
[0018] To achieve the above-mentioned purpose, the second aspect of the present application proposes a method for identifying the types of Chinese medicinal materials, comprising the following steps: obtaining a target image to be identified; inputting the target image to be identified into a trained Chinese medicinal material recognition model to obtain a corresponding recognition result, wherein the Chinese medicinal material recognition model is trained using the method described above.
[0019] According to the method for identifying the type of Chinese medicinal materials in the embodiment of the present application, the recognition accuracy of similar types of Chinese medicinal materials is improved by combining contrast learning in self-supervised learning with the recognition model for alternating training.
[0020] To achieve the above-mentioned purpose, the third aspect embodiment of the present application proposes a training device for a Chinese medicinal material identification model, comprising an acquisition module for acquiring a training data set, wherein the training data set comprises a first training data set and a second training data set; a model construction module for constructing a Chinese medicinal material identification model, wherein the Chinese medicinal material identification model comprises a backbone network and a contrast learning module; a model training module for inputting the training data set into the Chinese medicinal material identification model to obtain the detection loss corresponding to the first training data set through the backbone network, and to obtain the contrast loss corresponding to the second training data set through the contrast learning module; and alternately using the detection loss and the contrast loss to train the Chinese medicinal material identification model until a preset convergence condition is met to obtain a trained Chinese medicinal material identification model.
[0021] To achieve the above-mentioned objectives, the fourth aspect of the present application proposes a computer-readable storage medium, on which a training program for a Chinese medicinal material identification model is stored. When the training program for the Chinese medicinal material identification model is executed, the training method for the Chinese medicinal material identification model as described above is implemented.
[0022] To achieve the above-mentioned objectives, the fifth aspect of the present application proposes a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the training method of the Chinese medicinal material identification model as described above is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 Schematic diagram of a flow chart of a method for training a Chinese medicinal material recognition model according to an embodiment of the present application;
[0024] Figure 2 A schematic diagram of a photo of a uniformly cut sample of Chinese medicinal materials according to an embodiment of the present application;
[0025] Figure 3 A schematic diagram of a Chinese medicinal material sample segmented from a photo according to an embodiment of the present application;
[0026] Figure 4 is a schematic diagram of a cropped image and its corresponding sample mask according to an embodiment of the present application;
[0027] Figure 5 A schematic diagram of a composite image and its annotated file according to an embodiment of the present application;
[0028] Figure 6 A schematic diagram of a network structure of a Chinese medicinal material recognition model according to an embodiment of the present application;
[0029] Figure 7 It is a schematic diagram of a flow chart of a method for identifying the type of Chinese medicinal materials according to one embodiment of the present application;
[0030] Figure 8 A schematic diagram of a model recognition result according to an embodiment of the present application;
[0031] Fig. 9 It is a block diagram of a training device for a Chinese medicinal material recognition model according to one embodiment of the present application. DETAILED DESCRIPTION
[0032] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0033] In order to better understand the above technical solution, exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0034] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0035] Figure 1 FIG. 1 is a flow chart of a method for training a Chinese medicinal material recognition model according to an embodiment of the present application, such as Figure 1 As shown, the training method of the Chinese herbal medicine recognition model includes the following steps:
[0036] S101, obtaining a training data set, where the training data set includes a first training data set and a second training data set.
[0037] As an embodiment, obtaining a training data set includes: photographing each type of Chinese medicinal materials under specified conditions using a photographing device; preprocessing the photographed photos to obtain processed images corresponding to each type of Chinese medicinal materials; randomly extracting n types from the processed images, extracting m quantities from each type, and performing image synthesis to form a first training data set through multiple synthesized images.
[0038] Specifically, each type of Chinese medicinal material is photographed under specified conditions using photographing equipment, including: using a camera or mobile phone to take photos of various types of Chinese medicinal material samples, using white paper as the background when shooting, only one sample is included in each photo, and representative samples of each type of Chinese medicine are selected and photographed at multiple angles and under a variety of lighting conditions.
[0039] As an embodiment, the taken photos are preprocessed, including: uniformly cropping the taken photos; determining the upper and lower limits of each color component of the Chinese medicinal material sample according to the histogram of the color components of the cropped photos, using a threshold method to segment the Chinese medicinal material sample from the photo, and setting the pixel value of the background to 0; cropping the rectangular area where the segmented Chinese medicinal material sample is located to obtain a cropped image, and generating a sample mask corresponding to the cropped image, wherein the pixel value of the sample position in the sample mask is set to 255, and the pixel values of other positions are still 0.
[0040] As a specific embodiment, first, the photographs are uniformly cropped to 640×640 pixels. The cropped images are as follows: Figure 2 Then, according to the histogram of the red, green and blue color components of the photo, the upper and lower limits of each color component of the Chinese medicine sample are determined, and the Chinese medicine sample is segmented from the photo using the threshold method, and the pixel value of the background is set to 0. The Chinese medicine sample segmented from the photo is shown as follows: Figure 3 As shown; then, the rectangular area where the Chinese medicine sample is located is cropped out, and a sample mask is generated. In the mask, the pixel value of the sample position is set to 255, and the pixel values of other positions are still 0. The rectangular area where the sample is located and its sample mask are shown as follows Figure 4 shown.
[0041] That is to say, the rectangular area image where the sample is located and its sample mask are used as the preprocessed image.
[0042] As an embodiment, image synthesis is performed, including: setting the background of the synthesized image to white; randomly extracting a Chinese medicinal material sample, and generating the position of the upper left corner of the Chinese medicinal material sample in the synthesized image; embedding the sample image into the synthesized image, wherein the position where the sample mask is 255 in the synthesized image is replaced with the pixel value of the sample, and the position where the sample mask is 0 keeps the original pixel value unchanged; writing the annotation information of the sample image into an annotation file, wherein the annotation information includes the sample category, the normalized center point x coordinate, the normalized center point y coordinate, the normalized target frame width, the normalized target frame height, and the annotation information of each sample occupies one line; according to the sample type and quantity requirements of the synthesized image, a synthesized image is obtained.
[0043] That is to say, random types (randomly selected between 3 and 6 types) and random numbers (the number of each type is randomly selected between 1 and 3) of traditional Chinese medicine samples are extracted from the preprocessed image results for image synthesis.
[0044] As a specific embodiment, the method for synthesizing an image includes:
[0045] (1) Use a photo of white paper as the background of the composite image.
[0046] (2) Randomly select a sample.
[0047] (3) Randomly generate the position of the upper left corner of the sample in the synthetic image.
[0048] (4) The sample image is embedded into the synthetic image; in the synthetic image, the positions where the sample mask is 255 are replaced with the pixel values of the sample; and the positions where the sample mask is 0 keep the original pixel values unchanged.
[0049] (5) Write the sample annotation information into the annotation file. The annotation information follows the annotation format requirements of the YOLO model, including: sample category (expressed in numbers), normalized center point x coordinate, normalized center point y coordinate, normalized target box width, normalized target box height; each sample's annotation information occupies one line.
[0050] (6) Repeat the above steps (2) to (5) until the sample types and quantities meet the requirements.
[0051] (7) Save the composite image and its annotation file.
[0052] Specifically, Figure 5 It is a composite image and its annotation file, which includes three types of samples: wolfberry (3 pieces), red bean (3 pieces), and pea (2 pieces).
[0053] Therefore, by adopting the above method, any amount of image data with precise annotation information can be generated as the first training data set for training the deep learning model.
[0054] It should be noted that by preprocessing an image including a single sample, extracting the sample mask and bounding box, and then synthesizing samples of multiple categories using image processing technology, a training image including any number of samples and precise annotation information is generated.
[0055] As an embodiment, the second training data set includes similar N / 2 first-category Chinese medicinal material samples and N / 2 second-category Chinese medicinal material samples, and each image includes a Chinese medicinal material sample.
[0056] S102, constructing a Chinese medicinal material recognition model, which includes a backbone network and a comparative learning module.
[0057] As an example, this application uses the classic YOLO v5 model to recognize Chinese medicine sample images; however, there are some types of Chinese medicine with similar shapes, and the error rate of directly using the YOLO v5 model for recognition is high; therefore, Figure 6 As shown, this application combines contrastive learning in self-supervised learning with the YOLO model to improve the recognition accuracy of similar categories.
[0058] It should be noted that in conventional contrastive learning, positive samples are obtained by cropping, rotating, adding noise, etc., that is, the positive samples come from the same image. However, in the method adopted in this application, the positive samples come from images of the same type, and the negative samples come from images of similar types. The image features extracted in this way are more conducive to overcoming the inter-class similarity problem of traditional Chinese medicine.
[0059] Specifically, 10 groups of Chinese medicines with similar appearance and high recognition difficulty were selected from the Chinese medicines to be identified, two in each group, a total of 20, for comparative learning and training of deep neural networks. They are (red bean, red bean), (Atractylodes macrocephala, Atractylodes lancea), (Fritillaria cirrhosa, Fritillaria cirrhosa), (Peach kernel, Apricot kernel), (Astragalus membranaceus, Astragalus membranaceus), (Olibanum, Myrrh), (Yam, Radix Trichosanthis), (Planthoceras, American ginseng), (Ophiopogon japonicus, Ophiopogon japonicus), (Semen jujuba, Hovenia dulcis).
[0060] S103, inputting the training data set into the Chinese medicinal material recognition model to obtain the detection loss corresponding to the first training data set through the backbone network, and obtaining the contrast loss corresponding to the second training data set through the contrast learning module.
[0061] It should be noted that the detection loss adopts the standard calculation method of the YOLOv5 model, which includes three parts: classification loss, positioning loss and confidence loss.
[0062] Specifically, assuming that the batch size of each round of training is N=64, the training process of each round of contrastive learning is:
[0063] (1) Randomly select a group of similar Chinese medicines. Take (red bean, adzuki bean) as an example.
[0064] (2) Randomly select N / 2 photos of adzuki beans and N / 2 photos of red beans, synthesize them into a batch, and send them to the deep learning model. After feature extraction network, convolution, activation function and average pooling, each image obtains a feature vector of length 256.
[0065] (3) Calculate the contrast loss. The feature vectors of the N images are denoted as v1, v2, ..., v N , where v1~v N / 2 It's red beans, N / 2+1 ~v N is red bean. Calculate the mean of the eigenvectors of the two types of Chinese medicine respectively:
[0066]
[0067] Since we want to increase the intra-class similarity of feature vectors and reduce the inter-class similarity of feature vectors, we define the contrast loss as:
[0068]
[0069] Among them, τ represents a hyperparameter, which is taken as 2; sim(x,y) is a similarity function, using cosine similarity:
[0070]
[0071] (4) Use contrastive loss for back propagation to update model parameters.
[0072] S104, alternately using detection loss and contrast loss to train the Chinese medicinal material recognition model until a preset convergence condition is met to obtain a trained Chinese medicinal material recognition model.
[0073] That is to say, when using detection loss for training, the first input training data set is a synthetic image; when using contrast loss for training, each image in the second input training data set includes only one Chinese medicinal material sample; the model training is completed by alternating between detection loss and contrast loss until the detection loss no longer decreases significantly.
[0074] In summary, the training method of the Chinese medicinal material recognition model of the embodiment of the present invention designs a corresponding method for automatically generating annotated images for the recognition and classification problems of Chinese medicine images, which is used to train a deep learning model; by preprocessing an image including a single sample, extracting a sample mask and a bounding box, and then synthesizing samples of multiple categories using image processing technology, a training image containing any multiple categories of samples and precise annotation information is generated; and contrastive learning technology is introduced into Chinese medicine image recognition and classification, by performing contrastive learning on Chinese medicine categories that are similar in appearance and difficult to distinguish, the characteristic representation of the image data itself is mined, the feature extraction capability of the deep learning model is improved, and the similarity problem between Chinese medicine categories is solved.
[0075] In order to implement the above embodiment, this embodiment also provides a method for identifying the type of Chinese medicinal materials.
[0076] Figure 7 is a flow chart of a method for identifying the type of Chinese medicinal materials according to an exemplary embodiment. Figure 7 As shown, the method comprises the following steps:
[0077] S201, obtaining a target image to be identified.
[0078] S202, inputting the target image to be identified into the trained Chinese medicinal material identification model to obtain a corresponding identification result, wherein the Chinese medicinal material identification model is trained using the method as described above.
[0079] It should be noted that the schematic diagram of the classification result after the Chinese herbal medicine recognition model obtained by the above-mentioned training method for the Chinese herbal medicine recognition model performs type recognition is as follows: Figure 8 shown.
[0080] In summary, the method for identifying Chinese medicinal materials species in the embodiments of the present disclosure uses the Chinese medicinal materials recognition model obtained by the above-mentioned training method for the Chinese medicinal materials recognition model to perform species recognition, thereby improving the recognition accuracy of similar types of Chinese medicinal materials.
[0081] In order to implement the above-mentioned embodiment, the present disclosure provides a training device for a Chinese medicinal material identification model.
[0082] Fig. 9 is a block diagram of a training device for a Chinese medicinal material recognition model according to an exemplary embodiment. Fig. 9 The device includes: an acquisition module 10, a model building module 20 and a model training module 30.
[0083] Among them, the acquisition module 10 is used to acquire a training data set, and the training data set includes a first training data set and a second training data set; the model construction module 20 is used to construct a Chinese medicinal material recognition model, and the Chinese medicinal material recognition model includes a backbone network and a contrast learning module; the model training module 30 is used to input the training data set into the Chinese medicinal material recognition model to obtain the detection loss corresponding to the first training data set through the backbone network, and to obtain the contrast loss corresponding to the second training data set through the contrast learning module; the detection loss and contrast loss are alternately used to train the Chinese medicinal material recognition model until the preset convergence condition is met to obtain a trained Chinese medicinal material recognition model.
[0084] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the training method for the Chinese medicinal material identification model, and will not be elaborated here.
[0085] In summary, according to the training device of the Chinese medicinal material identification model of the embodiment of the present application, the recognition accuracy of similar types of Chinese medicinal materials is improved by combining contrast learning in self-supervised learning with the recognition model for alternating training.
[0086] In order to implement the above-mentioned embodiments, the embodiments of the present disclosure provide a computer-readable storage medium, on which a training program for a Chinese medicinal material identification model is stored. When the training program for the Chinese medicinal material identification model is executed, the training method for the Chinese medicinal material identification model as described above is implemented.
[0087] According to the computer-readable storage medium of an embodiment of the present invention, a training program for a Chinese medicinal material recognition model is stored so that a processor implements the training method for a Chinese medicinal material recognition model as described above when executing the training program for the Chinese medicinal material recognition model. Thus, the recognition accuracy of similar types of Chinese medicinal materials can be improved by combining contrast learning in self-supervised learning with the recognition model for alternate training.
[0088] In order to implement the above-mentioned embodiments, the embodiments of the present disclosure provide a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the training method of the Chinese medicinal material identification model as described above is implemented.
[0089] According to the computer device of the embodiment of the present application, the training program of the Chinese medicinal material recognition model is stored in the memory, so that when the training program of the Chinese medicinal material recognition model is executed by the processor, the above-mentioned training method of the Chinese medicinal material recognition model is implemented. Therefore, by combining the contrast learning in the self-supervised learning with the recognition model for alternating training, the recognition accuracy of similar types of Chinese medicinal materials can be improved.
[0090] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0091] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0092] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0093] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0094] It should be noted that in the claims, any reference signs placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The present application may be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names.
[0095] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0096] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
[0097] In the description of the present application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the feature. In the description of the present application, "plurality" means two or more, unless otherwise clearly and specifically defined.
[0098] In this application, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0099] In the present application, unless otherwise clearly specified and limited, a first feature being “above” or “below” a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being “above”, “above”, and “above” a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being “below”, “below”, and “below” a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.
[0100] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms should not be understood as necessarily being directed to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0101] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A training method for a Chinese medicinal material recognition model, characterized in that: The following steps are involved: Acquire a training data set, where the training data set includes a first training data set and a second training data set; Constructing a Chinese medicinal material recognition model, wherein the Chinese medicinal material recognition model includes a backbone network and a contrast learning module; Inputting the training data set into the Chinese medicinal material recognition model to obtain the detection loss corresponding to the first training data set through the backbone network, and obtaining the contrast loss corresponding to the second training data set through the contrast learning module; The detection loss and the contrast loss are alternately used to train the Chinese medicinal material recognition model until a preset convergence condition is met to obtain a trained Chinese medicinal material recognition model.
2. The training method for the Chinese medicinal material recognition model according to claim 1, characterized in that: Get the training dataset, including: Use photographic equipment to photograph each type of Chinese medicinal material under specified conditions; Preprocess the photographs to obtain processed images corresponding to each type of Chinese medicinal materials; Randomly extract n categories from the processed images, extract m quantities from each category, and perform image synthesis to form the first training data set through multiple synthesized images.
3. The training method for the Chinese medicinal material recognition model according to claim 2, characterized in that: Pre-process the captured photos, including: Uniformly crop the photos taken; The upper and lower limits of each color component of the Chinese herbal medicine sample are determined according to the histogram of the color component of the cropped photo, the Chinese herbal medicine sample is segmented from the photo using the threshold method, and the pixel value of the background is set to 0; The rectangular area where the segmented Chinese medicinal material sample is located is cropped to obtain a cropped image, and a sample mask corresponding to the cropped image is generated, wherein the pixel value of the position where the sample is located in the sample mask is set to 255, and the pixel values of other positions are still 0.
4. The training method for the Chinese medicinal material recognition model according to claim 3, characterized in that: Perform image synthesis, including: Set the background of the composite image to white; Randomly select a Chinese medicinal material sample and generate the position of the upper left corner of the Chinese medicinal material sample in the synthetic image; Embed the sample image into the composite image, wherein the positions where the sample mask is 255 in the composite image are replaced with the pixel values of the sample, and the positions where the sample mask is 0 keep the original pixel values unchanged; Write the annotation information of the sample image into the annotation file, where the annotation information includes the sample category, the normalized center point x coordinate, the normalized center point y coordinate, the normalized target frame width, and the normalized target frame height. Each sample's annotation information occupies one line. A composite image is obtained according to the sample type and quantity requirements of the composite image.
5. The training method for the Chinese medicinal material recognition model according to claim 1, characterized in that: The second training data set includes similar N / 2 first-category Chinese medicinal material samples and N / 2 second-category Chinese medicinal material samples.
6. The training method for the Chinese medicinal material recognition model according to claim 5, characterized in that: The contrast loss corresponding to the second training data set is obtained by the following formula: Among them, the feature vectors of N images are recorded as v1, v2, ..., v N , μ + represents the mean of the eigenvectors of the first category of Chinese medicinal materials samples, μ - represents the mean of the feature vector of the second category of Chinese medicinal materials samples, τ represents the hyperparameter, and sim represents the similarity function.
7. A method for identifying the type of Chinese medicinal materials, characterized in that: The following steps are involved: Acquire a target image to be identified; The target image to be identified is input into a trained Chinese medicinal material identification model to obtain a corresponding identification result, wherein the Chinese medicinal material identification model is trained using the method described in any one of claims 1-6.
8. A training device for a Chinese herbal medicine recognition model, characterized in that: include: An acquisition module, used to acquire a training data set, wherein the training data set includes a first training data set and a second training data set; A model building module, used to build a Chinese medicinal material recognition model, wherein the Chinese medicinal material recognition model includes a backbone network and a contrast learning module; A model training module is used to input the training data set into the Chinese medicinal material recognition model to obtain the detection loss corresponding to the first training data set through the backbone network, and to obtain the contrast loss corresponding to the second training data set through the contrast learning module; the detection loss and the contrast loss are alternately used to train the Chinese medicinal material recognition model until a preset convergence condition is met to obtain a trained Chinese medicinal material recognition model.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a training program for a Chinese medicinal material identification model, and when the training program for the Chinese medicinal material identification model is executed, the training method for a Chinese medicinal material identification model according to any one of claims 1 to 6 is implemented.
10. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the training method of the Chinese medicinal material recognition model according to any one of claims 1 to 6 is implemented.