Optimization and pruning method of electric power lightweight identification model

By preprocessing and generating feature heatmaps from power equipment image datasets, combined with data augmentation and structured pruning, and utilizing knowledge distillation to optimize the model, the problems of high computational cost and decreased accuracy in power equipment identification by deep learning models are solved, achieving lightweight and high-performance power equipment identification.

CN120997643APending Publication Date: 2025-11-21CHINA SOUTHERN POWER GRID COMPANY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510997710.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-19
Publication Date
2025-11-21

AI Technical Summary

Technical Problem

Existing deep learning models suffer from high computational and storage requirements in power equipment image recognition. Traditional pruning methods may ignore the dependencies between channels, leading to a decrease in accuracy. Distillation technology still needs further exploration in key feature extraction and transfer.

Method used

By preprocessing the power equipment image dataset to generate feature heatmaps, data augmentation techniques are used to add weather degradation and occlusion, channel importance-driven structured pruning is performed, and knowledge distillation techniques are used to optimize the model to ensure that key areas are not destroyed and to consider the dependencies between channels.

Benefits of technology

Achieving efficient and accurate identification of power equipment on resource-constrained devices improves the model's performance and robustness, adapts to complex environments, reduces redundant parameters, and avoids accuracy degradation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120997643A_ABST
    Figure CN120997643A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of electric power model pruning, and more particularly relates to an optimization and pruning method of an electric power lightweight identification model, which improves the adaptability of the model to a complex environment through preprocessing and feature statistics, generation of a feature thermodynamic diagram and guidance of a data enhancement process. In the data enhancement part, physical simulation is combined to add a weather degradation effect and a random shelter, meanwhile, a key area is protected, small target features are ensured not to be damaged, in the structured pruning, based on channel importance evaluation, redundant parameters are reduced, a model structure is optimized, meanwhile, the dependency relationship between channels is considered, precision reduction is avoided, and finally, the structural pruning is carried out. Knowledge distillation optimization migrates knowledge of a large model to a lightweight model, the performance and robustness of the lightweight model are improved, and the optimized model realizes efficient and accurate power equipment identification on resource-constrained equipment.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of power model pruning, and more particularly relates to an optimization and pruning method of a power lightweight identification model. BACKGROUND

[0002] In the field of smart grids, image recognition of power equipment is crucial for equipment inspection and fault detection. However, traditional deep learning models such as ResNet and Faster R-CNN, while performing well in accuracy, have large computational load and storage requirements, limiting their application on resource-constrained devices. Therefore, how to achieve model lightweight while maintaining recognition accuracy has become a core technical problem to be solved.

[0003] Existing lightweight methods mainly rely on model pruning and distillation techniques, but traditional pruning methods may ignore the dependency between channels, leading to a decrease in accuracy. Although distillation technology can transfer knowledge, the extraction and transmission of key features still need to be further explored. Therefore, a systematic method combining data augmentation, structured pruning and knowledge distillation is proposed to solve the contradiction between model lightweight and high performance. SUMMARY

[0004] The application provides an optimization and pruning method of a power lightweight identification model, aiming to solve the technical problem of the contradiction between model lightweight and high performance.

[0005] The optimization and pruning method of the power lightweight identification model comprises the following steps:

[0006] S1. Preprocess the original power equipment image dataset, and based on the scale distribution of the key features of the power equipment in the preprocessed image, obtain a feature heat map;

[0007] S2. Based on the preprocessed image dataset and the feature heat map, add weather degradation effects through physical simulation enhancement, and randomly generate occlusion masks. Then, using the feature heat map, rotate or twist the key areas of the power equipment to obtain an enhanced power image dataset;

[0008] S3. Use the enhanced power image data and the original high-precision power identification model to perform channel importance-driven structured pruning to obtain a pruned lightweight model;

[0009] S4. For the pruned lightweight model, use knowledge distillation technology for further optimization to obtain an optimized lightweight model.

[0010] The application generates a feature heat map through preprocessing and feature statistics, guides a data enhancement process, improves the adaptability of a model to a complex environment, combines physical simulation to add weather degradation effects and random occlusions in the data enhancement part while protecting key areas to ensure that small target features are not damaged, reduces redundant parameters based on channel importance evaluation in structured pruning to optimize the model structure, considers the dependency relationship between channels to avoid accuracy decline, finally, knowledge distillation optimization migrates the knowledge of a large model to a lightweight model to improve its performance and robustness, so that the optimized model realizes efficient and accurate power equipment identification on a resource-limited device.

[0011] Preferably, the preprocessing comprises the following steps:

[0012] The input color power inspection image is converted into a gray image, a Laplacian operator is applied to the entire gray image for calculation, the brightness difference degree of each pixel point in the image and its surrounding pixels is measured to obtain a gradient value, the variance of all pixel gradients is calculated, the variance is compared with the preset definition threshold based on the definition threshold, if the variance is greater than the definition threshold, it is determined as a clear image, if the variance is less than the definition threshold, it is determined as a fuzzy image, and the clear image is retained to form a clear power inspection image combination image set;

[0013] A pre-trained target detection model is used to scan and analyze the clear power inspection image combination image set, and the position of the boundary box of each detected object, the belonging category and the confidence score are given; if the object detected by the model belongs to the equipment type in the exclusive equipment category library and the confidence score of the detection result is greater than the preset threshold, the image is determined as a valid image, otherwise it is an invalid image, and based on this, an image set containing only valid power equipment images is obtained;

[0014] Image standardization processing is performed based on the image set containing only valid power equipment images to obtain a standardized power equipment image set.

[0015] Preferably, the generation of the feature heat map comprises the following steps:

[0016] A pre-trained deep convolutional neural network model is used as a feature extractor, the preprocessed image is input into the deep convolutional neural network model, forward propagation is performed until the last convolutional layer of the model, and based on the output of the optimal convolutional layer, a classification layer outputs the final prediction value;

[0017] The gradient of the prediction value of the deep convolutional network model with respect to each channel output of the last convolutional layer is calculated, and based on the gradient value of each channel, a scalar value is obtained by averaging in the spatial dimension, representing the global importance weight of the corresponding channel to the prediction target category;

[0018] The feature maps of all channels of the last convolutional layer output are weighted and summed using global importance weights; the weighted and summed feature maps are averaged in the spatial dimension to obtain a two-dimensional matrix, i.e. a heat map, wherein the value of each position in the matrix represents the importance of the corresponding pixel region in making a target class prediction by the model; the heat map is then normalized, and the normalized heat map is superimposed on the original standardized image with a predetermined transparency to form a superimposed heat map overlay.

[0019] Preferably, the step 1 further comprises the following steps:

[0020] The pixel positions in the normalized heat map that are greater than a predetermined threshold value are marked, and adjacent pixel points that satisfy the threshold condition are aggregated into independent regions using a connected region analysis algorithm in image processing to obtain connected regions, each of which represents a potential key component region that the model pays high attention to;

[0021] For each identified connected region, the coordinates of the circumscribed rectangle are calculated, and the pixel values of the width and height of each circumscribed rectangle are measured and recorded;

[0022] Based on the width and height data of all connected regions in all images, the width and height values are grouped according to a predetermined interval, the number of regions falling within each width interval and height interval is counted, and the frequency of each interval size is calculated to obtain a frequency histogram of the width and height size distribution;

[0023] The frequency histogram of the width and height size distribution is analyzed to identify the peak interval with the highest frequency, and then the typical feature size range and its representative value are identified.

[0024] Preferably, the step 1 further comprises the following steps:

[0025] An effective target region is obtained according to the target detection model, a background region is obtained except for the effective target region, and a heat map corresponding to the background region is determined,

[0026] The average heat value of the entire image is calculated, and the average heat value is calculated only for the background; if the average heat value of the background region is higher than the average heat value of the entire image, it is considered that the background region of the model should not be highly focused, and it is judged that there is a high-frequency false detection background region;

[0027] A local region in the background region where the heat value is continuously higher than a predetermined threshold value is found, and the corresponding position of the region is recorded. The coordinate information of the recorded high-frequency false detection region is stored.

[0028] Preferably, the step S2 comprises the following steps:

[0029] Based on the extracted heat map, a depth estimation model is used to estimate the depth of the image, generate a depth map, and calculate the degradation result of each pixel according to a randomly selected extinction coefficient to generate an enhanced image with rain and fog effects.

[0030] Based on the extracted heat map, Gaussian-distributed snow particles are randomly generated, and the generated snow particles are superimposed on the heat map to obtain an enhanced image with snow and frost effects.

[0031] Randomly select an image from a predefined bird nest and branch template library, adjust the polarity, size, rotate and position of the selected image randomly, and superimpose the adjusted bird nest and branch image on the background image to generate an enhanced image with bird nest or branch occlusion.

[0032] Using the heat map as a guide, a mask of the occlusion area is generated, and when superimposing the bird nest or branch image, the occlusion mask is used to ensure that the occlusion area does not cover the key power equipment, and an enhanced image with occlusion is obtained.

[0033] Randomly select whether to superimpose rain and fog, snow and frost, bird nest or branch enhancement effects, or superimpose multiple effects at the same time, and save the final enhanced image to a new dataset.

[0034] Preferably, the step S3 comprises the following steps:

[0035] Based on the enhanced dataset, the original ResNet34 model is trained, and the Taylor-FO algorithm is used to evaluate the channel importance during the training process, and iterative pruning is performed; wherein after each epoch training, the 5% channels with the lowest importance score are removed, and 2 epoch fine-tuning is immediately performed.

[0036] According to the heat map, the pruning rate of the edge feature layer and the pruning rate of the deep semantic layer are limited, wherein the pruning rate of the edge feature layer is less than or equal to 2%, and the pruning rate of the deep semantic layer is less than or equal to 10%, and a lightweight model is obtained based on this.

[0037] Preferably, the step S4 comprises the following steps:

[0038] The original ResNet34 model is used as a teacher model, and the lightweight model is used as a student model, the feature maps of the teacher model and the student model are extracted at the key feature layer, and the L2 distance between the two feature maps is calculated as the distillation loss;

[0039] A total loss function combining cross-entropy loss and distillation loss is constructed, wherein the cross-entropy loss is used to optimize the accuracy of the student model in the classification task, and the distillation loss is used to ensure that the student model can learn the high-level features of the teacher model.

[0040] The parameters of the student model are optimized to minimize the total loss function through iterative training, in which the parameters of the teacher model remain unchanged during the training process; finally, the student model is evaluated on the validation set to obtain the best-performing student model as the final lightweight model.

[0041] The beneficial effects of the present application include:

[0042] The present application generates a feature heat map through preprocessing and feature statistics, guides the data enhancement process, improves the model's adaptability to complex environments, and combines physical simulation to add weather degradation effects and random occlusions in the data enhancement part while protecting key areas to ensure that small target features are not damaged. In structured pruning, based on channel importance evaluation, redundant parameters are reduced to optimize the model structure, while considering the dependency between channels to avoid accuracy degradation. Finally, knowledge distillation optimization transfers the knowledge of the large model to the lightweight model to improve its performance and robustness, enabling the optimized model to achieve efficient and accurate power equipment identification on resource-constrained devices. BRIEF DESCRIPTION OF DRAWINGS

[0043] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0044] Figure 1 The overall step block diagram provided for the embodiments of the present application.

[0045] Figure 2 The step block diagram of step S1 provided for the embodiments of the present application. DETAILED DESCRIPTION

[0046] In order to make the technical problems, technical solutions and beneficial effects of the present application more clear, the present application will be further described in detail below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.

[0047] Referring to Figure 1 As shown in the figure, the optimization and pruning method of the power lightweight identification model includes the following steps:

[0048] S1. Preprocess the original power equipment image dataset, and based on the scale distribution of the key features of the power equipment after preprocessing, obtain a feature heat map;

[0049] Referring to Figure 2 As shown in the figure, the preprocessing includes the following steps:

[0050] The input color power inspection image is converted into a gray image, a Laplacian operator is applied to the entire gray image for calculation, the brightness difference degree of each pixel point in the image and its surrounding pixels is measured to obtain a gradient value; the variance of all pixel gradients is calculated, the variance is compared with the preset definition threshold based on the definition threshold, if the variance is greater than the definition threshold, it is determined as a clear image, if the variance is less than the definition threshold, it is determined as a fuzzy image; the clear images are retained to form a clear power inspection image combined image set; the specific expression is as follows:

[0051]

[0052] In the formula, I(x, y) represents a gray image pixel value; represents the Laplacian convolution result, the kernel size is 3x3; μ represents the mean value of the Laplacian convolution result; N represents the total number of image pixels; σ 2 represents the variance;

[0053] If σ 2 is less than 120, it is determined as fuzzy, and greater than or equal to 120, it is determined as a clear image.

[0054] A pre-trained target detection model (YOLOv5s model) is used to scan and analyze the clear power inspection image combined image set, and the position of the boundary box of each detected object, the belonging category and the confidence score are given; if the object detected by the model belongs to the equipment type in the exclusive equipment category library, and the confidence score of the detection result is greater than a preset threshold, the image is determined as a valid image, otherwise it is an invalid image, and based on this, an image set containing only valid power equipment images is obtained;

[0055] Based on the image set containing only valid power equipment images, image standardization processing is performed to obtain a standardized power equipment image set, for example:

[0056] The width-height ratio of the original image is calculated: Where w represents the width; h represents the height;

[0057] The scaling size is determined: if r is greater than or equal to 1, the temporary size is If r is less than 1, the temporary size is

[0058] The bilinear difference is scaled to 256x256 pixels; after scaling, the image may not reach 256x256 pixels (the height of the wide image is insufficient, and the width of the high image is insufficient), in order to fill to the standard size, the neutral gray with RGB value (128, 128, 128) is filled in the four corners or both sides of the scaled image, until the image size reaches 256x256 pixels.

[0059] The generation of the feature heat map includes the following steps:

[0060] A pre-trained deep convolutional neural network model (ResNet34) is used as a feature extractor. The preprocessed image is input into the deep convolutional neural network model for forward propagation until the last convolutional layer of the model, and the output of the last convolutional layer is used as the feature map A The final prediction value is output through a classification layer;

[0061] For the target class c, we calculate the gradient of the classification loss with respect to the feature map A using automatic differentiation techniques That is Where y c is the score of the target class;

[0062] The importance weight α c of each convolutional channel is calculated using the gradient G, and the formula is as follows:

[0063]

[0064] Where: H and W are the height and width of the feature map, respectively; is the value of the gradient G at position (i,j); α c is the importance weight of channel c, indicating the contribution of channel c to the target class c;

[0065] The Grad-CAM heat map L c is generated by weighting and summing the feature map A with the channel importance weight α Grad-CAM and processing it through the ReLU activation function:

[0066] Where: A c is the c-th channel in the feature map A; ReLU is a linear rectifier function that ensures negative values in the heat map are set to zero; the generated heat map L Grad-CAM is upsampled to the size of the input image 256x256 through bilinear interpolation, and finally the heat map and the original image are superimposed to visually display the key areas of the power equipment.

[0067] Through the generated Grad-CAM heat map, we can identify and count the key feature sizes of the power equipment; the specific steps are as follows:

[0068] By setting a threshold, the generated Grad-CAM heat map L Grad-CAM is binarized to obtain a binary heat map B:

[0069]

[0070] where: L ij is the heat map L Grad-CAM is the value of the heat map at position (i,j); max(L Grad-CAM ) is the maximum value of the heat map; 0.3 is the binary threshold coefficient;

[0071] Perform connected component analysis on the binary heat map B, label all connected regions, and extract the bounding boxes of these regions to obtain a set of bounding boxes.

[0072] For each bounding box, calculate its width and height, and draw a size frequency histogram, where the horizontal axis represents the width w with an interval of 10 pixels, and the vertical axis represents the frequency Freq(w), calculated as follows:

[0073]

[0074] where: count(w±5px) represents the target number within the range of w±5px pixels;

[0075] According to the frequency histogram, determine the typical size range of each type of power equipment, for example, the typical width of an insulator is 20±5 pixels, and the typical width of a digital meter is 8±2 pixels.

[0076] In order to mark the high-frequency false detection area, the following steps are taken:

[0077] According to the Grad-CAM heat map, determine whether a certain area is a false detection area, with the specific formula as follows:

[0078]

[0079] where: R bg represents the background area outside the YOLOv5 detection box; L ij represents the value of the heat map at position (i,j); |R bg | represents the total number of pixels in the background area; |I| represents the total number of pixels in the entire image; 1.2 represents the background interference determination coefficient;

[0080] If a certain area satisfies the false detection determination rule, i.e. IsFP(x,y) = 1, then mark the area as a high-frequency false detection area; record the coordinate list (x1,y1,x2,y2) of the high-frequency false detection area for protection in the subsequent data augmentation step.

[0081] In this embodiment, the quality and consistency of the power inspection image data are significantly improved through image processing and analysis, and the detection accuracy and generalization ability of the model are optimized. At the same time, by generating feature heat maps and statistical key feature sizes, important guidance is provided for subsequent data enhancement and model optimization. Not only the efficiency of power inspection is improved, but also strong technical support is provided for intelligent inspection and fault detection of power equipment.

[0082] S2. Based on the pre-processed image data set and the feature heat map, a weather degradation effect is added through physical simulation enhancement, and an occlusion mask is randomly generated. Then, the feature heat map is used to prohibit rotation or distortion in the key area of the power equipment, and small targets are copied and pasted to obtain an enhanced power image data set;

[0083] The step S2 includes the following steps:

[0084] Based on the extracted heat map, a depth estimation model (such as MiDaS) is used to perform depth estimation on the image to generate a depth map. Then, according to a randomly selected extinction coefficient, the degradation result of each pixel is calculated to generate an enhanced image with rain and fog effects. The specific expression is as follows:

[0085] J(x) = I(x) · e -βd(x) +B·(1-e -βd(x) );

[0086] In the formula, I(x) represents the pixel value of the original image; J(x) represents the degraded image; β represents the extinction coefficient, which takes a value in the range of 0.001 to 0.01, and controls the density of the fog; d(x) represents the depth map, which is generated by the depth estimation model, and represents the depth information of each point in the scene; B represents the brightness of the background area; e represents the base of the natural logarithm;

[0087] Based on the extracted heat map, a Gaussian distributed snow particle is randomly generated, and the generated snow particle is superimposed on the heat map to obtain an enhanced image with snow and frost effects. The specific expression is as follows:

[0088] J(x) = I(x) · (1-α) + snow_particle(x) · α;

[0089] In the formula, α represents the transparency parameter; snow_particle(x) represents the Gaussian distributed snow particle, with a mean value of 255 and a standard deviation of 10.

[0090] A template is selected from a predefined bird nest and branch image library, and the selected template is randomly scaled and rotated to adjust its size and angle. A random superposition position is selected to ensure that it does not overlap with the key area of the heat map. An image synthesis technique is used to superimpose the transformed template on the original image.

[0091] Identify key regions in the image using heat maps, prioritize regions with low heat values as occlusion regions based on heat maps, ensure key feature regions are not covered, generate occlusion masks based on selected occlusion regions for subsequent occlusion superposition;

[0092] Use special case markers to mark key regions in the image, dynamically adjust transformation parameters when performing geometric transformations such as rotation and scaling, ensure key regions are not damaged, reduce the impact on key features by randomly rotating angles between -15 and 15 degrees.

[0093] Use target detection models (such as YOLOv5) to detect small target defect regions in the image, randomly select detected defect regions, assign and paste them to other images, and control the assignment and pasting operation between 3-5 times to ensure data diversity and authenticity.

[0094] Based on the above enhancement method, use a random number generator to ensure that the parameters of each enhancement are different, control the parameter range of each enhancement step, and avoid data distortion caused by excessive enhancement.

[0095] In this embodiment, by randomly generating rain, fog and snow effects, the weather degradation in real scenes is simulated, significantly increasing the diversity and authenticity of the data set. For example, rain and fog simulation generates a depth map through a depth estimation model, and combines the extinction coefficient and background zone brightness to generate realistic rain and fog effects. Snow simulation generates snow particles through Gaussian distribution and superimposes them onto the image, further enhancing the diversity of the data.

[0096] And randomly select templates from a predefined nest and branch image library, and superimpose them onto the image by randomly scaling, rotating and positioning. This operation simulates the common occlusion problem in actual inspection, improves the model's adaptability to complex scenes, and further increases the number of small target samples in the data set by randomly selecting and pasting small target defect regions in the image, improving the model's detection ability for small targets.

[0097] S3. Use the enhanced power image data and the original high-precision power recognition model to perform channel importance driven structured pruning to obtain a pruned lightweight model;

[0098] The step S3 includes the following steps:

[0099] Based on the enhanced data set, the original ResNet34 model is trained, and the Taylor-FO algorithm is used to evaluate the channel importance during the training process, and iterative pruning is performed; wherein after each epoch training, the 5% channels with the lowest importance score are removed, and 2 epochs of fine-tuning are immediately performed.

[0100] According to the heat map, the pruning rate of the edge feature layer and the pruning rate of the deep semantic layer are limited, wherein the pruning rate of the edge feature layer is less than or equal to 2%, and the pruning rate of the deep semantic layer is less than or equal to 10%, and a lightweight model is obtained based on this.

[0101] The specific exemplary steps are as follows:

[0102] The enhanced data set is input to train the original ResNet34 model to generate a feature map of each channel, denoted as the feature map activation value of the i-th sample, the j-th position of the k-th channel as

[0103] The gradient of the k-th channel at the i-th sample and the j-th position is obtained by calculating the gradient of the loss function L

[0104] The importance score of each channel is calculated using the Taylor-FO algorithm, and the formula is as follows:

[0105]

[0106] In the formula: S k represents the importance score of the k-th channel; represents the gradient of the loss function L with respect to the k-th channel at the i-th sample and the j-th position; represents the feature activation value of the k-th channel at the i-th sample and the j-th position; C represents the number of input channels; N represents the number of spatial dimensions of each feature map;

[0107] By default, 5% of the channels with the lowest importance score are pruned after each epoch, except for the full-face layer, and the specific pruning rate limits are as follows:

[0108] The pruning rate of the edge layer (such as conv1) is less than or equal to 2%, and the pruning rate of the deep semantic layer (such as conv5_x) is less than or equal to 10%;

[0109] For the edge layer, the pruning number = min(5% x channel number, 2% x channel number);

[0110] For the deep semantic layer, the pruning number = = min(5% x channel number, 10% x channel number);

[0111] According to the importance score calculated in the foregoing, the channels of each layer are sorted in order from low to high according to the score, and the channels with the lowest score are selected for pruning, and the selected channels are removed from the network;

[0112] Then, the parameters of the remaining channels are adjusted through a fine-tuning stage to make up for the performance loss caused by pruning. The pruned model is trained for 50 rounds using the AdamW optimizer with a learning rate of 5e-4, and the parameters of the remaining channels are optimized.

[0113] In this embodiment, by combining image enhancement, physical simulation degradation, feature heat map guided occlusion superposition, small target copy and paste, and channel importance driven structured pruning, the quality of power inspection image data and the detection accuracy, generalization ability and lightweight level of the model are significantly improved. Specifically, the scheme improves the authenticity and diversity of the dataset by simulating complex scenes, protecting key areas, and optimizing data enhancement strategies; through channel importance evaluation and hierarchical pruning strategy, a lightweight and high-performance model is obtained; finally, efficient and reliable technical support is provided for the practical application of the power inspection system.

[0114] S4. For the pruned lightweight model, knowledge distillation technology is used for further optimization to obtain an optimized lightweight model.

[0115] The step S4 includes the following steps:

[0116] The original ResNet34 model is used as the teacher model, and the lightweight model is used as the student model. The feature maps of the teacher model and the student model are extracted at the key feature layer, and the L2 distance between the two feature maps is calculated as the distillation loss. The specific calculation formula is as follows:

[0117]

[0118] In the formula: N represents the number of key feature layers; Feature teacher,i represents the feature map of the i-th key feature layer of the teacher model; Feature student,i represents the feature map of the i-th key feature layer of the student model;

[0119] A total loss function combining cross-entropy loss and distillation loss is constructed, where cross-entropy loss is used to optimize the accuracy of the student model in the classification task, and distillation loss is used to ensure that the student model can learn the high-level features of the teacher model. The total loss function is as follows:

[0120] L total = α × L cross + β × L distill ;

[0121] In the formula: L total represents the total loss function; L cross represents the cross-entropy loss; and α and β represent the weights.

[0122] The parameters of the student model are optimized to minimize the total loss function through iterative training, in which the parameters of the teacher model remain unchanged during the training process.

[0123] The application generates a feature heat map through preprocessing and feature statistics, guides the data enhancement process, improves the adaptability of the model to complex environments, and combines physical simulation to add weather degradation effects and random occlusions in the data enhancement part while protecting key areas to ensure that small target features are not damaged.

[0124] The above is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. An optimization and pruning method for a power lightweight identification model, characterized in that, Includes the following steps: S1. Preprocess the original power equipment image dataset, and obtain a feature heatmap based on the scale distribution of key features of the power equipment according to the preprocessed images. S2. Based on the preprocessed image dataset and feature heatmap, weather degradation effects are added through physical simulation, and occlusion masks are randomly generated. Then, the feature heatmap is used to prevent rotation or distortion in key areas of power equipment. Small targets are copied and pasted to obtain the enhanced power image dataset. S3. Using the enhanced power image data and the original high-precision power identification model, channel importance-driven structured pruning is performed to obtain a lightweight pruned model. S4. For the pruned lightweight model, knowledge distillation technique is used for further optimization to obtain the optimized lightweight model.

2. The optimization and pruning method for the power lightweight identification model according to claim 1, characterized in that, The preprocessing includes the following steps: The input color power inspection image is converted into a grayscale image. The Laplacian operator is applied to the entire grayscale image to calculate the brightness difference between each pixel and its surrounding pixels, obtaining the gradient value. Then, the variance of all pixel gradients is calculated. Based on a preset sharpness threshold, the variance is compared with the sharpness threshold. If the variance is greater than the sharpness threshold, it is determined to be a sharp image; if the variance is less than the sharpness threshold, it is determined to be a blurry image. The sharp images are retained to form an image set of sharp power inspection images. A pre-trained object detection model is used to scan and analyze an image set composed of clear power inspection images, providing the bounding box position, category, and confidence score of each detected object. If the object detected by the model belongs to the equipment type in the dedicated equipment category library and the confidence score of the detection result is greater than the preset threshold, the image is determined to be a valid image; otherwise, it is an invalid image. Based on this, an image set containing only valid power equipment images is obtained. Based on the image set containing only valid power equipment images, image standardization processing is performed to obtain a standardized power equipment image set.

3. The optimization and pruning method for the power lightweight identification model according to claim 1, characterized in that, The generation of the feature heatmap includes the following steps: A pre-trained deep convolutional neural network model is used as a feature extractor. The pre-processed image is input into the deep convolutional neural network model and forward propagation is performed until the last convolutional layer of the model. Based on the output of the best convolutional layer, the final predicted value is output through a classification layer. The gradient of the prediction of the deep convolutional network model with respect to each channel of the output of the last convolutional layer is calculated, and the gradient values ​​of each channel are averaged in the spatial dimension to obtain a scalar value representing the global importance weight of the corresponding channel to the predicted target class. The feature maps of all channels output by the last convolutional layer are weighted and summed using global importance weights. The weighted feature maps are then averaged in the spatial dimension to obtain a two-dimensional matrix, i.e., a heatmap. The value of each position in the matrix represents the importance of the corresponding pixel region to the model's target category prediction. The heatmap is then normalized and superimposed onto the original normalized image with a predetermined transparency to form a superimposed heatmap.

4. The optimization and pruning method for the power lightweight identification model according to claim 3, characterized in that, Step 1 also includes the following steps: In the normalized heatmap, the pixel locations that exceed a predetermined threshold are marked. Then, using the connected component analysis algorithm in image processing, adjacent pixels that meet the threshold conditions are aggregated into independent regions to obtain connected regions. Each connected region represents a potential key component region that the model is highly concerned about. For each identified connected region, calculate the coordinates of the bounding rectangle, and measure and record the pixel values ​​of the width and height of each bounding rectangle; Based on the width and height data of all connected regions in all images, the width and height values ​​are grouped at predetermined intervals, the number of regions falling within each width and height interval is counted, the frequency of each interval size is calculated, and a frequency histogram of the width and height size distribution is obtained. By analyzing the frequency histograms of width and height dimension distributions, the highest frequency peak intervals can be identified, thereby identifying the typical characteristic dimension ranges and their representative values.

5. The optimization and pruning method for the power lightweight identification model according to claim 3, characterized in that, Step 1 also includes the following steps: The effective target region is obtained based on the target detection model, and the background region is obtained by removing the effective target region. Then, a heatmap corresponding to the background region is determined. Calculate the average heat value of the entire image, and only the background is considered based on the calculated average heat value; if the average heat value of the background region is higher than the average heat value of the entire image, then the background region performance of the model should not be given high attention, and it is judged as a high-frequency false detection background region. Locate the local area in the background region where the heat value is consistently higher than a predetermined threshold, record the corresponding location of the area, and store the coordinate information of the recorded high-frequency false detection area.

6. The optimization and pruning method for the power lightweight identification model according to claim 1, characterized in that, Step S2 includes the following steps: Based on the extracted heatmap, a depth estimation model is used to estimate the depth of the image, generating a depth map. Then, based on the randomly selected extinction coefficient, the degradation result of each pixel is calculated to generate an enhanced image with rain and fog effects. Based on the extracted heatmap, Gaussian-distributed snow particles are randomly generated. The generated snow particles are then superimposed onto the heatmap to obtain an enhanced image with a snow and frost effect. Randomly select images from a predefined library of bird nests and tree branches templates, randomly adjust the polarity, size, rotation, and position of the selected images, and overlay the adjusted bird nest and tree branch images onto the background image to generate an enhanced image with bird nests or tree branches occluding the background. Using heatmaps as a guide, a mask for occlusion areas is generated. When overlaying images of bird nests or tree branches, the occlusion mask is used to ensure that the occlusion areas do not cover critical power equipment, resulting in an enhanced image with occlusions. Randomly select whether to overlay enhancement effects such as rain, fog, snow, frost, bird nests, or tree branches, or overlay multiple effects simultaneously, and save the final enhanced image to a new dataset.

7. The optimization and pruning method for the power lightweight identification model according to claim 1, characterized in that, Step S3 includes the following steps: The original ResNet34 model was trained on the enhanced dataset. During training, the Taylor-FO algorithm was used to evaluate channel importance and iteratively prune the channel. During the iterative pruning process, after each epoch of training, the 5% of channels with the lowest importance scores were removed, and fine-tuning was performed immediately for 2 epochs. Based on the heatmap, the pruning rates of the edge feature layer and the deep semantic layer are restricted, with the pruning rate of the edge feature layer being less than or equal to 2% and the pruning rate of the deep semantic layer being less than or equal to 10%. Based on this, a lightweight model is obtained.

8. The optimization and pruning method for the power lightweight identification model according to claim 1, characterized in that, Step S4 includes the following steps: The original ResNet34 model is used as the teacher model, and the lightweight model is used as the student model. Feature maps of the teacher model and student model are extracted at the key feature layer, and the L2 distance between the two feature maps is calculated as the distillation loss. Construct a total loss function that combines cross loss and distillation loss, where cross loss is used to optimize the accuracy of the student model on the classification task, and distillation loss is used to ensure that the student model can learn the high-level features of the teacher model; Through iterative training, the parameters of the teacher model remain unchanged during training, while the parameters of the student model are optimized to minimize the total loss function. Finally, the student model is evaluated on the validation set, and the best-performing student model is obtained as the final lightweight model.