Image classification method and system based on improved lightweight channel attention mechanism
The lightweight channel attention mechanism connected to the residuals through the broadcast mechanism, solves the problems of high computational complexity and difficult training in the prior art, improves the stability and feature extraction capabilities of the model, and is especially suitable for image classification tasks, especially on resource-constrained devices.
Patent Information
- Application Number
- CN202510376945.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-28
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2045-03-28
AI Technical Summary
The existing channel attention mechanism has high computational complexity and high training difficulty in lightweight models, limited applicable scenarios, and insufficient stability of lightweight design, limited feature learning ability, and generalization ability needs to be improved.
A lightweight channel attention mechanism connected to the residual is adopted by a broadcast mechanism, and a channel attention weight is generated through global average pooling, lightweight convolution and Sigmoid activation functions, and a residual connection is introduced, which is directly added to the input feature map, reducing the calculation complexity and parameter amount, alleviating the problem of gradient disappearance, and improving feature extraction capabilities.
It significantly reduces the computational complexity and parameter quantity, improves model training stability and generalization capabilities, and enhances feature extraction capabilities. It is especially suitable for image classification tasks, especially on resource-constrained devices.
Smart Images

Figure CN120451621A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of convolutional neural networks (CNNs) in deep learning, and in particular relates to an image classification method and system based on an improved lightweight channel attention mechanism. Background Art
[0002] SENet (Squeeze-and-Excitation Networks) is a classic channel attention mechanism. Its core idea is to dynamically recalibrate channel feature responses through two steps: "squeezing" and "excitation". The specific implementation process is: the spatial dimension of the feature map is compressed to 1×1 through global average pooling, retaining the global information of the channel dimension; the squeezed features are passed through two fully connected layers. The first fully connected layer reduces the number of channels to the original 1 / r (r is the dimensionality reduction ratio), and the second fully connected layer restores the number of channels to the original size, and generates channel attention weights through the Sigmoid activation function; the generated channel attention weights are multiplied by the original feature map channel by channel to enhance important channel features and suppress unimportant channel features. SENet can significantly improve the performance of convolutional neural networks, especially in image classification tasks. However, SENet introduces additional fully connected layers, which increases the computational complexity and parameter count of the model, which is not conducive to the design of lightweight models. Although SENet can significantly improve the performance of convolutional neural networks, it has the following problems:
[0003] (1) High computational complexity: SENet introduces two fully connected layers. The first fully connected layer reduces the number of channels to 1 / r (r is the dimensionality reduction ratio), and the second fully connected layer restores the number of channels to the original size. This design increases the computational complexity and parameter count of the model, which is not conducive to the design of lightweight models.
[0004] (2) Difficulty in training: Due to the introduction of additional fully connected layers, SENet is prone to gradient vanishing or gradient exploding problems during training, especially in deep networks, which affects the convergence speed and final performance of the model.
[0005] (3) Limited applicable scenarios: SENet was originally designed to improve the performance of image classification tasks, but in some scenarios that require lightweight models (such as mobile devices or edge computing), its computational overhead and parameter count are too large, which limits its application scope.
[0006] ECA-Net (Efficient Channel Attention Networks) is a lightweight channel attention mechanism designed to reduce the computational overhead of the fully connected layers in SENet. Its core concept is to replace the two fully connected layers in SENet with an adaptive convolution kernel, thereby efficiently generating channel attention weights. The specific implementation process is as follows: ECA-Net first compresses the spatial dimensions of the feature map to 1×1 through global average pooling. ECA-Net then introduces an adaptive convolution kernel whose size dynamically adjusts based on the number of channels. This convolution kernel weights the squeezed features using a 1D convolution operation to generate channel attention weights. The generated channel attention weights are then multiplied channel by channel with the original feature map to achieve channel feature recalibration. While maintaining the performance of the channel attention mechanism, ECA-Net significantly reduces the amount of computation and parameters, making it suitable for lightweight model design. However, its adaptive convolution kernel design may not be as stable as SENet in some complex scenarios. While replacing the fully connected layers in SENet with adaptive convolution kernels, ECA-Net reduces computation and parameter requirements, but it suffers from the following issues in certain complex scenarios:
[0007] (1) Insufficient stability: Although the adaptive convolution kernel design of ECA-Net reduces computational overhead, its performance may not be as stable as SENet when dealing with complex scenarios or tasks with large changes in data distribution.
[0008] (2) Limited feature learning ability: ECA-Net sacrifices a certain amount of feature learning ability in its lightweight design. Especially when dealing with small target detection or complex background tasks, its feature enhancement effect may not be as significant as SENet.
[0009] (3) Generalization ability needs to be improved: Since the design of ECA-Net tends to be lightweight, it may not be able to fully utilize the advantages of the channel attention mechanism in certain specific tasks (such as high-resolution image processing), resulting in limited generalization ability.
[0010] Through the above analysis, the problems and defects of the existing technology are as follows: the existing channel attention mechanism SENet has high computational complexity, is difficult to train, and has limited applicable scenarios; while the lightweight channel attention mechanism ECA-Net is insufficiently stable, has limited feature learning ability, and its generalization ability needs to be improved. Summary of the Invention
[0011] To overcome the problems of high computational complexity, unstable training, and limited feature extraction capabilities of the existing channel attention mechanism in lightweight models, the disclosed embodiments of the present invention provide an image classification method and system based on an improved lightweight channel attention mechanism. The technical solution is as follows:
[0012] The present invention is implemented as follows: an image classification method based on an improved lightweight channel attention mechanism comprises the following steps:
[0013] S1, input feature map, through the global average pooling operation, compress the spatial dimension to 1×1, retain the global information of the channel dimension, and obtain the feature map after global average pooling;
[0014] S2, the feature map after global average pooling is sequentially operated with full connection layer and Sigmoid activation function to obtain the channel attention weight W att ;
[0015] S3, introduce residual connection, set the weight α of the residual connection, multiply the input feature map by the weight of the residual connection to obtain the output feature map F x ;
[0016] S4, through the broadcast mechanism, the obtained channel attention weight W att Expand to the output feature map F x With the same dimension, the output feature map F is obtained r , the output feature map F x With F r Add together to get the final output feature map F e .
[0017] In step S1, the dimension of the input feature map X is [b, c, h, w]; where b is the batch size, c is the number of channels, h is the height of the feature map, and w is the width of the feature map.
[0018] In step S1, a global average pooling operation is performed, including: creating a global average pooling layer, dynamically calculating the size and step size of the pooling window according to the size of the input feature map and the specified output size; performing an average pooling operation on each channel, and generating a single numerical output for each input channel.
[0019] In step S1, the feature map X after global average pooling pool for:
[0020]
[0021] Among them, h is the height of the feature map, w is the width of the feature map, i is the index of the feature map in the height direction, the value range of i is from 1 to h, j is the index of the feature map in the width direction, the value range of j is from 1 to w, X :,:,i,j is the value of the feature map at position (:,:,i,j).
[0022] In step S2, it also includes: the lightweight convolution operation is 1×1 convolution.
[0023] Furthermore, a convolution layer is created, and the weight parameter of the 1×1 convolution is set to K, the dimension is [c, c, 1, 1], the bias parameter is set to d, and the dimension is [c]. The features after global average pooling are weighted by 1×1 convolution to generate the channel attention weight raw score. The generated channel attention weight raw score is normalized using the Sigmoid activation function to obtain the channel attention weight W. att , this operation makes the channel attention weight W att The value range is between 0 and 1, and the expression is:
[0024] W att =σ(K·X pool +d)
[0025]
[0026] Where σ(·) is the Sigmoid activation function, which is used to normalize the generated channel attention weight raw score to between 0 and 1; K·X pool +d is a 1×1 convolution operation, which is used to perform weighted summation of the eigenvalues of each channel.
[0027] In step S3, the residual connection is introduced, the weight α of the residual connection is set, and the input feature map X is multiplied by α to obtain the output feature map F x , the expression is:
[0028] F x =α×X.
[0029] In step S4, the generated channel attention weights are directly added to the output feature map F through the broadcast mechanism. x Add together to get the final output feature map F e , the expression is:
[0030] F e =W att +F x =F r +F x
[0031] Among them, W att The dimension is [b,c,1,1], which is expanded to the same dimension as F through the broadcast mechanism. x Same dimensions [b,c,h,w], F r W att Expanded feature map.
[0032] Furthermore, the broadcasting mechanism follows the following rules: align the dimensions of the tensors from back to front; broadcast if the two tensors have the same size in a certain dimension, or if the size of one of the tensors in that dimension is 1; if the size of a tensor in a certain dimension is 1, expand to the size of the other tensor in that dimension.
[0033] Another object of the present invention is to provide an image classification system based on an improved lightweight channel attention mechanism, which is used to regulate the image classification method based on the improved lightweight channel attention mechanism, and the system includes:
[0034] The global average pooling module is used to compress the spatial dimension of the input feature map into 1×1 through the global average pooling operation, retaining the global information of the channel dimension, and obtaining the feature map after global average pooling;
[0035] The feature weighting module is used to weight the feature map after global average pooling through lightweight convolution operation, generate the original score of channel attention weight and normalize it using Sigmoid activation function to obtain the channel attention weight W. att ;
[0036] The residual connection module is used to introduce the residual connection, set the weight of the residual connection, and multiply the input feature map X by the weight of the residual connection to obtain the output feature map F x ;
[0037] The image classification module is used to broadcast the channel attention weight W of the feature weighting module through the broadcast mechanism. att Expand to the output feature map F x With the same dimension, the output feature map F is obtained r ; Output feature map F x With F r Add together to get the final output feature map F e .
[0038] In combination with all the above technical solutions, the beneficial effects of the present invention are as follows:
[0039] First, the present invention relates to a lightweight channel attention mechanism based on a broadcast mechanism and residual connections, which is mainly used to improve the performance of convolutional neural networks in image classification tasks. By introducing a channel attention mechanism, the present invention can better focus on the important channel information in the input feature map, thereby improving the distinguishing ability of feature expression and the generalization ability of the model. The key points are as follows:
[0040] (1) Lightweight design: This paper significantly reduces computational complexity and parameter count through a broadcast mechanism and lightweight convolution operations. This reduces the computational burden of the model and, through the design of residual connections, better preserves feature information and improves performance.
[0041] (2) Combination of broadcast mechanism and residual connection: The broadcast mechanism makes the processing of channel features more efficient and can quickly weight global information, thereby enhancing important features. Residual connection effectively alleviates the gradient vanishing problem in deep networks and improves the training stability and generalization ability of the model.
[0042] (3) Optimization for image classification tasks: This invention is specifically optimized for image classification tasks. Through lightweight design and optimized channel attention mechanism, the performance of the model in image classification tasks is significantly improved. This design enables the model to better extract and utilize image features while maintaining its lightweight, thereby improving classification accuracy. Through lightweight design, this invention can be better deployed on resource-constrained devices, such as mobile devices or edge computing platforms.
[0043] (4) Enhanced feature extraction: Through the broadcast mechanism and residual connections, the present invention can more effectively extract and utilize important features, significantly improving model performance, especially in complex backgrounds and multi-category image classification scenarios. This enhanced feature extraction capability helps improve the model's ability to distinguish between different image categories, thereby improving classification accuracy.
[0044] (5) High efficiency and stability: While reducing the amount of computation and parameters, the present invention maintains the high performance and stability of the model by optimizing the design of the channel attention mechanism. This gives the present invention a significant advantage in lightweight models and enables better adaptation to various application scenarios.
[0045] Second, this invention solves the following technical problems of the existing channel attention mechanism in lightweight models, thereby improving the performance and applicability of lightweight models in image classification tasks:
[0046] (1) Reduce computational complexity and parameter count: Existing channel attention mechanisms (such as SENet) recalibrate channel features by introducing multiple fully connected layers. Although this improves performance, it significantly increases the computational complexity and parameter count of the model. This makes it difficult for the model to run efficiently on resource-constrained devices (such as mobile devices or edge computing platforms). Although ECA-Net reduces the amount of computation through adaptive convolution kernels, its performance stability is insufficient in complex scenarios. Therefore, the present invention proposes a lightweight channel attention mechanism based on a broadcast mechanism and residual connections, aiming to further reduce computational complexity and parameter count while maintaining or improving model performance.
[0047] (2) Improving model training stability and generalization capabilities: Existing lightweight models are prone to gradient vanishing or gradient exploding problems during training, resulting in slow model convergence and limited generalization capabilities. By introducing residual connections, this paper alleviates the gradient problem in deep networks and improves the model training stability and generalization capabilities.
[0048] (3) Enhanced feature extraction capability: Lightweight models may lose some important feature information while reducing the number of parameters. This invention uses a broadcast mechanism and residual connections to more efficiently process channel features and enhance the model's ability to extract important features.
[0049] (4) Optimization for image classification tasks: This invention is specifically optimized for image classification tasks. Through lightweight design and optimized channel attention mechanism, the performance of the model in image classification tasks is significantly improved. This design enables the model to better extract and utilize image features while maintaining its lightweight, thereby improving classification accuracy. Through lightweight design, this invention can be better deployed on resource-constrained devices, such as mobile devices or edge computing platforms.
[0050] (5) Balance between efficiency and stability: While reducing the amount of computation and parameters, the model maintains high performance and stability by optimizing the design of the channel attention mechanism. This balance enables the model to be lightweight while maintaining high accuracy and stability, making it particularly suitable for image classification tasks that require efficient operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure;
[0052] Figure 1 This is a flow chart of an image classification method based on an improved lightweight channel attention mechanism provided by an embodiment of the present invention;
[0053] Figure 2 This is a schematic diagram of the principle of a lightweight channel attention mechanism based on a broadcast mechanism and residual connection provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0054] To make the above-mentioned objects, features, and advantages of the present invention more readily apparent, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings. The following description sets forth numerous specific details to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways than those described herein, and those skilled in the art may make similar modifications without departing from the scope of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0055] The innovation of the present invention is:
[0056] (1) Lightweight channel attention mechanism: We propose a lightweight channel attention mechanism that replaces the traditional fully connected layer with a broadcast mechanism and lightweight convolution operations (1×1 convolution), significantly reducing the computational complexity and number of parameters. This design makes the model more suitable for running on resource-constrained devices while maintaining high performance.
[0057] (2) Application of broadcast mechanism: The broadcast mechanism is used to directly add the channel attention weight to the input feature map instead of multiplying them. This design enhances the model's ability to extract important channel features.
[0058] (3) Optimization of residual connections: Residual connections are introduced to adjust the weighted ratio of input features and attention weights through the hyperparameter α. Residual connections effectively alleviate the gradient vanishing problem in deep networks and improve the training stability and generalization ability of the model.
[0059] (4) Optimization for image classification tasks: This paper is specifically optimized for image classification tasks. Through a lightweight design and an optimized channel attention mechanism, the model's performance in image classification tasks is significantly improved. This design enables the model to better extract and utilize image features while maintaining its lightweight, thereby improving classification accuracy.
[0060] (5) Balance between efficiency and stability: While reducing the amount of computation and parameters, the model maintains high performance and stability by optimizing the design of the channel attention mechanism. This balance enables the model to be lightweight while maintaining high accuracy and stability, making it particularly suitable for image classification tasks that require efficient operation.
[0061] Example 1, as Figure 1 and Figure 2 As shown, the image classification method based on the improved lightweight channel attention mechanism provided by the embodiment of the present invention includes the following steps:
[0062] S1, input feature map, through the global average pooling operation, compress the spatial dimension to 1×1, retain the global information of the channel dimension, and obtain the feature map after global average pooling;
[0063] Assume that the dimension of the input feature map X is [b,c,h,w], where b is the batch size, c is the number of channels, h is the height of the feature map, and w is the width of the feature map. The input feature map is compressed to 1×1 through the global average pooling operation, retaining the global information of the channel dimension, and the feature map X after global average pooling is obtained. pool , as shown below:
[0064]
[0065] Among them, h is the height of the feature map, w is the width of the feature map, i is the index of the feature map in the height direction, the value range of i is from 1 to h, j is the index of the feature map in the width direction, the value range of j is from 1 to w, X :,:,i,j is the value of the feature map at position (:,:,i,j).
[0066] Assume that the weight parameter of 1×1 convolution is K, its dimension is [c,c,1,1], the bias parameter is d, and the dimension is [c]. The features after global average pooling are weighted by lightweight convolution operation (1×1 convolution) to generate the channel attention weight raw score; the generated channel attention weight raw score is normalized using Sigmoid activation function to obtain the channel attention weight W. att , this operation makes the channel attention weight W att The value range of is between 0 and 1, as shown in the following formula:
[0067] W att =σ(K·X pool +d)(2)
[0068]
[0069] Where σ(·) is the Sigmoid activation function, which is used to normalize the generated channel attention weight raw score to between 0 and 1; K·X pool +d is a 1×1 convolution operation, which is used to perform weighted summation of the eigenvalues of each channel.
[0070] S2, the feature map after global average pooling is sequentially operated with full connection layer and Sigmoid activation function to obtain the channel attention weight W att ;
[0071] Introduce residual connection, set the weight α of residual connection, multiply the input feature map X by α to get the output feature map F x , as shown below:
[0072] F x =α×X(4)
[0073] Through the broadcast mechanism, the generated channel attention weights are directly added to the output feature map F x Add together to get the final output feature map F e , as shown below:
[0074] F e =W att +F x =F r +F x (5)
[0075] Among them, W att The dimension is [b,c,1,1], which is expanded to the same dimension as F through the broadcast mechanism. x Same dimensions [b,c,h,w], F r W att Expanded feature map.
[0076] The pseudo codes of step S1 and step S2 of the present invention are shown in Table 1.
[0077] Table 1 Pseudo code description of the present invention
[0078]
[0079]
[0080] S3, introduce residual connection, set the weight α of the residual connection, multiply the input feature map by the weight of the residual connection to obtain the output feature map F x ;
[0081] S4, through the broadcast mechanism, the obtained channel attention weight W att Expand to the output feature map F x With the same dimension, the output feature map F is obtained r , the output feature map F x With F r Add together to get the final output feature map F e .
[0082] In Example 2, an image classification system based on an improved lightweight channel attention mechanism provided by an embodiment of the present invention includes:
[0083] The global average pooling module is used to compress the spatial dimension of the input feature map into 1×1 through the global average pooling operation, retaining the global information of the channel dimension, and obtaining the feature map after global average pooling;
[0084] The feature weighting module is used to weight the feature map after global average pooling through lightweight convolution operation, generate the original score of channel attention weight and normalize it using Sigmoid activation function to obtain the channel attention weight W. att ;
[0085] The residual connection module is used to introduce the residual connection, set the weight of the residual connection, and multiply the input feature map X by the weight of the residual connection to obtain the output feature map F x ;
[0086] The image classification module is used to broadcast the channel attention weight W of the feature weighting module through the broadcast mechanism. att Expand to the output feature map F xWith the same dimension, the output feature map F is obtained r ; Output feature map F x With F r Add together to get the final output feature map F e .
[0087] The lightweight channel attention mechanism based on broadcast mechanism and residual connection proposed in this invention is inserted into the last layer of the backbone in the YOLOv8n-cls model. The dataset is the public dataset CIFAR-100, the epochs is 200, the imgsz is 32, the batch is 200, and the other hyperparameters are all default settings. The attention mechanism is inserted into the last layer of the backbone in the ResNet34 model, the epochs is 80, the Adam optimizer is used, the learning rate is 0.0001, and the experimental equipment are i9-14900k (CPU) and RTX-4090 (GPU); the experimental results are shown in Table 2.
[0088] Table 2 Experimental results
[0089] top1 Top 5 Parameter quantity FLOPs YOLOv8n-cls 56.63% 83.66% 1.57M 3.5G YOLOv8n-cls+the present invention 57.31% 83.84% 1.63M 3.5G ResNet34 71.28% 91.72% 21.34M 30.0G ResNet34+Invention 71.57% 91.79% 21.60M 30.0G
[0090] Experiments have shown that the lightweight channel attention mechanism based on broadcast mechanism and residual connection proposed in the present invention can significantly improve the classification performance of YOLOv8n-cls and ResNet34 models on the CIFAR-100 dataset, while maintaining high computational efficiency and good generalization ability. This mechanism enables the model to better focus on important features by enhancing the ability to extract channel features, thereby improving classification accuracy. Experimental results show that the present invention has a significant improvement in the top1 accuracy (0.68%) and a slight improvement in the top5 accuracy (0.18%) in the YOLOv8n-cls model. The original model of YOLOv8n-cls has 1.57M parameters. After adding the attention mechanism of the present invention, the number of parameters only increases to 1.63M, an increase of 0.06M (3.82%). This shows that the attention mechanism of the present invention only introduces a very small amount of additional parameters while improving performance, which is almost negligible. In the ResNet34 model, the top1 is improved by 0.29% and the top5 is improved by 0.07%. The original ResNet34 model has 21.34M parameters. After adding the attention mechanism of the present invention, the number of parameters increased to 21.60M, an increase of 0.26M (1.22%). Again, this increase in parameters is very small and has almost no impact on the overall complexity of the model. In both the YOLOv8n-cls and ResNet34 models, after adding the attention mechanism of the present invention, the FLOPs remained unchanged (3.5G and 30.0G, respectively), indicating that the attention mechanism of the present invention is very efficient in design and does not significantly increase the computational complexity of the model, thereby improving performance while maintaining efficient computation.
[0091] In addition, a detailed ablation experiment was conducted on the classification performance of YOLOv8n-cls on the CIFAR-100 dataset. The input feature map-adaptive average pooling-fully connected layer-Sigmoid activation-channel attention weight is used as module 1, the residual connection is used as module 2, and the broadcast-output feature map F is used as module 3. r As module 3, if module 3 is not used, the conventional operation in the field is adopted to multiply the channel attention weight with the input feature map. The experimental design is shown in Table 3, and the ablation experiment results are shown in Table 4.
[0092] Table 3 Experimental plan
[0093] Module 1 Module 2 Module 3 Solution 0 × × × Solution 1 √ × × Option 2 √ √ × Option 3 √ × √ Scheme 4 (the present invention) √ √ √
[0094] Table 4 Ablation experiment
[0095]
[0096]
[0097] Solution 4 is the complete solution of this invention, utilizing Modules 1, 2, and 3 simultaneously. Both the top 1 and top 5 scores for Solution 4 are the highest among all solutions, improving by 0.50% and 0.30%, respectively, over Solution 1. Although using Modules 1 and 3 simultaneously degrades performance, combining them with Module 2 significantly improves the model's classification performance. This demonstrates that each module can play a positive role when working in synergy with the others.
[0098] Considering the technical solution as a whole or from the perspective of the product, the present invention has the following effects, which are described in detail as follows:
[0099] (1) Significantly Reduced Computational Complexity and Storage Requirements: Through the broadcast mechanism and lightweight convolution operations, this paper significantly reduces the amount of computation and the number of parameters. Compared with the traditional SENet, this paper uses 1×1 convolution instead of the traditional fully connected layer and uses it only once, further reducing the computational complexity of the model. The lightweight model significantly reduces the storage space requirements, making it easier to store and transmit in bandwidth-constrained environments.
[0100] (2) Improving model training stability and generalization capabilities: This paper introduces residual connections, which effectively alleviate the vanishing gradient problem in deep networks and improve the training stability and generalization capabilities of the model. Residual connections allow input information to directly skip one or more layers and be added to the output of subsequent layers, thereby avoiding the vanishing and exploding gradient problems in deep networks.
[0101] (3) Enhanced feature extraction capabilities: The broadcast mechanism makes channel feature processing more efficient and can quickly weight global information, thereby enhancing important features. Residual connections further enhance the model's ability to extract important features, especially in small target detection and complex background scenes, which can significantly improve the model's performance.
[0102] (4) Energy saving and environmental benefits: Lightweight models typically consume less computing resources, thereby reducing energy consumption. This is particularly important for devices that need to run for a long time, such as drones or sensor networks. In addition, the widespread deployment of lightweight models helps reduce the consumption of hardware resources, thereby achieving environmental benefits.
[0103] (5) Reduce labor intensity and improve user experience: The fast reasoning capability of lightweight models enables the model to complete tasks in a shorter time, thereby improving user experience. For example, in smart security cameras, lightweight object detection models can identify abnormal objects more quickly, issue alarms in a timely manner, and improve the response speed of the security system.
[0104] Experiments have shown that the lightweight channel attention mechanism based on the broadcast mechanism and residual connection of the present invention can significantly improve the classification performance of the YOLOv8n-cls and ResNet34 models on the CIFAR-100 dataset, while maintaining high computational efficiency and good generalization ability. This mechanism enables the model to better focus on important features by enhancing the ability to extract channel features, thereby improving classification accuracy. Experimental results show that the present invention has a significant improvement in the top1 accuracy (0.68%) and a slight improvement in the top5 accuracy (0.18%) in the YOLOv8n-cls model. In the ResNet34 model, the top1 is improved by 0.29% and the top5 is improved by 0.07%, and both maintain high efficiency in the training and inference stages.
[0105] By improving the accuracy and efficiency of image classification, this invention could help enhance the performance of various computer vision applications, such as autonomous driving, intelligent surveillance, medical image analysis, and smartphone photography. Secondly, due to its lightweight design, this method is particularly suitable for deployment on resource-constrained devices, such as mobile devices and edge computing platforms, further expanding its application scope and market potential. Furthermore, the technology's high efficiency and stability make it attractive for industries requiring fast and accurate image processing, such as online advertising, content recommendation systems, and real-time data processing services.
[0106] The present invention solves the problems of high computational complexity, high training difficulty, and limited feature extraction capabilities in the prior art by introducing a lightweight channel attention mechanism and a broadcast mechanism. Although existing channel attention mechanisms at home and abroad, such as SENet and ECA-Net, have achieved certain results in improving model performance, they still have deficiencies in lightweight design, training stability, and generalization capabilities. The technical solution of the present invention significantly reduces the computational complexity and the number of parameters by optimizing the channel attention mechanism, while improving the training stability and generalization capabilities of the model; the combination of the broadcast mechanism and the residual connection of the present invention provides a new optimization idea for image classification tasks, further promoting the technological development of deep learning in the field of image processing.
[0107] In the field of deep learning, especially in image classification tasks, how to design lightweight models that are both efficient and accurate has always been a challenge facing researchers and engineers. Although the existing channel attention mechanism can improve model performance, it is often accompanied by high computational complexity and a large number of parameters, which limits its application on resource-constrained devices. The present invention significantly reduces the computational complexity and parameter count of the model by introducing a lightweight channel attention mechanism and a broadcast mechanism, while maintaining high performance, effectively solving this problem. In addition, the present invention also improves the training stability and generalization ability of the model through the design of residual connections, further promoting the development and application of lightweight models.
[0108] The technical solution of the present invention overcomes the prejudice against the performance of lightweight models in the prior art. In the field of deep learning, people often believe that lightweight models will sacrifice the performance of the model while reducing the amount of calculation and the number of parameters. However, the present invention proves that lightweight models can also achieve high performance by optimizing the channel attention mechanism and introducing the broadcast mechanism. The present invention not only maintains the high performance of the model while reducing the amount of calculation and the number of parameters, but also improves the training stability and generalization ability of the model through the design of residual connections, thereby overcoming the prejudice against the performance of lightweight models. In addition, the lightweight design and optimized channel attention mechanism of the present invention make the model more suitable for deployment on resource-constrained devices, further broadening the application scope of deep learning technology.
[0109] The above description is only a preferred specific implementation method of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with this technical field within the technical scope disclosed by the present invention and within the spirit and principles of the present invention should be covered by the scope of protection of the present invention.
Claims
1. An image classification method based on an improved lightweight channel attention mechanism, characterized in that: The method comprises the following steps: S1, input feature map, through the global average pooling operation, compress the spatial dimension to 1×1, retain the global information of the channel dimension, and obtain the feature map after global average pooling; S2, the feature map after global average pooling is sequentially operated with full connection layer and Sigmoid activation function to obtain the channel attention weight W att ; S3, introduce residual connection, set the weight α of the residual connection, multiply the input feature map by the weight of the residual connection to obtain the output feature map F x ; S4, through the broadcast mechanism, the obtained channel attention weight W att Expand to the output feature map F x With the same dimension, the output feature map F is obtained r , the output feature map F x With F r Add together to get the final output feature map F e .
2. The image classification method based on the improved lightweight channel attention mechanism according to claim 1, characterized in that: In step S1, the dimension of the input feature map X is [b, c, h, w]; where b is the batch size, c is the number of channels, h is the height of the feature map, and w is the width of the feature map.
3. The image classification method based on the improved lightweight channel attention mechanism according to claim 1, characterized in that: In step S1, the global average pooling operation includes: creating a global average pooling layer, dynamically calculating the size and step size of the pooling window according to the size of the input feature map and the specified output size; performing an average pooling operation on each channel, and generating a single numerical output for each input channel.
4. The image classification method based on the improved lightweight channel attention mechanism according to claim 1, characterized in that: In step S1, the feature map X after global average pooling pool for: Among them, h is the height of the feature map, w is the width of the feature map, i is the index of the feature map in the height direction, the value range of i is from 1 to h, j is the index of the feature map in the width direction, the value range of j is from 1 to w, X :,:,i,j is the value of the feature map at position (:,:,i,j).
5. The image classification method based on the improved lightweight channel attention mechanism according to claim 1, characterized in that: In step S2, it also includes: the lightweight convolution operation is 1×1 convolution.
6. The image classification method based on the improved lightweight channel attention mechanism according to claim 5, characterized in that: Create a convolution layer, set the weight parameter of 1×1 convolution to K, the dimension to [c,c,1,1], the bias parameter to f, the dimension to [c]; weight the features after global average pooling through 1×1 convolution to generate the channel attention weight raw score; use the Sigmoid activation function to normalize the generated channel attention weight raw score to obtain the channel attention weight W att , this operation makes the channel attention weight W att The value range is between 0 and 1, and the expression is: W att =σ(K·X pool +d) Where σ(·) is the Sigmoid activation function, which is used to normalize the generated channel attention weight raw score to between 0 and 1; K·X pool +d is a 1×1 convolution operation, which is used to perform weighted summation of the eigenvalues of each channel.
7. The image classification method based on the improved lightweight channel attention mechanism according to claim 1, characterized in that: In step S3, the residual connection is introduced, the weight α of the residual connection is set, and the input feature map X is multiplied by α to obtain the output feature map F x , the expression is: F x =α×X。 8. The image classification method based on the improved lightweight channel attention mechanism according to claim 1, characterized in that: In step S4, the generated channel attention weights are directly added to the output feature map F through the broadcast mechanism. x Add together to get the final output feature map F e , the expression is: F e =W att +F x =F r +F x Among them, W att The dimension is [b,c,1,1], which is expanded to the same dimension as F through the broadcast mechanism. x Same dimensions [b,c,h,w], F r W att Expanded feature map.
9. The image classification method based on the improved lightweight channel attention mechanism according to claim 8, characterized in that: The broadcasting mechanism follows the following rules: align the dimensions of the tensors from back to front; broadcast if the two tensors have the same size in a certain dimension, or if the size of one of the tensors in that dimension is 1; if the size of a tensor in a certain dimension is 1, expand to the size of the other tensor in that dimension.
10. An image classification system based on an improved lightweight channel attention mechanism, characterized in that: The system is used to control the image classification method based on the improved lightweight channel attention mechanism according to any one of claims 1 to 9, and the system includes: The global average pooling module is used to compress the spatial dimension of the input feature map into 1×1 through the global average pooling operation, retaining the global information of the channel dimension, and obtaining the feature map after global average pooling; The feature weighting module is used to weight the feature map after global average pooling through lightweight convolution operation, generate the original score of channel attention weight and normalize it using Sigmoid activation function to obtain the channel attention weight W. att ; The residual connection module is used to introduce the residual connection, set the weight of the residual connection, and multiply the input feature map X by the weight of the residual connection to obtain the output feature map F x ; The image classification module is used to broadcast the channel attention weight W of the feature weighting module through the broadcast mechanism. att Expand to the output feature map F x With the same dimension, the output feature map F is obtained r ; Output feature map F x With F r Add together to get the final output feature map F e .
Citation Information
Patent Citations
Medical image super-resolution reconstruction method based on multi-attention residual feature fusion
CN113298717A
Lightweight image feature extraction method based on attention mechanism
CN116935145A
Global and local feature facial expression recognition method based on attention replacement
CN118658189A
Emotion recognition method based on global feature and local feature fusion network
CN119339420A
Aviation turbine blade service damage monitoring method based on digital twinning
CN119416395A