Image classification method and system based on F1-score weighted voting
By adopting F1-score weighted voting method in alkaline battery electrode image classification, the problem of category imbalance is solved, the detection accuracy and efficiency are improved, and the production cost is reduced.
Patent Information
- Application Number
- CN202510224523.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-27
- Publication Date
- 2025-05-13
AI Technical Summary
The alkaline battery electrode image dataset has category imbalance problem, which leads to category deviations in the classification model during training, reducing detection accuracy and recall.
The image classification method based on F1-score weighted voting is adopted, and the convolutional neural network is optimized through the dual random sampling strategy and the efficient channel attention mechanism, multiple weak classification network models are generated, and integrated prediction is performed through F1-score weighted voting.
It significantly improves the accuracy and efficiency of the detection of defects of alkaline battery electrodes, reduces the leakage detection rate and false detection rate, improves the detection ability of a few categories of defects, and reduces production costs.
Smart Images

Figure CN119992217A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of alkaline battery electrode image classification, and in particular to an image classification method and system based on F1-score weighted voting. Background Art
[0002] In actual industrial production scenarios, the collection and processing of alkaline battery electrode image datasets often face significant class imbalance problems, which is one of the key factors restricting the improvement of battery quality inspection accuracy. Specifically, the number of images of normal battery samples usually occupies an absolute advantage (accounting for about 85%-95%), while defective samples are relatively scarce (accounting for about 5%-15%); at the same time, in the defect category, the number of samples of conventional defect types (such as electrode gaps, electrode bumps, electrode missing, etc.) is much higher than that of rare defect types (such as electrode scratches, electrode contamination, electrode bumps, etc.). This long-tail distribution phenomenon further aggravates the imbalance of the data. This imbalance in data distribution will cause obvious class bias in the classification model during the training process, which is specifically manifested as: the model overfits the majority class samples, resulting in a decrease in the classification accuracy of the main categories; at the same time, due to the underfitting of minority class samples, the recall rate of rare defects is insufficient. This dual impact will eventually seriously restrict the overall performance indicators of the model and reduce its practical application value in industrial quality inspection. Especially in high-precision manufacturing scenarios, even tiny defects may lead to serious product quality problems. Therefore, how to effectively solve the problem of class imbalance in the acquisition and processing of image datasets has become one of the key technical bottlenecks in improving the accuracy of battery production quality inspection.
[0003] The above problems need to be solved urgently. Summary of the invention
[0004] The purpose of the present invention is to overcome at least one technical problem existing in the prior art and to provide an image classification method and system based on F1-score weighted voting.
[0005] On the one hand, an embodiment of the present invention provides an image classification method based on F1-score weighted voting, the method comprising: S1, dividing a data set into a training set, a test set and a validation set; S2, adopting a double random sampling strategy to sample weak classification tasks on the training set; S3, constructing a convolutional neural network basic model; S4, optimizing the convolutional neural network basic model by introducing an efficient channel attention mechanism and a PReLU activation function to obtain WV-ResNet as a feature extractor; S5, inputting N weak classification tasks sampled from the training set into the feature extractor through a parallel network structure, and performing parallel training on the high-dimensional deep features extracted by the feature extractor to obtain N weak classification network models respectively; S6, calculating the F1-score of the N weak classification network models on the validation set during the training process; S7, based on the F1-score of the N weak classification network models, using an integrated prediction method of F1-score weighted voting to vote on the prediction results generated based on the validation set during the training process to determine the prediction category of the final output;
[0006] S8, completing the training process of the WV-ResNet based on the output prediction category; S9, inputting the collected alkaline battery electrode image into the trained WV-ResNet to obtain the classification result of the alkaline battery electrode image.
[0007] Furthermore, the step S2, adopting a double random sampling strategy to sample the training set for the weak classification task includes: the double random sampling strategy includes random category sampling and random image sampling; the random category sampling includes randomly selecting categories from the training set to ensure that each category receives balanced attention during the training process; the random image sampling includes randomly selecting the same number of images in each category.
[0008] Furthermore, the step S4, optimizing the convolutional neural network basic model by introducing an efficient channel attention mechanism and a PReLU activation function to obtain WV-ResNet as a feature extractor, includes: the optimized convolutional neural network model is composed of four residual modules, and the residual module includes applying batch normalization and a PReLU activation function after each convolution layer; an efficient channel attention module is introduced into the optimized convolutional neural network model; the optimized convolutional neural network model uses a global average pooling layer and a fully connected layer as the last two layers instead of using two fully connected layers as the last two layers in the convolutional neural network basic model.
[0009] Furthermore, the step S7, based on the F1-score of the N weak classification network models, uses an integrated prediction method of F1-score weighted voting to vote on the prediction results generated based on the verification set during the training process to determine the prediction category of the final output, including: selecting M weak classification network models that meet the performance requirements from the N weak classification network models generated during the training process; verifying the M weak classification network models that meet the performance requirements through the verification set to obtain the F1-scores of the M weak classification network models on the verification set; using the F1-score as the weight in the weighted voting process, and calculating a comprehensive voting score for each category based on the image input in the verification set through a soft voting mechanism; and using the Softmax function to calculate the prediction probability of each category based on the comprehensive voting score of each category.
[0010] Furthermore, the selecting M weak classification network models that meet the performance requirements from the N weak classification network models generated during the training process includes: selecting the M models with the best performance based on the F1-score of each weak classification model on the validation set, and the performance is positively correlated with the F1-score; the F1-score calculation formula is:
[0011]
[0012] In the formula, Precision is the accuracy of the model, and Recall is the recall rate of the model.
[0013] Furthermore, the method of calculating the prediction probability of each category based on the comprehensive voting score of each category using the Softmax function includes:
[0014]
[0015] In the formula, x represents the input image, k represents the predicted category, and V ik Represents the predicted probability of the i-th weak classification model for category k, F1 i represents the F1 score of the i-th weak classification model, and c' is the total number of categories.
[0016] Furthermore, the step S7, based on the F1-score of the N weak classification network models, uses an integrated prediction method of F1-score weighted voting to vote on the prediction results generated based on the verification set during the training process to determine the prediction category of the final output, including: constructing a dictionary corresponding to a key value for each image in the verification set, wherein the key is a potential category label and the value is a cumulative voting result of the corresponding category based on a weighted score; calculating a comprehensive voting score for each category by weighted summing up the prediction results given by the selected M weak classification models according to their F1 scores; and calculating the prediction probability of each category based on the comprehensive voting score using the Softmax function.
[0017] Furthermore, the step S8, completing the training process of the WV-ResNet based on the predicted category of the output includes: calculating the multi-category cross entropy loss by comparing the predicted category probability of the validation set with the corresponding true category label; and performing model training according to the multi-category cross entropy loss using stochastic gradient descent.
[0018] Furthermore, the method also includes: calculating the precision, recall and F1 score of the model for the trained WV-ResNet through a test set; and evaluating the model through the precision, recall and F1 score.
[0019] In the second aspect, an embodiment of the present invention provides an image classification system based on F1-score weighted voting, the system adopts the above-mentioned image classification method based on F1-score weighted voting, and the system includes: a partitioning module, suitable for dividing a data set into a training set, a test set and a validation set; a weak classification task sampling module, suitable for sampling weak classification tasks on the training set using a double random sampling strategy; a network model building module, suitable for building a convolutional neural network basic model; a network model optimization module, suitable for optimizing the convolutional neural network basic model by introducing an efficient channel attention mechanism and a PReLU activation function to obtain WV-ResNet as a feature extractor; a weak classification network model generation module, suitable for sampling N weak classification tasks in the training set through a parallel network The structure is input to the feature extractor, and the high-dimensional deep features extracted by the feature extractor are trained in parallel to obtain N weak classification network models respectively; a calculation module is used to calculate the F1-score of the N weak classification network models on the verification set during the training process; a verification module is used to vote on the prediction results generated based on the verification set during the training process based on the F1-score of the N weak classification network models using an integrated prediction method of F1-score weighted voting to determine the prediction category of the final output; a training module is used to complete the training process of the WV-ResNet based on the output prediction category; a result output module is used to input the collected alkaline battery electrode image into the trained WV-ResNet to obtain the classification result of the alkaline battery electrode image.
[0020] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the above-mentioned image classification method based on F1-score weighted voting when executed by the processor.
[0021] In a fourth aspect, an embodiment of the present invention further provides a readable storage medium, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the above-mentioned image classification method based on F1-score weighted voting.
[0022] The beneficial effects of the present invention are:
[0023] (1) Improve the efficiency and accuracy of industrial quality inspection: This invention significantly improves the accuracy and efficiency of alkaline battery electrode defect detection by optimizing the convolutional neural network architecture and introducing innovative classification strategies. In actual industrial production, the algorithm can quickly and accurately identify a variety of defect types, including common defects and rare defects, thereby significantly reducing the missed detection rate and false detection rate and improving product quality.
[0024] (2) Solve the problem of class imbalance and reduce production costs: In response to the common class imbalance problem in alkaline battery electrode image datasets, the present invention effectively alleviates the impact of uneven data distribution on model performance through a double random sampling strategy and an F1-score weighted voting method. The algorithm can significantly improve the detection capability of defects in a few categories without increasing the cost of data acquisition, reduce product rework and scrapping due to missed defects, and thus reduce production costs.
[0025] (3) Lightweight design, suitable for industrial embedded devices: By simplifying the network structure and introducing technologies such as efficient channel attention mechanism (ECA) and global average pooling (GAP), the present invention significantly reduces the number of model parameters and computational complexity. The algorithm can run efficiently on industrial embedded devices or edge computing platforms, meet real-time detection requirements, and is suitable for large-scale industrial deployment.
[0026] (4) Strong generalization ability and can be extended to other industrial fields: The algorithm framework of the present invention is highly general and scalable. It is not only suitable for alkaline battery electrode defect detection, but can also be extended to other industrial visual inspection scenarios, such as defect detection in lithium batteries, semiconductors, etc. By adjusting the network structure and training strategy, the algorithm can quickly adapt to the needs of different industrial scenarios and has broad application potential.
[0027] (5) Promote the development of intelligent manufacturing and Industry 4.0: This invention provides an efficient and intelligent solution for industrial quality inspection, which is in line with the development trend of intelligent manufacturing and Industry 4.0. By deeply integrating deep learning technology with industrial production, the algorithm can help enterprises realize the automation and intelligent upgrade of the production process and enhance overall competitiveness.
[0028] (6) Significant economic and social benefits: In terms of economic benefits, the present invention can help enterprises improve product quality and reduce production costs, while reducing reliance on manual quality inspection and saving human resources. In terms of social benefits, the algorithm helps to promote the advancement of industrial quality inspection technology and promote technological upgrading and sustainable development of related industries. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0030] Figure 1 This is a flow chart of an image classification method based on F1-score weighted voting provided in Example 1 of the present invention.
[0031] Figure 2 This is a schematic diagram of a WV-ResNet structure provided in Example 1 of the present invention.
[0032] Figure 3It is a schematic diagram of the overall structure of a classification algorithm based on deep category representation and F1-score weighted voting provided in Example 1 of the present invention.
[0033] Figure 4 It is a schematic diagram of a loss reduction curve of WV-ResNet during training provided by Example 1 of the present invention.
[0034] Figure 5 It is a schematic diagram of a confusion matrix of the recognition effects of various types of images on a test set using different network models provided in Example 1 of the present invention.
[0035] Figure 6 It is a schematic diagram of the structure of an image classification system based on F1-score weighted voting provided in Example 2 of the present invention.
[0036] Figure 7 This is a partial block diagram of an electronic device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0037] It should be mentioned before discussing the exemplary embodiments in more detail that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the operations as sequential processes, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0038] It should be understood that, although the terms "first", "second", etc. may be used herein to describe various units, these units should not be limited by these terms. These terms are used only to distinguish one unit from another unit. For example, without departing from the scope of the exemplary embodiments, a first unit may be referred to as a second unit, and a similar second unit may be referred to as a first unit. The term "and / or" used herein includes any and all combinations of one or more of the listed associated items.
[0039] The present invention will now be described in detail with reference to the accompanying drawings. This figure is a simplified schematic diagram, which only illustrates the basic structure of the present invention in a schematic manner, and therefore only shows the components related to the present invention.
[0040] Example 1
[0041] For ease of understanding, the inventive concept is generally described below before describing the embodiments of the present invention in detail:
[0042] This application proposes a new classification algorithm based on deep category representation and F1-score weighted voting to address the imbalance of various defect categories, complex morphology and category imbalance in alkaline battery electrode defect detection. This algorithm significantly improves the model's feature extraction capability and classification performance by optimizing the convolutional neural network (CNN) architecture and introducing innovative classification strategies.
[0043] The specific implementation is as follows:
[0044] like Figure 1 As shown, it is a flow chart of an image classification method based on F1-score weighted voting provided by the present invention.
[0045] As an example, the method includes: S1, dividing the data set into a training set, a test set and a validation set; S2, adopting a double random sampling strategy to sample the weak classification task on the training set; S3, building a convolutional neural network basic model; S4, optimizing the convolutional neural network basic model by introducing an efficient channel attention mechanism and a PReLU activation function to obtain WV-ResNet as a feature extractor; S5, sampling N weak classification tasks from the training set and inputting them into the feature extractor through a parallel network structure, and parallel training the high-dimensional deep features extracted by the feature extractor to obtain N weak Classification network model; S6, during the training process, respectively calculate the F1-score of N weak classification network models on the validation set; S7, based on the F1-score of the N weak classification network models, use the F1-score weighted voting integrated prediction method to vote on the prediction results generated based on the validation set during the training process to determine the final output prediction category; S8, based on the output prediction category, complete the training process of the WV-ResNet; S9, input the collected alkaline battery electrode image into the trained WV-ResNet to obtain the classification result of the alkaline battery electrode image.
[0046] In some feasible implementations, the step S2, adopting a double random sampling strategy to sample the training set for the weak classification task, includes: the double random sampling strategy includes random category sampling and random image sampling; the random category sampling includes randomly selecting categories from the training set to ensure that each category receives balanced attention during the training process; the random image sampling includes randomly selecting the same number of images in each category. Specifically, in the weak classification task, the sample resampling and training process are as follows: the input training set is defined as D = {(x1, y1),…, (x n ,y n )}, which includes the training image x i And the corresponding true category label y i , where y i∈{1,…,c}. The category of the weak classification task is defined as T=RS({1,…,c},c'), where RS(X,n) means randomly selecting n elements from the set X, and c' matches the number of categories in the test set. Using the strategy, in the weak classification stage, the randomly selected sample labels are reassigned numbers by category, ranging from 1 to c'. Therefore, in different small sample weak classification tasks, images belonging to the same category may correspond to different category labels. This method enables the model to learn a higher level of category description in order to better distinguish the differences between different categories. Compared with traditional practices, this method does not simply map each category image to a fixed numerical label. In the weak classification task, equal sampling is performed from each category so that the data used by the classification model in iterative training remains balanced. Overall, this means that the majority category is undersampled and the minority category is oversampled during multiple rounds of iterative training.
[0047] In some feasible embodiments, in combination with Figure 2As shown, the step S4, optimizing the convolutional neural network basic model by introducing an efficient channel attention mechanism and a PReLU activation function to obtain WV-ResNet as a feature extractor includes: the optimized convolutional neural network model is composed of four residual modules, and the residual module includes applying batch normalization and a PReLU activation function after each convolution layer; the optimized convolutional neural network model introduces an efficient channel attention module; the optimized convolutional neural network model uses a global average pooling layer and a fully connected layer as the last two layers instead of using two fully connected layers as the last two layers in the convolutional neural network basic model. Specifically, the network architecture is composed of four residual modules, each of which is composed of a standard branch and a residual shortcut branch. The standard branch refers to the design concept of VGG Net, and internally realizes a receptive field equivalent to a 7×7 convolution through a combination of three 3×3 convolutional layers, while reducing the parameters by about 50%. In each residual module, the first convolution layer of the standard branch and the residual shortcut branch double the number of channels of the feature map by amplifying the convolution kernel, while the subsequent layers maintain the number of channels unchanged. All convolutional layers use a 3×3 size, and the stride and padding are set to 1 to ensure that the input and output feature maps are consistent in dimension. This method allows the standard branch and the residual shortcut branch to be directly added, which promotes the fusion of shallow and deep features, simplifies the learning process of the identity mapping, and thus accelerates the convergence speed and representation ability of the model. After the feature fusion of each residual module, the feature map is downsampled by using a 2×2 pooling layer to reduce its height and width to half of the original to achieve the purpose of feature dimensionality reduction and reduce the possibility of overfitting. The design of the residual module includes applying batch normalization (BN) and PReLU activation function after each convolutional layer. As a core component of CNN, the BN layer normalizes the mean and variance of batch data, which not only significantly improves the convergence speed of the model, but also effectively alleviates the problem of gradient disappearance. In addition, this application uses the PReLU activation function to replace the traditional ReLU to promote faster model convergence and alleviate the problem of gradient disappearance. And the Efficient Channel Attention (ECA) module is introduced into the network, which adopts a local cross-channel interaction mechanism without dimensionality reduction and is efficiently executed through one-dimensional convolution. In addition, the convolution kernel size k is set by an adaptive function to adjust the range of local channel interaction, thereby providing enhanced cross-channel interaction capabilities for layers with more channels. Finally, in the convolutional neural network, the global average pooling layer is followed by the fully connected layer as the last two layers. Compared with the traditional two-layer fully connected layer design, this method significantly reduces the number of model parameters. That is, global average pooling can effectively extract the channel features of the feature map, while significantly reducing the total number of parameters in the model, which helps to reduce the possibility of overfitting of the model, thereby improving the generalization ability of the model.
[0048] In some feasible embodiments, in combination with Figure 3 As shown, step S5, the N weak classification tasks sampled in the training set are input into the feature extractor through a parallel network structure, and the high-dimensional deep features extracted by the feature extractor are trained in parallel to obtain N weak classification network models. Specifically, in order to enhance the clustering and characterization capabilities of the model, the algorithm adopts a weak classification network framework based on a parallel network structure and metric learning. This framework uses WV-ResNet as a feature extractor to train the extracted high-dimensional deep features. The main purpose of designing a weak classification network model is to learn a metric space with a robust local decision boundary through tasks created by random sampling. In this metric space, the difference between the query set sample and each support set sample can be evaluated by calculating the feature distance. This method can not only achieve simple and effective classification, but also effectively avoid the overfitting problem of the model on most class data. That is, the network architecture of the above-mentioned N weak classification network models is the same, but the parameters of their network models are different due to the difference in their training data.
[0049] In some feasible embodiments, in combination with Figure 3 As shown, the step S7, based on the F1-score of the N weak classification network models, adopts the integrated prediction method of F1-score weighted voting to vote on the prediction results generated based on the verification set during the training process to determine the prediction category of the final output, including: selecting M weak classification network models that meet the performance requirements from the N weak classification network models generated during the training process; verifying the M weak classification network models that meet the performance requirements through the verification set to obtain the F1-scores of the M weak classification network models on the verification set respectively; using the F1-score as the weight in the weighted voting process, and calculating a comprehensive voting score for each category based on the image input from the verification set through the soft voting mechanism; and using the Softmax function to calculate the prediction probability of each category based on the comprehensive voting score of each category.
[0050] Preferably, the selecting M weak classification network models that meet the performance requirements from the N weak classification network models generated during the training process includes: screening out the M models with the best performance based on the F1-score of each weak classification model on the validation set, and the performance is positively correlated with the F1-score; the F1-score calculation formula is:
[0051] In the formula, Precision is the accuracy of the model, and Recall is the recall rate of the model.
[0052] That is, by calculating the F1 scores, the M weak classification network models with the highest F1 scores are selected.
[0053] Preferably, the step of calculating the predicted probability of each category based on the comprehensive voting score of each category using the Softmax function includes:
[0054]
[0055] In the formula, x represents the input image, k represents the predicted category, and V ik Represents the predicted probability of the i-th weak classification model for category k, F1 i represents the F1 score of the i-th weak classification model, and c' is the total number of categories.
[0056] That is, due to the complexity of alkaline battery electrode image data and the significant imbalance in the number of categories, even images within the same category may have huge differences in their feature distribution. This leads to differences in the category feature representation even for the same validation set, due to the selection of different training set images for different weak classification tasks, which affects the consistency of the prediction results. Therefore, in order to make full use of existing data resources and improve the performance of the model, a weighted voting based on F1-score is introduced to obtain the final prediction results based on the fine-grained category representation capability of the weak classification framework. By integrating the prediction results of the trained weak classification models through weighted voting, a classifier with high accuracy and high generalization is constructed to achieve accurate classification of the test set images. In the F1-score weighted voting method, the top-M models with the best performance are first selected based on the F1 score of each weak classification model on the validation set. The F1 scores of these models are used as weights in the weighted voting process, and the final category attribution of the test image is determined through a soft voting mechanism.
[0057] In some feasible implementations, the step S7, based on the F1-score of the N weak classification network models, uses an integrated prediction method of F1-score weighted voting to vote on the prediction results generated based on the validation set during the training process to determine the prediction category of the final output, including: constructing a dictionary corresponding to a key value for each image in the validation set, wherein the key is a potential category label and the value is a cumulative voting result of the corresponding category based on a weighted score; calculating a comprehensive voting score for each category by weighted summing up the prediction results given by the selected M weak classification models according to their F1 scores; and calculating the prediction probability of each category based on the comprehensive voting score using the Softmax function.
[0058] The step S8, completing the training process of the WV-ResNet based on the predicted category of the output, includes: calculating the multi-category cross entropy loss by comparing the predicted category probability of the validation set with the corresponding true category label; and performing model training according to the multi-category cross entropy loss using stochastic gradient descent. Specifically, in the training phase, the multi-category cross entropy loss is calculated by comparing the predicted category probability of the validation set with the corresponding true category label. Then, the model is trained according to this weak classification loss using stochastic gradient descent (SGD), and this process is repeated for each iteration. Since the training process of the neural network is already very mature in the prior art, it will not be described here.
[0059] In some feasible embodiments, in combination with Figure 4 As shown in the figure, the horizontal axis is the number of iterations, and the vertical axis is the loss function value. The training loss of WV-ResNet decreases rapidly and steadily approaches zero after about 25 batches, indicating the applicability of the selected hyperparameters and the stability of the training process. At the same time, the loss trend of the validation set is roughly consistent with that of the training set, indicating that the algorithm effectively avoids overfitting and exhibits good generalization.
[0060] In some feasible embodiments, in combination with Figure 5 As shown in the figure, in order to specifically illustrate the effects of different methods on various image recognition on the test set, a confusion matrix is used for display. In the figure, the vertical axis represents the actual category, and the horizontal axis represents the predicted category. The alkaline battery electrode images are divided into ten main categories: normal positive electrode image (A1), normal negative electrode image (A2), negative electrode notch (A3), negative electrode protrusion (A4), negative electrode without cover (A5), negative electrode scratch (A6), positive electrode notch (A7), negative electrode contamination (A8), positive electrode contamination (A9), positive electrode bruise (A10). It can be seen that the traditional deep learning method ( Figure 5 (a)-(c)) in the example tend to misclassify samples of the minority class as the majority class when dealing with data imbalance. This is mainly because the majority of the head classes are dominant in the gradient descent process. Specifically, the weighted voting (WV-ResNet) ( Figure 5 (d)) classification method, and two strategies commonly used to deal with data imbalance problems: weighted loss function W-ResNet ( Figure 5 (b)) and the oversampling method O-ResNet( Figure 5(c)) are compared, and these two methods represent the common approaches to solving the problem at the data level and algorithm level, respectively. Among them, O-ResNet oversamples the original data to make the number of samples in each category in the training set the same. The loss weight of each category in W-ResNet is calculated by dividing the number of samples in the largest category by the number of samples in each category. To ensure the fairness of the comparison, the above three models all use the same basic feature extraction network, namely ECA-ResNet. In the defect classification of alkaline battery electrode images, WV-ResNet uses a 10-way 5-shot 5-query weak classification task, in which the hyperparameters of the weak classification task are flexibly set according to the sample distribution of the data set and the available hardware conditions. All models are trained using SGD (stochastic gradient descent) and a momentum of 0.9. The initial learning rate and weight decay are 0.001 and 0.0005, respectively. The step-wise learning rate strategy uses a method of reducing the learning rate every 25 cycles, with a learning rate decay step size (step_size) of 25 and a learning rate decay weight (gamma) of 0.1, that is, reducing the learning rate by 0.1 times every 25 cycles. In addition, for the alkaline battery electrode image dataset, based on a comprehensive consideration of computational cost and prediction performance, the top 50 weak classification models with the highest F1 scores were selected for weighted voting prediction.
[0061] In some feasible implementations, the method further includes: calculating the precision, recall and F1 score of the trained WV-ResNet using a test set; and evaluating the model using the precision, recall and F1 score. Specifically, the test results of the F1 score are shown in Table 1 below.
[0062] Table 1: F1 accuracy comparison of alkaline battery electrode image classification results
[0063]
[0064] The analysis shows that the average F1 score of WV-ResNet reaches 0.983, which is 0.041 higher than that of ECA-ResNet.
[0065] Example 2
[0066] See also Figure 6 , this embodiment provides a structural schematic diagram of an image classification system based on F1-score weighted voting.
[0067] As an example, the system adopts the image classification method based on F1-score weighted voting described in Example 1, and the system includes:
[0068] The partitioning module 610 is adapted to partition the data set into a training set, a test set and a validation set.
[0069] The weak classification task sampling module 620 is adapted to perform weak classification task sampling on the training set using a double random sampling strategy.
[0070] The network model building module 630 is suitable for building a convolutional neural network basic model.
[0071] The network model optimization module 640 is suitable for optimizing the convolutional neural network basic model by introducing an efficient channel attention mechanism and a PReLU activation function to obtain WV-ResNet as a feature extractor.
[0072] The weak classification network model generation module 650 is suitable for inputting N weak classification tasks sampled from the training set into the feature extractor through a parallel network structure, and performing parallel training on the high-dimensional deep features extracted by the feature extractor to obtain N weak classification network models respectively.
[0073] The calculation module 660 is adapted to calculate the F1-scores of the N weak classification network models on the validation set during the training process.
[0074] The verification module 670 is adapted to determine the prediction category of the final output by voting on the prediction results generated based on the verification set during the training process based on the F1-score of the N weak classification network models using an integrated prediction method of F1-score weighted voting.
[0075] The training module 680 is adapted to complete the training process of the WV-ResNet based on the predicted category of the output.
[0076] The result output module 690 is adapted to input the collected alkaline battery electrode image into the trained WV-ResNet to obtain the alkaline battery electrode image classification result.
[0077] It is not difficult to find that this embodiment is a system embodiment corresponding to the first embodiment, and this embodiment can be implemented in conjunction with the first embodiment. The relevant technical details mentioned in the first embodiment are still valid in this embodiment, and in order to reduce repetition, they are not repeated here. Accordingly, the relevant technical details mentioned in this embodiment can also be applied in the first embodiment.
[0078] It is worth mentioning that all modules involved in this embodiment are logical units. In practical applications, a logical unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. In addition, in order to highlight the innovative part of the present invention, this embodiment does not introduce units that are not closely related to solving the technical problem proposed by the present invention, but this does not mean that there are no other units in this embodiment.
[0079] Example 3
[0080] See also Figure 7 An embodiment of the present invention further provides an electronic device, comprising: a memory and a processor; the memory stores at least one program instruction; the processor implements the image classification method based on F1-score weighted voting provided in Example 1 by loading and executing the at least one program instruction.
[0081] The memory 702 and the processor 701 are connected in a bus manner, and the bus may include any number of interconnected buses and bridges, and the bus connects various circuits of one or more processors 701 and the memory 702 together. The bus can also connect various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. The data processed by the processor 701 is transmitted on a wireless medium via an antenna, and further, the antenna also receives data and transmits the data to the processor 701.
[0082] The processor 701 is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management and other control functions. The memory 702 can be used to store data used by the processor 701 when performing operations.
[0083] Example 4
[0084] The embodiment of the present invention further proposes a storage medium, on which is stored an image classification method based on F1-score weighted voting, and when the image classification program based on F1-score weighted voting is executed by a processor, the steps of the image classification method based on F1-score weighted voting as described above are implemented. Since the storage medium adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought by the technical solutions of the above embodiments, which will not be repeated here one by one.
[0085] The above is only an embodiment of the present invention. The common sense such as the known specific structure and characteristics in the scheme is not described in detail here. The ordinary technicians in the relevant field know all the common technical knowledge in the technical field of the invention before the application date or priority date, can know all the existing technologies in the field, and have the ability to apply the conventional experimental means before that date. The ordinary technicians in the relevant field can improve and implement this scheme in combination with their own abilities under the enlightenment given by this application. Some typical known structures or known methods should not become obstacles for ordinary technicians in the relevant field to implement this application. It should be pointed out that for those skilled in the art, without departing from the structure of the present invention, several deformations and improvements can be made, which should also be regarded as the scope of protection of the present invention, which will not affect the effect of the implementation of the present invention and the practicality of the patent. The scope of protection required by this application shall be based on the content of its claims, and the specific implementation methods and other records in the specification can be used to interpret the content of the claims.
Claims
1. An image classification method based on F1-score weighted voting, characterized in that: The method comprises: S1, divide the data set into training set, test set and validation set; S2. Using a double random sampling strategy to sample the weak classification task on the training set; S3. Build a basic convolutional neural network model; S4. By introducing an efficient channel attention mechanism and a PReLU activation function, the convolutional neural network basic model is optimized to obtain WV-ResNet as a feature extractor; S5, sampling the N weak classification tasks obtained in the training set and inputting them into the feature extractor through a parallel network structure, and performing parallel training on the high-dimensional deep features extracted by the feature extractor to obtain N weak classification network models respectively; S6. Calculate the F1-score of the N weak classification network models on the validation set during the training process; S7, based on the F1-score of the N weak classification network models, an integrated prediction method of F1-score weighted voting is used to vote on the prediction results generated based on the validation set during the training process to determine the prediction category of the final output; S8. Complete the training process of the WV-ResNet based on the output prediction category; S9. Input the collected alkaline battery electrode image into the trained WV-ResNet to obtain the alkaline battery electrode image classification result.
2. The image classification method based on F1-score weighted voting according to claim 1, characterized in that: The step S2, sampling the training set for weak classification tasks using a double random sampling strategy, comprises: The double random sampling strategy includes random category sampling and random image sampling; The random category sampling includes randomly selecting categories from the training set to ensure that each category receives balanced attention during the training process; The random image sampling includes randomly selecting the same number of images in each category.
3. The image classification method based on F1-score weighted voting according to claim 1, characterized in that: The step S4, optimizing the convolutional neural network basic model by introducing an efficient channel attention mechanism and a PReLU activation function to obtain WV-ResNet as a feature extractor, comprises: The optimized convolutional neural network model consists of four residual modules, which include batch normalization and PReLU activation function applied after each convolution layer; An efficient channel attention module is introduced into the optimized convolutional neural network model; The optimized convolutional neural network model uses a global average pooling layer and a fully connected layer as the last two layers instead of using two fully connected layers as the last two layers in the convolutional neural network basic model.
4. The image classification method based on F1-score weighted voting according to claim 1, characterized in that: The step S7, based on the F1-score of the N weak classification network models, adopts an integrated prediction method of F1-score weighted voting to vote on the prediction results generated based on the validation set during the training process to determine the prediction category of the final output, including: Select M weak classification network models that meet the performance requirements from the N weak classification network models generated during the training process; The M weak classification network models that meet the performance requirements are verified through the verification set to obtain the F1-scores of the M weak classification network models on the verification set; The F1-score is used as a weight in the weighted voting process, and a comprehensive voting score is calculated for each category based on the images input from the validation set through a soft voting mechanism; The Softmax function is used to calculate the predicted probability of each category based on the comprehensive voting score of each category.
5. The image classification method based on F1-score weighted voting according to claim 4, characterized in that: The selecting M weak classification network models that meet the performance requirements from the N weak classification network models generated during the training process includes: Based on the F1-score of each weak classification model on the validation set, M models with the best performance are selected, and the performance is positively correlated with the F1-score; The F1-score calculation formula is: In the formula, Precision is the accuracy of the model, and Recall is the recall rate of the model.
6. The image classification method based on F1-score weighted voting according to claim 4, characterized in that: The method of calculating the predicted probability of each category based on the comprehensive voting score of each category using the Softmax function includes: In the formula, x represents the input image, k represents the predicted category, and V ik Represents the predicted probability of the i-th weak classification model for category k, F1 i represents the F1 score of the i-th weak classification model, and c' is the total number of categories.
7. The image classification method based on F1-score weighted voting according to claim 4, characterized in that: The step S7, based on the F1-score of the N weak classification network models, adopts an integrated prediction method of F1-score weighted voting to vote on the prediction results generated based on the validation set during the training process to determine the prediction category of the final output, including: For each image in the validation set, a key-value dictionary is constructed, where the key is the potential category label and the value is the cumulative voting result of the corresponding category based on the weighted score; By weighting the prediction results given by the selected M weak classification models according to their F1 scores, a comprehensive voting score is calculated for each category; The Softmax function is used to calculate the predicted probability of each category based on the comprehensive voting scores.
8. The image classification method based on F1-score weighted voting according to claim 1, characterized in that: The step S8, completing the training process of the WV-ResNet based on the output prediction category, includes: The multi-class cross entropy loss is calculated by comparing the predicted class probabilities of the validation set with their corresponding true class labels; The model is trained using stochastic gradient descent according to the multi-class cross entropy loss.
9. The image classification method based on F1-score weighted voting according to claim 1, characterized in that: The method further comprises: The precision, recall and F1 score of the model are calculated by using the test set for the trained WV-ResNet. The model is evaluated by the precision, recall and F1 score.
10. An image classification system based on F1-score weighted voting, characterized in that: The system adopts the image classification method based on F1-score weighted voting according to any one of claims 1 to 9, and the system includes: The partitioning module is used to divide the data set into training set, test set and validation set; A weak classification task sampling module, adapted to perform weak classification task sampling on the training set using a double random sampling strategy; Network model building module, suitable for building convolutional neural network basic models; A network model optimization module, adapted to optimize the convolutional neural network basic model by introducing an efficient channel attention mechanism and a PReLU activation function to obtain WV-ResNet as a feature extractor; A weak classification network model generation module is adapted to input N weak classification tasks sampled from a training set into the feature extractor through a parallel network structure, and perform parallel training on the high-dimensional deep features extracted by the feature extractor to obtain N weak classification network models respectively; The calculation module is used to calculate the F1-score of N weak classification network models on the validation set during the training process; A verification module is adapted to vote on the prediction results generated based on the verification set during the training process to determine the prediction category of the final output based on the F1-score of the N weak classification network models using an integrated prediction method of F1-score weighted voting; A training module, adapted to complete a training process of the WV-ResNet based on the predicted category of the output; The result output module is suitable for inputting the collected alkaline battery electrode image into the trained WV-ResNet to obtain the classification result of the alkaline battery electrode image.
Citation Information
Cited By
Transfer learning method and device based on privacy sample importance evaluation
CN120910558A