Unsupervised Hash agricultural disease and insect pest image retrieval method based on discriminant quantization code words

Through the unsupervised hashing method based on discriminant quantized codewords, combined with linear fully connected layer and multi-scale feature fusion module, the problem of small differences between classes in pest and pest images is solved, and efficient unsupervised pest and pest image retrieval is achieved, which improves agriculture Efficiency and accuracy of pest diagnosis.

CN119025700AActive Publication Date: 2024-11-26SANYA SCI & EDUCATION INNOVATION PARK WUHAN UNIV OF TECH

Patent Information

Application Number
CN202411505148.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2024-11-26
Estimated Expiration
2044-10-28

AI Technical Summary

Technical Problem

The existing supervised hash retrieval method is difficult to extract key discriminant information under the characteristics of small differences between classes and large differences within classes in pest and disease images, and the lack of a large amount of label data, resulting in insufficient model performance.

Method used

Unsupervised hashing agricultural pest and disease image retrieval method based on discriminative quantized codewords is adopted, and the feature extraction network, discriminative selection quantized feature reconstruction module and quantitative reconstruction feature storage container are used, combined with linear fully connected layer and multi-scale feature fusion module to reduce Influence of redundant information, design codeword diversity maintains loss terms and cross-entropy loss terms to improve model performance.

Benefits of technology

It realizes efficient pest and disease image retrieval under the lack of label information, improves the efficiency and accuracy of agricultural pest and disease diagnosis, and enhances the model's ability to distinguish positive and negative samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119025700A_ABST
    Figure CN119025700A_ABST
Patent Text Reader

Abstract

The invention provides an unsupervised Hash agricultural disease and insect pest image retrieval method based on discriminant quantized code words, and belongs to the technical field of image retrieval. The unsupervised Hash agricultural disease and insect pest image retrieval method comprises the following steps: constructing an unsupervised Hash disease and insect pest image retrieval model based on the discriminant quantized code words; in the model, a linear full connection layer and a multi-scale feature fusion module are adopted to enable extracted features to have global and local feature information, and a discriminant selection quantization feature reconstruction module is adopted to reduce the influence of redundant information on the validity of quantization code words, so that more discriminant quantization reconstruction features are obtained; the diversity of the code words is designed to keep loss items, so that the independence between the code words is continuously restrained in the model training process, the distinguishing capability of the cross loss enhancement model on positive and negative samples based on soft quantization reconstruction characteristics is further designed, the performance of the model is improved, and pest image retrieval under the condition of lack of a large number of pest tags can be realized; and the efficiency and precision of agricultural pest diagnosis are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image retrieval, and in particular to an unsupervised hash agricultural pest image retrieval method based on discriminative quantization codewords. Background Art

[0002] Crops have always been one of the keys to ensuring people's livelihoods. Many interfering factors such as diseases or pests can easily pose a serious threat to crop growth. As a means of assisting in the diagnosis of diseases or pests, deep hash pest image retrieval has the ability to quickly retrieve the same type of diseases or pests from massive data, which can effectively help prevent and control crop diseases and pests. With the development of artificial intelligence technology and the continuous accumulation of pest image data, the field of deep hash pest image retrieval has also received more and more attention and research.

[0003] Although some supervised hash retrieval methods can learn good image features through deep learning models under the guidance of semantic information of labels, pest images have the characteristics of small inter-class differences and large intra-class differences, which makes it difficult for supervised retrieval methods to extract features with key discriminant information. Moreover, in actual production, there is usually a lack of a large number of pest labels, and it is time-consuming and labor-intensive to obtain labels for a large number of pest image sample data. In order to reduce the model's dependence on data labels, how to implement an unsupervised pest hash retrieval algorithm without label information guidance has become a very important task. Summary of the invention

[0004] In view of the technical problems such as limited prior data in the supervised hash retrieval method in the prior art, the present invention provides an unsupervised hash agricultural pest and disease image retrieval method based on discriminant quantization codewords, which can effectively improve the performance of the model.

[0005] The first aspect of the present invention provides an unsupervised hash agricultural pest image retrieval method based on discriminative quantization codewords, comprising: Step S1, collecting pest and disease image datasets and preprocessing the pest and disease datasets; Step S2, constructing an unsupervised hash agricultural pest image retrieval model based on discriminative quantization codewords, the model includes a feature extraction network, a discriminative selection quantization feature reconstruction module and a quantization reconstruction feature storage container; the discriminative selection quantization feature reconstruction module includes a codebook attention quantizer and a discriminative selection reconstruction module, which is used to reconstruct the quantization feature of the extracted image feature z∈R^D, specifically including: (1) Image features Divide into M sub-vectors of the same dimension, that is, , , d = D / M; then, each sub-feature vector is quantized using the vector quantization method to obtain a sub-codebook containing M , where each sub-codebook Include There are K code words in total, and each sub-codebook Corresponding to a subvector ; (2) Perform normalization operation on each sub-vector and codeword, which can be expressed by the following formula:

[0006]

[0007] Then, each sub-vector is quantized by codebook attention. The quantization process of the sub-vector can be expressed by the following formula:

[0008] In the formula, AttQ represents the codebook attention quantization operation, represents the attention score of the i-th codeword in the m-th sub-codebook, which is calculated by the following formula:

[0009]

[0010] The attention score of each codeword is calculated by Operations are concatenated, and then each sub-codebook To splice, is the soft quantization codeword of the training sample; (3) For the mth subcodebook , in descending order to their corresponding attention scores Sort and select the index of the first ξ attention score to generate the attention mask sequence , and define:

[0011] The corresponding mask With attention score Multiply and normalize, that is , get the final codeword attention score ; Recalculate the reconstructed features based on the processed attention scores, and perform feature concatenation to obtain soft quantized reconstructed features. The specific formula is as follows:

[0012] .

[0013] Step S3, training the model using a loss function, and updating the pest and disease image retrieval model through a back propagation algorithm; Step S4, input the image to be retrieved into the trained pest image retrieval model, and output the pest image data related thereto.

[0014] Furthermore, the collected pest and disease image datasets include the New Plant Disease dataset, the New PlantDiseases Dataset, and the Crop pest and disease dataset, which are divided into training sets and test sets in a ratio of 7:3 for each category for model training, reasoning, and retrieval evaluation.

[0015] Furthermore, the preprocessing of the pest and disease dataset in step S1 includes: Each image x_d in the pest and disease training dataset is preprocessed by two different data augmentation operations f_1 and f_2. Each augmentation operation is combined with random cropping of the image to 224×224 pixels, with the cropping scale randomly selected between 0.5 and 1.0, adjusting the image color, converting the image to grayscale with a probability of 0.2, and applying Gaussian blur.

[0016] Furthermore, the feature extraction network is used to extract the disease or pest image as the input of the proposed IAMF model. ; The network first uses the improved pre-trained ResNet-18 model to extract local features of the image, and then inputs the acquired local features into the linear fully connected layer and the multi-scale feature fusion module respectively; The linear fully connected layer extracts the global features of the image based on the acquired local features; The multi-scale feature fusion module extracts the multi-scale features of the same type of lesions in the disease or pest images, and then based on the extracted multi-scale features, further captures more inter-class discrimination information through the interactive perception attention module, thereby solving the problem of small inter-class differences; then, through the multi-level feature fusion module, the global information and local information are fused to fully explore the complementary information between global and local features.

[0017] Furthermore, a quantized reconstruction feature storage container module is used to store a large number of negative samples and update them during the training process, specifically including: After multiple rounds of warm-up training, the soft quantization codewords of any training batch data in any round are randomly selected. Initialize the storage container , at each training batch stage, from the storage container The stored soft quantization codebook is taken out, and then the corresponding reconstructed features are obtained by discriminating and selecting the quantization feature reconstruction module And constrain the storage container through the loss function The relationship between negative samples and anchor images; After each training batch, the storage container Update as a queue, add the soft quantization codewords of the current batch into the queue, and remove the soft quantization codewords initially stored from the queue; store the quantization reconstruction feature storage container The capacity is set to a multiple of the batch size Num.

[0018] Furthermore, in step S3), the loss function L includes a decoupled contrast loss term , codeword diversity preservation loss term and the cross entropy loss term based on soft quantization reconstruction features , the total loss function L of the model is expressed as:

[0019] in, and They represent the hyperparameters that control the codeword diversity preservation term and the cross entropy loss weight based on soft quantization reconstruction features.

[0020] Furthermore, the calculation formula of the decoupled contrast loss term is:

[0021]

[0022]

[0023] In the formula and They represent the sum of the similarities between the current sample and the negative sample in the current quantized reconstruction feature storage container, and the sum of the similarities between the current sample and the negative sample in the current batch; Indicates the similarity between the current sample and the positive sample; is a positive example prior used to correct the bias of erroneous negative samples; Sim represents the similarity measure, q, -and Represent the indexes of anchor samples, negative samples, and positive samples respectively; Represents the negative sample index in the quantized reconstructed feature storage container.

[0024] Furthermore, the calculation formula of the codeword diversity preservation loss term is:

[0025] in, represents the average similarity between codewords, represents the diversity among quantization codewords, is a hyperparameter that controls the weight of the average similarity term between codewords; and Calculated by the following formula:

[0026]

[0027] Where M and K represent the number of sub-codebooks and the number of codewords in the sub-codebooks, respectively. represents the jth codeword of the mth codebook, T is the matrix transpose, represents the i-th codeword of the m-th codebook, represents; E represents the identity matrix.

[0028] Furthermore, the calculation formula of the cross entropy loss term based on the soft quantization reconstruction feature is:

[0029] in, Represent the soft quantization reconstruction features of anchor samples and positive samples respectively, and Represent the soft quantization codewords of anchor point samples and positive samples respectively.

[0030] In a second aspect of the present invention, the present invention provides a computer-readable storage medium storing a computer program, characterized in that when the computer program is executed by a processor, any one of the methods in the first aspect is implemented.

[0031] The invention provides an unsupervised hash agricultural pest image retrieval method based on discriminative quantization codewords, belonging to the technical field of image retrieval. The invention constructs an unsupervised hash agricultural pest image retrieval model based on discriminative quantization codewords. A linear full connection layer and a multi-scale feature fusion module are adopted in the model so that the extracted features have both global and local feature information. A discriminative selection quantization feature reconstruction module is adopted to reduce the influence of redundant information on the effectiveness of quantization codewords, so as to obtain more discriminative quantization reconstruction features. The loss term is maintained by designing codeword diversity, so that the independence between codewords is continuously constrained during model training. A cross loss enhancement model based on soft quantization reconstruction features is designed to distinguish positive and negative samples, thereby improving the performance of the model, helping to realize the retrieval of pest image in the absence of a large number of pest labels, and improving the efficiency and accuracy of agricultural pest diagnosis. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1It is a simplified flow chart of the unsupervised hashing agricultural pest image retrieval method based on discriminative quantization codewords; Figure 2 Schematic diagram of the network structure for unsupervised quantitative pest and disease image retrieval. DETAILED DESCRIPTION

[0033] The following will be combined with the drawings in the embodiments of the present application to further clearly and completely describe the technical solutions in the embodiments of the present application. It should be noted that the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of this application.

[0034] In order to make the invention objectives, technical solutions and advantages of the present application clearer, the embodiments of the present application are further described in detail in conjunction with the drawings in the specification: In order to more clearly understand the above-mentioned objects, features and advantages of the present invention, the advantages of the present invention will be further illustrated by comparing the embodiments in conjunction with the drawings and specific implementation methods.

[0035] like Figure 1 As shown, in an embodiment of the present invention, the present invention provides an unsupervised hash agricultural pest image retrieval method based on discriminative quantization codewords, comprising: Step S1, collecting pest and disease image datasets and preprocessing the pest and disease datasets; Step S2, constructing an unsupervised hash agricultural pest image retrieval model based on discriminative quantization codewords, the model comprising a feature extraction network, a discriminative selection quantization feature reconstruction module and a quantization reconstruction feature storage container; Step S3, training the model using a loss function, and updating the pest and disease image retrieval model through a back propagation algorithm; Step S4, input the image to be retrieved into the trained pest image retrieval model, and output the pest image data related thereto.

[0036] In this embodiment, after collecting the pest image dataset, the training set, validation set and test set are divided according to the proportion, which are used for subsequent model training, verification and evaluation. The pest image dataset obtained in this embodiment includes three pest image datasets, namely the New Plant Disease dataset, the New Plant Diseases Dataset dataset and the Crop pest and disease dataset, which are divided into training set, validation set and test set according to the ratio of 6:2:2 for each category, and are used for subsequent model training, reasoning and retrieval evaluation.

[0037] In this embodiment, preprocessing the pest and disease dataset in step S1 includes: Each image x_d in the pest and disease training dataset is preprocessed by two different data augmentation operations f_1 and f_2. Each augmentation operation is combined with random cropping of the image to 224×224 pixels, with the cropping scale randomly selected between 0.5 and 1.0, adjusting the image color, converting the image to grayscale with a probability of 0.2, and applying Gaussian blur.

[0038] In this embodiment, an unsupervised hash pest image retrieval method model based on discriminative quantization codewords is constructed, and the model structure is as follows: Figure 2 As shown, the model includes a feature extraction network, a discriminative selection and quantization feature reconstruction module, and a quantization and reconstruction feature storage container.

[0039] Among them, the feature extraction network is used to extract image features based on the input pest and disease image The network first uses the improved pre-trained ResNet-18 model to extract local features of the image, and then inputs the acquired local features into the linear fully connected layer and the multi-scale feature fusion module respectively; the linear fully connected layer extracts the global features of the image based on the acquired local features; the multi-scale feature fusion module extracts the multi-scale features of the same type of lesions in the disease or pest image, and then based on the extracted multi-scale features, further captures more inter-class discrimination information through the interactive perception attention module, thereby solving the problem of small inter-class differences; then, through the multi-level feature fusion module, the global information and local information are fused to fully explore the complementary information between global and local features.

[0040] In this embodiment, the discriminant selection quantized feature reconstruction module includes a codebook attention quantizer and a discriminant selection reconstruction module, which is used to reconstruct the quantized features of the extracted image features z∈R^D, specifically including: (1) Image features Divide into M sub-vectors of the same dimension, that is, , , d = D / M. Then, each sub-feature vector is quantized using the vector quantization method to obtain a sub-codebook containing M , where each sub-codebook Include There are K code words in total, and each sub-codebook Corresponding to a subvector However, this process is based on clustering and therefore cannot be trained via back-propagation in deep learning models.

[0041] (2) Perform normalization operation on each sub-vector and codeword, which can be expressed by the following formula:

[0042]

[0043] Then, each sub-vector is quantized by codebook attention. The quantization process of the sub-vector can be expressed by the following formula:

[0044] Among them, AttQ represents the codebook attention quantization operation, represents the attention score of the i-th codeword in the m-th sub-codebook, which is calculated by the following formula:

[0045]

[0046] represents the attention score of the ith codeword in the mth subcodebook, and the attention score of each codeword is calculated by Operations are concatenated, and then each sub-codebook To splice, is the soft quantization codeword of the training sample.

[0047] In order to reduce the noise gradient interference generated by irrelevant codewords during the network optimization process, the present invention proposes a discriminative selective reconstruction structure, which further selectively reconstructs each sub-vector quantized by the codebook attention operation to obtain more discriminative quantized reconstruction features.

[0048] For the mth subcodebook , in descending order to their corresponding attention scores Sort and select the index of the first ξ attention score to generate the attention mask sequence , and define:

[0049] Then, by applying the corresponding mask With attention score Multiply and normalize, that is , get the final codeword attention score The reconstructed features are recalculated based on the processed attention scores, and feature concatenation is performed to obtain soft quantized reconstructed features. The specific formula is as follows:

[0050] .

[0051] In this embodiment, the quantized reconstruction feature storage container is used to store a large number of negative samples and update them during the training process. There is a storage container-based method that caches a large number of samples and uses them as negative samples, but as the model is continuously updated during the training process, the negative samples cached in the early stage will have a negative impact on the model. Therefore, the unsupervised quantization method follows XBM and introduces a quantized reconstruction feature storage container to store a large number of negative samples and update them during the training process.

[0052] In this embodiment, a quantized reconstruction feature storage container is used. storage The specific process is as follows: After several rounds of warm-up training, the soft quantization codewords of any training batch data in any round are randomly selected. Initialize the storage container , at each training batch stage, from the storage container Take out the stored soft quantization codebook, and then use the above formula to get the corresponding reconstruction feature And constrain the storage container through the loss function The relationship between negative samples and anchor images.

[0053] After each training batch, the storage container As a queue, the soft quantization codewords of the current batch are queued and the soft quantization codewords initially stored are dequeued. In the proposed model, the quantization reconstruction feature storage container The capacity is set to a multiple of the batch size Num.

[0054] like Figure 2 As shown in the figure, the model takes two enhanced views of a pest image as positive sample pairs as input, extracts image features through the model and obtains quantized reconstructed features. At the same time, the model stores the quantized reconstructed features of other pest images in a batch in the quantized reconstructed feature storage container as negative samples. Under the constraints of the loss function, the model weight parameters are optimized, and the final output of the model training process is a model with optimized parameters.

[0055] The loss function in step S3) includes a similarity preservation term, a cross entropy loss term and a quantization error term. During the model training process, it can not only maintain the similarity between images in the original RGB space, but also reduce the gap between the predicted category and the true category, and reduce the impact of the quantization error generated in the process of network mapping hash codes on the model retrieval performance.

[0056] In order to learn a better quantization reconstruction feature detector, the model in this embodiment uses an objective function to constrain the contrastive learning of the distance between positive pairs and negative pairs. The objective function contains three items: a decoupled contrast loss term, a codeword diversity loss term, and a cross-entropy loss term based on soft quantization reconstruction features. Among them, the decoupled contrast loss term is the basic contrast loss in the field of contrastive learning, which assists the network in learning the distance between positive and negative samples and anchor samples, while reducing the negative impact of erroneous negative samples in contrastive learning on the performance of the method; the codeword diversity preservation loss term aims to enhance the discriminability and effectiveness of quantization codewords by maintaining the independence between codewords, and avoid suboptimal retrieval performance caused by model degradation problems; the cross-entropy loss term based on soft quantization reconstruction features further focuses on the deterministic prediction of positive samples, making the distribution of positive samples more concentrated.

[0057] Next, we will introduce the three loss terms in detail.

[0058] (1) Decoupled contrast loss term The unsupervised hash agricultural pest image retrieval model based on discriminative quantization code proposed in this embodiment is based on a contrastive learning framework. Since the input data of the model is randomly selected from a large amount of unlabeled data, it is inevitable to introduce erroneous negative samples, which affects the contrastive learning framework to learn the relationship between positive and negative samples and anchor samples. At the same time, in order to solve the problem that simple positive sample pairs and simple negative sample pairs reduce the efficiency of contrastive learning, a decoupled contrast loss term is introduced in this embodiment, which can be expressed by the following formula:

[0059]

[0060]

[0061] In the formula and They represent the sum of the similarities between the current sample and the negative sample in the current quantized reconstruction feature storage container, and the sum of the similarities between the current sample and the negative sample in the current batch; Indicates the similarity between the current sample and the positive sample; is a positive example prior used to correct the bias of erroneous negative samples; Sim represents the similarity measure, q, -and Represent the indexes of anchor samples, negative samples, and positive samples respectively; Represents the negative sample index in the quantized reconstructed feature storage container.

[0062] (2) Codeword diversity preservation loss In order to maintain the independence of codewords in the same codebook and effectively learn the quantized codeword representation of pest and disease images, a novel codeword diversity preservation loss term is introduced. First, the average similarity between codewords is defined as:

[0063] Then, in the proposed model, the diversity among quantization codewords is defined as :

[0064] Finally, the codeword diversity preservation loss term combines the two formulas to optimize the network model, so the codeword diversity preservation loss term can be expressed by the following formula:

[0065] In the first formula, M and K represent the number of subcodebooks and the number of codewords in the subcodebooks, respectively. represents the jth codeword of the mth codebook, represents the i-th codeword of the m-th codebook; in the second formula, E represents the identity matrix; in the third formula, is a hyperparameter that controls the weight of the average similarity term between codewords.

[0066] (3) Cross entropy loss term based on soft quantization reconstruction features In order to strengthen the alignment between positive example pairs, the model pays more attention to the deterministic prediction of positive samples in the comparative retrieval task, and enhances the model's ability to distinguish between positive and negative samples. The soft quantization codewords of the anchor samples are used in this loss to predict the reconstruction features of the positive samples. At the same time, the soft quantization codewords of the positive samples are used to predict the reconstruction features of the soft anchor samples. The cross entropy loss term based on the soft quantization reconstruction features can be expressed by the following formula:

[0067] In the above formula, Represent the soft quantization reconstruction features of anchor samples and positive samples respectively, and Represent the soft quantization codewords of anchor point samples and positive samples respectively.

[0068] Taking the above three loss terms into consideration, the overall objective function of the model can be expressed as follows:

[0069] in, and They represent the hyperparameters that control the codeword diversity preservation term and the cross entropy loss weight based on soft quantization reconstruction features.

[0070] In a second embodiment of the present invention, the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-mentioned unsupervised hash agricultural pest and disease image retrieval method based on discriminative quantization codewords.

[0071] The invention provides an unsupervised hash agricultural pest image retrieval method based on discriminative quantization codewords, belonging to the technical field of image retrieval. The invention constructs an unsupervised hash agricultural pest image retrieval model based on discriminative quantization codewords. A linear full connection layer and a multi-scale feature fusion module are adopted in the model so that the extracted features have both global and local feature information. A discriminative selection quantization feature reconstruction module is adopted to reduce the influence of redundant information on the effectiveness of quantization codewords, so as to obtain more discriminative quantization reconstruction features. The loss term is maintained by designing codeword diversity, so that the independence between codewords is continuously constrained during model training. A cross loss enhancement model based on soft quantization reconstruction features is designed to distinguish positive and negative samples, thereby improving the performance of the model, helping to realize the retrieval of pest image in the absence of a large number of pest labels, and improving the efficiency and accuracy of agricultural pest diagnosis.

[0072] In addition, it should be understood that although the present specification is described according to implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.

Claims

1. An unsupervised hash agricultural pest image retrieval method based on discriminative quantization codewords, characterized in that: include: Step S1, collecting pest and disease image datasets and preprocessing the pest and disease datasets; Step S2, constructing an unsupervised hash agricultural pest image retrieval model based on discriminative quantization codes, wherein the model includes a feature extraction network, a discriminative selection quantization feature reconstruction module, and a quantization reconstruction feature storage container; The discriminant selection quantized feature reconstruction module includes a codebook attention quantizer and a discriminant selection reconstruction module, which is used to reconstruct the quantized features of the extracted image features z∈R^D, specifically including: (1) Image features Divide into M sub-vectors of the same dimension, that is, , , d = D / M; then, each sub-feature vector is quantized using the vector quantization method to obtain a sub-codebook containing M , where each sub-codebook Include There are K code words in total, and each sub-codebook Corresponding to a subvector ; (2) Perform normalization operation on each sub-vector and codeword, which can be expressed by the following formula: ; ; Then, each sub-vector is quantized by codebook attention. The quantization process of the sub-vector can be expressed by the following formula: ; In the formula, AttQ represents the codebook attention quantization operation, represents the attention score of the i-th codeword in the m-th sub-codebook, which is calculated by the following formula: ; ; The attention score of each codeword is calculated by Operations are concatenated, and then each sub-codebook To splice, is the soft quantization codeword of the training sample; (3) For the mth subcodebook , in descending order to their corresponding attention scores Sort and select the index of the first ξ attention score to generate the attention mask sequence , and define: ; The corresponding mask With attention score Multiply and normalize, that is , get the final codeword attention score ; Recalculate the reconstructed features based on the processed attention scores, and perform feature concatenation to obtain soft quantized reconstructed features. The specific formula is as follows: ; ; Step S3, training the model using a loss function, and updating the pest image retrieval model through a back propagation algorithm; Step S4, input the image to be retrieved into the trained pest image retrieval model, and output the pest image data related thereto.

2. According to claim 1, an unsupervised hash agricultural pest image retrieval method based on discriminative quantization codewords is characterized in that: The collected pest and disease image datasets include the New Plant Disease dataset, the NewPlant Diseases Dataset, and the Crop pest and disease dataset, which are divided into training set, validation set, and test set in a ratio of 6:2:2 for each category, and are used for subsequent model training, reasoning, and retrieval evaluation.

3. The unsupervised hash agricultural pest image retrieval method based on discriminative quantization codewords according to claim 2 is characterized in that: The preprocessing of the pest and disease dataset in step S1 includes: Each image x_d in the pest and disease training dataset is preprocessed by two different data augmentation operations f_1 and f_2. Each augmentation operation is combined with random cropping of the image to 224×224 pixels, with the cropping scale randomly selected between 0.5 and 1.0, adjusting the image color, converting the image to grayscale with a probability of 0.2 and applying Gaussian blur.

4. The unsupervised hash agricultural pest image retrieval method based on discriminative quantization codewords according to claim 1 is characterized in that: The feature extraction network first uses an improved pre-trained ResNet-18 model to extract local features of the image, and then inputs the acquired local features into a linear fully connected layer and a multi-scale feature fusion module respectively; The linear fully connected layer extracts the global features of the image based on the acquired local features; The multi-scale feature fusion module extracts the multi-scale features of the same type of lesions in the disease or pest images, and then based on the extracted multi-scale features, further captures more inter-class discrimination information through the interactive perception attention module, thereby solving the problem of small inter-class differences; then, through the multi-level feature fusion module, the global information and local information are fused to fully explore the complementary information between global and local features.

5. The unsupervised hash agricultural pest image retrieval method based on discriminative quantization codewords according to claim 1 is characterized in that: The quantized reconstruction feature storage container module is used to store a large number of negative samples and update them during the training process, specifically including: After multiple rounds of warm-up training, the soft quantization codewords of any training batch data in any round are randomly selected. Initialize the storage container , at each training batch stage, from the storage container The stored soft quantization codebook is taken out, and then the corresponding reconstructed features are obtained by discriminating and selecting the quantization feature reconstruction module And constrain the storage container through the loss function The relationship between negative samples and anchor images; After each training batch, the storage container Update as a queue, add the soft quantization codewords of the current batch into the queue, and remove the soft quantization codewords initially stored from the queue; store the quantization reconstruction feature storage container The capacity is set to a multiple of the batch size Num.

6. The unsupervised hash agricultural pest image retrieval method based on discriminative quantization codewords according to claim 1 is characterized in that: The loss function L in step S3) includes , codeword diversity preservation loss term and the cross entropy loss term based on soft quantization reconstruction features , the total loss function L of the model is expressed as: ; in, and They represent the hyperparameters that control the codeword diversity preservation term and the cross entropy loss weight based on soft quantization reconstruction features.

7. The unsupervised hash agricultural pest image retrieval method based on discriminative quantization codewords according to claim 6 is characterized in that: The calculation formula of the decoupled contrast loss term is: ; ; ; In the formula and They represent the sum of the similarities between the current sample and the negative sample in the current quantized reconstruction feature storage container, and the sum of the similarities between the current sample and the negative sample in the current batch; Indicates the similarity between the current sample and the positive sample; is a positive example prior used to correct the bias of erroneous negative samples; Sim represents the similarity measure, q, -and Represent the indexes of anchor samples, negative samples, and positive samples respectively; Represents the negative sample index in the quantized reconstructed feature storage container.

8. The unsupervised hash agricultural pest image retrieval method based on discriminative quantization codewords according to claim 6 is characterized in that: The calculation formula of the codeword diversity preservation loss term is: ; in, represents the average similarity between codewords, represents the diversity among quantization codewords, is a hyperparameter that controls the weight of the average similarity term between codewords; and Calculated by the following formula: ; ; Where M and K represent the number of sub-codebooks and the number of codewords in the sub-codebooks, respectively. represents the jth codeword of the mth codebook, T represents transposition, represents the i-th codeword of the m-th codebook, represents; E represents the identity matrix.

9. The unsupervised hash agricultural pest image retrieval method based on discriminative quantization codewords according to claim 6 is characterized in that: The calculation formula of the cross entropy loss term based on soft quantization reconstruction features is: ; in, Represent the soft quantization reconstruction features of anchor samples and positive samples respectively, and Represent the soft quantization codewords of anchor point samples and positive samples respectively.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Large-scale image library retrieval method based on local similarity hash algorithm

    CN104199922A

  • Zero-sample hash retrieval method based on ensemble learning

    CN112364192A

  • Crop disease and pest image retrieval method and device

    CN117033687A

Cited By

  • Agricultural disease hash retrieval method based on DV stabilization and adaptive feature enhancement

    CN121278128A