Image classification method and system based on feature weighting and related device
Through the feature-weighted image classification method, the problem of false features in traditional agricultural disease monitoring is solved, the generalization ability and recognition effect of the model are improved, and it is suitable for the field of agricultural disease monitoring.
Patent Information
- Application Number
- CN202411033832.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-11-12
AI Technical Summary
Traditional agricultural disease monitoring relies on manual labor, has low efficiency and low accuracy, and deep learning models have a performance decline in the case of large data distribution differences, resulting in the problem of false characteristics that has not been effectively solved.
Using feature weighting-based image classification method, the false association between features is reduced through the Hilbert-Schmidt independent criterion of random Fourier features, the sample weight is learned and the classification loss is weighted, the feature extraction and classification prediction functions are updated, and the feature extraction and classification prediction functions are improved. Generalization ability of the model.
Effectively reduce the false correlation between features, enhance the ability of deep learning models to generalize disease data sets, and improve the identification effect of agricultural disease monitoring and the adaptability of models.
Smart Images

Figure CN118941868A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of generalization enhancement of agricultural disease monitoring, and in particular to an image classification method, system and related devices based on feature weighting. Background Art
[0002] Diseases are the main factors affecting agricultural production efficiency. They may cause increased agricultural production costs, waste of agricultural production resources, decreased agricultural output, decreased quality, or even no harvest. Therefore, the monitoring and prevention of agricultural diseases have always been valued and paid attention to. However, traditional agricultural disease monitoring and prevention and control mainly rely on manual labor, which has many problems such as low efficiency, low accuracy, and poor effect, so the effect is not good.
[0003] In the face of this situation, intelligent technology should be applied to agricultural disease monitoring, and the advantages of intelligent technology should be used to improve the effectiveness of agricultural disease monitoring and prevention and control, so as to effectively protect agricultural production. Technologies such as neural network deep learning provide new ways for intelligent disease detection.
[0004] However, there are currently no standards and rules for the collection of disease imaging data, so the forms of data collection are also varied. On the one hand, the data collection environment is different. Some data sets were collected on the laboratory bench. Researchers collected many plant leaves with target diseases in advance, brought them back to the laboratory, and collected data with high-definition cameras; data sets were collected on-site in the farmland. Researchers use smartphones, digital cameras and other devices to enter the field to identify and collect image data of diseases. On the other hand, even in the same data collection environment, due to complex differences in lighting, background, angle, etc., the collected data is still not uniform in style. That is, the data distribution in the data set is quite different. This distribution difference will cause the deep learning model that performs well on the training set to collapse when it encounters a test set with a large difference in data distribution.
[0005] There is a widely accepted explanation for the degradation of deep learning models in this context. Namely, the degradation of the model is caused by spurious correlations between features that arise from non-causal correlations present in the original dataset.
[0006] Therefore, in order to solve these problems in agricultural disease identification, it is necessary to propose an image classification method based on feature weighting. Summary of the invention
[0007] In view of this, the present invention provides an image classification method based on feature weighting, which can use feature weighting to reduce false correlations between features, improve the generalization ability of deep learning models for disease data sets, and transform traditional neural networks to reduce the correlations between features, so as to better adapt to the generalization tasks of agricultural disease monitoring, so as to solve the technical problems in the prior art that the false correlations between features are not paid enough attention and the non-causal correlations existing in the original data set are not correctly processed and dealt with.
[0008] In order to achieve the above technical objectives, the present invention adopts the following technical solutions:
[0009] In a first aspect, the present invention provides an image classification method based on feature weighting, comprising the following steps:
[0010] Acquire a detection image, input the detection image into a preset backbone network, and extract image features based on a feature extraction module of the backbone network;
[0011] Based on the image features, a Hilbert-Schmidt independence criterion independent statistic based on random Fourier features is used as a measure of feature correlation to generate a random Fourier measure of the features;
[0012] Simultaneously learning weights of a set of samples based on the generated characteristic random Fourier measure;
[0013] Based on the learning of the sample weights, a save and reload method is adopted, which combines and stores all the features and sample weights encountered in the training phase, and weights the classification loss to obtain a weighted loss;
[0014] Based on the final loss of the weighted loss calculation model, the feature extraction function and the classification prediction function in the backbone network are updated with the final loss;
[0015] Based on the updated feature extraction function and classification prediction function, feature extraction and classification prediction are performed on the training image again to obtain the final classification result of the image.
[0016] Furthermore, the backbone network is constructed based on the resnet-18 network model.
[0017] Furthermore, when training the network model, the dataset image is scaled so that the training image and the detection image have the same specifications before being input into the backbone network; when scaling the multi-level image, the area to be cropped is blackened; the image is randomly flipped and a random Gaussian filter is applied.
[0018] Furthermore, the Hilbert-Schmidt independence criterion measure calculation formula based on random Fourier characteristics is:
[0019]
[0020] Where u, v are random Fourier characteristic functions, which have the following form:
[0021] u(Z i )=(u1(Z i ), u1(Z i ), …u n1 (Z i )),u j (Z i )∈H RFF (3)
[0022] v(Z j )=(v1(Z j ), v2(Z j ), …v n2 (Z j )),v j (Z i )∈H RFF (4)
[0023] H RFF The function space representing random Fourier features has the following form:
[0024]
[0025] where w is taken from the standard normal distribution and φ is the uniform distribution, The Frobenius criterion is defined by the following formula:
[0026]
[0027] According to the above principle, is a non-negative number. When it is zero, the two features are independent, that is, there is no correlation.
[0028] Furthermore, sample weighting is used to process the correlation between features. After weighting, the cross-covariance matrix of the random variable part is calculated as follows:
[0029]
[0030] During the training process, w will be gradually optimized to minimize the correlation. The specific calculation formula is as follows:
[0031]
[0032] Among them, Δ B express
[0033] Furthermore, during the training process, the intermediate features generate random Fourier feature measures and learn the weights of a set of samples, which are used to weight the classification loss, while updating the representation function f(·) and the prediction function g(·) in sequence.
[0034]
[0035] The L(·,·) is the cross entropy loss function with an initial value of (1, 1, 1…, 1).
[0036] Furthermore, each training iteration is saved and reloaded, and the features and sample weights encountered in the training phase are combined and stored; the information is reloaded as global knowledge of all training data to optimize the sample weights; based on the reloaded global knowledge, weight features for optimizing each batch of samples are generated, stored in batches, and continuously updated with the iterations of training to obtain the final classification prediction results.
[0037] In a second aspect, the present invention further provides an image classification system based on feature weighting, comprising a main data preprocessing module, a feature extraction module, a classification prediction module and a weight learning module;
[0038] Based on the data preprocessing module, specific data of the training image and the test image are obtained as input of the network and input into the feature extraction module;
[0039] The feature extraction module is used to extract features from the input image, and according to the extracted image features, it is used as a classification prediction module and a weight learning module respectively;
[0040] Based on the classification prediction module, after inputting the image features, a preliminary classification result prediction is performed on the image;
[0041] Based on the weight learning module, the input image features are first subjected to feature correlation detection by the feature correlation detection module to obtain feature correlation measurement;
[0042] Based on the feature correlation detection module, the Hilbert-Schmidt independence criterion independent statistic based on random Fourier features is used as a measure of feature correlation;
[0043] While obtaining the feature correlation measure, learn a set of sample weights that will weight the classification loss;
[0044] Based on the learning of the sample weights, a save and reload method is used, which combines and stores all features and sample weights encountered during the training phase;
[0045] Based on all the saved features and sample weights, reload them as global knowledge for all trainings to optimize the sample weights;
[0046] Based on the sample weight optimization described above, the corresponding features will then be generated, and the weights of each batch will be stored in batches and continuously updated with the training iterations;
[0047] Based on the continuous update of the weight optimization described above, these weights are re-weighted to the classification loss again to calculate the final loss;
[0048] Based on the final loss, the representation function of feature extraction and the classification prediction module are updated;
[0049] Based on the classification prediction module, it is used to perform classification prediction on the extracted image features to obtain the classification result of the image.
[0050] In a third aspect, the present invention further provides a computer device, comprising a processor and a memory, wherein the memory is used to store a computer executable program, and the processor reads the computer executable program from the memory and executes it. When the processor executes the computer executable program, the feature-weighted image classification method described in the present invention can be implemented.
[0051] At the same time, a computer-readable storage medium is provided for storing a computer-readable program or instruction. When the program or instruction is executed by a processor, the steps in the feature-weighted image classification method in any of the above implementations can be implemented.
[0052] The present invention provides a method for image classification based on feature weighting. First, a data preprocessing module is used to divide a data set into a specific training set and a test set, and samples with low quality are eliminated. Secondly, based on the input training image, the image features are obtained through a feature extraction module, and a preliminary classification prediction result is generated at the same time. Finally, independent statistics based on the independent criterion of random Fourier features are performed on each pair of image features, and the statistic is calculated as a feature correlation measure. At the same time, the weights of a group of samples are learned, and the classification loss is weighted by these weights. The weights are updated with the continuous iteration of training. After that, the final loss is calculated each time the weights are updated, and the final loss is used to update the representation function of feature extraction and the classification prediction function to obtain the final classification result of the image. The method of the present invention is different from the mainstream practice of ignoring the false correlation between features in the existing agricultural disease monitoring domain generalization. Instead, it uses feature weighting, continuously updates and iterates, reduces the false correlation between features, thereby further enhancing the extraction of feature representation and the prediction of classification results, and enhancing the domain generalization ability of agricultural disease monitoring. In addition, the preset feature extraction module and backbone network in this method can be replaced by other classic related modules and networks, which greatly reduces the training cost and operation complexity of the model, making it suitable for promotion and application in practice. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 A schematic diagram of the flow of the feature-weighted image classification method provided by the present invention.
[0054] Figure 2 A schematic diagram of dividing a data set of an embodiment of a data preprocessing module provided by the present invention.
[0055] Figure 3 A structural diagram of an embodiment of a complete main network structure provided by the present invention. DETAILED DESCRIPTION
[0056] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0057] The present invention provides an image classification method and system based on feature weighting, which are respectively described below.
[0058] Combination Figure 1 As shown, a specific embodiment of the present invention discloses an image classification method based on feature weighting, comprising:
[0059] Step S101, obtaining a detection image, inputting the detection image into a preset backbone network, and extracting image features based on a feature extraction module of the backbone network;
[0060] Step S102: Based on the image features, a Hilbert-Schmidt independence criterion (HSIC) independence statistic based on random Fourier features is used as a measure of feature correlation to generate a random Fourier measure of the features;
[0061] Step S103, based on the generated random Fourier measure, simultaneously learning the weights of a group of samples;
[0062] Step S104: Based on the learned sample weights, all features and sample weights encountered in the training phase are combined and stored by a save and reload method, the sample weights are used to weight the classification loss, and the sample weights are updated with the continuous iteration of training, and the final loss is calculated at the same time;
[0063] Step S105: re-updating the feature extraction function and classification prediction function in the backbone network based on the final loss;
[0064] Step S106: Perform feature extraction and classification prediction on the training image again based on the updated feature extraction function and classification prediction function to obtain a final classification result of the image.
[0065] Compared with the prior art, the method of this embodiment first uses a feature extraction module of a preset backbone network to extract image features; secondly, the image feature correlation is measured and calculated based on the Hilbert-Schmidt independence criterion (HSIC) independence statistic of random Fourier features to obtain a measure of the image feature correlation; at the same time, a set of sample weights are learned, and a save and reload method is adopted. This method combines and stores all features and sample weights encountered in the training phase, and weights the classification loss to obtain a weighted loss; then, the feature extraction function and classification prediction function in the backbone network are re-updated based on the weighted loss; finally, based on the updated feature extraction function and classification prediction function, feature extraction and classification prediction are performed on the training image again to obtain the final classification result of the image.
[0066] The method of this embodiment is different from the mainstream approach in the existing agricultural disease monitoring domain generalization that does not pay attention to the non-causal correlations existing in the original data set. Instead, it uses an innovative neural network structure. This structure uses a feature weighting mechanism to reduce false correlations between features, improves the generalization ability of deep learning models for disease data sets, is more adaptable, and is more effectively applied to the field of agricultural disease monitoring, improving the overall monitoring and identification effects. Since it is impossible to accurately distinguish causal features from non-causal features, a conservative approach is to reduce the correlation between features to reduce the false correlations between causal features and non-causal features. This method allows the model to be trained end-to-end in a weakly supervised learning manner, which greatly reduces the training cost and operational complexity of the model, making it suitable for promotion and application in practice.
[0067] It should be noted that the above-mentioned feature-weighted image classification method can be applied to most common backbone networks for image classification, such as convolutional neural networks and their variants (such as resnet50, resnet101), Transformer networks (such as ViT, Swim-Transformer), and has strong versatility.
[0068] In some embodiments, the detected image is scaled to a uniform size and then input into the backbone network. The input image is first converted into a fixed size for subsequent processing by the model, for example, uniformly converted into a RGB three-channel color image of size 448*448.
[0069] As a preferred embodiment, the preset backbone network is constructed based on the resnet-18 network model, and the Hilbert-Schmidt independence criterion (HSIC) independence statistic based on random Fourier features is used to measure and calculate the correlation of image features to obtain a measure of the correlation of image features. At the same time, a set of sample weights are learned, and the feature representation function and classification prediction function in the backbone network are updated based on the weights.
[0070] Compared with the traditional convolutional neural network method, a new neural network structure is used. This architecture uses feature weighting to reduce the false correlation between features, improves the generalization ability of deep learning models on data sets, and transforms traditional neural networks. Since it is impossible to accurately distinguish causal features from non-causal features, the conservative approach is to reduce the correlation between features to reduce the false correlation between causal features and non-causal features. The feature extraction ability and single-domain generalization ability of the model are enhanced. The resnet-18 network can be applied to other computer vision tasks through transfer learning, making it suitable for a variety of application fields.
[0071] In a specific embodiment, the selected preset backbone network can load the pre-trained weights of the network after training on datasets such as ImageNet, and the backbone network can accelerate convergence and obtain better classification results through transfer learning.
[0072] As a preferred embodiment, the preprocessing of the dataset images includes:
[0073] The dataset from the 2018 Botanical Village competition, which contains 4 types of apple diseases, that is, the classification task has 4 categories, namely Alternaria-Boltch, Grey-spot, Mosaic, and Rust, was used as the original dataset and the following operations were performed. The entire dataset was divided into two parts according to the collection process of each data, namely laboratory data and field data. The background color of the laboratory data is relatively single, and it is usually shot with a high-resolution camera. The shooting angle is mainly frontal and will not be disturbed by other objects in the image. The field data is collected in the wild, with complex backgrounds and changing brightness. It is collected using various image acquisition tools, and the shooting angles and brightness are uneven. These two types of data are regarded as two domains. In the experiment, the laboratory data is used as the source domain for training, and the field dataset is used as the target domain for testing. Figure 2 As shown, Figure 2 A schematic diagram showing the partitioning of a data set setting embodiment of a data preprocessing module is shown;
[0074] The entire data set image is also scaled so that the specifications of the training image and the detection image before being input into the backbone network are consistent; when the multi-level background image is scaled, the area to be cropped is blackened; the image is randomly flipped and a random Gaussian filter is applied to increase the generalization of the model and prevent the model from overfitting.
[0075] As a preferred embodiment, the processed image is input into the backbone network again, and after the image feature extraction module extracts the features, the features are subjected to feature correlation processing;
[0076] At this time, it is necessary to select a statistic to represent the independence between features. The present invention adopts the Hilbert-Schmidt independence criterion (HSIC) independence statistic based on random Fourier features as a measure of feature correlation, thereby reducing the correlation of features.
[0077] As a preferred embodiment, the Hilbert-Schmidt independence criterion (HSIC) measurement calculation formula based on random Fourier features is:
[0078]
[0079] Where u, v are random Fourier characteristic functions, which have the following form:
[0080] u(Z i )=(u1(Z i ), u1(Z i ), …u n1 (Z i )),u j (Z i )∈H RFF(3)
[0081] v(Z j )=(v1(Z j ), v2(Z j ), …v n2 (Z j )),v j (Z i )∈H RFF (4)
[0082] Furthermore, H RFF The function space representing random Fourier features has the following form:
[0083]
[0084] Among them, w is taken from the standard normal distribution, and For uniform distribution;
[0085] Furthermore, The Frobenius criterion is defined by the following formula:
[0086]
[0087] According to the above principle, is a non-negative number. When it is zero, the two features are independent, that is, there is no correlation.
[0088] It should be noted that the backbone network has multiple layers to extract image features. The more layers the image passes through, the more abstract the features extracted by the network. In the process of measuring the feature correlation of the image, the image data only needs to be calculated to the middle layer in the backbone network, and then it can be processed in the module responsible for processing the feature correlation measurement, thereby saving computing resources and improving classification speed.
[0089] As a preferred embodiment, a set of sample weights are learned while performing random Fourier measurement. The learning of sample weights adopts a save and reload method, which combines and stores all features and sample weights encountered in the training phase, and weights the classification loss to obtain a weighted loss, which is then used to re-update the feature extraction function and classification prediction function in the backbone network; Figure 3 As shown, Figure 3 A schematic diagram of the structure of a complete feature weighting embodiment is shown.
[0090] In some embodiments, if the backbone network uses a convolutional neural network (CNN) as the backbone network, other methods can be used to replace the feature weighting module of resnet-18 to reflect the different levels of attention paid by the network to the correlation of detected image features. For example, the backbone network can be used to obtain the importance of different regions of the original image through the Grad-CAM or Grad-CAM++ method.
[0091] As a preferred embodiment, the feature weighting includes:
[0092] Sample weighting is used to reduce the correlation between features. After weighting, the cross-covariance matrix of the random variable part can be calculated as follows:
[0093]
[0094] Then, during the training process, w is gradually optimized to minimize the correlation. The specific calculation formula is as follows:
[0095]
[0096] Among them, Δ B express
[0097] Furthermore, during the training process, the intermediate features generate random Fourier feature measures and learn the weights of a set of samples, which will weight the classification loss and calculate the final loss, while updating the representation function f(·) and the prediction function g(·) in turn.
[0098]
[0099] Where L(·,·) is the cross entropy loss function, and its initial value is (1, 1, 1…, 1);
[0100] As a preferred embodiment, the classification result of the detection image is obtained according to the updated representation function f(·) and prediction function g(·), including:
[0101] The input features of the processed image are again subjected to the updated representation function f(·) for feature extraction, and then fed back to the updated classification prediction function g(·) to obtain the classification result of the detection image.
[0102] The present invention greatly enhances the feature extraction capability and single-domain generalization capability of the agricultural disease monitoring model by weighting the features.
[0103] In order to illustrate the method of the present invention in more detail, Figure 3 As shown, Figure 3The main processing framework of the above overall processing process is shown. First, the backbone network is selected and the generalization model of the agricultural disease monitoring domain is trained. Then, the test image is preprocessed to speed up the classification speed and improve the classification accuracy. The processed test image goes through two stages. The first stage is the image feature extraction stage, and the second stage is feature weighting. These two stages are interrelated, which enables the model to capture the features in the image more accurately while also using the intermediate features to generate random Fourier feature measures and learn the weights of a set of samples. These weights will weight the classification loss. Each time the weight is updated, the final loss is calculated and used to update the representation function and prediction function, reducing the correlation between features, thereby improving the model's feature extraction ability and single domain generalization ability. Finally, good results have been achieved in agricultural disease monitoring classification.
[0104] This embodiment also provides an image classification method system based on feature weighting, including a data preprocessing module, a feature extraction module, a classification prediction module and a weight learning module;
[0105] Based on the data preprocessing module, it is used to obtain training images, based on the data preprocessing module, obtain specific data of the training images and the test images, as input of the network, and input into the feature extraction module;
[0106] The feature extraction module is used to extract features from the input image, and according to the extracted image features, it is used as a classification prediction module and a weight learning module respectively;
[0107] Based on the classification prediction module, after inputting the image features, a preliminary classification result prediction is performed on the image;
[0108] Based on the weight learning module, the input image features are first subjected to feature correlation detection by the feature correlation detection module to obtain feature correlation measurement;
[0109] Based on the feature correlation detection module, the Hilbert-Schmidt independence criterion (HSIC) independence statistic based on random Fourier features is used as a measure of feature correlation;
[0110] While obtaining the feature correlation measure, learn a set of sample weights that will weight the classification loss to reduce the feature correlation;
[0111] Based on the learning of the sample weights, a save and reload method is used, which combines and stores all features and sample weights encountered during the training phase;
[0112] Based on all the saved features and sample weights, reload them as global knowledge for all trainings to optimize the sample weights;
[0113] Based on the sample weight optimization described above, the corresponding features will then be generated, and the weights of each batch will be stored in batches and continuously updated with the training iterations;
[0114] Based on the continuous update of the weight optimization described above, these weights are re-weighted to the classification loss again to calculate the final loss;
[0115] Based on the final loss, the representation function of feature extraction and the classification prediction module are updated;
[0116] Based on the classification prediction module, it is used to perform classification prediction on the extracted image features to obtain the classification result of the image.
[0117] On the other hand, this embodiment further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the image classification method based on feature weighting described in the present invention can be implemented.
[0118] The computer device may be a laptop computer, a desktop computer or a workstation.
[0119] The present invention can also provide a computer device, including a processor and a memory, the memory is used to store a computer executable program, the processor reads the computer executable program from the memory and executes it, and when the processor executes the computer executable program, the feature-weighted image classification method described in the present invention can be implemented.
[0120] The processor may be a central processing unit (CPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), or an off-the-shelf field programmable gate array (FPGA).
[0121] The memory described in the present invention may be an internal storage unit of a notebook computer, a desktop computer or a workstation, such as a memory or a hard disk; or an external storage unit, such as a mobile hard disk or a flash memory card.
[0122] Computer-readable storage media may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer-readable storage media may include: read-only memory (ROM), random access memory (RAM), solid-state drives (SSD) or optical disks, etc. Among them, random access memory may include resistance random access memory (ReRAM) and dynamic random access memory (DRAM)
[0123] In summary, the present invention provides an image classification method based on feature weighting. First, the data preprocessing module is used to divide the data set into a specific training set and a test set, and the samples with low quality are eliminated. Secondly, based on the input training image, the image features are obtained through the feature extraction module, and a preliminary classification prediction result is generated at the same time. Finally, each pair of image features is subjected to independent statistics based on the independent criterion of random Fourier features, and the statistic is calculated as a feature correlation measure. At the same time, the weights of a group of samples are learned, and the classification loss is weighted by these weights, and the weights are updated with the continuous iteration of training. After that, the final loss is calculated each time the weights are updated, and the final loss is used to update the representation function of feature extraction and the classification prediction function to obtain the final classification result of the image. The method of the present invention is different from the mainstream practice of ignoring the false correlation between features in the existing agricultural disease monitoring domain generalization. Instead, it uses feature weighting, continuously updates and iterates, and reduces the false correlation between features, thereby further enhancing the extraction of feature representation and the prediction of classification results, and enhancing the domain generalization ability of agricultural disease monitoring. In addition, the preset feature extraction module and backbone network in the present method can be replaced by other classic related modules and networks, which greatly reduces the training cost and operation complexity of the model, and is suitable for promotion and application in practice. And the backbone network used in the method can be replaced by other commonly used backbone networks. At the same time, the model is allowed to be trained end-to-end in a weakly supervised learning manner, which greatly reduces the training cost and operation complexity of the model. The method of the present invention overcomes the inertial thinking of the prior art, and does not adopt the mainstream approach of only focusing on the strong discrimination area of the image. Instead, it innovatively reduces the correlation problem between features by feature weighting, which greatly improves the feature extraction ability and single-domain generalization ability of the model, and has achieved good results in practical application. Therefore, the present method has the advantages of good versatility, high feasibility, and innovative and efficient.
[0124] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A feature-weighted image classification method, characterized in that: The following steps are involved: Acquire a detection image, input the detection image into a preset backbone network, and extract image features based on a feature extraction module of the backbone network; Based on the image features, a Hilbert-Schmidt independence criterion independent statistic based on random Fourier features is used as a measure of feature correlation to generate a random Fourier measure of the features; Simultaneously learning weights of a set of samples based on the generated characteristic random Fourier measure; Based on the learning of the sample weights, a save and reload method is adopted, which combines and stores all the features and sample weights encountered in the training phase, and weights the classification loss to obtain a weighted loss; Based on the final loss of the weighted loss calculation model, the feature extraction function and classification prediction function in the backbone network are updated with the final loss; Based on the updated feature extraction function and classification prediction function, feature extraction and classification prediction are performed on the training image again to obtain the final classification result of the image.
2. The image classification method based on feature weighting according to claim 1, characterized in that: The backbone network is built based on the resnet-18 network model.
3. The image classification method based on feature weighting according to claim 1, characterized in that: When training the network model, the dataset image is scaled so that the training image and the test image have the same specifications before being input into the backbone network; when scaling the multi-level image, the area to be cropped is blackened; Randomly flip the image and apply a random Gaussian filter.
4. The image classification method based on feature weighting according to claim 1, characterized in that: The Hilbert-Schmidt independence criterion measure calculation formula based on random Fourier characteristics is: Where u, v are random Fourier characteristic functions, which have the following form: u(Z i )=(u1(Z i ),u1(Z i ),…at n1 (WITH i )),at j (WITH i )∈H RFF (3) in(Z j )=(v1(Z j ),v2(Z j ),…in n2 (With j )),in j (With i )∈H RFF (4) H RFF The function space representing random Fourier features has the following form: where w is taken from the standard normal distribution and φ is the uniform distribution, The Frobenius criterion is defined by the following formula: According to the above principle, is a non-negative number. When it is zero, the two features are independent, that is, there is no correlation.
5. The image classification method based on feature weighting according to claim 1, characterized in that: Sample weighting is used to deal with the correlation between features. After weighting, the cross-covariance matrix of the random variable part is calculated as follows: During the training process, w will be gradually optimized to minimize the correlation. The specific calculation formula is as follows: Among them, Δ B express 6. The image classification method based on feature weighting according to claim 1, characterized in that: During the training process, the intermediate features generate random Fourier feature measures and learn the weights of a set of samples, which are used to weight the classification loss, while updating the representation function f(·) and the prediction function g(·) in sequence. The L(·,·) is the cross entropy loss function with an initial value of (1, 1, 1…, 1).
7. The image classification method based on feature weighting according to claim 6, characterized in that: Each training iteration is saved and reloaded to combine and store the features and sample weights encountered during the training phase; the information is reloaded as global knowledge of all training data to optimize the sample weights; based on the reloaded global knowledge, weight features for optimizing each batch of samples are generated, stored in batches, and continuously updated with the iterations of training to obtain the final classification prediction results.
8. A feature-weighted image classification system, characterized in that: It includes main data preprocessing module, feature extraction module, classification prediction module and weight learning module; Based on the data preprocessing module, specific data of the training image and the test image are obtained as input of the network and input into the feature extraction module; The feature extraction module is used to extract features from the input image, and according to the extracted image features, it is used as a classification prediction module and a weight learning module respectively; Based on the classification prediction module, after inputting the image features, a preliminary classification result prediction is performed on the image; Based on the weight learning module, the input image features are first subjected to feature correlation detection by the feature correlation detection module to obtain feature correlation measurement; Based on the feature correlation detection module, the Hilbert-Schmidt independence criterion independent statistic based on random Fourier features is used as a measure of feature correlation; While obtaining the feature correlation measure, learn a set of sample weights that will weight the classification loss; Based on the learning of the sample weights, a save and reload method is used, which combines and stores all features and sample weights encountered during the training phase; Based on all the features and sample weights saved, reload them as global knowledge for all training and optimize the sample weights; Based on the sample weight optimization described above, the corresponding features will then be generated, and the weights of each batch will be stored in batches and continuously updated with the training iterations; Based on the continuous update of the weight optimization described above, these weights are re-weighted to the classification loss again to calculate the final loss; Based on the final loss, the representation function of feature extraction and the classification prediction module are updated; Based on the classification prediction module, it is used to perform classification prediction on the extracted image features to obtain the classification result of the image.
9. A computer device, characterized in that: It includes a processor and a memory, the memory is used to store a computer executable program, the processor reads part or all of the computer executable program from the memory and executes it, and when the processor executes part or all of the computer executable program, it can implement the steps in the feature-weighted image classification method described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Used to store computer-readable programs or instructions, which, when executed by a processor, can implement the steps of the feature-weighted image classification method described in any one of claims 1 to 7.
