A tobacco leaf detection method integrating main vein features and edge features

By integrating main vein features and edge features, the tobacco leaf detection method uses an adversarial generation network to generate unfolded images, which solves the problem of low detection efficiency caused by curling, folding, and shrinkage of tobacco leaves, realizes automatic detection grading, and improves detection efficiency.

CN118537660BActive Publication Date: 2024-10-18NANTONG INST OF TECH
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410971612.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2024-10-18
Estimated Expiration
2044-07-19

AI Technical Summary

Technical Problem

In the existing technology, tobacco leaves are prone to curling, folding, shrinking and other defects during transportation and storage, which requires manual unfolding for inspection and grading, which is labor-intensive and inefficient.

Method used

A tobacco leaf detection method that combines main vein features and edge features is used to generate expanded sample images and target expanded images through an adversarial generation network. The main vein-edge-tobacco leaf generation model is used to automatically generate the unfolded image of tobacco leaves, thereby realizing curl, fold, and wrinkle detection. Automatic detection and classification of reduced tobacco leaves.

Benefits of technology

It overcomes the problem of low efficiency caused by manual unfolding and realizes automatic detection and classification of curled, folded and shrunken tobacco leaves, improving detection efficiency and reducing manual intervention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118537660B_ABST
    Figure CN118537660B_ABST
Patent Text Reader

Abstract

The present invention discloses a tobacco leaf detection method integrating main vein features and edge features, comprising: obtaining a sample image and a paired target image, wherein the sample image contains tobacco leaves that need to be unfolded before detection and grading, and the sample image corresponds to the paired target image; establishing a main vein-edge-tobacco leaf generation model, extracting the main vein features and edge features of tobacco leaves from the sample image extraction model, and fusing to obtain the main vein-edge features, using the main vein-edge features and the sample image to combine the main vein-edge-tobacco leaf generation model to train the main vein-edge-tobacco leaf generation model, and combining the trained main vein-edge-tobacco leaf generation model with the tobacco leaf detection model to detect tobacco leaves during detection. The present invention adds a main vein-edge-tobacco leaf generation model, which automatically generates an unfolded tobacco leaf image based on a tobacco leaf image collected in a natural state, thereby detecting and grading tobacco leaves with defects that are difficult to be accurately graded.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of computer vision, and in particular relates to a tobacco leaf detection method integrating main vein features and edge features. Background Art

[0002] Tobacco is an important economic crop in my country, and grading flue-cured tobacco is an important production link. With the continuous development of computer vision, deep learning and other technologies, and the rapid development of artificial intelligence, technologies that can process tobacco leaf images and automatically grade them have emerged. Existing technologies can identify whether tobacco leaves have defects such as curling, folding, and shrinkage by processing tobacco leaf images, and can also collect data on the color, length, etc. of the unfolded tobacco leaves. Deep learning technology can then be used to obtain more accurate tobacco leaf grading results.

[0003] However, when inspecting and grading tobacco leaves, factors that need to be considered include the length and defects of the tobacco leaves. In order to accurately detect the relevant data, the tobacco leaves need to be in a basically fully expanded state. During transportation and storage, tobacco leaves will inevitably curl, shrink, fold, etc. At this time, if relevant inspections are to be carried out, the tobacco leaves need to be unfolded. In order to reduce the damage of tobacco leaves when unfolded, they are generally unfolded manually and then images of the unfolded tobacco leaves are collected to detect the length and defects of the tobacco leaves, which requires a lot of manpower and is inefficient. Summary of the invention

[0004] The purpose of the present invention is to provide a tobacco leaf detection method that integrates main vein features and edge features, which is used to solve the technical problem in the prior art that tobacco leaves need to be unfolded because defects such as curling, folding, and shrinkage affect tobacco leaf detection and grading, and that the tobacco leaves need to be manually unfolded and images need to be collected for detection and grading, which is labor-intensive and inefficient.

[0005] The tobacco leaf detection method integrating main vein features and edge features comprises: obtaining an initial sample image and a paired target image, wherein the initial sample image contains tobacco leaves that need to be expanded for detection and grading, and the initial sample image corresponds to the paired target image; establishing a main vein-edge-tobacco leaf generation model, wherein the main vein-edge-tobacco leaf generation model comprises a first adversarial generation network, a second adversarial generation network, a main vein feature extraction module, an edge feature extraction module and a main vein-edge fusion module; extracting the main vein feature and edge feature of tobacco leaves from the initial sample image through a main vein feature extraction module and an edge feature extraction module, respectively, and fusing them to obtain the main vein-edge feature one, combining the main vein-edge feature one with the corresponding paired target image to train the first adversarial generation network, the first adversarial generation network generates an expanded sample image using the initial sample image, and both the expanded sample image and the initial sample image belong to sample images for training the second adversarial generation network, and the second adversarial generation network converts the sample image into a target expanded sample image. Open image, GAN 1 and GAN 2 form a cyclic GAN, and the target unfolded image generated by GAN 2 is used as the input of GAN 1 trained before, so as to obtain the sample reconstructed image generated by GAN 1; the sample image and the paired target image are used to train the discriminator of GAN 1 and the discriminator of GAN 2 respectively; the model loss of the main vein-edge-tobacco leaf generation model includes the adversarial generation loss 1 corresponding to GAN 1, the adversarial generation loss 2 corresponding to GAN 2, cycle consistency loss, main vein feature loss and edge feature loss; the main vein feature loss represents the loss between the main vein feature extracted from the sample reconstructed image and the main vein feature extracted from the sample image, and the edge feature loss represents the loss between the edge feature extracted from the sample reconstructed image and the edge feature extracted from the sample image. During detection, the trained main vein-edge-tobacco leaf generation model is combined with the tobacco leaf detection model to detect tobacco leaves.

[0006] Preferably, the tobacco leaf detection method comprises the following steps.

[0007] S1. Collect initial sample images and establish an initial sample image set. The initial sample images include tobacco leaves that need to be unfolded for detection and grading.

[0008] S2. Establish a main vein-edge-tobacco leaf generation model.

[0009] S3. Expand the number of sample images, extract the main vein features and edge features from the initial sample images of the tobacco leaves to be unfolded, and fuse them. Use the fused main vein-edge features and the corresponding paired target images to train a generative adversarial network. Then, input the initial sample images of the tobacco leaves to be unfolded into the trained generative adversarial network to generate expanded sample images. Both the expanded sample images and the initial sample images are sample images.

[0010] S4. Let the first generative adversarial network and the second generative adversarial network form a cyclic generative adversarial network, extract the main vein-edge feature 2 obtained by fusion from the sample image, and use the main vein-edge feature 2 in combination with the sample image to train the second generative adversarial network.

[0011] S5. Combining the trained main vein-edge-tobacco leaf generation model with the tobacco leaf detection model to detect tobacco leaves. The tobacco leaf detection model includes a tobacco leaf defect detection model and a tobacco leaf grading detection model.

[0012] Preferably, the main vein feature extraction module outputs the main vein feature containing only the main vein part. mx , the edge feature extraction module outputs only the edge features of the tobacco leaf edge ex Then, the main vein features are merged into the edge fusion module mx and edge features ex Fusion as main vein-edge feature mex 1, the corresponding calculation formula is: , where α is the main vein feature mx The weight of β is the edge feature ex The weights of α and β are calculated as follows: , ;in A α and A β They are respectively the parameter matrix for adjusting the weight α and the parameter matrix for adjusting the weight β.

[0013] Preferably, the adversarial generative network comprises a generator G y and the discriminator D y , generator one G y It includes an encoder 1 and a mixer 1; in step S3, from the initial sample image x 0 Extract the main vein features and edge features and fuse them to get the main vein-edge feature mex 1; The input of the adversarial generation network is the paired target image y , paired target image y First processed by encoder 1, the features extracted by encoder 1 are combined with the main vein-edge features obtained previously mex 1 After splicing, it is input to the mixer to generate an expanded sample image x' , and then expand the sample image x' Input Discriminator 1 D y , by pairing the target image with y The corresponding initial sample image x0 For the discriminator D y Train and train the discriminator D y Then use the discriminator D y For generator one G y Train the network to obtain the trained adversarial generation network 1.

[0014] Preferably, the second adversarial generative network includes a generator G x And Discriminator 2 D x , the generator two G x It includes encoder 2 and mixer 2; in step S4, from the sample image x Extract the main vein feature and edge feature and fuse them to get the main vein-edge feature 2 mex 2; Sample image x Input Generator 2 G x Processed by encoder 2, the features extracted by encoder 2 are consistent with the main vein-edge feature 2 mex 2 After splicing, it is input to mixer 2 to generate the target expanded image y' , and then expand the target image y' Input Discriminator 2 D x , by corresponding to the sample image x Paired target image y For discriminator 2 D x Train and train the discriminator 2 D x Then use the discriminator 2 D x For generator 2 G x Train to obtain the trained adversarial generation network 2.

[0015] Preferably, in step S4, the generator G x Generated target expanded image y' As the input of the previously trained adversarial generation network 1, the generator 1 G y In the example, the features extracted by encoder 1 are the same as those extracted by main vein-edge features 2. mex 2 After splicing, it is input to mixer 1 to obtain the sample reconstructed image generated by adversarial generation network 1 ; Reconstruct the sample image Input Discriminator 1D y , by pairing the target image with y The corresponding sample image x For the discriminator D y Train and train the discriminator D y Then use the discriminator D y For generator one G y Perform training to obtain the trained adversarial generation network 1.

[0016] Preferably, the resistance generation loss is L GANy , Adversarial Generation Loss 2 L GANx , cycle consistency loss L cyc , main vein feature loss L MAI and edge feature loss L EDG The calculation formulas are as follows:

[0017]

[0018]

[0019]

[0020]

[0021]

[0022] Among them, E represents the mathematical expectation and is used to calculate the error, that is, the loss; In the sample image x The expectation under the distribution, Indicates that the target image is expanded y' Expectations under distribution; Indicates that in the paired target image y The expectation under the distribution, In the sample image x And sample reconstructed image The expectation under the distribution of MAI ( x ) indicates that the main vein feature extraction module is used to process the sample image x ; EDG ( x ) indicates that the sample image is processed using the edge feature extraction module x .

[0023] Preferably, the model loss function of the main vein-edge-tobacco leaf generation model is:

[0024]

[0025] Among them is λ cyc , λ MAI and λ EDG They are the corresponding cycle consistency loss Lcyc, the main vein feature loss L MAI and edge feature loss L EDG The weight is also an adjustable hyperparameter.

[0026] Preferably, in step S5, the tobacco leaf detection model includes a tobacco leaf defect detection model and a tobacco leaf grading detection model; the tobacco leaf defect detection model identifies the defective part from the image and classifies the defective part, and the corresponding output is the defect label obtained by classification; based on the defect label, it is determined whether the image contains tobacco leaves to be unfolded; if the image contains tobacco leaves to be unfolded, it is first input into the main vein-edge-tobacco leaf generation model to be converted into a target unfolded image y' , and then input the tobacco leaf grading detection model for detection and grading, otherwise directly input the tobacco leaf grading detection model for detection and grading.

[0027] The present invention has the following advantages: the method utilizes the existing tobacco leaf image detection technology and implements classification based on characteristic information such as the length, edge contour, and color of the tobacco leaf. For tobacco leaves that cannot be unfolded in a natural state due to factors such as curling, folding, and shrinkage, the method adds a main vein-edge-tobacco leaf generation model, so that the unfolded tobacco leaf image can be automatically generated based on the collected tobacco leaf image in a natural state, which is called the target unfolded image. The target unfolded image generated by the main vein-edge-tobacco leaf generation model after training is similar to the target image obtained after the tobacco leaf is actually unfolded, so it can be used to detect the unfolded tobacco leaf image of the tobacco leaf that needs to be unfolded. In this way, tobacco leaves that were originally difficult to be accurately graded due to the above-mentioned defects can be detected and graded based on the automatically generated unfolded tobacco leaf image, overcoming the defects of the prior art.

[0028] However, the curling, folding and shrinking defects of tobacco leaves are not effective when detected based solely on image edge detection. Especially when detecting the length of tobacco leaves, it is difficult to determine the extension of the main vein of tobacco leaves with the above defects based solely on the edge features of the tobacco leaf image, and it is difficult to determine its actual unfolding effect. On the other hand, due to the above defects, the main vein features will be partially obscured by the folded or curled parts of the leaves, making it difficult to directly determine the structure and length of the tobacco leaves. Therefore, this solution uses a weighted fusion method to comprehensively process the sample image and the collected tobacco leaf edge features and main vein features, and uses a generator to automatically generate an image of the unfolded tobacco leaf. Since the edge features and main vein features are comprehensively considered, a better generation effect can be obtained. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 This is a basic flow chart of the tobacco leaf detection method of the present invention that integrates main vein features and edge features.

[0030] Figure 2 The figure is a schematic diagram of the workflow of the present invention when expanding the number of sample images.

[0031] Figure 3 The figure is a schematic diagram of the workflow of the present invention when training the main vein-edge-tobacco leaf generation model. DETAILED DESCRIPTION

[0032] The specific implementation modes of the present invention will be further explained in detail below by describing the embodiments with reference to the accompanying drawings, so as to help those skilled in the art to have a more complete, accurate and in-depth understanding of the inventive concept and technical solution of the present invention.

[0033] like Figures 1 - 3 As shown, the present invention provides a tobacco leaf detection method integrating main vein features and edge features, comprising the following steps.

[0034] S1. Collecting initial sample images and establishing an initial sample image set. The initial sample images include tobacco leaves that need to be unfolded for detection and grading.

[0035] Collect initial sample images of several tobacco leaves, place the tobacco leaves on a transparent conveying device of a carrier, convey the tobacco leaves through a photographing station, use the light source below the carrier to illuminate the leaves upward, and use the camera above the tobacco leaves to collect the translucent image formed by the light source illuminating the tobacco leaves, and use the translucent image as the object of identification for sample collection.

[0036] According to the detection needs, the corresponding tobacco leaves are selected for shooting in the above manner, and the light-transmitting images of the tobacco leaves are collected. The tobacco leaves include complete and normally unfolded tobacco leaves and defective tobacco leaves. The defects of the latter affect the detection effect. The defective tobacco leaves include tobacco leaves whose curling seriously affects the identification of the main vein, tobacco leaves whose leaf edges are partially folded, tobacco leaves whose entire leaves are folded, tobacco leaves whose leaf edges are partially incomplete, tobacco leaves whose leaf incompletely damages the main vein, and tobacco leaves whose leaves are wrinkled. The corresponding defect labels are marked when collecting the light-transmitting images. For tobacco leaves with defective labels such as tobacco leaves whose curling seriously affects the identification of the main vein, tobacco leaves whose leaf edges are partially folded, tobacco leaves whose entire leaves are folded, and tobacco leaves whose leaves are wrinkled, they need to be unfolded to obtain a complete image so that they can be accurately detected and graded by existing technologies. Therefore, tobacco leaves with these defective labels are classified as tobacco leaves that need to be unfolded. For tobacco leaves that need to be unfolded, after collecting the light-transmitting images of tobacco leaves in the natural state, the tobacco leaves that need to be unfolded are straightened and unfolded, and then the light-transmitting images are collected. The light-transmitted image of the tobacco leaves to be unfolded collected in the natural state is the initial sample image x 0 , and the light transmission image collected after the tobacco leaves to be unfolded are the same as the initial sample image x 0 One-to-one paired target images y .

[0037] S2. Establish a main vein-edge-tobacco leaf generation model, wherein the main vein-edge-tobacco leaf generation model includes a first generative adversarial network, a second generative adversarial network, a main vein feature extraction module, an edge feature extraction module and a main vein-edge fusion module.

[0038] If each tobacco leaf to be unfolded is unfolded manually, a lot of manpower is needed when the sample size is large. y The acquisition efficiency is very low. Therefore, this step is to establish a pair of target images. y Generate dilated sample images x' The adversarial generation network 1 includes a generator 1 G y and the discriminator D y , generator one G y It includes an encoder 1 and a mixer 1. At the same time, based on the prior art of leaf vein recognition and leaf edge recognition, a main vein feature extraction module and an edge feature extraction module are respectively constructed, and a main vein-edge fusion module is constructed.

[0039] The input of the first adversarial network is the paired target image y , the adversarial generation network combines the initial sample graph x Extract the main vein-edge features obtained by fusion from the image mex1 Generate dilated sample image x' The input of the second adversarial generation network is an initial sample image x 0 and the dilated sample image x' Sample images including x , the adversarial generation network 2 combines the sample image x Extract the main vein-edge feature obtained by fusion mex 2. Generate a target expanded image. The target expanded image is an automatically generated image of the tobacco leaves to be expanded, and is used to input the detection and grading model of the prior art to realize the detection and grading of tobacco leaves.

[0040] S3. Expand the number of sample images, extract the main vein features (i.e., the main vein image in the tobacco leaf veins) and edge features (i.e., the image of the edge of the tobacco leaf) from the initial sample images of the tobacco leaves to be unfolded and fuse them, use the fused main vein-edge features and the corresponding paired target images to train a generative adversarial network, and then input the initial sample images of the tobacco leaves to be unfolded into the trained generative adversarial network to generate expanded sample images. Both the expanded sample images and the initial sample images are sample images.

[0041] The tobacco leaf image is input into the main vein feature extraction module and the edge feature extraction module respectively. When performing feature extraction, the image is preprocessed and grayed. Based on the Sobel edge detection algorithm, the image is accurately edge detected. The main vein feature extraction module and the edge feature extraction module are respectively used to extract the vein edge and the leaf edge. The former can also accurately segment the main vein image. The main vein feature extraction module outputs the main vein feature that only contains the main vein part. mx , the edge feature extraction module outputs only the edge features of the tobacco leaf edge ex Then the main vein features are merged into the edge fusion module. mx and edge features ex Fusion as main vein-edge feature mex 1, the corresponding calculation formula is: , where α is the main vein feature mx The weight of β is the edge feature ex The weights of α and β are calculated as follows: , ;in A α and A β They are the parameter matrix for adjusting the weight α and the parameter matrix for adjusting the weight β. The weight parameters can be calculated through softmax processing so that their range is within [0,1] and their sum is 1.

[0042] Pair the target image yAs the input of the adversarial network, the paired target image y First processed by encoder 1, the features extracted by encoder 1 are combined with the main vein-edge features obtained previously mex 1 After splicing, it is input to the mixer to generate an expanded sample image x' , and then expand the sample image x' Input Discriminator 1 D y , by pairing the target image with y The corresponding initial sample image x 0 For the discriminator D y Train and train the discriminator D y Then use the discriminator D y For generator one G y After one round of training, the training process can be repeated to obtain the discriminator. D y and generator one G y Alternate training until the sample image is expanded x' The corresponding adversarial generation loss is minimal.

[0043] The trained adversarial generative network can transform each paired target image y Initial sample images with different defect labels x 0 The main vein-edge features extracted from mex 1 to generate multiple dilated sample images x' , dilated sample image x' After generation, according to the main vein-edge features used mex 1 corresponds to the initial sample image x 0 The defect labels of the expanded leaves are automatically labeled. This can quickly expand the number of samples of tobacco leaves that need to be expanded while ensuring the accuracy of the defect labels, and automatically realize the labeling of the corresponding defect labels. The expanded sample image generated by the adversarial generative network x' Not only does it have the corresponding defect label, but also the paired target image of the corresponding input adversarial generation network 1 y The corresponding relationship formed can also be used to train the adversarial generative network 2 that generates the target expanded image based on the sample image. x' and the initial sample image x 0 All are sample images x, the two together constitute the training sample image set, which is used to train the adversarial generation network 2.

[0044] S4. Let the first generative adversarial network and the second generative adversarial network form a cyclic generative adversarial network, extract the main vein-edge feature 2 obtained by fusion from the sample image, and use the main vein-edge feature 2 in combination with the sample image to train the main vein-edge-tobacco leaf generation model.

[0045] First, according to step S2, the sample image x Obtain the fused main vein-edge feature 2 mex 2. Using the fused main vein-edge feature 2 mex 2 and the corresponding sample image x Train the second adversarial generative network, and then input the initial sample image of the tobacco leaf to be unfolded into the trained adversarial generative network. x 0 Generate dilated sample images x' , thereby expanding the number of sample images that need to be unfolded tobacco leaves.

[0046] The adversarial generation network 2 includes a generator 2 G x And Discriminator 2 D x , the generator two G x Including encoder 2 and mixer 2. Based on the sample image containing the tobacco leaves to be unfolded x In this step, the fused main vein-edge feature is first obtained according to the method of step S2. mex 2. Then the sample image containing the tobacco leaves to be unfolded x Input Generator 2 G x Processed by encoder 2, the features extracted by encoder 2 are consistent with the main vein-edge feature 2 mex 2 After splicing, it is input to mixer 2 to generate the target expanded image y' , and then expand the target image y' Input Discriminator 2 D x , by corresponding to the sample image x Paired target image y For discriminator 2 D x Train and train the discriminator 2 D x Then use the discriminator 2 D x For generator 2 G x After one round of training, the training process can be repeated to obtain the discriminator 2. Dx and generator 2 G x Alternate training until the target image is expanded y' The corresponding adversarial generation loss is the smallest.

[0047] Although the adversarial generative network can expand the number of sample images and generate dilated sample images x' , but the corresponding paired target image y The number of pairs of target images has not increased, so y There is still a problem of poor training effect. Here, we can combine the first and second adversarial generative networks to form a cyclic adversarial generative network. G x Generated target expanded image y' As the input of the previously trained adversarial generation network 1, the generator 1 G y In the example, the feature extracted by encoder 1 is the same as the main vein-edge feature 2. mex 2 After splicing, it is input to mixer 1 to obtain the sample reconstructed image generated by adversarial generation network 1 . Reconstruct the image from the sample Input Discriminator 1 D y , by pairing the target image with y The corresponding sample image x For the discriminator D y Train and train the discriminator D y Then use the discriminator D y For generator one G y Train until the sample reconstructs the image The corresponding adversarial generation loss 2 is the smallest, and the trained adversarial generation network 1 is obtained.

[0048] At this time, as a recurrent adversarial network, the loss of the main vein-edge-tobacco leaf generation model includes the adversarial generation loss of the adversarial network- L GANy , the adversarial generation loss of the adversarial generation network itself L GANx And cycle consistency loss L cyc , cycle consistency loss L cyc That is, the sample image x Reconstruct the image with the sample The loss between .L GANy , Adversarial Generation Loss 2 L GANx And cycle consistency loss L cyc The calculation formulas are as follows:

[0049]

[0050]

[0051]

[0052] Among them, E represents the mathematical expectation and is used to calculate the error, that is, the loss; In the sample image x The expectation under the distribution, To calculate the discriminator D y The sample image x The errors identified as real data, Indicates that the target image is expanded y' Expectations under the distribution. To calculate the discriminator D y The generator G y The output result is identified as an error of false data; Indicates that in the paired target image y The expectation under the distribution, Used to calculate the discriminator D x Pair the target image y

[0053] The errors identified as real data, Used to calculate the discriminator D x Generator 2 G x The output result is identified as an error of false data, In the sample image x And sample reconstructed image The expectation under the distribution of is used to calculate the sample image x And sample reconstructed image The error between.

[0054] From the perspective of the entire model, the main vein-edge-tobacco leaf generation model is based on the main vein features. mx and edge features ex The main vein-edge-tobacco leaf generation model for image generation. The model loss of the entire model also includes the sample reconstructed image With sample image x The loss of main vein features and edge features. L MAI Represents the reconstructed image extracted from the sample The main vein features are extracted from the sample image x The loss between the main vein features is calculated as follows: ,in MAI ( x ) indicates that the main vein feature extraction module is used to process the sample image x ; Edge feature loss L EDG Represents the reconstructed image extracted from the sample The edge features of the sample image are extracted from x The loss between the edge features is calculated as follows: ,in EDG ( x ) indicates that the sample image is processed using the edge feature extraction module x ; Therefore, the model loss function of the main vein-edge-tobacco leaf generation model is:

[0055]

[0056] Among them is λ cyc , λ MAI and λ EDG They are the corresponding cycle consistency loss Lcyc, the main vein feature loss L MAI and edge feature loss L EDG The weights of the main vein-edge-tobacco leaf generation model are also adjustable hyperparameters. Optimizing these three weights can improve training performance and results. L cycleGAN By minimizing, we get the optimal model that can be directly used to generate the target unfolded image.

[0057] S5. Combine the trained main vein-edge-tobacco leaf generation model with the tobacco leaf detection model to detect tobacco leaves.

[0058] The tobacco leaf detection model includes a tobacco leaf defect detection model and a tobacco leaf grading detection model. The tobacco leaf defect detection model identifies the defective part from the image and classifies the defective part, and the corresponding output is the defect label obtained by classification. When the corresponding defect label includes any of the following types of tobacco leaves: tobacco leaves with curling that seriously affects the identification of the main vein, tobacco leaves with folded edges, tobacco leaves with overall folding, and tobacco leaves with wrinkled leaves, it is judged that the image contains tobacco leaves that need to be unfolded. Images containing tobacco leaves that need to be unfolded cannot be directly input into the tobacco leaf grading detection model for detection and grading, but must first be input into the main vein-edge-tobacco leaf generation model to be converted into the target unfolded image. y' , in order to expand the target image y' The images are input into the tobacco leaf grading detection model for more accurate detection and grading. The images that do not contain the tobacco leaves to be unfolded are directly input into the tobacco leaf grading detection model, and the detection and grading are completed through the existing detection technology.

[0059] The detected image containing the tobacco leaves to be unfolded is input into the main vein-edge-tobacco leaf generation model, and the main vein features are first extracted from the image. mx and edge features, and fuse the two to obtain the main vein-edge features, and then the image is input to generator 2 G x The target image is obtained after the second mixer processing. y' . Target expanded image y' The tobacco leaf in the image is in an unfolded state. y' Output to the tobacco leaf grading detection model to complete the detection and grading. The tobacco leaf grading detection model and the tobacco leaf defect detection model can be implemented by existing technologies, and their specific model structures and methods will not be described in detail here.

[0060] The existing tobacco leaf defect detection model can distinguish tobacco leaf images that affect subsequent detection and grading in the image. These tobacco leaf images containing tobacco leaves that need to be unfolded are processed by the main vein-edge-tobacco leaf generation model provided by the present invention, thereby obtaining a target unfolded image that can be directly detected and graded by the tobacco leaf grading detection model. This overcomes the problem in the prior art that tobacco leaf images that need to be unfolded can only be unfolded manually one by one, resulting in a large amount of labor consumption and a significant reduction in the efficiency of automatic detection and grading.

[0061] The present invention is described above by way of example in conjunction with the accompanying drawings. It is obvious that the specific implementation of the present invention is not limited to the above-mentioned method. As long as various non-substantial improvements are made using the inventive concept and technical solution of the present invention, or the inventive concept and technical solution are directly applied to other occasions without improvement, they are all within the protection scope of the present invention.

Claims

1. A tobacco leaf detection method integrating main vein features and edge features, Features: include: An initial sample image and a paired target image are obtained, wherein the initial sample image contains tobacco leaves that need to be expanded for detection and grading, and the initial sample image corresponds to the paired target image; a main vein-edge-tobacco leaf generation model is established, wherein the main vein-edge-tobacco leaf generation model includes a first adversarial generative network, a second adversarial generative network, a main vein feature extraction module, an edge feature extraction module, and a main vein-edge fusion module; the main vein feature and the edge feature of the tobacco leaves are respectively extracted from the initial sample image by the main vein feature extraction module and the edge feature extraction module, and the main vein-edge feature one is obtained by fusion; the main vein-edge feature one is combined with the corresponding paired target image to train the first adversarial generative network; the first adversarial generative network generates an expanded sample image using the initial sample image; the expanded sample image and the initial sample image both belong to sample images for training the second adversarial generative network; the second adversarial generative network converts the sample image into a target expanded image; the first adversarial generative network and the adversarial generative network The anti-generative network 2 forms a cyclic adversarial generative network, and the target unfolded image generated by the adversarial generative network 2 is used as the input of the previously trained adversarial generative network 1, so as to obtain the sample reconstructed image generated by the adversarial generative network 1; the sample image and the paired target image are used to train the discriminator of the adversarial generative network 1 and the discriminator of the adversarial generative network 2 respectively; the model loss of the main vein-edge-tobacco leaf generation model includes the adversarial generation loss 1 corresponding to the adversarial generation network 1, the adversarial generation loss 2 corresponding to the adversarial generation network 2, the cycle consistency loss, the main vein feature loss and the edge feature loss; the main vein feature loss represents the loss between the main vein feature extracted from the sample reconstructed image and the main vein feature extracted from the sample image, and the edge feature loss represents the loss between the edge feature extracted from the sample reconstructed image and the edge feature extracted from the sample image. During detection, the trained main vein-edge-tobacco leaf generation model is combined with the tobacco leaf detection model to detect tobacco leaves; The tobacco leaf detection method comprises the following steps: S1. Collecting initial sample images and establishing an initial sample image set, wherein the initial sample images include tobacco leaves that need to be unfolded for detection and grading; S2, establishing a main vein-edge-tobacco leaf generation model; S3, expanding the number of sample images, extracting main vein features and edge features from the initial sample image of the tobacco leaf to be unfolded and fusing them, using the fused main vein-edge feature one and the corresponding paired target image to train a generative adversarial network one, and then inputting the initial sample image of the tobacco leaf to be unfolded into the trained generative adversarial network one to generate an expanded sample image, wherein the expanded sample image and the initial sample image are both sample images; The main vein feature extraction module outputs the main vein features that only contain the main vein part mx , the edge feature extraction module outputs only the edge features of the tobacco leaf edge ex Then, the main vein features are merged into the edge fusion module mx and edge features ex Fusion as main vein-edge feature mex 1 , the corresponding calculation formula is: , where α is the main vein feature mx The weight of β is the edge feature ex The weights of α and β are calculated as follows: , ;in A α and A β They are the parameter matrix for adjusting the weight α and the parameter matrix for adjusting the weight β respectively; S4, let the first generative adversarial network and the second generative adversarial network form a cyclic generative adversarial network, extract the main vein-edge feature 2 obtained by fusion from the sample image, and use the main vein-edge feature 2 and the sample image to train the second generative adversarial network; The adversarial generation network 2 includes a generator 2 G x And Discriminator 2 D x , the generator two G x The encoder 2 and the mixer 2 are included; first, according to step S2, the sample image is obtained. x Extract the main vein feature and edge feature and fuse them to get the main vein-edge feature 2 mex 2 ; Sample image x Input Generator 2 G x Processed by encoder 2, the features extracted by encoder 2 are consistent with the main vein-edge feature 2 mex 2 After splicing, it is input to mixer 2 to generate the target expanded image y' , and then expand the target image y' Input Discriminator 2 D x , by corresponding to the sample image x Paired target image y For discriminator 2 D x Train and train the discriminator 2 D x Then use the discriminator 2 D x For generator 2 G x Perform training to obtain the trained adversarial generation network 2; Generator 2 G x Generated target expanded image y' As the input of the previously trained adversarial generation network 1, the generator 1 G y In the example, the feature extracted by encoder 1 is the same as the main vein-edge feature 2. mex 2 After splicing, it is input to mixer 1 to obtain the sample reconstructed image generated by adversarial generation network 1 ; Reconstruct the sample image Input Discriminator 1 D y , by pairing the target image with y The corresponding sample image x For the discriminator D y Train and train the discriminator D y Then use the discriminator D y For generator one G y Perform training to obtain a trained adversarial generation network 1; S5. Combining the trained main vein-edge-tobacco leaf generation model with the tobacco leaf detection model to detect tobacco leaves. The tobacco leaf detection model includes a tobacco leaf defect detection model and a tobacco leaf grading detection model.

2. A tobacco leaf detection method integrating main vein features and edge features according to claim 1, Features: Generative Adversarial Networks - including Generators - G y and the discriminator D y , generator one G y It includes an encoder 1 and a mixer 1; in step S3, from the initial sample image x 0 Extract the main vein features and edge features and fuse them to get the main vein-edge feature mex 1 ; The input of the adversarial generation network is the paired target image y , paired target image y First processed by encoder 1, the features extracted by encoder 1 are combined with the main vein-edge features obtained previously mex 1 After splicing, it is input to the mixer to generate the dilated sample image. x' , and then expand the sample image x' Input Discriminator 1 D y , by pairing the target image with y The corresponding initial sample image x 0 For the discriminator D y Train and train the discriminator D y Then use the discriminator D y For generator one G y Train the network to obtain the trained adversarial generation network 1.

3. A tobacco leaf detection method integrating main vein features and edge features according to claim 1, Features: Adversarial Generation Loss 1 L GANy , Adversarial Generation Loss 2 L GANx , cycle consistency loss L cyc , main vein feature loss L MAI and edge feature loss L EDG The calculation formulas are as follows: Among them, E represents the mathematical expectation and is used to calculate the error, that is, the loss; In the sample image x The expectation under the distribution, Indicates that the target image is expanded y' Expectations under distribution; Indicates that in the paired target image y The expectation under the distribution, In the sample image x And sample reconstructed image The expectation under the distribution of MAI ( x ) indicates that the main vein feature extraction module is used to process the sample image x ; EDG ( x ) indicates that the sample image is processed using the edge feature extraction module x .

4. A tobacco leaf detection method integrating main vein features and edge features according to claim 3, Features: The model loss function of the main vein-edge-tobacco leaf generation model is: Among them is λ cyc , λ MAI and λ EDG The corresponding cycle consistency loss is L cyc , main vein feature loss L MAI and edge feature loss L EDG The weight is also an adjustable hyperparameter.

5. The tobacco leaf detection method integrating main vein features and edge features according to claim 1, Features: In step S5, the tobacco leaf detection model includes a tobacco leaf defect detection model and a tobacco leaf grading detection model; the tobacco leaf defect detection model identifies defective parts from the image and classifies the defective parts, and the corresponding output is a defect label obtained by classification; Based on the defect label, it is determined whether the image contains tobacco leaves that need to be unfolded; if the image contains tobacco leaves that need to be unfolded, it is first input into the main vein-edge-tobacco leaf generation model to be converted into the target unfolded image y' , and then input the tobacco leaf grading detection model for detection and grading, otherwise directly input the tobacco leaf grading detection model for detection and grading.

Citation Information

Patent Citations

  • Online automatic tobacco leaf grade sorting identification method based on machine vision

    CN111274860A

  • Calligraphy character generation method based on skeleton and contour

    CN117058266A

  • Method for rapidly identifying and grading cinnabar cigarettes based on deep learning

    CN117853925A

  • Tobacco leaf image data enhancement method based on CycleGAN

    CN117934298A