Agricultural pest image data enhancement method and system based on MTS multi-network model
Through the agricultural pest image data enhancement method based on the MTS multi-network model, combined with direct enhancement and meta-learning, the data enhancement parameters and image screening are optimized, which solves the problems of difficult parameter adjustment and low quality in agricultural pest image data enhancement, and realizes the data set The expansion and deduplication improve image quality and diversity.
Patent Information
- Application Number
- CN202411112570.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2044-08-14
AI Technical Summary
The existing technology has problems such as difficulty in adjusting parameters and low quality of synthesized images when enhancing agricultural pest image data, making it unsuitable for data enhancement tasks.
A method based on the MTS multi-network model is adopted, through a combination of direct enhancement and meta-learning enhancement, using mask image separation and geometric transformation operations to generate new background images, combining adversarial networks and meta-learning strategies, optimizing data enhancement parameters, and using Minkowski distance Filter high-quality images.
Effectively expand and deduplicate agricultural pest data sets, improve image quality and diversity, enhance the learning ability of deep learning models for complex contours, and provide richer data resources.
Smart Images

Figure CN118628924B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of data processing, and in particular to a method and system for enhancing agricultural pest image data based on an MTS multi-network model. Background Art
[0002] Existing data enhancement technologies can be divided into traditional data enhancement technologies and data enhancement technologies based on deep learning. Traditional data enhancement technologies include but are not limited to methods such as adding noise, rotation, flipping, cropping, and scaling, while deep learning-based data enhancement technologies include the use of generative adversarial networks (GANs), autoencoders, and other technologies to synthesize new training data to improve the generalization ability and robustness of the model.
[0003] The above methods have certain limitations when applied to data enhancement of agricultural pest images. For example, it is difficult to manually adjust parameters when using traditional data enhancement. When using generative adversarial networks to enhance data, due to the complex contours of agricultural pests, it is easy to produce synthetic images with distorted shapes when generating images. When synthesizing images, it is easy to produce low-quality or repeated images, which are not suitable for data enhancement tasks.
[0004] Therefore, in the existing technology, when performing agricultural pest image enhancement, there is still a common problem of difficulty in adjusting parameters, and the quality of the synthesized image is low and not suitable for data enhancement. Summary of the invention
[0005] In view of the shortcomings of the prior art, the purpose of the present invention is to provide a method and system for agricultural pest image data enhancement based on the MTS multi-network model, aiming to solve the problems in the prior art that when enhancing agricultural pest images, there are still common difficulties in adjusting parameters and the quality of synthesized images is low and not suitable for data enhancement.
[0006] The first aspect of the present invention is to provide a method for enhancing agricultural pest image data based on an MTS multi-network model, the method comprising:
[0007] Obtain agricultural pest images and create a new agricultural pest image dataset with customized background;
[0008] Directly enhancing and meta-learning enhancing are respectively performed on the agricultural pest images in the agricultural pest image dataset, and agricultural pest enhanced images are respectively output;
[0009] Screening the agricultural pest enhanced image based on a preset adversarial network and outputting a first process image;
[0010] Performing quality detection on the first process image to output a second process image;
[0011] extracting reconstruction features in the second process image, and storing the reconstruction features in a representation library;
[0012] The reconstructed features of the newly acquired target image are compared with the reconstructed features stored in the characterization library, and images with features greater than a preset threshold are stored in the image library to obtain an enhanced data set of agricultural pests.
[0013] According to one aspect of the above technical solution, the steps of directly enhancing and meta-learning enhancing the agricultural pest images in the agricultural pest image dataset and outputting the agricultural pest enhanced images respectively specifically include:
[0014] Using the mask image to separate the foreground image and the background image in the agricultural pest image, merging the foreground image and the new background image by dot multiplication to obtain the agricultural pest image with the new background;
[0015] The agricultural pest image is transformed by using a preset data enhancement method so that the agricultural pest image is more consistent with the distribution of the target domain, and an agricultural pest enhanced image based on a direct enhancement method is obtained;
[0016] The optimal data augmentation parameters are found by using an adaptive data augmentation strategy based on meta-learning, and enhanced images of agricultural pests based on meta-learning are obtained.
[0017] According to one aspect of the above technical solution, the step of using a mask image to separate a foreground image and a background image in an agricultural pest image, merging the foreground image with a new background image by dot multiplication, and obtaining an agricultural pest image with a new background specifically includes:
[0018] Use a labeling tool to obtain a mask image corresponding to the agricultural pest image, set the pixel value of the foreground image of the mask image to 1, and set the pixel value of the background area of the mask image to 0, perform a dot product operation on the mask image and the foreground image, and obtain the agricultural pest foreground image;
[0019] Constructing a geometric transformation operation set, traversing the agricultural pest foreground image through the sub-operations in the geometric transformation operation set, and determining whether to apply the sub-operation according to the application probability, and performing geometric transformation on the agricultural pest foreground image according to the enhancement amplitude;
[0020] The agricultural pest foreground image after geometric transformation is merged with the background image of the target domain to obtain the agricultural pest image with a new background;
[0021] Constructing a color transformation operation set, traversing each sub-operation in the color transformation operation set based on the agricultural pest image, and performing color transformation on the agricultural pest image according to the application probability and the enhancement amplitude;
[0022] And the agricultural pest images are learned by combining with an adversarial network to expand the data set by generating images through the network.
[0023] According to one aspect of the above technical solution, in the step of finding the optimal data enhancement parameters using an adaptive data enhancement strategy based on meta-learning to obtain an enhanced image of agricultural pests based on meta-learning, the training process of the enhanced model enhanced by meta-learning includes:
[0024] Agricultural pest identification is used as a subtask, and the cross entropy loss function is used as the performance metric of the model in the subtask;
[0025] Perform multiple subtask training on the meta-training set to obtain the loss function value corresponding to each operation path, and use the loss function value to optimize the parameters of the search space to adjust the operation weight of each data augmentation operation;
[0026] And update the operation weights using a One-pass joint optimization strategy.
[0027] According to one aspect of the above technical solution, the training process of the meta-learning enhanced model specifically includes: forward propagation, loss calculation, backward propagation and parameter update.
[0028] According to one aspect of the above technical solution, the forward propagation calculation expression is:
[0029] ;
[0030] In the formula, is the predicted value, that is, the label probability vector output by the model, F is the model forward propagation function, which is used to convert input data into prediction results. W are model parameters or weights, consisting of the weights and biases of all layers, i is a set of data enhancement parameters, including the probability and amplitude of various transformations, X Enter data for batches;
[0031] The loss calculation expression is:
[0032] ;
[0033] In the formula, L is the loss function, which measures the predicted value of the model prediction and the true label vector Y The difference between the true label vector Y Each element in is the true classification label of the corresponding input data. j is the index used to traverse all output categories;
[0034] The calculation expression for backward propagation is:
[0035] ;
[0036] In the formula, For the enhancement parameters i The unbiased estimated gradient of ∂ is the symbol for partial derivative, indicating the calculation of gradient, is the loss function L In the enhanced parameters i for The value of For the t The data enhancement parameters for the iteration, R is the RELAX estimator function, which is used to calculate the gradient approximation of non-differentiable data augmentation operations. Z is the random noise introduced to help R Function estimation i gradient.
[0037] According to one aspect of the above technical solution, parameter updating is used to jointly update model weights and enhancement parameters;
[0038] The calculation expression of model weight is:
[0039] ;
[0040] The calculation expression of the enhancement parameter is:
[0041] ;
[0042] In the formula, , are the updated model weights and data enhancement parameters, respectively. , are the model weights and data enhancement parameters of the current iteration, respectively. , are the learning rates of model weights and data enhancement parameters, respectively, used to control the step size of gradient descent, , Respectively for W and i The loss gradient and unbiased estimated gradient of .
[0043] The second aspect of the present invention is to provide an agricultural pest image data enhancement system based on the MTS multi-network model, which is applied to the method described in the above technical solution, and the system comprises:
[0044] A dataset creation module is used to obtain agricultural pest images and create a new agricultural pest image dataset with a customized background;
[0045] An image enhancement module, used for performing direct enhancement and meta-learning enhancement on the agricultural pest images in the agricultural pest image dataset, and outputting agricultural pest enhanced images respectively;
[0046] An image screening module, used for screening the agricultural pest enhanced image based on a preset adversarial network and outputting a first process image;
[0047] An image detection module, used for performing quality detection on the first process image to output a second process image;
[0048] A feature extraction module, used for extracting reconstruction features in the second process image and storing the reconstruction features in a representation library;
[0049] The data set output module is used to compare the reconstructed features of the newly acquired target image with the reconstructed features stored in the characterization library, and store images greater than a preset threshold in the image library to obtain an enhanced data set of agricultural pests.
[0050] A third aspect of the present invention is to provide a readable storage medium having a computer program stored thereon, which implements the method described in the above technical solution when executed by a processor.
[0051] The fourth aspect of the present invention is to provide an electronic device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the method described in the above technical solution when executing the computer program.
[0052] Compared with the prior art, the agricultural pest image data enhancement method and system based on the MTS multi-network model shown in the present invention has the following beneficial effects:
[0053] In view of the scarcity and difficulty of collecting agricultural pest image data, as well as the problem of duplicate or similar images in the enhanced data, the present invention proposes the MTS multi-network model to expand, screen and deduplicate the agricultural pest dataset. First, through the optimized discriminator and automatic image screening network, high-quality synthetic images are screened and retained, and applied to data enhancement tasks to enhance the deep learning model's learning ability for complex contours. Secondly, the agricultural pest image synthesis method based on mask transformation merges the foreground image and the background image through rotation transformation to generate diversified agricultural pest images, providing richer data resources. Finally, the image screening method based on Minkowski distance is adopted to effectively detect and remove duplicate or similar images in the dataset, ensuring the diversity of the data. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0055] Figure 1 Schematic diagram of the process of agricultural pest image data enhancement method based on MTS multi-network model in one embodiment of the present invention;
[0056] Figure 2 It is a structural block diagram of an agricultural pest image data enhancement system based on the MTS multi-network model in one embodiment of the present invention. DETAILED DESCRIPTION
[0057] In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings. Several embodiments of the present invention are shown in the accompanying drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive.
[0058] It should be noted that when an element is referred to as being "fixed to" another element, it may be directly on the other element or there may be a central element. When an element is considered to be "connected to" another element, it may be directly connected to the other element or there may be a central element at the same time. The terms "vertical", "horizontal", "left", "right" and similar expressions used herein are for illustrative purposes only.
[0059] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0060] Embodiment 1
[0061] See also Figure 1 The first embodiment of the present invention provides a method for enhancing agricultural pest image data based on an MTS multi-network model, the method comprising steps S10 to S60:
[0062] Step S10, obtaining agricultural pest images and creating a new agricultural pest image dataset with a customized background.
[0063] Step S20, performing direct enhancement and meta-learning enhancement on the agricultural pest images in the agricultural pest image dataset, and outputting agricultural pest enhanced images respectively.
[0064] Step S30, screening the agricultural pest enhanced image based on a preset adversarial network, and outputting a first process image.
[0065] Step S40: Perform quality detection on the first process image to output a second process image.
[0066] Step S50: extracting reconstruction features from the second process image and storing the reconstruction features in a representation library.
[0067] Step S60, comparing the newly acquired reconstructed features of the target image with the reconstructed features stored in the characterization library, and storing images greater than a preset threshold in the image library to obtain an enhanced dataset of agricultural pests.
[0068] In response to the problem of lack of agricultural pest images, this embodiment proposes a technical study on agricultural pest image data enhancement based on the MTS (Multi-stage image domain transfer method based on meta-learning, Two-stage deformable generative adversarial network, Synthetic Image Screening Method Based on Minkowski Distance) multi-network model. First, a basic agricultural pest dataset is constructed through image acquisition. Next, a multi-stage image domain transfer method based on meta-learning will be used to enhance scene diversity. Then, a two-stage deformable generative adversarial network is used to improve image quality, and a discriminator is used to screen low-quality synthetic images. Finally, a similar image detection algorithm based on Minkowski distance is used to check image duplication, thereby ultimately creating a high-quality synthetic image dataset.
[0069] Among them, the multi-stage image domain migration method based on meta-learning:
[0070] In order to meet the challenges of diversified task scenarios, this embodiment proposes a multi-stage image domain migration method based on meta-learning. This method aims to use existing data sets to synthesize agricultural pest images in new scenarios. First, the agricultural pest foreground image and background image are separated by a mask image, and the agricultural pest foreground image and the new background image are merged by dot multiplication to change the background. Secondly, the synthesized new background agricultural pest image is transformed by traditional data enhancement methods to eliminate the differences in posture and color style of agricultural pests between different regions, so that the synthesized image is more in line with the distribution of the target domain. Finally, an adaptive data enhancement strategy based on meta-learning is used to find the optimal data enhancement parameters. Through model training, the optimal data enhancement selection weights and enhancement amplitudes are automatically learned.
[0071] Among them, the multi-stage image domain migration method:
[0072] In order to synthesize agricultural pest images with more agricultural pests in different backgrounds, this embodiment proposes a multi-stage image domain migration method, which combines the original agricultural pest image dataset with the new background image to synthesize the new background agricultural pest image. The specific operations are as follows:
[0073] In the first step, the mask image corresponding to the agricultural pest image is obtained using the annotation tool and the pixel values of the foreground part are set to 1 and the pixel values of the background part are set to 0. The agricultural pest foreground image A is obtained by performing a dot multiplication operation between the mask image M and the original real agricultural pest image I.
[0074] The second step is to construct a geometric transformation operation set O1, which contains n geometric transformation operations F. Each geometric transformation operation F contains two parameters: application probability p and enhancement amplitude w. The agricultural pest foreground image A is traversed through the sub-operations F of the set O1. The application probability p determines whether to apply the sub-operation F, and the agricultural pest foreground image A is geometrically transformed according to the enhancement amplitude w. The values of the application probability p and the enhancement amplitude w are obtained through training in the meta-learning framework.
[0075] The third step is to merge the agricultural pest foreground image A with the background image B of the target domain. The specific operations are as follows:
[0076] (1) Change the size of the target domain background image B to make it the same size as the agricultural pest foreground image A.
[0077] (2) Traverse each pixel in the agricultural pest foreground image A and replace the point with a pixel value of 0 with the pixel value of the corresponding position point in the background image B.
[0078] Through the above steps, the background transformation is completed and the agricultural pest image A' of the new background is obtained.
[0079] The fourth step is to construct a color transformation operation set O2. The structure of set O2 is the same as that of set O1. The agricultural pest image A' is traversed through each sub-operation F of set O2, and the color of the image is transformed according to the application probability p and the enhancement amplitude w.
[0080] Finally, the dual-stage deformation generative adversarial network shown in this embodiment is combined to learn the synthesized agricultural pest image A', and the dataset is further expanded by generating images through the network.
[0081] Among them, the adaptive data enhancement strategy based on meta-learning:
[0082] In the field of machine learning, an excellent data augmentation strategy is crucial to improving algorithm performance. In order to select the optimal data augmentation strategy, this embodiment uses the DADA (Data Augmentation with Differentiable Augmentation) model for data augmentation, and adjusts the sampling space and sub-strategy structure for the cross-domain identification task of agricultural pests. The details are as follows:
[0083] The recognition of agricultural pest images in complex environments is set as a subtask, Resnet50 is used as the subtask recognition model, the existing agricultural pest image dataset in complex environments is used as the subtask test set, and the images enhanced by the multi-stage image domain migration method are used as the subtask training set. The application probability p and enhancement amplitude w of each enhancement operation in the multi-stage image domain migration are trainable parameters.
[0084] When constructing the search space, the original two-by-two combination enhancement method in the DADA model is difficult to simulate agricultural pest images in complex environments. Therefore, the structure of the search space is adjusted in this embodiment, and multiple data enhancement operations are connected in series to form a new operation sequence. The operation sequence can be regarded as a search space, in which each operation path represents a different data enhancement strategy, and the parameter optimization problem is provided with an unbiased gradient estimate through the RELAX estimator, and the loss can be continuously optimized through training.
[0085] In the training phase, this embodiment uses agricultural pest identification as a subtask and uses the cross entropy loss function as the performance metric of the model on this subtask. By training multiple subtasks on the meta-training set, the loss function value corresponding to each operation path is obtained, and then the feedback value of the subtask (i.e., the loss function value) is used to optimize the parameters of the search space to adjust the weight of each data enhancement operation. The operation weight is updated through the one-pass joint optimization strategy so that the result of selecting the operation in the new task can better achieve the goal. The complete training process can be expressed as follows:
[0086] (1) Forward propagation, the calculation expression is:
[0087] ;
[0088] In the formula, is the predicted value, that is, the label probability vector output by the model, F is the model forward propagation function, which is used to convert input data into prediction results. W is the model weight, which consists of the weights and biases of all layers, i is a set of data enhancement parameters, including the probability and amplitude of various transformations, X In this step, batch data is entered.X After data enhancement (by parameters i control), and through the model F The forward propagation path generates the prediction results .
[0089] (2) Loss calculation: The calculation expression is:
[0090] ;
[0091] In the formula, L is the loss function, which measures the predicted value of the model prediction and the true label vector Y The difference between the true label vector Y Each element in is the true classification label of the corresponding input data. j is the index used to traverse all output categories. In this step, the current model weight is calculated by cross entropy loss W and data augmentation parameters i The prediction error below.
[0092] (3) Backward propagation, the calculation expression is:
[0093] ;
[0094] In the formula, For the enhancement parameters i The unbiased estimated gradient of is the symbol for partial derivative, indicating the calculation of gradient, is the loss function L In the enhanced parameters i for The value of For the t The data enhancement parameters for the iteration, R is the RELAX estimator function, which is used to calculate the gradient approximation of non-differentiable data augmentation operations. Z is the random noise introduced to help R Function Estimation i The gradient of . In this step, the RELAX estimator R Combining the traditional gradient term with a random noise Z To get the data enhancement parameters i An unbiased estimate of the gradient.
[0095] (4) Parameter update, which is used to jointly update the model weights and enhancement parameters. The calculation expressions are:
[0096] ;
[0097] ;
[0098] In the formula, , are the updated model weights and data enhancement parameters, respectively. , are the model weights and data enhancement parameters of the current iteration, respectively. , are the learning rates of model weights and data enhancement parameters, respectively, used to control the step size of gradient descent, , Respectively W and i The loss gradient and unbiased estimated gradient of . In this step, the model weights W and data augmentation parameters i Updated jointly according to their own gradients and learning rates to reduce the loss in the next iteration step L .
[0099] Among them, agricultural pest image enhancement technology based on dual-stage deformation generation adversarial network:
[0100] In order to stably generate high-quality agricultural pest images, the discriminator in the generative adversarial network is improved in this embodiment, and the image screening network is trained to automatically select synthetic images. First, the TCFE module is added to the discriminator to enhance the discriminator's learning ability for complex contours, and the improved generative adversarial network is trained to synthesize agricultural pest images for data enhancement; then, in order to automatically screen out synthetic images that are conducive to data enhancement, low-quality synthetic images are screened out as negative samples through artificial visual perception, and real images are used as positive samples. The improved discriminator is retrained to perform quality assessment on synthetic images to retain high-quality synthetic images; finally, the synthetic images are added to the original data set to train the Resnet50 model for agricultural pest recognition, and the model performance is improved by expanding the data set.
[0101] Among them, TCFE module:
[0102] Since the traditional discriminator is composed of ordinary convolution, which lacks the ability to adaptively perceive local areas in the image and cannot well learn the complex contours and postures of agricultural pests, it is easy to generate distorted agricultural pest images. Therefore, this embodiment constructs a TCFE module based on deformable convolution and adds it to the discriminator.
[0103] This module improves the learning ability of the model by connecting deformable convolution with ordinary convolution in parallel. However, deformable convolution increases the complexity of the model, which is not conducive to model training. Therefore, a 1*1 convolution layer is introduced in the module to reduce the number of channels and model complexity, thereby improving the training efficiency of the model. To further improve the stability of training and the representation ability of the model, this module uses the channel attention mechanism to weight the channels output by the convolution layer to adaptively adjust the channel weights and enhance the representation ability of the model. The specific formula is as follows:
[0104] ;
[0105] First, the deformable convolution is connected in parallel with the ordinary convolution. The specific formula is as follows:
[0106] ;
[0107] in, x represents the input feature map, y represents the output feature map, and denote the operations of ordinary convolution and deformable convolution respectively, and concat (·) is the feature merging operation. In this step, the input feature map is operated by ordinary convolution and deformable convolution to obtain two different output feature maps. Then these two feature maps are added to obtain the final output feature map. y At the same time, the input and output shapes of ordinary convolution and deformable convolution need to be consistent in order to perform parallel operations. The above method makes full use of the geometric transformation ability of deformable convolution on images, increasing the diversity and authenticity of generated images.
[0108] Then the features extracted by the two convolutions are combined and input into the 1x1 convolution layer to convert the feature map y The concatenated features are fused and reduced in dimension through a 1x1 convolutional layer to obtain the final output feature map . The purpose of doing this is to make full use of the features extracted by the two convolution operations and reduce the complexity of the model. In deformable convolution, due to its deformable nature, some useless features may be captured, which may interfere with the model's learning of useful features. By using the channel attention mechanism, the model can selectively focus on important feature channels and suppress useless information, thereby improving the accuracy and generalization ability of the model. Therefore, this embodiment uses the SE module to weight feature channels, and the specific formula is as follows:
[0109] ;
[0110] in, represents the operation of the channel attention mechanism, and * represents element-by-element multiplication. In this process, the channel attention mechanism is used to Weighted, get a feature map with the same number of channels. Then multiply the weighted feature map with the feature map before concatenation element by element to get the final output feature map The feature map During the operation of the network, the classification accuracy of the discriminator can be improved, thereby improving the performance of the entire generative adversarial network, thereby achieving better image generation effects.
[0111] Among them, the image screening network:
[0112] The GAN model can sample an infinite number of noise vector inputs from a normal distribution and generate an infinite number of synthetic images. Although the GAN model can synthesize a large number of images to effectively expand the dataset, some of them will be of low quality.
[0113] In order to reduce the randomness of the quality of generated images during data enhancement and selectively add new synthetic images, this embodiment uses a discriminator to screen synthetic images. Since the discriminator after adversarial training pays more attention to the texture and detail information of the image, it will still predict a higher confidence for the deformed and distorted synthetic image, and this kind of image makes the model learn wrong information in the data enhancement task. Therefore, this study retrained the discriminator when using it for image screening. First, the discriminator weights obtained through adversarial training are loaded and regarded as pre-training; then the image is generated for artificial visual perception screening, and the deformed, distorted and blurred low-quality images are selected as negative samples, and the real image is used as the positive sample; finally, the cross entropy loss function is used to train the discriminator to judge the quality of the synthetic image. The specific formula of the model training process is as follows:
[0114] ;
[0115] in, i represents the parameters of the discriminator, Indicates i The input image is Indicates i The label of the image (0 represents a negative sample, 1 represents a positive sample), ResNet50 network pair The predicted output.
[0116] Finally, the trained discriminator is used to classify the synthetic images, and the synthetic images judged as positive samples are retained for data enhancement. This step is repeated until a specified number of synthetic images are generated.
[0117] Among them, the synthetic image screening method based on Minkowski distance:
[0118] This embodiment proposes a new similar image detection method, which is suitable for screening duplicate images in an agricultural pest image database. Compared with the traditional similar image detection method, this embodiment does not need to annotate the image, and the similarity is judged by calculating the Minkowski distance between the image reconstruction features. The specific process is to input the image to be detected into the autoencoder for encoding to obtain a low-dimensional potential feature vector representation. Then, these feature vectors are compared with the feature vectors of other images in the known image library, and the images with similarity lower than the threshold are regarded as duplicate images and removed by setting a threshold. This method not only avoids the possible errors and subjective influences in the annotation process, but also improves the accuracy and efficiency of image detection. At the same time, the screening results can be flexibly adjusted by manually setting the threshold to meet the needs of different application scenarios. This embodiment provides a new idea for the screening of similar images, which can adapt to the similarity detection tasks of synthetic image data sets and improve the accuracy and efficiency of detection.
[0119] Among them, including reconstruction similarity feature extractor:
[0120] This embodiment first uses a multi-stage image domain migration method to perform relative geometric transformation on the image, and generates pairs of similar images for training the autoencoder model to obtain the reconstruction features of the image. During the training process, the cross entropy loss function is used as the optimization target, and the output of the Conv3 layer is selected as the reconstruction feature of the image. The original image is encoded into a low-dimensional feature representation through the autoencoder model, and then decoded and reconstructed to obtain an image sample that is close to the original.
[0121] When saving an image to a new image database, this embodiment calculates the Minkowski distance between the reconstructed features of each saved image and the reconstructed features of the saved image as an evaluation index of the similarity.
[0122] The loss function of this model is as follows:
[0123] ;
[0124] Where image is the training image, pixel is the pixel value in the image, and model is the reconstruction model. The model training is guided by calculating the sum of the absolute errors between the original image and the reconstructed image to complete the image reconstruction.
[0125] ;
[0126] Among them, Aug is the data enhancement method library. The data enhancement method will be randomly selected during training. q is the amplitude of data enhancement. Similar images can be automatically generated by this method. Therefore, the value of q should not be too large. By reasonably adjusting the q value, the similarity of the screened image data set can be effectively controlled.
[0127] ;
[0128] Among them, F1 and F2 represent the reconstructed features of the original image and the enhanced image respectively, p is the hyperparameter of the Minkowski distance, which represents the balance of the weights of the Euclidean distance and the Manhattan distance. n represents the dimension of the reconstructed features. Through this method, the reconstructed distances of similar images can be made closer, further improving the detection accuracy of similar images.
[0129] To sum up, the final loss function is as follows:
[0130] ;
[0131] Among them, w is a hyperparameter used to balance the order of magnitude of the loss function to ensure the stability of training, and Loss is the total loss. The loss function is reduced through iterative training so that the model can extract the reconstruction loss that is beneficial to similar image detection.
[0132] By calculating the Minkowski distance between images, the similarity between images is judged according to the size of the distance value. Images with similarity lower than the threshold are regarded as duplicate images and removed, and images with similarity higher than the threshold are saved in the database for model training of downstream tasks.
[0133] This embodiment also includes the construction and use of the characterization library:
[0134] In order to improve the computational efficiency, this embodiment establishes a representation library of agricultural pests to store the reconstructed features of the image data set. Each time the similarity is calculated, the model can directly extract the reconstructed features from the representation library, avoiding repeated calculations and improving the detection efficiency. Through this method, the model can effectively screen duplicate images and perform efficient image comparison calculations through the representation library.
[0135] In the actual application process, it is assumed that an agricultural pest detection model needs to be developed in a new application scenario, but a data set is lacking. At this time, the method shown in this embodiment can be used to construct a data set. First, a certain number of background images in actual application scenarios need to be taken and uploaded to the system. Next, you can choose to directly synthesize new background images or use an intelligent generation solution. When selecting the intelligent generation solution, it is necessary to provide several agricultural pest images taken in actual scenes, and the enhancement parameters will be automatically adjusted according to these pictures to generate images that are closer to real agricultural pests. Then you can choose to directly obtain the data set, or use a generative adversarial network to further enhance the diversity of the data set (it is necessary to wait for a long training time for the model). Finally, this method also detects the quality and similarity of the synthesized images to ensure the quality and diversity of the large number of images generated and avoid redundancy of the data set.
[0136] Therefore, compared with the prior art, the agricultural pest image data enhancement method based on the MTS multi-network model shown in this embodiment has the following beneficial effects:
[0137] In view of the scarcity and difficulty of collecting agricultural pest image data, as well as the problem of duplicate or similar images in the enhanced data, this embodiment proposes the MTS multi-network model to expand, screen and deduplicate the agricultural pest dataset. First, through the optimized discriminator and automatic image screening network, high-quality synthetic images are screened and retained, and applied to data enhancement tasks to enhance the deep learning model's learning ability for complex contours. Secondly, the agricultural pest image synthesis method based on mask transformation merges the foreground image and the background image through a rotation transformation to generate a variety of agricultural pest images, providing richer data resources. Finally, the image screening method based on Minkowski distance is used to effectively detect and remove duplicate or similar images in the dataset, ensuring the diversity of the data.
[0138] Embodiment 2
[0139] See also Figure 2 The second embodiment of the present invention provides an agricultural pest image data enhancement system based on the MTS multi-network model, which is applied to the method described in the above technical solution, and the system includes:
[0140] A dataset creation module 10 is used to obtain agricultural pest images and create a new agricultural pest image dataset with a customized background;
[0141] An image enhancement module 20, used for performing direct enhancement and meta-learning enhancement on the agricultural pest images in the agricultural pest image dataset, and outputting agricultural pest enhanced images respectively;
[0142] An image screening module 30, configured to screen the agricultural pest enhanced image based on a preset adversarial network and output a first process image;
[0143] An image detection module 40, configured to perform quality detection on the first process image to output a second process image;
[0144] A feature extraction module 50, for extracting reconstruction features in the second process image and storing the reconstruction features in a representation library;
[0145] The data set output module 60 is used to compare the reconstructed features of the newly acquired target image with the reconstructed features stored in the characterization library, and store images greater than a preset threshold in the image library to obtain an enhanced data set of agricultural pests.
[0146] Therefore, compared with the prior art, the agricultural pest image data enhancement system based on the MTS multi-network model shown in this embodiment has the following beneficial effects:
[0147] In view of the scarcity and difficulty of collecting agricultural pest image data, as well as the problem of duplicate or similar images in the enhanced data, this embodiment proposes the MTS multi-network model to expand, screen and deduplicate the agricultural pest dataset. First, through the optimized discriminator and automatic image screening network, high-quality synthetic images are screened and retained, and applied to data enhancement tasks to enhance the deep learning model's learning ability for complex contours. Secondly, the agricultural pest image synthesis method based on mask transformation merges the foreground image and the background image through a rotation transformation to generate a variety of agricultural pest images, providing richer data resources. Finally, the image screening method based on Minkowski distance is used to effectively detect and remove duplicate or similar images in the dataset, ensuring the diversity of the data.
[0148] Embodiment 3
[0149] A third embodiment of the present invention provides a readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method described in the above embodiment is implemented.
[0150] Embodiment 4
[0151] A fourth embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the method described in the above embodiments when executing the computer program.
[0152] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" 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 invention. In this specification, the schematic representation of the above terms does not necessarily refer 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.
[0153] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for those of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A method for agricultural pest image data enhancement based on MTS multi-network model, characterized in that: The MTS multi-network model is a multi-stage image domain migration based on meta-learning, a dual-stage deformable generative adversarial network, and a multi-network model for synthetic image screening based on Minkowski distance. The method includes: Obtain agricultural pest images and create a new agricultural pest image dataset with customized backgrounds; Directly enhancing and meta-learning enhancing are respectively performed on the agricultural pest images in the agricultural pest image dataset, and agricultural pest enhanced images are respectively output; Screening the agricultural pest enhanced image based on a preset adversarial network and outputting a first process image; Performing quality detection on the first process image to output a second process image; extracting reconstruction features in the second process image, and storing the reconstruction features in a representation library; Comparing the reconstructed features of the newly acquired target image with the reconstructed features stored in the characterization library, and storing images greater than a preset threshold in the image library to obtain an enhanced dataset of agricultural pests; Among them, in the step of screening the agricultural pest enhanced image based on a preset adversarial network, the preset adversarial network is a two-stage deformable generative adversarial network, and the two-stage deformable generative adversarial network adds a TCFE module based on deformable convolution in the discriminator. The TCFE module connects the deformable convolution with the ordinary convolution in parallel, and introduces a 1*1 convolution layer. The channel of the 1*1 convolution layer output is weighted using the channel attention mechanism, and then the improved discriminator is retrained. Finally, the trained discriminator is used to classify the synthetic image, and the synthetic image judged as a positive sample is retained for data enhancement. This step is repeated until a specified number of synthetic images are generated; In the step of comparing the reconstructed features of the newly acquired target image with the reconstructed features stored in the representation library, the reconstructed features of the newly acquired target image are compared with the reconstructed features stored in the representation library by synthetic image screening based on the Minkowski distance; The steps of directly enhancing and meta-learning enhancing the agricultural pest images in the agricultural pest image dataset and outputting the agricultural pest enhanced images respectively specifically include: Using the mask image to separate the foreground image and the background image in the agricultural pest image, merging the foreground image and the new background image by dot multiplication to obtain the agricultural pest image with the new background; The agricultural pest image is transformed by using a preset data enhancement method so that the agricultural pest image is more consistent with the distribution of the target domain, and an agricultural pest enhanced image based on a direct enhancement method is obtained; The optimal data enhancement parameters are found by using an adaptive data enhancement strategy based on meta-learning, and enhanced images of agricultural pests based on meta-learning are obtained. Among them, in the step of finding the optimal data enhancement parameters by using the adaptive data enhancement strategy based on meta-learning to obtain the enhanced image of agricultural pests based on meta-learning, the training process of the enhanced model enhanced by meta-learning includes: Agricultural pest identification is used as a subtask, and the cross entropy loss function is used as the performance metric of the model in the subtask; Perform multiple subtask training on the meta-training set to obtain the loss function value corresponding to each operation path, and use the loss function value to optimize the parameters of the search space to adjust the operation weight of each data augmentation operation; And update the operation weights using a One-pass joint optimization strategy.
2. The agricultural pest image data enhancement method based on the MTS multi-network model according to claim 1 is characterized in that: The steps of using a mask image to separate a foreground image and a background image in an agricultural pest image, and merging the foreground image with a new background image by dot multiplication to obtain an agricultural pest image with a new background specifically include: Use a labeling tool to obtain a mask image corresponding to the agricultural pest image, set the pixel value of the foreground image of the mask image to 1, and set the pixel value of the background area of the mask image to 0, perform a dot product operation on the mask image and the foreground image, and obtain the agricultural pest foreground image; Constructing a geometric transformation operation set, traversing the agricultural pest foreground image through the sub-operations in the geometric transformation operation set, and determining whether to apply the sub-operation according to the application probability, and performing geometric transformation on the agricultural pest foreground image according to the enhancement amplitude; The agricultural pest foreground image after geometric transformation is merged with the background image of the target domain to obtain the agricultural pest image with a new background; Constructing a color transformation operation set, traversing each sub-operation in the color transformation operation set based on the agricultural pest image, and performing color transformation on the agricultural pest image according to the application probability and the enhancement amplitude; And the agricultural pest images are learned by combining with an adversarial network to expand the data set by generating images through the network.
3. The agricultural pest image data enhancement method based on the MTS multi-network model according to claim 1 is characterized in that: The training process of the meta-learning enhanced model specifically includes: forward propagation, loss calculation, backward propagation and parameter update.
4. The agricultural pest image data enhancement method based on the MTS multi-network model according to claim 3 is characterized in that: The forward propagation calculation expression is: ; In the formula, is the predicted value, that is, the label probability vector output by the model, F is the model forward propagation function, which is used to convert input data into prediction results. W are model parameters or weights, consisting of the weights and biases of all layers, θ is a set of data enhancement parameters, including the probability and amplitude of various transformations, X Enter data for batches; The loss calculation expression is: ; In the formula, L is the loss function, which measures the predicted value of the model prediction and the true label vector Y The difference between the true label vector Y Each element in is the true classification label of the corresponding input data. j is the index used to traverse all output categories; The calculation expression for backward propagation is: ; In the formula, For the enhancement parameters θ The unbiased estimated gradient of is the symbol for partial derivative, indicating the calculation of gradient, is the loss function L In the enhanced parameters θ for The value of For the t The data enhancement parameters for the iteration, R is the RELAX estimator function, which is used to calculate the gradient approximation of non-differentiable data augmentation operations. Z is the random noise introduced to help R Function estimation θ gradient.
5. The agricultural pest image data enhancement method based on the MTS multi-network model according to claim 4 is characterized in that: Parameter update is used to jointly update model weights and enhancement parameters; The calculation expression of model weight is: ; The calculation expression of the enhancement parameter is: ; In the formula, , are the updated model weights and data enhancement parameters, respectively. , are the model weights and data enhancement parameters of the current iteration, respectively. , are the learning rates of model weights and data enhancement parameters, respectively, used to control the step size of gradient descent, , Respectively W and θ The loss gradient and unbiased estimated gradient of .
6. An agricultural pest image data enhancement system based on MTS multi-network model, characterized in that: The method applied to any one of claims 1 to 5, wherein the system comprises: A dataset creation module is used to obtain agricultural pest images and create a new agricultural pest image dataset with a customized background; An image enhancement module, used for performing direct enhancement and meta-learning enhancement on the agricultural pest images in the agricultural pest image dataset, and outputting agricultural pest enhanced images respectively; An image screening module, used for screening the agricultural pest enhanced image based on a preset adversarial network and outputting a first process image; An image detection module, used for performing quality detection on the first process image to output a second process image; A feature extraction module, used for extracting reconstruction features in the second process image and storing the reconstruction features in a representation library; The data set output module is used to compare the reconstructed features of the newly acquired target image with the reconstructed features stored in the characterization library, and store images greater than a preset threshold in the image library to obtain an enhanced data set of agricultural pests.
7. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and capable of being executed on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
