Solar detection optical image compression method
By constructing a YOLOv5s solar detection optical image compression model based on ShuffleNetV2 backbone network, the problem of difficulty in taking into account the compression ratio and image quality in the existing technology is solved, and efficient and reliable solar detection optical image compression is achieved, which is suitable for data transmission in space detection tasks.
Patent Information
- Application Number
- CN202411711799.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-04-22
AI Technical Summary
The existing image compression methods are difficult to take into account both the compression ratio and image quality when processing solar images with high-dimensional and complex textures. Especially in spatial detection tasks, transmission bandwidth and storage resources are limited, and efficient image compression methods are urgently needed.
The YOLOv5s solar detection optical image compression model is constructed based on the ShuffleNetV2 backbone network. By improving the network structure, combining compact design and structured pruning technology, it realizes efficient compression of solar detection optical images.
It realizes significantly improving the compression rate, reducing the bit error rate, simplifying the compression and transmission process while maintaining image quality, improving the reliability and efficiency of data transmission, and suitable for data transmission requirements in space detection.
Smart Images

Figure CN119863533A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of image processing, and in particular to a solar detection optical image compression method. Background Art
[0002] With the rapid development of space exploration technology, a large amount of high-resolution optical image data generated by solar observation missions provides rich information for scientific research. However, the storage and transmission of observation image data face huge challenges, especially in the space environment, where transmission bandwidth and storage resources are limited. Efficient image compression methods are urgently needed to reduce the data volume. In solar exploration missions, image compression methods must not only significantly reduce the amount of data, but also maintain the details of key areas such as solar activity and surface features to meet the requirements of subsequent research and analysis.
[0003] Existing image compression methods mainly include traditional lossless and lossy compression algorithms, as well as compression techniques based on deep learning. Although traditional methods have achieved certain results in conventional image compression, it is often difficult to balance compression ratio and image quality when processing solar images with high dimensions and complex textures. Summary of the invention
[0004] The object of the present invention is to provide a method for compressing solar detection optical images, comprising the following steps:
[0005] 1) Construct a YOLOv5s solar detection optical image compression model based on the ShuffleNetV2 backbone network;
[0006] 2) Acquire solar exploration optical images;
[0007] 3) Input the solar detection optical image into the YOLOv5s solar detection optical image compression model to realize the compression of the solar detection optical image.
[0008] Further, in step 1), the steps of constructing a YOLOv5s solar detection optical image compression model based on the ShuffleNetV2 backbone network include:
[0009] 1.1) Use the ShuffleNetV2 backbone network to replace the YOLOv5s backbone network New CSP-Darknet;
[0010] 1.2) Adjust the ShuffleNetV2 backbone network structure to obtain the adjusted ShuffleNetV2 backbone network structure;
[0011] 1.3) Perform structured pruning on the adjusted ShuffleNetV2 backbone network structure.
[0012] Furthermore, the adjusted ShuffleNetV2 backbone network structure includes input layer, convolution layer, maximum pooling layer, basic unit stacking block Stage 2, basic unit stacking block Stage 3, basic unit stacking block Stage 4, and normalization layer;
[0013] The input layer is used to receive solar detection optical images;
[0014] The convolution layer and the maximum pooling layer sequentially perform convolution and maximum pooling operations on the solar detection optical image;
[0015] The basic unit stacking block Stage 2, the basic unit stacking block Stage 3, the basic unit stacking block Stage 4
[0016] The basic unit stacking block Stage 2 includes 1 basic unit unit2 and 2 basic units unit1;
[0017] The basic unit stacking block Stage3 includes 1 basic unit unit2 and 5 basic units unit1;
[0018] The basic unit stacking block Stage4 includes 1 basic unit unit2 and 2 basic units unit1;
[0019] The basic unit unit1 is used to extract the features of the solar detection optical image to obtain a solar detection feature map;
[0020] The basic unit unit2 is used to reduce the size of the solar detection feature image to obtain a solar detection feature compressed image;
[0021] The normalization layer is used to perform a normalization operation on the solar detection feature compressed image.
[0022] Further, the basic unit unit2 and the basic unit unit1 perform group convolution and channel shuffling operations on the solar detection optical image after the maximum pooling, so as to output a solar detection feature compressed image;
[0023] Parameter P of the characteristic compressed image of solar detection ~ , calculation amount G ~ They are as follows:
[0024]
[0025]
[0026] In the formula, C in , C out is the number of input feature channels and output channels; g×g is the product kernel size; H×W is the input feature size; GN is the number of groups.
[0027] Furthermore, the channel shuffling is used to fuse the feature information after the group convolution.
[0028] Further, in step 1.3), the step of performing structured pruning on the adjusted ShuffleNetV2 backbone network structure includes:
[0029] 1.3.1) Perform sparse training on the improved model, perform channel pruning based on the results of sparse training, and prune the first n channels with the lowest importance in the normalization layer of the ShuffleNetV2 backbone network;
[0030] 1.3.2) Fine-tune the pruned model to determine whether the compression rate reaches 75%. If not, return to step 1.3.1).
[0031] Furthermore, the output of the normalization layer is as follows:
[0032]
[0033]
[0034]
[0035]
[0036] In the formula, x i is the input; n is the amount of input data; μ B , σ B 2 are mean and variance; γ and β are learning parameters; ε is a hyperparameter; is the normalized input. i is the output of the normalization layer.
[0037] Furthermore, in step 1.3.2), when fine-tuning the pruned model, the learning parameters γ and β are updated as follows:
[0038]
[0039]
[0040]
[0041]
[0042]
[0043]
[0044] Where L is the improved loss function; is the normalized input; γ and β are learning parameters; μ B , σ B 2 is the mean and variance; ε is a hyperparameter; n is the amount of input data; x i is the input; i is the output of the normalization layer.
[0045] Further, the improved loss function L is as follows:
[0046]
[0047] Where Г represents the set of all pruned channels, W represents the network weight parameter, λ represents the sparsity factor, x represents the input, y represents the actual value, (x, y) represents the input and output of the training, g() represents sparse regularization; f(x, W) is the model prediction value; l(f(x, W), y) represents the loss function.
[0048] The technical effect of the present invention is unquestionable. The present invention proposes a solar detection optical image compression model. By improving the network structure and combining compact design with structured pruning technology, this method can achieve efficient compression of solar detection optical images while reducing the model calculation complexity and ensuring the retention of details in key image areas, making it more suitable for data transmission needs in space exploration.
[0049] Backbone network construction based on ShuffleNetV2: Based on the comparative analysis of the existing New-CSP Darknet and lightweight MobileNet networks, the present invention proposes a YOLOv5s solar detection optical image compression model based on the ShuffleNetV2 backbone network. The ShuffleNetV2 network has high feature extraction capabilities and computational efficiency, providing the present invention with an infrastructure that takes into account both accuracy and real-time performance.
[0050] ShuffleNetV2 structure optimization: Based on ShuffleNetV2, the present invention further optimizes its network structure and further improves the feature extraction capability by appropriately adjusting the network hierarchy and convolution operations. This optimized design can retain detailed features such as prominences and flares in solar observation images as much as possible while compressing images, thereby ensuring the practicability and accuracy of image compression.
[0051] Channel pruning based on BN layer: For the improved ShuffleNetV2 backbone network, this paper performs channel pruning at the Batchormalization layer to effectively remove redundant channels in the model and further compress the image. This pruning strategy significantly reduces the number of model parameters and the amount of calculation while maintaining the image compression quality, making the model more streamlined and efficient, and suitable for deployment environments.
[0052] Through the above three technical innovations, the present invention realizes a lightweight, low-computational-cost and efficient solar detection optical image compression network, and provides an optimized solution suitable for application for the real-time transmission and processing of solar detection data. The following technical effects are achieved in the compression processing of solar detection optical images:
[0053] Significantly improve compression rate: Compared with traditional lossless and lossy compression methods, the feature extraction and selective compression of solar images in this invention significantly reduces the amount of data while ensuring the image quality of key areas. The results show that this method can increase the compression ratio to several times that of the original method while maintaining the effective information of the image.
[0054] Adaptive retention of image details: By automatically identifying and enhancing solar active areas and other important feature areas in the image, the present invention can adjust the compression strength according to the image content to retain more details in key areas. This adaptive compression ensures clear presentation of small but critical changes in the image (such as prominences, flares, etc.), thereby retaining the detailed information required for scientific research while transmitting and storing the image.
[0055] Significant reduction in bit error rate: Due to the use of a deep learning model to intelligently compress solar images, the bit error rate of the present invention when decoding image data is significantly lower than that of traditional compression methods. Under the same transmission conditions, the bit error rate of this method is reduced, thereby improving the reliability of data transmission.
[0056] Automation and simplification of the compression and transmission process: This method uses automatic feature extraction to complete the compression process without manual intervention, making the entire operation process easier. Compared with the traditional method that requires manual setting of compression parameters, the operation steps are greatly simplified, thereby reducing human resource investment and improving work efficiency.
[0057] Improved compression accuracy: Differentiated compression strategies are used for different areas of the image content, which improves the overall compression accuracy and image clarity. The image quality generated by this method is better than that of conventional methods at the same compression ratio, especially in terms of detail restoration, and can meet higher image clarity requirements.
[0058] Enhanced real-time performance: With fast feature extraction capability, it is suitable for real-time processing of large quantities of solar observation images. Through the application of this network structure, the present invention enables the compression process to be completed in a short time, has high real-time performance, and provides technical support for real-time data processing of space exploration missions.
[0059] Optimization of transmission bandwidth: Due to the higher compression rate, the present invention can significantly reduce the bandwidth occupation during image transmission, thereby adapting to the bandwidth limitation in space detection. When transmitting the same number of images, the bandwidth occupation of the method of the present invention is reduced, which greatly improves the efficiency of data transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 It is a lightweight and improved YOLOv5s network structure of the present invention;
[0061] Figure 2 It is the MobileNetV2-YOLOv5s network structure of the present invention;
[0062] Figure 3 This is the basic structure of the Bottlenecks of the present invention;
[0063] Figure 4 The present invention is based on the improved backbone network structure of ShuffleNetV2;
[0064] Figure 5 It is the basic unit of ShuffleNetV2 of the present invention;
[0065] Figure 6 Schematic diagram of group convolution and channel shuffling of the present invention;
[0066] Figure 7 It is the structured pruning compression flow chart of the present invention;
[0067] Figure 8 It is a schematic diagram of channel pruning compression based on the BN layer of the present invention. DETAILED DESCRIPTION
[0068] The present invention is further described below in conjunction with the embodiments, but it should not be understood that the above subject matter of the present invention is limited to the following embodiments. Without departing from the above technical ideas of the present invention, various substitutions and changes are made according to the common technical knowledge and customary means in the art, which should all be included in the protection scope of the present invention.
[0069] Embodiment 1:
[0070] See also Figures 1 to 8 , a solar detection optical image compression method, comprising the following steps:
[0071] 1) Construct a YOLOv5s solar detection optical image compression model based on the ShuffleNetV2 backbone network;
[0072] 2) Acquire solar exploration optical images;
[0073] 3) Input the solar detection optical image into the YOLOv5s solar detection optical image compression model to realize the compression of the solar detection optical image.
[0074] In step 1), the steps of constructing the YOLOv5s solar detection optical image compression model based on the ShuffleNetV2 backbone network include:
[0075] 1.1) Use the ShuffleNetV2 backbone network to replace the YOLOv5s backbone network New CSP-Darknet;
[0076] 1.2) Adjust the ShuffleNetV2 backbone network structure to obtain the adjusted ShuffleNetV2 backbone network structure;
[0077] 1.3) Perform structured pruning on the adjusted ShuffleNetV2 backbone network structure.
[0078] The adjusted ShuffleNetV2 backbone network structure includes input layer, convolution layer, maximum pooling layer, basic unit stacking block Stage 2, basic unit stacking block Stage 3, basic unit stacking block Stage 4, and normalization layer;
[0079] The input layer is used to receive solar detection optical images;
[0080] The convolution layer and the maximum pooling layer sequentially perform convolution and maximum pooling operations on the solar detection optical image;
[0081] The basic unit stacking block Stage 2, the basic unit stacking block Stage 3, the basic unit stacking block Stage 4
[0082] The basic unit stacking block Stage 2 includes 1 basic unit unit2 and 2 basic units unit1;
[0083] The basic unit stacking block Stage3 includes 1 basic unit unit2 and 5 basic units unit1;
[0084] The basic unit stacking block Stage4 includes 1 basic unit unit2 and 2 basic units unit1;
[0085] The basic unit unit1 is used to extract the features of the solar detection optical image to obtain a solar detection feature map;
[0086] The basic unit unit2 is used to reduce the size of the solar detection feature image to obtain a solar detection feature compressed image;
[0087] The normalization layer is used to perform a normalization operation on the solar detection feature compressed image.
[0088] The basic unit unit2 and the basic unit unit1 perform group convolution and channel shuffling operations on the solar detection optical image after maximum pooling, thereby outputting a solar detection feature compressed image;
[0089] Parameter P of the characteristic compressed image of solar detection ~ , calculation amount G ~ They are as follows:
[0090]
[0091]
[0092] In the formula, C in , C out is the number of input feature channels and output channels; g×g is the product kernel size; H×W is the input feature size; GN is the number of groups.
[0093] The channel shuffling is used to fuse the feature information after the group convolution.
[0094] In step 1.3), the steps of performing structured pruning on the adjusted ShuffleNetV2 backbone network structure include:
[0095] 1.3.1) Perform sparse training on the improved model, perform channel pruning based on the results of sparse training, and prune the first n channels with the lowest importance in the normalization layer of the ShuffleNetV2 backbone network;
[0096] 1.3.2) Fine-tune the pruned model to determine whether the compression rate reaches 75%. If not, return to step 1.3.1).
[0097] The present invention adaptively compresses solar detection optical images, retaining key areas while reducing the amount of image data. In order to more clearly define the "ideal model compression effect", the relevant quantitative indicators are specifically described:
[0098] 1. Compression Ratio
[0099] The image compression effect is mainly quantified by the compression ratio. The compression ratio is defined as the ratio of the compressed data volume to the original data volume. The ideal goal achieved in the experiment is: Original data volume: For example, the input image is a grayscale image with a resolution of 2048×2048 and a data volume of 4MB (assuming 8-bit depth). Compressed data volume: The data volume represented by the compressed image features is 1MB. Compression ratio: Reach 75% (that is, the data volume is reduced to 25% of the original data volume).
[0100] 2. Improved data transmission efficiency
[0101] After compression, the image transmission efficiency is greatly improved. Taking 1Gbps bandwidth as an example: original image transmission time: 4MB image takes about 32ms to transmit. After compression, image transmission time: 1MB image only takes about 8ms to transmit. Improvement: Data transmission time is shortened by 75%.
[0102] The output of the normalization layer is as follows:
[0103]
[0104]
[0105]
[0106]
[0107] In the formula, x i is the input; n is the amount of input data; μ B , σ B 2 are mean and variance; γ and β are learning parameters; ε is a hyperparameter; is the normalized input. i is the output of the normalization layer.
[0108] In step 1.3.2), when fine-tuning the pruned model, the learning parameters γ and β are updated as follows:
[0109]
[0110]
[0111]
[0112]
[0113]
[0114]
[0115] Where L is the improved loss function; is the normalized input; γ and β are learning parameters; μ B , σ B 2 is the mean and variance; ε is a hyperparameter; n is the amount of input data; x i is the input; i is the output of the normalization layer.
[0116] The improved loss function L is as follows:
[0117]
[0118] Where Г represents the set of all pruned channels, W represents the network weight parameter, λ represents the sparsity factor, x represents the input, y represents the actual value, (x, y) represents the input and output of the training, g() represents sparse regularization; f(x, W) is the model prediction value; l(f(x, W), y) represents the loss function.
[0119] In summary, the present invention combines the basic unit unit 2 and realizes adaptive compression of solar detection optical images through a deep learning method. The present invention extracts key feature information of the image through a neural network and removes redundant information, thereby achieving a compression effect.
[0120] Specifically:
[0121] Implementation mechanism of image compression:
[0122] ShuffleNetV2 is used as the lightweight backbone network. Through the feature mapping capability of the model, the high-frequency redundant information of the input image is filtered out to generate a compact feature representation to achieve the compression purpose.
[0123] Image size and data volume after compression: The compression method of the present invention is mainly based on feature extraction and redundant information filtering of deep learning models. Therefore, the size (pixel resolution) of the compressed image is consistent with the original image. For example: Input image size: 2048×2048 pixels. Image size after compression: 2048×2048 pixels. This size-preserving compression method is different from the traditional resolution reduction or downsampling. Instead, it reduces the amount of data stored and transmitted by constructing a compact feature representation while retaining important image information. Data volume after compression: The reduction of image data volume is the core goal of the present invention. The compression effect can be quantitatively analyzed by comparing the number of bytes required for image storage before and after compression. The following takes a typical solar exploration optical image as an example: Assuming that the input is a single-channel grayscale image with a resolution of 2048×2048 and 8 bits (1 byte) per pixel, the original data volume is: Original data volume = 2048×2048×1 = 4,194,304 bytes (≈4MB). Data after compression: Image features are extracted as a compact representation, and only important information is retained for subsequent analysis or reconstruction. The compression ratio of the feature representation is 4:1, so the amount of compressed data is: 1,048,576 bytes (≈1MB)
[0124] Embodiment 2:
[0125] A solar detection optical image compression method comprises the following steps:
[0126] 1) Construct a YOLOv5s solar detection optical image compression model based on the ShuffleNetV2 backbone network;
[0127] 2) Acquire solar exploration optical images;
[0128] 3) Input the solar detection optical image into the YOLOv5s solar detection optical image compression model to realize the compression of the solar detection optical image.
[0129] Embodiment 3:
[0130] A solar detection optical image compression method, the technical content is the same as that of Example 2, further, in step 1), the step of constructing a YOLOv5s solar detection optical image compression model based on the ShuffleNetV2 backbone network includes:
[0131] 1.1) Use the ShuffleNetV2 backbone network to replace the YOLOv5s backbone network New CSP-Darknet;
[0132] 1.2) Adjust the ShuffleNetV2 backbone network structure to obtain the adjusted ShuffleNetV2 backbone network structure;
[0133] 1.3) Perform structured pruning on the adjusted ShuffleNetV2 backbone network structure.
[0134] Embodiment 4:
[0135] A solar detection optical image compression method, the technical content is the same as any one of embodiments 2-3, further, the adjusted ShuffleNetV2 backbone network structure includes an input layer, a convolution layer, a maximum pooling layer, a basic unit stacking block Stage2, a basic unit stacking block Stage3, a basic unit stacking block Stage4, and a normalization layer;
[0136] The input layer is used to receive solar detection optical images;
[0137] The convolution layer and the maximum pooling layer sequentially perform convolution and maximum pooling operations on the solar detection optical image;
[0138] The basic unit stacking block Stage 2, the basic unit stacking block Stage 3, the basic unit stacking block Stage 4
[0139] The basic unit stacking block Stage 2 includes 1 basic unit unit2 and 2 basic units unit1;
[0140] The basic unit stacking block Stage3 includes 1 basic unit unit2 and 5 basic units unit1;
[0141] The basic unit stacking block Stage4 includes 1 basic unit unit2 and 2 basic units unit1;
[0142] The basic unit unit1 is used to extract the features of the solar detection optical image to obtain a solar detection feature map;
[0143] The basic unit unit2 is used to reduce the size of the solar detection feature image to obtain a solar detection feature compressed image;
[0144] The normalization layer is used to perform a normalization operation on the solar detection feature compressed image.
[0145] Embodiment 5:
[0146] A solar detection optical image compression method, the technical content of which is the same as any one of embodiments 2-4, further, the basic unit unit2 and the basic unit unit1 perform group convolution and channel shuffling operations on the solar detection optical image after maximum pooling, thereby outputting a solar detection feature compressed image;
[0147] The parameter quantities and calculation quantities of the solar detection characteristic compression image are as follows:
[0148]
[0149]
[0150] In the formula, C in , C out is the number of input feature channels and output channels; g×g is the product kernel size; H×W is the input feature size; GN is the number of groups.
[0151] Embodiment 6:
[0152] A method for compressing solar detection optical images, the technical content of which is the same as any one of Examples 2-5, and further, the channel shuffling is used to fuse the feature information after group convolution.
[0153] Embodiment 7:
[0154] A solar detection optical image compression method, the technical content of which is the same as any one of embodiments 2-6, further, in step 1.3), the step of performing structured pruning on the adjusted ShuffleNetV2 backbone network structure comprises:
[0155] 1.3.1) Perform sparse training on the improved model, perform channel pruning based on the results of sparse training, and prune the first n channels with the lowest importance in the normalization layer of the ShuffleNetV2 backbone network;
[0156] 1.3.2) Fine-tune the pruned model to determine whether the compression rate reaches 75%. If not, return to step 1.3.1).
[0157] Embodiment 8:
[0158] A solar detection optical image compression method, the technical content is the same as any one of embodiments 2-7, further, the output of the normalization layer is as follows:
[0159]
[0160]
[0161]
[0162]
[0163] Where x is the input; γ and β are learning parameters; ε is a hyperparameter.
[0164] Embodiment 9:
[0165] A method for compressing solar detection optical images, the technical content of which is the same as any one of Embodiments 2-8, further, in step 1.3.2), when fine-tuning the pruned model, the learning parameters γ and β are updated as follows:
[0166]
[0167]
[0168]
[0169]
[0170]
[0171]
[0172] Where L is the loss function.
[0173] Embodiment 10:
[0174] A solar detection optical image compression method, the technical content is the same as any one of embodiments 2-9, and further, the loss function L is as follows:
[0175]
[0176] Where Г represents the set of all pruning channels, W represents the network weight parameter, λ represents the sparsity factor, x represents the input, y represents the final target, (x, y) represents the input and output of the training, and g() represents sparse regularization.
[0177] Embodiment 11:
[0178] A solar detection optical image compression method is as follows:
[0179] The YOLOv5s solar detection optical image compression model based on the ShuffleNetV2 backbone network is used to efficiently compress solar detection image data, achieving a high compression ratio of image data while ensuring the retention of key detail areas.
[0180] The present invention introduces ShuffleNetV2 as the backbone network based on the YOLOv5s network. After comparing and analyzing the existing YOLOv5s and New-CSP Darknet, MobileNet and other models, it is determined to adopt the ShuffleNetV2 structure to construct a compression model suitable for solar detection optical images. ShuffleNetV2 has high computing efficiency and feature extraction capabilities, and realizes real-time compression of solar images.
[0181] In order to further improve the feature extraction capability, the present invention improves the network structure of ShuffleNetV2, mainly by adjusting the number of network layers, convolution kernel size and convolution operation order to reduce the number of parameters and calculations, while enhancing the feature extraction capability. This optimized design can preserve the detailed features of solar observation images such as prominences and flares as much as possible while compressing the image, ensuring the practicality and accuracy of image compression.
[0182] The present invention adds a channel pruning technology based on the BN layer to the improved ShuffleNetV2 backbone network. This method further streamlines the model by calculating the weight importance in the BN layer and selectively removing redundant channels. By pruning unimportant feature channels, the image is greatly compressed while reducing the number of model parameters and computational complexity, so that the compression model can run more efficiently on embedded devices, meeting the needs of bandwidth constraints and real-time processing in space exploration. The improved technology of the present invention not only improves the efficiency of image compression, but also ensures the real-time processing capability of the device end, providing a more applicable solution for the efficient compression of solar exploration images. The structure is as follows: Figure 1 shown.
[0183] The present invention improves the solar detection optical image compression model in two aspects. The first aspect is to replace the original complex backbone network New CSP-Darknet of YOLOv5s with the network ShuffleNetV2. Then, by adjusting the number of stacks of basic units 1 in the ShuffleNetV2 network structure, the network depth is reduced, and the model complexity is further reduced. The second aspect is to perform structured pruning on the network after the backbone network, and use sparse networks to filter redundant connections, so that the redundancy of the model is reduced, and the number of parameters and calculations of the model are further reduced.
[0184] MobileNet is a lightweight convolutional neural network mainly designed for mobile devices. The network has multiple advantages such as small size and excellent performance. The present invention designs a lightweight network for solar detection optical image compression based on the MobileNet module, and uses the lightweight network MobileNetV2 to replace the original backbone network New CSP-Darknet of YOLOv5s to construct a MobileNetV2-YOLOv5s network. The backbone network structure is as follows: Figure 2 shown.
[0185] MobileNetV2 is based on MobileNetV1 and mainly proposes two innovations: linear bottleneck layer and inverted residual module. Compared with MobileNetV1, it has higher accuracy and smaller model. MobileNetV2 network consists of a series of Bottleneck stacks. Bottlenecks are divided into two structures according to the different Strides, namely Bottleneck-1 and Bottleneck-2. Figure 3 Bottleneck-1 Figure 3 As shown in the figure, when the stride is 1, the channel dimension of the input solar detection feature map is first expanded through the 1×1 convolution of the first layer. Then, the output solar detection feature map is obtained through the 3×3 depth convolution in the middle layer, the 1×1 point convolution and the linear last layer. Finally, the input solar detection feature map and the output solar detection feature map are added element by element, and the obtained solar detection feature map is input to the next module. Bottleneck-2 is as follows Figure 3 As shown in the figure, the difference from Bottleneck-1 is that the middle layer is a 3×3 depthwise convolution with a stride of 2. There is no element-by-element addition and jump connection operation at this time, and the rest of the Bottleneck-1 module is the same.
[0186] Figure 3 In it, DWConv means depth convolution, PWConv means point convolution, Conv means ordinary convolution, Add means element-by-element addition operation, Linear means linear activation function, and Stride means stride.
[0187] The MobileNetV2 network downsamples the input solar detection image by different multiples, and then outputs the corresponding downsampled feature maps MF1 = (80, 80, 32), MF2 = (40, 40, 96) and MF3 = (20, 20, 320). According to the connection method between the original backbone network and the Neck layer of the YOLOv5s network, the MF1, MF2 and MF3 feature maps output from the MobileNetV2 network are input into the Neck layer of the YOLOv5s network to achieve the lightweight of the YOLOv5s network. The main parameters of the model of the present invention with MobileNetV2 as the backbone network are shown in Table 1.
[0188] Table 1 Backbone network parameters based on MobileNetV2
[0189]
[0190]
[0191] At present, most networks use group convolution to make the network lightweight. Simply put, the main computation is concentrated on 1×1 convolution operations, such as MobileNetV2. This is conducive to model compression and speed improvement, but it sacrifices compression accuracy. However, this operation loses a lot of cross-channel operations in a certain sense, and it is based on this consideration that ShuffleNet was proposed.
[0192] To this end, the present invention uses the ShuffleNetV2 module as the backbone network of the model to achieve the lightweight of the solar detection optical image compression model, and further improves ShuffleNetV2 by adjusting the number of stacking basic units 1 in the ShuffleNetV2 network structure and reducing the network depth, thereby reducing the model complexity and further making the model more lightweight. Finally, the improved ShuffleNetV2 network is used to replace the original backbone network New CSP-Darknet of YOLOv5s. The model of the present invention is based on the backbone network structure of the improved ShuffleNetV2. Figure 4 shown.
[0193] ShuffleNetV2 convolutional neural network is an efficient and lightweight model for mobile terminals, which has achieved a good balance between speed and accuracy. At the same time, ShuffleNet V2 proposes four principles for designing lightweight and efficient networks. The core idea is to neither over-group nor over-use convolution while keeping the number of channels unchanged. New basic units are designed, such as Figure 5 shown. Figure 5 Here, unit1 is basic unit 1, and unit2 is basic unit 2.
[0194] The basic unit of ShuffleNetV2 is mainly composed of grouped convolution and channel shuffle. Grouped convolution is as follows Figure 6 As shown in (1), taking the number of groups GN = 3 as an example, the input feature F (C × H × K) is divided into 3 groups according to the channel, and the number of channels in each group is C / 3. Each group is connected to the ungrouped state and then the convolution operation is performed within the group. Finally, the results of the grouped convolution operation of the 3 groups are concat-superimposed and output. Assume that the size of the input feature F is H × W and the number of channels is C. in , the output channel is C out The convolution kernel size is g×g. Without using grouped convolution, the number of parameters is P, and the amount of calculation is G. After using grouped convolution, the number of parameters is P~, and the amount of calculation is G~. The calculation formulas are as follows:
[0195] P=g·g·C in ·C out
[0196] G=H·W·g·g·C in ·C out
[0197]
[0198]
[0199] It can be seen that the number of parameters and the amount of calculation of group convolution are 1 / GN of standard convolution, but the larger the GN value is, the better it is. In ShuffleNet, it is mentioned that when the GN value gradually increases, the network will be saturated or the accuracy will decrease. Finally, it is found that when GN=3, the accuracy and calculation speed are optimal.
[0200] The disadvantage of grouped convolution is that different groups are independent of each other. The feature information of the output channel after grouped convolution only comes from the feature information of the channel in the same group after grouping. The output in the group is only related to the input in the group, and the information of other groups cannot be obtained, resulting in the problem of "feature communication closure", such as Figure 6 (1). Therefore, ShuffleNet proposed to shuffle the channels of the output feature map to solve the problem of “feature communication closure”. Figure 6 (3) is the channel shuffling method of (2), which fully integrates the information from different groups through the channel shuffling operation on the output features after group convolution.
[0201] Since the ShuffleNetV2 network is mainly designed for classifying 1000 categories of the ImageNet data set, but the present invention does not involve complex classification requirements, it does not require an excessively deep network depth. To this end, the present invention studies the adjustment of the ShuffleNetV2 network structure, reduces the depth of the ShuffleNetV2 network, and further reduces the number of network parameters and the amount of computation. The main parameters of the ShuffleNetV2 network structure after adjustment are shown in Table 2.
[0202] Table 2 shows each stage of feature extraction of the improved ShuffleNetv2 backbone network, where Stage represents the combination of ShuffleNetV2 basic units. The continuous use of ShuffleNetV2 modules enhances the feature extraction capability without increasing the amount of computation. Stage2, Stage3, and Stage4 all contain two parts: basic unit 1 and basic unit 2. When stride is 2, it means that basic unit 2 is used to reduce the size of the output solar detection feature map. When stride is 1, basic unit 1 is used to extract the features of the solar detection image, and no downsampling operation is performed at this time.
[0203] Table 2 Main parameters of ShuffleNetV2 after network structure adjustment
[0204]
[0205]
[0206] The ShuffleNetV2 network starts with a normal convolution and maximum pooling, and then is divided into three stages, each of which uses the basic units of ShuffleNetV2 for stacking, replacing the previous residual module. The present invention obtains the best basic unit 1 stacking combination through experiments, and adjusts the number of repetitions of basic unit 1 from 3 times to 2 times when the stride is 1 in stage two and stage four. When the stride is 1 in stage three, the number of repetitions of basic unit 1 is adjusted from 7 times to 5 times. The number of stacking combinations of basic units 2 is not changed, and the original network settings are maintained.
[0207] The present invention adopts a structured pruning method to further compress the image while realizing the lightweight of the solar detection optical image compression model. The process of structured pruning is as follows: Figure 7 shown.
[0208] First, the improved model is sparsely trained. According to the results of sparse training, channel pruning is then performed to prune the channels with lower importance, and the pruned model is fine-tuned. If the result after pruning can achieve the ideal model compression effect, the pruned model is obtained. Otherwise, sparse training needs to be performed again, followed by pruning and fine-tuning, and this process is repeated many times to achieve the ideal model compression effect.
[0209] In the parameter tensor, the weight values that meet certain pruning conditions are replaced with zero to prune the connections between the networks, so unstructured pruning is usually simple to operate. At the same time, the widely used deep learning framework, such as pytorch, makes it simple to implement. However, the existing computer hardware cannot improve its computing speed, and specific hardware needs to be specially formulated to improve the actual running speed. However, the network pruning of the convolutional layer usually lacks flexibility, and the pruning granularity is too large to achieve accurate pruning. Compared with the first two, channel pruning performs better than convolutional layer pruning in terms of flexibility, and is not much different from unstructured pruning in terms of actual operation effect. Channel pruning has no restrictions on the number of layers of the neural network, and its application range is wide, suitable for fully connected layers and convolutional layers, and can usually achieve ideal pruning results, not only maintaining a high accuracy rate but also fast training speed. Therefore, the pruning method based on the channel of the present invention further compresses the picture while reducing the complexity of the model, so that the model is further streamlined, which is convenient for the implementation and deployment of software and hardware.
[0210] In order to achieve fast convergence and better generalization performance, most deep learning networks, such as ResNet, ShuffleNets and MobileNets, have a batch normalization layer (BatchNorm, BN) after the convolution layer. The input data of the normalization layer is processed by shifting and scaling parameters, so that the output data of each convolution layer is normalized to a reasonable range.
[0211] The basic principle of the BatchNorm layer is: Assume that a batch of solar detection images B = {x1, x2, ... x (n-1) ,x n} has n inputs x and the output is {y i =BN γ,β (x1)}, and also need to introduce a hyperparameter ε to prevent the denominator from being zero and two parameters β and γ that need to be learned. The calculation formula of the BN layer is as follows:
[0212]
[0213]
[0214]
[0215]
[0216] The BN layer uses normalization operations before the activation function receives input data to solve the problem of input data offset and enlargement, but this also limits the range of data values. For activation functions such as sigmoid, it can only use the approximate linear part, which will reduce the model's expressiveness to a certain extent. Therefore, two trainable scaling and translation coefficients γ and β can be added to preserve the model's expressiveness. During the reverse training of the neural network, the parameters γ and β can be learned by chain derivation, and the corresponding results are shown below:
[0217]
[0218]
[0219]
[0220]
[0221]
[0222]
[0223] After the calculation of the BN layer, the influence of data offset can be eliminated. In model training, unlike the previous need to gradually adjust the learning rate, after the introduction of the BN layer, a larger learning rate can be set at the beginning of training to obtain a faster training speed.
[0224] The activation function follows the BN layer. When the scaling parameter γ of the BN layer is very small, even close to zero, the parameter of the activation function that maps the input of the channel to the output will also be smaller, indicating that the output of the BN layer and the corresponding channel play a small role in the network. The channel can be removed, and the network will become more streamlined after removing redundant channels.
[0225] During the model training process, the model loss function does not include the γ parameter in the training. After training, the mathematical distribution of the γ parameter is roughly normal, and only a small part of the γ parameter is close to 0. Therefore, channel pruning for such a network cannot achieve the expected effect. In order to find the channel with less impact on the network, the γ parameter of the BN layer is added to the loss function of the network model for joint training. The improved loss function is as follows:
[0226]
[0227] Among them, the first term represents the loss function of the normal training of the network model, and the second summation term is the L1 regularization sparse processing of the γ parameter. The two terms are added to get the improved loss function. Г represents the set of all pruned channels, W represents the network weight parameter, λ represents the sparse factor, x represents the input, y represents the final target, (x, y) represents the input and output of the training, and g() represents sparse regularization.
[0228] Schematic diagram of channel pruning based on BN layer, as shown in Figure 8 As shown in the figure. First, through sparse training, the γ parameter of the BN layer in the network is gradually reduced to achieve network sparseness. Secondly, by controlling the value of the hyperparameter λ, the network can obtain moderate sparsity, which is convenient for screening and pruning channels with less impact in the network.
Claims
1. A solar detection optical image compression method, characterized in that: The following steps are involved: 1) Build a YOLOv5s solar detection optical image compression model based on the ShuffleNetV2 backbone network. 2) Acquire solar exploration optical images; 3) Input the solar detection optical image into the YOLOv5s solar detection optical image compression model to realize the compression of the solar detection optical image.
2. The method for compressing solar detection optical images according to claim 1, characterized in that: In step 1), the steps of constructing the YOLOv5s solar detection optical image compression model based on the ShuffleNetV2 backbone network include: 1.1) Use the ShuffleNetV2 backbone network to replace the YOLOv5s backbone network New CSP-Darknet; 1.2) Adjust the ShuffleNetV2 backbone network structure to obtain the adjusted ShuffleNetV2 backbone network structure; 1.3) Perform structured pruning on the adjusted ShuffleNetV2 backbone network structure.
3. The method for compressing solar detection optical images according to claim 2, characterized in that: The adjusted ShuffleNetV2 backbone network structure includes input layer, convolution layer, maximum pooling layer, basic unit stacking block Stage 2, basic unit stacking block Stage 3, basic unit stacking block Stage 4, and normalization layer; The input layer is used to receive solar detection optical images; The convolution layer and the maximum pooling layer sequentially perform convolution and maximum pooling operations on the solar detection optical image; The basic unit stacking block Stage 2, the basic unit stacking block Stage 3, the basic unit stacking block Stage 4 The basic unit stacking block Stage 2 includes 1 basic unit unit2 and 2 basic units unit1; The basic unit stacking block Stage3 includes 1 basic unit unit2 and 5 basic units unit1; The basic unit stacking block Stage4 includes 1 basic unit unit2 and 2 basic units unit1; The basic unit unit1 is used to extract the features of the solar detection optical image to obtain a solar detection feature map; The basic unit unit2 is used to reduce the size of the solar detection feature image to obtain a solar detection feature compressed image; The normalization layer is used to perform a normalization operation on the solar detection feature compressed image.
4. The method for compressing solar detection optical images according to claim 3, characterized in that: The basic unit unit2 and the basic unit unit1 perform group convolution and channel shuffling operations on the solar detection optical image after maximum pooling, thereby outputting a solar detection feature compressed image; Parameter P of the characteristic compressed image of solar detection ~ , calculation amount G ~ They are as follows: In the formula, C in , C out is the number of input feature channels and output channels; g×g is the product kernel size; H×W is the input feature size; GN is the number of groups.
5. The method for compressing solar detection optical images according to claim 4, characterized in that: The channel shuffling is used to fuse the feature information after the group convolution.
6. The method for compressing solar detection optical images according to claim 2, characterized in that: In step 1.3), the steps of performing structured pruning on the adjusted ShuffleNetV2 backbone network structure include: 1.3.1) Perform sparse training on the improved model, perform channel pruning based on the results of sparse training, and prune the first n channels with the lowest importance in the normalization layer of the ShuffleNetV2 backbone network; 1.3.2) Fine-tune the pruned model to determine whether the compression rate reaches 75%. If not, return to step 1.3.1).
7. The method for compressing solar detection optical images according to claim 6, characterized in that: The output of the normalization layer is as follows: In the formula, x i is the input; n is the amount of input data; μ B , σ B 2 are mean and variance; γ and β are learning parameters; ε is a hyperparameter; is the normalized input; y i is the output of the normalization layer.
8. The method for compressing solar detection optical images according to claim 6, characterized in that: In step 1.3.2), when fine-tuning the pruned model, the learning parameters γ and β are updated as follows: Where L is the improved loss function; is the normalized input; γ and β are learning parameters; μ B , σ B 2 is the mean and variance; ε is a hyperparameter; n is the amount of input data; x i is the input; i is the output of the normalization layer.
9. The method for compressing solar detection optical images according to claim 8, characterized in that: The improved loss function L is as follows: Where Г represents the set of all pruned channels, W represents the network weight parameter, λ represents the sparsity factor, x represents the input, y represents the actual value, (x, y) represents the input and output of the training, g() represents sparse regularization; f(x, W) is the model prediction value; l(f(x, W), y) represents the loss function.