Tobacco insect data enhancement model training method based on mean absolute error
By improving the activation function and loss function of the SinGAN algorithm, combined with the pyramid-type network structure, diverse smokeworm images are generated, which solves the problem of insufficient training of the tobacco insect recognition algorithm, and achieves efficient data expansion and improvement of recognition accuracy.
Patent Information
- Application Number
- CN202310402213.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-13
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2043-04-13
AI Technical Summary
The existing technology cannot effectively train the smokeworm image detection model, resulting in insufficient accuracy and generalization capabilities of the recognition algorithm, and high data acquisition costs.
The SinGAN tobaccoworm data enhancement method based on average absolute error is used to improve the activation function to ELU, and instead use MAE to replace MSE. The generator and discriminator generate real tobaccoworm images through multiple trainings to form a pyramid-type network structure.
Generate diverse smokeworm images, expand data sets, reduce data acquisition costs, and improve the accuracy and generalization capabilities of identification algorithms.
Smart Images

Figure CN116385852B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cigarette manufacturing, and in particular to a tobacco insect data enhancement model training method based on mean absolute error. Background Art
[0002] During the storage and processing of tobacco, pests and diseases are a serious problem, and tobacco beetles (hereinafter referred to as tobacco beetles) are one of the most common pests. In order to prevent pests and improve tobacco production quality, computer-assisted tobacco beetle recognition is an important technical means.
[0003] However, due to the limited resources of tobacco insect images and the lack of professional tobacco insect image datasets in the industry, existing methods are unable to fully train tobacco insect image detection models, resulting in insufficient accuracy and generalization ability of tobacco insect recognition algorithms, thereby reducing the credibility of the algorithm.
[0004] If tobacco companies increase the number of cameras used to take pictures of tobacco, although the number of pictures can be increased to a certain extent, it will still take a lot of time and manpower to find pictures with tobacco worms, and it will also increase equipment costs. Summary of the Invention
[0005] In view of the above, the present invention aims to provide a tobacco insect data enhancement model training method based on mean absolute error, with the aim of proposing a tobacco insect data enhancement idea based on SinGAN (SinGAN) with mean absolute error, which can improve the tobacco insect details while retaining the excellent enhancement ability of the SinGAN strategy for single tobacco insect images.
[0006] The technical solution adopted in the present invention is as follows:
[0007] The present invention provides a tobacco insect data enhancement model training method based on mean absolute error, which includes:
[0008] Read an original tobacco insect image;
[0009] Downsampling the original tobacco insect image as a training sample in a preset adversarial network to obtain an image generator and an image discriminator corresponding to each scale;
[0010] The image generator directly takes the noise map corresponding to the current scale as input, performs convolution and normalization, activates it through the ELU activation function, and then generates an image through deconvolution. At all scales except the coarsest scale, the input of the image generator at the nth scale is the image generated by the image generator at the n+1th scale plus the noise map corresponding to the current scale. After convolution and normalization, it is activated by the ELU activation function and then generates an image through deconvolution. The variance of the noise map is determined by the mean absolute error between the reconstructed image and the true image.
[0011] The image sample generated at the current scale and the existing downsampled original image sample are used as input to the image discriminator to determine whether the generated tobacco insect image is real. If the judgment result is not real, it returns to the image generation link to continue generating the image. If the judgment result is real, the image sample is output upward.
[0012] At each scale, the image generator and image discriminator are trained multiple times so that the image generator can generate real and valid samples.
[0013] In at least one possible implementation, the training of the image generator and the image discriminator multiple times includes:
[0014] At the coarsest scale, the image generator learns the layout and characteristics of the input image and maps the spatial Gaussian white noise into an image sample;
[0015] At subsequent scales, the image generator receives an upsampled version of the image generated at a coarser scale as input, and adds details that were not generated at the previous scale. The image samples generated at the current scale and the downsampled original image samples are then used as input to the image discriminator.
[0016] The image discriminator calculates the authenticity score of the input image through comparison and returns the score to the image generator;
[0017] The image generator adjusts based on the score and generates new image samples, and the image discriminator updates its own parameters accordingly;
[0018] When the image discriminator determines that the result is true, it outputs a valid image sample upward;
[0019] Repeat the above process until the generated image reaches the desired image resolution.
[0020] In at least one possible implementation manner, the image discriminator compares the texture and statistical features of the input image.
[0021] In at least one possible implementation manner, the statistical features include at least brightness and color distribution.
[0022] In at least one possible implementation, the adversarial network structure is pyramid-shaped from bottom to top, and the corresponding scale is from coarse to fine.
[0023] In at least one possible implementation, downsampling the original tobacco insect image as a training sample in a preset adversarial network includes: calculating the total number of scales and the number of downsampling times based on the size of the original tobacco insect image, the set lowest layer image size and the downsampling rate parameter.
[0024] Compared with the existing technology, the main design concept of the present invention is to combine computer vision and deep learning data preprocessing technology to improve the detection model algorithm used for tobacco insect identification based on specific scenarios. The activation function of SinGAN is changed to Exponential Linear Units (ELU) activation function, which greatly avoids the gradient vanishing problem and ensures the robustness of the algorithm. The mean squared error (MSE) of SinGAN is changed to the mean absolute error (MAE) between the reconstructed image and the real image, effectively improving the diversity of the generated images. The present invention can generate a variety of images with varying numbers and locations of tobacco insects, expanding the limited image dataset to a dataset sufficient for network training. While achieving tobacco insect image enhancement in different scenarios, it greatly reduces the cost of data acquisition and effectively improves the accuracy and generalization ability of the tobacco insect identification algorithm, providing data guarantee and key technical support for improving the accuracy of tobacco insect identification technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention will be further described below with reference to the accompanying drawings, in which:
[0026] Figure 1 A schematic diagram of a flow chart of a tobacco insect data enhancement model training method based on mean absolute error provided by an embodiment of the present invention;
[0027] Figure 2 A schematic diagram of the SinGAN algorithm structure based on mean absolute error provided by an embodiment of the present invention;
[0028] Figure 3 This is a diagram showing the experimental results of the SinGAN algorithm based on mean absolute error provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0029] The following describes embodiments of the present invention in detail. 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 only to explain the present invention and are not to be construed as limiting the present invention.
[0030] The present invention proposes an embodiment of a tobacco insect data enhancement model training method based on mean absolute error. Specifically, Figure 1 shown, including:
[0031] Step S1, read an original tobacco insect image;
[0032] That is, SinGAN does not require a large number of image samples, and a tobacco insect image can be used as the initial training sample.
[0033] Step S2: using the original tobacco insect image as a training sample in a preset adversarial network, downsampling is performed (including: calculating the total number of scales and the number of downsampling times according to the size of the original tobacco insect image, the set lowest layer image size, and the downsampling rate parameter) and obtaining an image generator and an image discriminator corresponding to each scale;
[0034] Specifically, take an original tobacco insect image sample as the input of the network. Assuming the image size is 500×375, the image is downsampled n times. If the lowest layer image size is set to 40×40 and the downsampling rate is 0.85, it needs to be downsampled 30 times through calculation. Each scale corresponds to an image generator G. n and an image discriminator D n , the relevant formulas involved can be referred to as follows:
[0035]
[0036] According to formula (1), the total number of scales is 31, and 30 downsampling operations are required. At each scale, the sample size of the scale is calculated according to formula (2) to ensure that the final generated sample size is consistent with the original image:
[0037] The sample size generated by this scale = original size × downsampling rate 当前尺度 (2)
[0038] Recombination Figure 2 As shown in the figure, the network structure is pyramid-shaped from bottom to top, and the scale gradually changes from coarse to fine. The input of the image generator at the nth scale is the result of adding the image generated by the image generator at the n+1th scale and the corresponding random noise. For example, the input of the 30th scale is composed of the image generated at the 31st scale, which is upsampled to the size of the scale and added to the noise. After 5 groups of 3×3 convolutions and image data normalization, it is activated by the activation function and finally the image is generated by the deconvolution operation.
[0039] In this step, the SinGAN activation function is changed to the Exponential Linear Units (ELU) activation function through convolution and normalization of the image data, which is also a non-saturated linear activation function. This effectively avoids the gradient vanishing problem while improving accuracy and shortening training time.
[0040] And, for the noise spectrum z in the SinGAN loss function * The original mean squared error (MSE) is changed to the mean absolute error (MAE) between the reconstructed image and the real image. Adding the number of details to each image generator processing as an indicator can effectively improve the diversity of generated images.
[0041] Specifically, the training loss of each image generator includes the adversarial loss L adv and reconstruction loss L rec :
[0042]
[0043] Where α is the weight of the reconstruction loss, G n Represents the corresponding generation network, D n Represents the corresponding discriminant network;
[0044] The significance of this loss function is to maximize the loss function of the discriminator so that it can distinguish between real images and generated images as much as possible, while minimizing the loss function of the generator so that it can generate images that are increasingly close to real images; through iterative training, an equilibrium state is eventually reached, the generator can generate images that are close to real images, and the discriminator cannot accurately distinguish between generated images and real images.
[0045] Among them, regarding the adversarial loss L adv :
[0046]
[0047] Adversarial loss function L adv Refers to the image discriminator D n For the image generator G n The discriminative ability of the generated image, that is, the discriminator D n Can the generated images be distinguished from real images? Take real samples, x~P G Take the generated sample, take the random number ∈~U[0,1], Yes λ is the penalty coefficient, is the weight of the discriminator.
[0048] Among them, regarding the reconstruction loss L rec :
[0049] The calculation of the reconstruction loss is divided into two cases: n < N and n = N. When n < N, the noise is 0, and the input of G n is the upsampled generated image of the output of the previous level. At this time, the reconstruction loss is as follows:
[0050]
[0051] Among them represents generating an image at the n+1 scale using the noise map. The former means that at the current scale, the image generated at a coarser scale is used as the input of the image generator to generate a new image. r is the scaling factor used to control the resolution and quality of the generated image, and x n represents the real image at the current scale;
[0052] When n = N, the input of G n is only the noise map z * , and the reconstruction loss is as follows:
[0053] L rec = ||G n (z * ) - x N || 2 (6)
[0054] Among them, the reconstruction loss function L rec refers to the difference between the image generated by the image generator G n and the original image, that is, the reconstruction error of the image. It is mainly used to measure the difference between the output image of the generator and the input image (or the original image). It is hoped that the generated image can restore the details and textures of the original image as much as possible, and it is ensured that the coarsest scale can directly generate an image from the noise map, ensuring a similar image style, such as directly generating an image from a 40×40 noise map at the 31st scale.
[0055] It can be emphasized again that in step S3, at the coarsest scale, the image generator directly takes the noise spectrum corresponding to the current scale as input for convolution and normalization, and activates it through the ELU activation function, and then generates an image by deconvolution operation; and at other scales except the coarsest scale, the input of the image generator at the nth scale is the image generated by the image generator at the n+1th scale plus the noise spectrum corresponding to the current scale, and after convolution and normalization, it is activated by the ELU activation function, and then generates an image by deconvolution operation, so that details that were not generated at the previous scale can be added. Among them, the variance of the noise spectrum is determined by the mean absolute error between the reconstructed image and the real image, that is, the number of details added is determined by the MAE error.
[0056] Step S4: The image generated at the current scale and the existing downsampled original image samples are used as inputs to the image discriminator to determine whether the generated tobacco insect image is real. If the judgment result is not real, the process returns to step S3, with the goal of the image generator generating a new sample to deceive the image discriminator. If the judgment result is real, the valid image sample is output upward, that is, it is used as the input sample for the next scale.
[0057] Step S5: At each scale, the image generator and the image discriminator are trained multiple times so that the image generator generates real and valid samples.
[0058] In this embodiment, the image generator G n and image discriminator D n Mutual competition and mutual promotion, the specific implementation process is as follows: First, at the coarsest scale, G n Learn the layout and characteristics of the input image and transform the spatial Gaussian white noise z N Mapped into an image sample;
[0059] In subsequent other scales, G n Receive the upsampled version of the coarser scale generated image as input, add details that were not generated at the previous scale, and then use the image samples generated at the current scale and the original image samples after downsampling as D n Input;
[0060] Image Discriminator D n By comparing, the authenticity score of the input image is calculated and returned to the generator G n ;
[0061] Generator G n According to the score, it adjusts and tries to generate new samples, while simultaneously, the discriminator D nThe two models promote each other to update until the discriminator D n If the result is true, the valid image sample is output upwards. The above steps are repeated until the required image resolution is reached.
[0062] Specifically, the image samples generated at the current scale and the existing original image samples are used as D n The image discriminator compares the texture and statistical features (such as brightness, color distribution, etc.) of the input image. By comparing the input image with the known real image, the discriminator calculates the authenticity score of the input image and returns the score to the generator. The generator adjusts according to the score and tries to generate new samples to deceive D. n , and D n Update parameters to more accurately distinguish true from false; the two models promote each other's updates until D n The judgment result is true.
[0063] The experimental results are as follows Figure 3 As shown in the figure, under the premise that the input original tobacco insect image is the same, compared with the traditional SinGAN algorithm (original model), the tobacco insect image generated by the improved SinGAN algorithm of the present invention is more realistic in visual presentation, reducing problems such as false contours and missing details, and the position, size and number of tobacco insects have certain changes.
[0064] From an objective perspective, the Structural Similarity Index (SSIM) can be used to evaluate image quality. The SSIM metric quantifies the similarity between two images in terms of brightness, contrast, and structure, thereby assessing the degree of image similarity. SSIM values range from 0 to 1, with higher values indicating more similar images.
[0065] When comparing the image generation quality of the SinGAN algorithm and the improved SinGAN algorithm of our invention, we can see that the improved SinGAN algorithm has a higher SSIM value, indicating that the generated image is closer to the original image, with more similar structure and details. Therefore, from the perspective of the SSIM metric, the improved SinGAN algorithm of our invention performs better in image generation. See Table 1 below for details.
[0066] Table 1 Algorithm comparison experiment
[0067]
[0068] In summary, by combining computer vision and deep learning data preprocessing technology, the detection model algorithm used for tobacco insect identification is improved based on specific scenarios. The activation function of SinGAN is changed to the Exponential Linear Units (ELU) activation function, which greatly avoids the problem of gradient vanishing and ensures the robustness of the algorithm. The mean squared error (MSE) of SinGAN is changed to the mean absolute error (MAE) between the reconstructed image and the real image, effectively improving the diversity of the generated images. The present invention can generate a variety of images with varying numbers and locations of tobacco insects, expanding the limited image data set to a data set sufficient for network training. While achieving tobacco insect image enhancement in different scenarios, it greatly reduces the cost of data acquisition and effectively improves the accuracy and generalization ability of the tobacco insect identification algorithm, providing data guarantee and key technical support for improving the accuracy of tobacco insect identification technology.
[0069] In the embodiment of the present invention, "at least one" refers to one or more, and "more" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, a and b, a and c, b and c, or a, b and c, where a, b, c can be single or multiple.
[0070] The above describes in detail the structure, features and effects of the present invention based on the embodiments shown in the drawings, but the above is only a preferred embodiment of the present invention. It should be noted that the technical features involved in the above embodiments and their preferred modes can be reasonably combined and matched into a variety of equivalent schemes by those skilled in the art without departing from or changing the design ideas and technical effects of the present invention; therefore, the scope of implementation of the present invention is not limited to what is shown in the drawings. Any changes made in accordance with the concept of the present invention, or modifications to equivalent embodiments with equivalent changes, which still do not exceed the spirit covered by the description and drawings, should be within the scope of protection of the present invention.
Claims
1. A tobacco insect data enhancement model training method based on mean absolute error, characterized in that: include: Read an original tobacco insect image; Downsampling the original tobacco insect image as a training sample in a preset adversarial network to obtain an image generator and an image discriminator corresponding to each scale; The image generator directly takes the noise map corresponding to the current scale as input for convolution and normalization, activates it through the ELU activation function, and then generates an image through deconvolution operation; At all scales except the coarsest, the input to the image generator at scale n is the sum of the image generated by the image generator at scale n+1 and the noise map corresponding to the current scale. After convolution and normalization, the image is activated by the ELU activation function and then deconvolution is performed to generate the image. The variance of the noise map is determined by the mean absolute error between the reconstructed image and the true image. The image sample generated at the current scale and the existing downsampled original image sample are used as input to the image discriminator to determine whether the generated tobacco insect image is real. If the judgment result is not real, it returns to the image generation link to continue generating the image. If the judgment result is real, the image sample is output upward. At each scale, the image generator and image discriminator are trained multiple times to ensure that the image generator generates realistic and effective samples, including: At the coarsest scale, the image generator learns the layout and characteristics of the input image and maps the spatial Gaussian white noise into an image sample; At subsequent scales, the image generator receives an upsampled version of the image generated at a coarser scale as input, and adds details that were not generated at the previous scale. The image samples generated at the current scale and the downsampled original image samples are then used as input to the image discriminator. The image discriminator calculates the authenticity score of the input image through comparison and returns the score to the image generator; The image generator adjusts based on the score and generates new image samples, and the image discriminator updates its own parameters accordingly; When the image discriminator determines that the result is true, it outputs a valid image sample upward; Repeat the above process until the generated image reaches the desired image resolution.
2. The tobacco insect data enhancement model training method based on mean absolute error according to claim 1 is characterized in that: The image discriminator compares the texture and statistical features of the input image.
3. The tobacco insect data enhancement model training method based on mean absolute error according to claim 2, characterized in that: The statistical features include at least brightness and color distribution.
4. The tobacco insect data enhancement model training method based on mean absolute error according to claim 1, characterized in that: The adversarial network structure is pyramid-shaped from bottom to top, and the corresponding scale is from coarse to fine.
5. The tobacco insect data enhancement model training method based on mean absolute error according to any one of claims 1 to 4, characterized in that: The downsampling of the original tobacco insect image as a training sample in a preset adversarial network includes: calculating the total number of scales and the number of downsampling times according to the size of the original tobacco insect image, the set lowest layer image size and the downsampling rate parameter.
Citation Information
Patent Citations
Tobacco insect target detection method fusing attention model
CN113673618A
Image inpainting method for improving incoherence phenomenon of edge of inpainting area
CN114387170A