Image classification method based on attention mechanism and knowledge distillation

By introducing attention mechanisms and knowledge distillation technologies in image classification methods, build teachers and student models, and through historical training image transmission classification standards, the accuracy and generalization of traditional image classification methods in complex scenarios and large -scale data are solved The problem of insufficient ability achieves higher classification accuracy and reliability.

CN118762248BActive Publication Date: 2025-01-28YANCHENG INST OF TECH +1

Patent Information

Application Number
CN202410736731.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2025-01-28
Estimated Expiration
2044-06-07

AI Technical Summary

Technical Problem

Traditional image classification methods have low accuracy and weak generalization capabilities when processing complex scenarios and large-scale data, resulting in poor classification results.

Method used

Adopting image classification methods based on attention mechanisms and knowledge distillation, by building a teacher model and student model, and using historical training images to train the teacher model to ensure the accuracy of the teacher model. Then, the attention mechanism and student model packaging, and training the packaging results through the teacher model and historical training image, pass the image classification standards and strategies, and improve the processing effect of the student model.

Benefits of technology

It improves the accuracy and effect of the processing of classified images, ensure the accuracy and reliability of the classification results, and enhance the image classification ability of complex scenarios and large -scale data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118762248B_ABST
    Figure CN118762248B_ABST
Patent Text Reader

Abstract

The present invention provides an image classification method based on attention mechanism and knowledge distillation, including: constructing a teacher model and a student model, and performing a first training on the teacher model based on historical training images; encapsulating the attention mechanism and the student model, and performing a second training on the encapsulated result based on the first training result and the historical training images to obtain an image classification prediction model; analyzing and processing the image to be classified based on the image classification prediction model to obtain an image classification result of the image to be classified. The image classification prediction model obtained by training analyzes and processes the image to be classified, thereby achieving accurate and effective classification of the image to be classified, and ensuring the accuracy and reliability of the classification result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to an image classification method based on attention mechanism and knowledge distillation. Background Art

[0002] Image classification is a core task in the computer field. It is to automatically assign input images to one or more predefined categories. With the rapid development of deep learning and computing power, image classification technology has made significant progress and also facilitated other fields such as medical image analysis, autonomous driving, intelligent monitoring and augmented reality.

[0003] However, traditional image classification methods still have some problems when dealing with complex scenes and large-scale data, such as low accuracy and weak generalization ability, which greatly reduces the classification effect of images;

[0004] Therefore, in order to overcome the above defects, the present invention provides an image classification method based on attention mechanism and knowledge distillation. Summary of the invention

[0005] The present invention provides an image classification method based on attention mechanism and knowledge distillation, which is used to construct a teacher model and a student model, and first train the teacher model through historical training images to ensure that the teacher model can accurately obtain a mechanism for classifying images. Secondly, by encapsulating the attention mechanism and the student model, it is convenient to lock the key features and key image areas of the image to be classified through the attention mechanism, so as to improve the accuracy and effect of the student model in processing the image to be classified. At the same time, the encapsulation result of the attention mechanism and the student model is trained through the teacher model and the historical training images, so as to effectively transfer the image classification criteria and strategies in the teacher model to the student model, ensure the processing effect of the encapsulation result on the image to be classified, and also ensure the accuracy and reliability of the encapsulation result. Finally, the image classification prediction model obtained by training is used to analyze and process the image to be classified, so as to achieve accurate and effective classification of the image to be classified, and ensure the accuracy and reliability of the classification result.

[0006] The present invention provides an image classification method based on attention mechanism and knowledge distillation, comprising:

[0007] Step 1: Construct a teacher model and a student model based on knowledge distillation, and perform the first training of the teacher model based on historical training images;

[0008] Step 2: Encapsulate the attention mechanism and the student model, and perform a second training on the encapsulated result based on the first training result and the historical training images to obtain an image classification prediction model;

[0009] Step 3: Analyze and process the image to be classified based on the image classification prediction model to obtain the image classification result of the image to be classified.

[0010] Preferably, an image classification method based on attention mechanism and knowledge distillation, in step 1, constructing a teacher model and a student model, including:

[0011] Obtain execution projects based on the control terminal, and parse the execution projects to obtain basic business information;

[0012] Determine the application scenario and operation requirements of the model to be built based on the basic business information, and obtain reference indicators of the model to be built based on the application scenario and operation requirements;

[0013] Perform a global traversal of the multi-category entries in the preset model library based on the reference indicators, and obtain the model framework based on the global traversal results;

[0014] Based on the requirements of knowledge distillation, the model framework is reconstructed and optimized to obtain the initial teacher model and student model.

[0015] Preferably, in an image classification method based on attention mechanism and knowledge distillation, in step 1, a first training of a teacher model is performed based on historical training images, comprising:

[0016] Accessing the image library, and retrieving historical training images based on the access results, and performing feature extraction on the historical training images to obtain an image feature set;

[0017] Obtain the model hierarchy structure of the teacher model, and decompose the teacher model based on the model hierarchy structure to obtain sub-teacher model blocks;

[0018] Based on the image feature set, the sub-teacher model blocks are respectively trained N times iteratively, and the model loss value of each sub-teacher model block after each iterative training is determined;

[0019] Based on the model loss value, the optimal sub-teacher model block is selected from the N iterative training results, and the optimal sub-teacher model block is associated based on the execution logic of the teacher model to complete the first training of the teacher model.

[0020] Preferably, an image classification method based on attention mechanism and knowledge distillation selects the optimal sub-teacher model block from N iteration training results based on the model loss value, including:

[0021] Obtain the optimal sub-teacher model block, and determine the role weights of the optimal sub-teacher models based on the model hierarchy structure;

[0022] Determine the key transfer knowledge of each optimal sub-teacher model block to the student model based on the action weight, and determine the joint training mechanism of each optimal sub-teacher model block to the student model based on the key transfer knowledge;

[0023] Convert the joint training mechanism into a model training guidance file, and record and retain the model training guidance file.

[0024] Preferably, an image classification method based on attention mechanism and knowledge distillation, in step 2, encapsulating the attention mechanism and the student model, including:

[0025] Schedule the attention mechanism based on the structure of the student model and the task requirements, and determine the working properties of the attention mechanism;

[0026] Determine the docking stage between the attention mechanism and the student model based on the working attributes, and allocate a docking interface to the attention mechanism in the student model based on the docking stage;

[0027] The attention mechanism is connected to the student model based on the connection interface, and the workflow of the connected attention mechanism and student model is adapted based on the work attributes;

[0028] Based on the adaptation results, the attention mechanism and the student model are encapsulated to obtain the attention guidance mechanism.

[0029] Preferably, an image classification method based on attention mechanism and knowledge distillation, in step 2, the encapsulation result is subjected to second training based on the first training result and the historical training image to obtain an image classification prediction model, including:

[0030] Obtaining the encapsulation results of the attention mechanism and the student model, and randomly extracting a known number of teacher model parameters from the teacher model corresponding to the first training result, and initializing the parameters of the encapsulation results based on the known number of teacher model parameters;

[0031] Based on the parameter initialization results, the multi-scale pixel relationships of the teacher model and the encapsulation results are extracted respectively, and the multi-scale pixel relationships are analyzed based on the attention mechanism to obtain the multi-dimensional feature representations of the teacher model and the encapsulation results respectively;

[0032] The model difference between the teacher model and the encapsulated result is obtained based on the multi-dimensional feature representation, and the distillation loss is determined based on the model difference;

[0033] The distillation loss is processed M times based on the model loss function of the encapsulation result, and the result of each processing is used as the first training parameter;

[0034] The historical training images are respectively associated with the first training parameters, and the encapsulation results are processed M times based on the association results to obtain a converged encapsulation result, and the converged encapsulation result is used as the final image classification prediction model.

[0035] Preferably, an image classification method based on attention mechanism and knowledge distillation uses the converged encapsulation result as the final image classification prediction model, including:

[0036] Obtain the obtained image classification prediction model, and input the preset test image set into the image classification prediction model for processing;

[0037] Determine the multi-dimensional performance index value of the image classification prediction model based on the processing results, and trigger the deployment mechanism of the image classification prediction model when the multi-dimensional performance index values ​​all meet the preset thresholds;

[0038] Obtain the deployment environment based on the deployment mechanism, and adapt the deployment environment based on the operating requirements of the image classification prediction model;

[0039] The image classification prediction model is deployed based on the adaptation results.

[0040] Preferably, in an image classification method based on an attention mechanism and knowledge distillation, in step 3, the image to be classified is analyzed and processed based on an image classification prediction model to obtain an image classification result for the image to be classified, including:

[0041] Obtaining images to be classified, and inputting the images to be classified into the image classification prediction model in sequence;

[0042] Performing regional segmentation on the image to be classified, and determining the image features of each region based on the regional segmentation results;

[0043] Analyze image features based on the attention mechanism to obtain spatial information of the image to be classified, and determine the attention weights of different image regions based on the spatial information and image features;

[0044] Based on the attention weight, the same-scale attention map of the image to be classified is obtained, and the same-scale attention map is superimposed and visualized with the image to be classified;

[0045] The key image area is obtained based on the superimposed visualization results, and the record subject and morphological features in the key image area are extracted based on the student model in the image classification prediction model;

[0046] The image to be classified is analyzed and processed based on the recorded subject and morphological features to obtain an image classification result of the image to be classified.

[0047] Preferably, an image classification method based on attention mechanism and knowledge distillation obtains an image classification result for an image to be classified, including:

[0048] Obtain the image classification results, and extract image category features of each category of images based on the image classification results;

[0049] Generate image category labels based on image category features;

[0050] Build a distributed image cache library and label the distributed image cache library based on image category labels;

[0051] An image cache library is obtained based on the category labeling results, and the images to be classified are sequentially cached to corresponding areas in the image cache library based on the image classification results.

[0052] Preferably, in an image classification method based on attention mechanism and knowledge distillation, in step 3, obtaining an image classification result for the image to be classified includes:

[0053] Obtaining a preset number of image classification results and receiving feedback data on the image classification results from the management terminal;

[0054] Perform statistical analysis on the feedback data to determine the classification accuracy parameters of the image classification prediction model for the image to be classified, and obtain the classification loss value of the image classification prediction model based on the classification accuracy parameters;

[0055] Determine the attention weight offset of the attention mechanism in the image classification prediction model based on the classification loss value, and modify the attention mechanism based on the attention weight offset;

[0056] A negative feedback adjustment mechanism of the image classification prediction model is constructed based on the correction result, and an execution cycle is configured for the negative feedback adjustment mechanism;

[0057] The image classification prediction model is periodically iteratively adjusted based on the configuration results.

[0058] Compared with the prior art, the present invention has the following beneficial effects:

[0059] 1. By constructing a teacher model and a student model, and first training the teacher model with historical training images, it is ensured that the teacher model can accurately obtain the mechanism for classifying images. Secondly, by encapsulating the attention mechanism and the student model, it is convenient to lock the key features and key image areas of the image to be classified through the attention mechanism, so as to improve the accuracy and effect of the student model in processing the image to be classified. At the same time, the encapsulation results of the attention mechanism and the student model are trained through the teacher model and historical training images to effectively transfer the image classification criteria and strategies in the teacher model to the student model, ensuring the processing effect of the encapsulation results on the image to be classified, and also ensuring the accuracy and reliability of the encapsulation results. Finally, the image classification prediction model obtained through training is used to analyze and process the image to be classified, so as to achieve accurate and effective classification of the image to be classified, and ensure the accuracy and reliability of the classification results.

[0060] 2. The teacher model parameters of the teacher model are used to initialize the parameters of the attention mechanism and the encapsulation results of the student model, so as to facilitate the transfer of the key knowledge of the teacher model to the student model. Secondly, the multi-scale pixel relationship between the teacher model and the encapsulation result is determined according to the parameter initialization result, so as to accurately and effectively determine the model difference between the teacher model and the encapsulation result according to the multi-scale pixel relationship. Finally, the encapsulation result is processed M times according to the obtained model difference, which ensures the accuracy and reliability of the final attention mechanism and student model, and also improves the accuracy of classification processing of the images to be classified.

[0061] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures specifically pointed out in this application document.

[0062] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:

[0064] Figure 1 It is a flowchart of an image classification method based on attention mechanism and knowledge distillation in an embodiment of the present invention;

[0065] Figure 2 This is a flowchart of step 1 in an image classification method based on attention mechanism and knowledge distillation in an embodiment of the present invention;

[0066] Figure 3 This is a flowchart of step 2 in an image classification method based on attention mechanism and knowledge distillation in an embodiment of the present invention. DETAILED DESCRIPTION

[0067] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.

[0068] Embodiment 1:

[0069] This embodiment provides an image classification method based on attention mechanism and knowledge distillation. Figure 1 As shown, including:

[0070] Step 1: Construct a teacher model and a student model based on knowledge distillation, and perform the first training of the teacher model based on historical training images;

[0071] Step 2: Encapsulate the attention mechanism and the student model, and perform a second training on the encapsulated result based on the first training result and the historical training images to obtain an image classification prediction model;

[0072] Step 3: Analyze and process the image to be classified based on the image classification prediction model to obtain the image classification result of the image to be classified.

[0073] In this embodiment, knowledge distillation is a model compression technology that improves the performance of a student model by transferring knowledge from a teacher model to a student model. In image classification, knowledge distillation can be used to transfer the knowledge of the teacher model to the student model to help the student model better learn and classify images.

[0074] In this embodiment, the historical training images are known in advance and are data samples used to train the teacher model and the student model.

[0075] In this embodiment, the first training refers to training the teacher model through historical training images, thereby facilitating effective training of the student model through the teacher model and improving the effect and accuracy of the student model in classifying images.

[0076] In this embodiment, the attention mechanism can help the model focus on the key parts of the image and improve the accuracy of classification. In the image classification task, the key features of the image can be learned through the attention mechanism.

[0077] In this embodiment, the purpose of encapsulating the attention mechanism with the student model is to lock the key areas and key features of the graphics to be classified through the attention mechanism, so that the student model can classify the images to be classified according to the key areas and key features, thereby improving the accuracy of image classification.

[0078] In this embodiment, the second training refers to training the attention mechanism and the student model through the teacher model and historical training data obtained by the first training, that is, transferring the known image classification knowledge in the teacher model to the student model to improve the processing effect of the student model.

[0079] In this embodiment, the image to be classified refers to an image that needs to be classified and is not unique.

[0080] The working principle and beneficial effects of the above technical solution are: by constructing a teacher model and a student model, and first training the teacher model through historical training images, it is ensured that the teacher model can accurately obtain a mechanism for classifying images; secondly, by encapsulating the attention mechanism and the student model, it is convenient to lock the key features and key image areas of the image to be classified through the attention mechanism, thereby facilitating the improvement of the accuracy and effect of the student model in processing the image to be classified; at the same time, the encapsulation results of the attention mechanism and the student model are trained through the teacher model and historical training images, so as to effectively transfer the image classification criteria and strategies in the teacher model to the student model, thereby ensuring the processing effect of the encapsulation results on the image to be classified, and also ensuring the accuracy and reliability of the encapsulation results; finally, the image classification prediction model obtained through training is used to analyze and process the image to be classified, so as to achieve accurate and effective classification of the image to be classified, and ensure the accuracy and reliability of the classification results.

[0081] Embodiment 2:

[0082] Based on Example 1, this example provides an image classification method based on attention mechanism and knowledge distillation, such as Figure 2 As shown, in step 1, the teacher model and the student model are constructed, including:

[0083] Step 101: Obtain an execution project based on a management and control terminal, and parse the execution project to obtain basic business information;

[0084] Step 102: Determine the application scenario and operation requirements of the model to be constructed based on the basic business information, and obtain reference indicators of the model to be constructed based on the application scenario and operation requirements;

[0085] Step 103: globally traverse the multi-category entries in the preset model library based on the reference index, and obtain the model framework based on the global traversal result;

[0086] Step 104: Reconstruct and optimize the model framework based on the knowledge distillation requirements to obtain the initial teacher model and student model.

[0087] In this embodiment, the execution project refers to the business type obtained from the management terminal that needs to be performed through the knowledge distillation method.

[0088] In this embodiment, the basic business information refers to the project type of the execution project and the execution purpose to be achieved.

[0089] In this embodiment, the reference index refers to the basic requirements corresponding to the model to be constructed when it is constructed.

[0090] In this embodiment, the preset model library is known in advance and is used to store a variety of different model frameworks, wherein the category entries are different types of sub-model storage units in the preset model pants.

[0091] In this embodiment, the knowledge distillation requirements are known in advance and are used to characterize the purpose to be achieved by the model, wherein reconstruction and optimization are to adaptively adjust the model framework according to the knowledge distillation requirements, thereby ensuring that the final model can perform image classification tasks.

[0092] The working principle and beneficial effects of the above technical solution are: by parsing the execution projects, the basic business information can be accurately and effectively determined, so as to match the model framework suitable for the current business execution requirements from the preset model library according to the basic business information, and reconstruct and optimize the model framework according to the knowledge distillation requirements to ensure the accuracy and reliability of the teacher model and student model, and also facilitate accurate and effective classification operations of images according to knowledge distillation.

[0093] Embodiment 3:

[0094] On the basis of Example 1, this embodiment provides an image classification method based on attention mechanism and knowledge distillation. In step 1, a teacher model is first trained based on historical training images, including: accessing an image library, retrieving historical training images based on the access results, and extracting features from the historical training images to obtain an image feature set;

[0095] Obtain the model hierarchy structure of the teacher model, and decompose the teacher model based on the model hierarchy structure to obtain sub-teacher model blocks;

[0096] Based on the image feature set, the sub-teacher model blocks are respectively trained N times iteratively, and the model loss value of each sub-teacher model block after each iterative training is determined;

[0097] Based on the model loss value, the optimal sub-teacher model block is selected from the N iterative training results, and the optimal sub-teacher model block is associated based on the execution logic of the teacher model to complete the first training of the teacher model.

[0098] In this embodiment, the image feature set refers to features corresponding to historical training images, including recorded objects in the image and the resolution of the image.

[0099] In this embodiment, the model hierarchy structure refers to the parameter structure inside the teacher model, and the purpose is to conduct targeted and effective training on the teacher model according to the model hierarchy structure.

[0100] In this embodiment, the sub-teacher model block refers to each model component obtained by structurally splitting the teacher model according to the model hierarchy structure.

[0101] In this embodiment, the model loss value is used to characterize the training effect on the sub-teacher model block, wherein a larger model loss value indicates a worse processing effect of the current sub-teacher model.

[0102] In this embodiment, the execution logic is used to characterize the order in which each sub-teacher model block processes an image.

[0103] The working principle and beneficial effects of the above technical solution are: by retrieving historical training images from the image library, and iteratively training the obtained teacher model according to the image feature set of the historical training images, and monitoring the training process according to the model loss value during the iterative training process, ultimately ensuring the accuracy and reliability of the obtained teacher model, providing convenience and basis for image classification.

[0104] Embodiment 4:

[0105] Based on Example 3, this embodiment provides an image classification method based on attention mechanism and knowledge distillation, which selects the optimal sub-teacher model block from N iteration training results based on the model loss value, including:

[0106] Obtain the optimal sub-teacher model block, and determine the role weights of the optimal sub-teacher models based on the model hierarchy structure;

[0107] Determine the key transfer knowledge of each optimal sub-teacher model block to the student model based on the action weight, and determine the joint training mechanism of each optimal sub-teacher model block to the student model based on the key transfer knowledge;

[0108] Convert the joint training mechanism into a model training guidance file, and record and retain the model training guidance file.

[0109] In this embodiment, the role weight is used to characterize the importance of each sub-teacher model in the entire teacher model.

[0110] In this embodiment, the key transfer knowledge refers to the image classification criteria or image classification strategy that needs to be transferred from the teacher model to the student model.

[0111] In this embodiment, the training guide file refers to the result of converting the joint training mechanism into a corresponding file format, the purpose of which is to facilitate the corresponding training of the student model, thereby realizing the knowledge transfer to the teacher model.

[0112] The working principle and beneficial effects of the above technical solution are: by determining the role weights of each optimal sub-teacher model, the key transfer knowledge of different optimal sub-teacher models is determined according to the role weights, and the obtained key transfer knowledge is associated to achieve accurate and effective construction of the model training guidance file, thereby ensuring the reliability of training the encapsulation results of the student model and the attention mechanism.

[0113] Embodiment 5:

[0114] Based on Example 1, this example provides an image classification method based on attention mechanism and knowledge distillation, such as Figure 3 As shown, in step 2, the attention mechanism is encapsulated with the student model, including:

[0115] Step 201: Schedule the attention mechanism based on the structure of the student model and the task requirements, and determine the working properties of the attention mechanism;

[0116] Step 202: determining the docking stage of the attention mechanism and the student model based on the working attributes, and allocating a docking interface to the attention mechanism in the student model based on the docking stage;

[0117] Step 203: docking the attention mechanism with the student model based on the docking interface, and performing workflow adaptation on the docked attention mechanism and student model based on the work attributes;

[0118] Step 204: Encapsulate the attention mechanism and the student model based on the adaptation result to obtain an attention guidance mechanism.

[0119] In this embodiment, the structure and task requirements of the student model refer to the structural characteristics of the student model, including interfaces and model composition, and the task requirements refer to the tasks that the student model needs to perform, including task categories and purposes.

[0120] In this embodiment, the working attributes refer to the working characteristics of the attention mechanism and the types of data that can be processed.

[0121] In this embodiment, the docking stage is used to characterize the specific docking location of the attention mechanism and the student model, that is, to dock the attention mechanism with the data input interface of the student model.

[0122] In this embodiment, workflow adaptation refers to the configuration of the collaborative processing flow of the attention mechanism and the student model for the image, ensuring that the attention mechanism and the student model can be effectively integrated.

[0123] The working principle and beneficial effect of the above technical solution are: by calling the attention mechanism and connecting the attention mechanism with the student model, it is ensured that effective image information of the image to be classified can be extracted through the attention mechanism first, and then the effective image information is processed again through the student model, thereby ensuring the efficiency and accuracy of image classification processing.

[0124] Embodiment 6:

[0125] On the basis of Example 1, this embodiment provides an image classification method based on attention mechanism and knowledge distillation. In step 2, the encapsulation result is subjected to second training based on the first training result and the historical training image to obtain an image classification prediction model, including:

[0126] Obtaining the encapsulation results of the attention mechanism and the student model, and randomly extracting a known number of teacher model parameters from the teacher model corresponding to the first training result, and initializing the parameters of the encapsulation results based on the known number of teacher model parameters;

[0127] Based on the parameter initialization results, the multi-scale pixel relationships of the teacher model and the encapsulation results are extracted respectively, and the multi-scale pixel relationships are analyzed based on the attention mechanism to obtain the multi-dimensional feature representations of the teacher model and the encapsulation results respectively;

[0128] The model difference between the teacher model and the encapsulated result is obtained based on the multi-dimensional feature representation, and the distillation loss is determined based on the model difference;

[0129] The distillation loss is processed M times based on the model loss function of the encapsulation result, and the result of each processing is used as the first training parameter;

[0130] The historical training images are respectively associated with the first training parameters, and the encapsulation results are processed M times based on the association results to obtain a converged encapsulation result, and the converged encapsulation result is used as the final image classification prediction model.

[0131] In this embodiment, the teacher model parameters refer to the specific model data corresponding to the trained teacher model.

[0132] In this embodiment, parameter initialization refers to adjusting the parameters of the attention mechanism and the encapsulation result of the student model through the teacher model parameters, that is, training the student model and the encapsulation result of the attention mechanism through the teacher model.

[0133] In this embodiment, the multi-scale pixel relationship is used to characterize the consideration strategy and method between pixels of different scales between the teacher model and the encapsulation result (student model) when classifying an image.

[0134] In this embodiment, the multi-dimensional feature representation refers to the processing characteristics and specific execution methods of the teacher model and the encapsulation results when performing image processing.

[0135] In this embodiment, the distillation loss is used to characterize the omission of the encapsulation result when learning the relevant image classification knowledge in the teacher model, and is used to characterize the degree of difference between the encapsulation result and the teacher model.

[0136] In this embodiment, processing the distillation loss M times based on the model loss function of the encapsulation result means ensuring that the distillation loss is minimized, thereby improving the training effect of the student model and the attention mechanism.

[0137] In this embodiment, the first training parameter refers to specific training data corresponding to minimizing the distillation loss.

[0138] In this embodiment, converging the encapsulation result refers to training the encapsulation result through the association result of the historical training image and the first training parameter until the encapsulation result can effectively perform the data classification task.

[0139] The working principle and beneficial effects of the above technical solution are: the parameters of the attention mechanism and the encapsulation results of the student model are initialized through the teacher model parameters of the teacher model, so as to facilitate the transfer of the key knowledge of the teacher model to the student model; secondly, the multi-scale pixel relationship between the teacher model and the encapsulation result is determined according to the parameter initialization result, so as to achieve accurate and effective determination of the model difference between the teacher model and the encapsulation result according to the multi-scale pixel relationship; finally, the encapsulation result is processed M times according to the obtained model difference, which ensures the accuracy and reliability of the final attention mechanism and student model, and also improves the accuracy of classification processing of the classified images.

[0140] Embodiment 7:

[0141] Based on Example 6, this embodiment provides an image classification method based on attention mechanism and knowledge distillation, and uses the converged encapsulation result as the final image classification prediction model, including:

[0142] Obtain the obtained image classification prediction model, and input the preset test image set into the image classification prediction model for processing;

[0143] Determine the multi-dimensional performance index value of the image classification prediction model based on the processing results, and trigger the deployment mechanism of the image classification prediction model when the multi-dimensional performance index values ​​all meet the preset thresholds;

[0144] Obtain the deployment environment based on the deployment mechanism, and adapt the deployment environment based on the operating requirements of the image classification prediction model;

[0145] The image classification prediction model is deployed based on the adaptation results.

[0146] In this embodiment, the multi-dimensional performance index value refers to the result obtained after the image classification prediction model analyzes the preset test image set, and is used to characterize the processing effect of the image classification prediction model.

[0147] The working principle and beneficial effect of the above technical solution are: by performing performance verification on the obtained image classification prediction model, and deploying the image classification prediction model after passing the performance verification, it is convenient to apply the obtained image classification prediction model, thereby ensuring the classification accuracy of the images to be classified.

[0148] Embodiment 8:

[0149] On the basis of Example 1, this embodiment provides an image classification method based on attention mechanism and knowledge distillation. In step 3, the image to be classified is analyzed and processed based on the image classification prediction model to obtain an image classification result of the image to be classified, including:

[0150] Obtaining images to be classified, and inputting the images to be classified into the image classification prediction model in sequence;

[0151] Performing regional segmentation on the image to be classified, and determining the image features of each region based on the regional segmentation results;

[0152] Analyze image features based on the attention mechanism to obtain spatial information of the image to be classified, and determine the attention weights of different image regions based on the spatial information and image features;

[0153] Based on the attention weight, the same-scale attention map of the image to be classified is obtained, and the same-scale attention map is superimposed and visualized with the image to be classified;

[0154] The key image area is obtained based on the superimposed visualization results, and the record subject and morphological features in the key image area are extracted based on the student model in the image classification prediction model;

[0155] The image to be classified is analyzed and processed based on the recorded subject and morphological features to obtain an image classification result of the image to be classified.

[0156] In this embodiment, the image feature of each region refers to the image subject in each image region obtained after the image to be classified is divided into regions and the imaging state of the image subject.

[0157] In this embodiment, spatial information refers to the position of each area of ​​the image and its distribution in the complete image obtained by analyzing image features through an attention mechanism.

[0158] In this embodiment, the same-scale attention map refers to an attention map with the same size as the image to be classified, which is used to characterize the importance of different regions.

[0159] The working principle and beneficial effects of the above technical solution are: by inputting the image to be classified into the image classification prediction model for processing, the key image area in the image to be classified is locked by the image classification prediction model, and the recording subject and morphological features in the key image area are determined. Finally, the image to be classified is accurately classified according to the recording subject and morphological features, thereby ensuring the accuracy and reliability of the classification results.

[0160] Embodiment 9:

[0161] On the basis of Example 8, this embodiment provides an image classification method based on attention mechanism and knowledge distillation, and obtains an image classification result for the image to be classified, including:

[0162] Obtain the image classification results, and extract image category features of each category of images based on the image classification results;

[0163] Generate image category labels based on image category features;

[0164] Build a distributed image cache library and label the distributed image cache library based on image category labels;

[0165] An image cache library is obtained based on the category labeling results, and the images to be classified are sequentially cached to corresponding areas in the image cache library based on the image classification results.

[0166] In this embodiment, the image category feature refers to the pixel characteristics shared by each category of images, such as all being landscape images.

[0167] In this embodiment, the category label is a marking symbol used to distinguish images of different categories.

[0168] The working principle and beneficial effects of the above technical solution are: by extracting the image category features of each category of images, the corresponding image category labels are generated according to the image category features, so as to facilitate category marking in the distributed image cache library constructed by the category label degree. Finally, the image classification results are stored in the corresponding areas in sequence according to the category labels, so as to realize accurate and reliable management of the image classification results.

[0169] Embodiment 10:

[0170] On the basis of Example 1, this embodiment provides an image classification method based on attention mechanism and knowledge distillation. In step 3, an image classification result of the image to be classified is obtained, including:

[0171] Obtaining a preset number of image classification results and receiving feedback data on the image classification results from the management terminal;

[0172] Perform statistical analysis on the feedback data to determine the classification accuracy parameters of the image classification prediction model for the image to be classified, and obtain the classification loss value of the image classification prediction model based on the classification accuracy parameters;

[0173] Determine the attention weight offset of the attention mechanism in the image classification prediction model based on the classification loss value, and modify the attention mechanism based on the attention weight offset;

[0174] A negative feedback adjustment mechanism of the image classification prediction model is constructed based on the correction result, and an execution cycle is configured for the negative feedback adjustment mechanism;

[0175] The image classification prediction model is periodically iteratively adjusted based on the configuration results.

[0176] In this embodiment, the preset number of times is set in advance, for example, ten times, etc., and can be adjusted.

[0177] In this embodiment, the feedback data refers to the evaluation data made by the management terminal for the classification result, including whether the classification is accurate or not.

[0178] In this embodiment, the classification loss value is used to characterize the degree of classification error that occurs when the image classification prediction model classifies the image to be classified.

[0179] In this embodiment, the attention weight offset refers to the degree of error when the attention mechanism in the encapsulation result extracts the key area of ​​the image.

[0180] The working principle and beneficial effect of the above technical solution are: by comprehensively analyzing the image classification results of a preset number of times of the image classification prediction model, an accurate and effective evaluation of the classification loss value of the image classification prediction model is achieved, thereby facilitating the correction of the image classification prediction model according to the classification loss value, ensuring the stability and reliability of the image classification prediction model, and also ensuring the classification accuracy of the images to be classified.

[0181] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. An image classification method based on attention mechanism and knowledge distillation, characterized in that: include: Step 1: Construct a teacher model and a student model based on knowledge distillation, and perform the first training of the teacher model based on historical training images; Step 2: Encapsulate the attention mechanism and the student model, and perform a second training on the encapsulated result based on the first training result and the historical training images to obtain an image classification prediction model; Step 3: Analyze and process the image to be classified based on the image classification prediction model to obtain the image classification result of the image to be classified; Wherein, in step 1, the teacher model is first trained based on the historical training images, including: Accessing the image library, and retrieving historical training images based on the access results, and performing feature extraction on the historical training images to obtain an image feature set; Obtain the model hierarchy structure of the teacher model, and decompose the teacher model based on the model hierarchy structure to obtain sub-teacher model blocks; Based on the image feature set, the sub-teacher model blocks are respectively trained N times iteratively, and the model loss value of each sub-teacher model block after each iterative training is determined; Select the best sub-teacher model block from the N iterative training results based on the model loss value, and associate the best sub-teacher model block based on the execution logic of the teacher model to complete the first training of the teacher model; Among them, in step 2, the attention mechanism and the student model are encapsulated, including: Schedule the attention mechanism based on the structure of the student model and the task requirements, and determine the working properties of the attention mechanism; Determine the docking stage between the attention mechanism and the student model based on the working attributes, and allocate a docking interface to the attention mechanism in the student model based on the docking stage; The attention mechanism is connected to the student model based on the connection interface, and the workflow of the connected attention mechanism and student model is adapted based on the work attributes; Based on the adaptation results, the attention mechanism and the student model are encapsulated to obtain the attention guidance mechanism; Among them, in step 3, the image to be classified is analyzed and processed based on the image classification prediction model to obtain the image classification result of the image to be classified, including: Obtaining images to be classified, and inputting the images to be classified into the image classification prediction model in sequence; Performing regional segmentation on the image to be classified, and determining the image features of each region based on the regional segmentation results; Analyze image features based on the attention mechanism to obtain spatial information of the image to be classified, and determine the attention weights of different image regions based on the spatial information and image features; Based on the attention weight, the same-scale attention map of the image to be classified is obtained, and the same-scale attention map is superimposed and visualized with the image to be classified; The key image area is obtained based on the superimposed visualization results, and the record subject and morphological features in the key image area are extracted based on the student model in the image classification prediction model; The image to be classified is analyzed and processed based on the recorded subject and morphological features to obtain an image classification result of the image to be classified.

2. According to claim 1, the image classification method based on attention mechanism and knowledge distillation is characterized in that: In step 1, the teacher model and student model are constructed, including: Obtain execution projects based on the control terminal, and parse the execution projects to obtain basic business information; Determine the application scenario and computing requirements of the model to be built based on the basic business information, and obtain reference indicators of the model to be built based on the application scenario and computing requirements; Perform a global traversal of the multi-category entries in the preset model library based on the reference indicators, and obtain the model framework based on the global traversal results; Based on the requirements of knowledge distillation, the model framework is reconstructed and optimized to obtain the initial teacher model and student model.

3. The image classification method based on attention mechanism and knowledge distillation according to claim 1, characterized in that: The optimal sub-teacher model block is selected from the N iteration training results based on the model loss value, including: Obtain the optimal sub-teacher model block, and determine the role weights of the optimal sub-teacher models based on the model hierarchy structure; Determine the key transfer knowledge of each optimal sub-teacher model block to the student model based on the action weight, and determine the joint training mechanism of each optimal sub-teacher model block to the student model based on the key transfer knowledge; Convert the joint training mechanism into a model training guidance file, and record and retain the model training guidance file.

4. The image classification method based on attention mechanism and knowledge distillation according to claim 1, characterized in that: In step 2, the encapsulation result is subjected to second training based on the first training result and the historical training image to obtain an image classification prediction model, including: Obtaining the encapsulation results of the attention mechanism and the student model, and randomly extracting a known number of teacher model parameters from the teacher model corresponding to the first training result, and initializing the parameters of the encapsulation results based on the known number of teacher model parameters; Based on the parameter initialization results, the multi-scale pixel relationships of the teacher model and the encapsulation results are extracted respectively, and the multi-scale pixel relationships are analyzed based on the attention mechanism to obtain the multi-dimensional feature representations of the teacher model and the encapsulation results respectively; The model difference between the teacher model and the encapsulated result is obtained based on the multi-dimensional feature representation, and the distillation loss is determined based on the model difference; The distillation loss is processed M times based on the model loss function of the encapsulation result, and the result of each processing is used as the first training parameter; The historical training images are respectively associated with the first training parameters, and the encapsulation results are processed M times based on the association results to obtain a converged encapsulation result, and the converged encapsulation result is used as the final image classification prediction model.

5. The image classification method based on attention mechanism and knowledge distillation according to claim 4, characterized in that: The converged encapsulation results are used as the final image classification prediction model, including: Obtain the obtained image classification prediction model, and input the preset test image set into the image classification prediction model for processing; Determine the multi-dimensional performance index value of the image classification prediction model based on the processing results, and trigger the deployment mechanism of the image classification prediction model when the multi-dimensional performance index values ​​all meet the preset thresholds; Obtain the deployment environment based on the deployment mechanism, and adapt the deployment environment based on the operating requirements of the image classification prediction model; The image classification prediction model is deployed based on the adaptation results.

6. The image classification method based on attention mechanism and knowledge distillation according to claim 1, characterized in that: Get the image classification results for the image to be classified, including: Obtain the image classification results, and extract image category features of each category of images based on the image classification results; Generate image category labels based on image category features; Build a distributed image cache library and label the distributed image cache library based on image category labels; An image cache library is obtained based on the category labeling results, and the images to be classified are sequentially cached to corresponding areas in the image cache library based on the image classification results.

7. The image classification method based on attention mechanism and knowledge distillation according to claim 1, characterized in that: In step 3, the image classification result of the image to be classified is obtained, including: Obtaining a preset number of image classification results and receiving feedback data on the image classification results from the management terminal; Perform statistical analysis on the feedback data to determine the classification accuracy parameters of the image classification prediction model for the image to be classified, and obtain the classification loss value of the image classification prediction model based on the classification accuracy parameters; Determine the attention weight offset of the attention mechanism in the image classification prediction model based on the classification loss value, and modify the attention mechanism based on the attention weight offset; A negative feedback adjustment mechanism of the image classification prediction model is constructed based on the correction result, and an execution cycle is configured for the negative feedback adjustment mechanism; The image classification prediction model is periodically iteratively adjusted based on the configuration results.

Citation Information

Patent Citations

  • Image classification method and device

    CN113989577A

  • Apparatus for Training Model, Method and Computer Readable Recording Medium Thereof

    US20230135163A1

Cited By

  • Temperature self-adaptive knowledge distillation method, system and equipment and storage medium

    CN120823377A

  • A temperature adaptive knowledge distillation method, system, device and storage medium

    CN120823377B