Large electric power model dynamic pruning method, device and equipment and storage medium

By performing multi-dimensional complexity evaluation and adaptive pruning on power equipment images and dynamically adjusting the lightweight network, the problem of improper allocation of computational resources in large visual language models for power equipment defect identification is solved, achieving efficient and low-latency defect identification.

CN121660018APending Publication Date: 2026-03-13ELECTRIC POWER RESEARCH INSTITUTE OF STATE GRID SHANDONG ELECTRIC POWER COMPANY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-08
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Existing large-scale visual language models based on the Transformer architecture cannot dynamically adjust the model inference depth according to the complexity of the input image in power equipment defect identification. This results in redundant computation and energy waste in simple scenarios, while the recognition accuracy decreases in complex scenarios. It is difficult to achieve flexible optimization that maintains accuracy in complex tasks and improves efficiency in simple tasks.

Method used

By performing multi-dimensional complexity evaluation on the input image, a comprehensive complexity score is generated. The K-Means clustering algorithm is used to determine the adaptive threshold, the pruning rate is determined according to the complexity level, a candidate pruning window set is generated, and the lightweight network is dynamically switched through the parameter masking mechanism to achieve adaptive pruning and lightweight network replacement, adapting to the computational needs of different scenarios.

Benefits of technology

It significantly reduces redundant computation and inference latency while ensuring the accuracy of power equipment defect identification, solves the problem of efficiency and accuracy imbalance in existing technologies, and adapts to the computing resource allocation needs of different scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121660018A_ABST
    Figure CN121660018A_ABST
Patent Text Reader

Abstract

The invention provides an electric power large model dynamic pruning method and device, equipment and a storage medium, and the method comprises the steps: obtaining an input image from an electric power inspection edge device, and carrying out the multi-dimensional complexity evaluation of the input image; determining a self-adaptive threshold by using a clustering algorithm, and dividing complexity levels according to the self-adaptive threshold; determining a pruning rate according to the grade, generating a candidate pruning window set, and screening an optimal pruning window based on the power inspection calibration data; training a lightweight network by aiming at the training model, wherein the training comprises feature fitting pre-training and task adaptation fine tuning; and marking an optimal pruning window by using a parameter mask mechanism, dynamically switching the lightweight network, and performing electrical equipment defect identification on the input image. According to the method, through dynamic pruning and lightweight network replacement, a calculation path can be adaptively adjusted according to image complexity, the recognition precision is ensured, redundant calculation and reasoning delay are reduced, and the defects of an existing static method are overcome.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of model pruning, and in particular relates to a method, apparatus, equipment and storage medium for dynamic pruning of a large power model. Background Technology

[0002] Deep learning-based image recognition models are used for defect identification in power equipment, replacing traditional, inefficient manual inspection methods to achieve automated and intelligent inspections of transmission lines, substations, and distribution networks. Specifically, this technology aims to automatically detect typical defects such as insulator cracks, conductor erosion, hardware corrosion, and foreign object adhesion through models, thereby improving inspection efficiency and accuracy.

[0003] Currently, large-scale visual language models based on the Transformer architecture (such as QwenVL and LLaVA) achieve semantic understanding of images and text through multimodal joint inference, thereby handling complex scenarios in power line inspection. Simultaneously, they employ static lightweight methods, reducing the model parameter size through a fixed compression rate to lower computational and storage overhead. Through these approaches, existing technologies can achieve high defect recognition accuracy in certain scenarios and alleviate the limitation of computing power on edge devices.

[0004] However, in the process of fixing the compression model through the "static lightweight method", the inference depth of the model cannot be dynamically adjusted according to the complexity of the input image (such as lighting, occlusion, texture, etc.), resulting in redundant calculations and energy waste in simple scenarios, while in complex scenarios, the recognition accuracy decreases due to excessive pruning, making it difficult to achieve flexible optimization of "maintaining accuracy for complex tasks and improving efficiency for simple tasks". Summary of the Invention

[0005] The purpose of this application is to overcome the deficiencies in the prior art and provide a method, apparatus, device and storage medium for dynamic pruning of a large power model.

[0006] This application provides a dynamic pruning method for a large power model, including:

[0007] Input images are obtained from power line inspection edge devices;

[0008] A multi-dimensional complexity evaluation is performed on the input image to generate a comprehensive complexity score. The multi-dimensional complexity evaluation includes calculating image information entropy, abnormal pixel ratio, illumination uniformity, and semantic complexity, and weighted fusion of the image information entropy, the abnormal pixel ratio, the illumination uniformity, and the semantic complexity to generate the comprehensive complexity score.

[0009] An adaptive threshold is determined using the K-Means clustering algorithm based on the comprehensive complexity score.

[0010] The complexity level is determined based on the comprehensive complexity score and the adaptive threshold, and the complexity level includes a first complexity level and a second complexity level;

[0011] The pruning rate is determined based on the complexity level.

[0012] A set of candidate pruning windows is generated based on the pruning rate;

[0013] The optimal pruning window in the candidate pruning window set is selected based on power inspection and calibration data.

[0014] A lightweight network is trained for the optimal pruning window, and the training includes feature fitting pre-training and task adaptation fine-tuning.

[0015] The optimal pruning window is marked according to the parameter masking mechanism, and the lightweight network is dynamically switched according to the marking.

[0016] The input image is used to identify power equipment defects using the dynamically switched lightweight network.

[0017] Optionally, a multi-dimensional complexity evaluation is performed on the input image to generate a comprehensive complexity score, including:

[0018] The image information entropy, the proportion of abnormal pixels, the illumination uniformity, and the semantic complexity are standardized.

[0019] The comprehensive complexity score is generated by weighting and fusing the standardized image information entropy, the proportion of abnormal pixels, the illumination uniformity, and the semantic complexity using learnable hyperparameters; the learnable hyperparameters are adaptively optimized during the model training process.

[0020] Optionally, generating a candidate pruning window set based on the pruning rate includes:

[0021] When the complexity level is the first complexity level, a first size window set is generated, which is generated by sliding the starting index to traverse all consecutive layer combinations;

[0022] When the complexity level is the second complexity level, a second-size window set is generated, which is generated by sliding the starting index to traverse all consecutive layer combinations.

[0023] Optionally, training a lightweight network for the optimal pruning window includes:

[0024] When the complexity level is the first complexity level, the lightweight network adopts a basic feedforward network architecture, which includes a linear transformation and a ReLU activation function.

[0025] When the complexity level is the second complexity level, the lightweight network adopts an enhanced gated linear unit architecture, which includes parallel linear transformation and Sigmoid gating mechanism.

[0026] Optionally, the training includes feature fitting pre-training and task adaptation fine-tuning, including:

[0027] The feature fitting pre-training uses the mean squared error loss function to calculate the difference between the lightweight network output and the pruned window features;

[0028] The task adaptation fine-tuning, combined with the cross-entropy loss function, optimizes the accuracy of lightweight networks in identifying defects in power equipment.

[0029] Optionally, the optimal pruning window is marked according to a parameter masking mechanism, and the lightweight network is dynamically switched according to the marked window, including:

[0030] Construct a binary mask matrix, in which the layer position corresponding to the optimal pruning window is assigned a value of zero, and the non-pruning layer position is assigned a value of one;

[0031] During the forward propagation, consecutive zero-value windows in the binary mask matrix are identified, the original Transformer layer calculation of the consecutive zero-value windows is skipped, and the input features are fed into the lightweight network for processing.

[0032] A single-backbone dual-lightweight network deployment architecture is adopted, the lightweight network parameters are preloaded, and the mask matrix and network call pointer are dynamically switched according to the complexity level.

[0033] Optionally, the input image is used for power equipment defect identification based on the dynamically switched lightweight network, including:

[0034] The input image is processed using a lightweight network that has been trained.

[0035] Based on the processed features, output the category and location information of power equipment defects;

[0036] The defect identification process is implemented with low latency on the edge device.

[0037] This application also provides a dynamic pruning device for a large-scale power model, comprising:

[0038] The acquisition module acquires input images from the power inspection edge device;

[0039] The evaluation module performs a multi-dimensional complexity evaluation on the input image to generate a comprehensive complexity score. The multi-dimensional complexity evaluation includes calculating image information entropy, abnormal pixel ratio, illumination uniformity, and semantic complexity, and weightedly fuses the image information entropy, the abnormal pixel ratio, the illumination uniformity, and the semantic complexity to generate the comprehensive complexity score.

[0040] The clustering module uses the K-Means clustering algorithm to determine an adaptive threshold based on the comprehensive complexity score;

[0041] The grading module determines the complexity level based on the comprehensive complexity score and the adaptive threshold, wherein the complexity level includes a first complexity level and a second complexity level.

[0042] The pruning rate module determines the pruning rate based on the complexity level.

[0043] The window module generates a set of candidate pruning windows based on the pruning rate;

[0044] The optimization module filters the optimal pruning window from the candidate pruning window set based on power inspection and calibration data;

[0045] The training module trains a lightweight network for the optimal pruning window, and the training includes feature fitting pre-training and task adaptation fine-tuning.

[0046] The switching module marks the optimal pruning window according to the parameter masking mechanism and dynamically switches the lightweight network according to the marking.

[0047] The identification module identifies power equipment defects in the input image based on the dynamically switched lightweight network.

[0048] Optionally, the evaluation module performs a multi-dimensional complexity evaluation on the input image to generate a comprehensive complexity score, including:

[0049] The image information entropy, the proportion of abnormal pixels, the illumination uniformity, and the semantic complexity are standardized.

[0050] The comprehensive complexity score is generated by weighting and fusing the standardized image information entropy, the proportion of abnormal pixels, the illumination uniformity, and the semantic complexity using learnable hyperparameters; the learnable hyperparameters are adaptively optimized during the model training process.

[0051] Optionally, the window module generates a set of candidate pruning windows based on the pruning rate, including:

[0052] When the complexity level is the first complexity level, a first size window set is generated, which is generated by sliding the starting index to traverse all consecutive layer combinations;

[0053] When the complexity level is the second complexity level, a second-size window set is generated, which is generated by sliding the starting index to traverse all consecutive layer combinations.

[0054] Optionally, the training module trains a lightweight network for the optimal pruning window, including:

[0055] When the complexity level is the first complexity level, the lightweight network adopts a basic feedforward network architecture, which includes a linear transformation and a ReLU activation function.

[0056] When the complexity level is the second complexity level, the lightweight network adopts an enhanced gated linear unit architecture, which includes parallel linear transformation and Sigmoid gating mechanism.

[0057] Optionally, the training module training includes feature fitting pre-training and task adaptation fine-tuning, including:

[0058] The feature fitting pre-training uses the mean squared error loss function to calculate the difference between the lightweight network output and the pruned window features;

[0059] The task adaptation fine-tuning, combined with the cross-entropy loss function, optimizes the accuracy of lightweight networks in identifying defects in power equipment.

[0060] Optionally, the switching module marks the optimal pruning window according to a parameter masking mechanism, and dynamically switches the lightweight network according to the marking, including:

[0061] Construct a binary mask matrix, in which the layer position corresponding to the optimal pruning window is assigned a value of zero, and the non-pruning layer position is assigned a value of one;

[0062] During the forward propagation, consecutive zero-value windows in the binary mask matrix are identified, the original Transformer layer calculation of the consecutive zero-value windows is skipped, and the input features are fed into the lightweight network for processing.

[0063] A single-backbone dual-lightweight network deployment architecture is adopted, the lightweight network parameters are preloaded, and the mask matrix and network call pointer are dynamically switched according to the complexity level.

[0064] Optionally, the recognition module performs power equipment defect recognition on the input image based on the dynamically switched lightweight network, including:

[0065] The input image is processed using a lightweight network that has been trained.

[0066] Based on the processed features, output the category and location information of power equipment defects;

[0067] The defect identification process is implemented with low latency on the edge device.

[0068] This application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method described above.

[0069] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the above-described method.

[0070] The beneficial effects of this application are:

[0071] This application provides a dynamic pruning method for a large power grid model, comprising: acquiring an input image from a power grid inspection edge device; performing a multi-dimensional complexity assessment on the input image to generate a comprehensive complexity score, wherein the multi-dimensional complexity assessment includes calculating image information entropy, abnormal pixel ratio, illumination uniformity, and semantic complexity, and weightedly fusing the image information entropy, the abnormal pixel ratio, the illumination uniformity, and the semantic complexity to generate the comprehensive complexity score; determining an adaptive threshold using a K-Means clustering algorithm based on the comprehensive complexity score; and determining an adaptive threshold based on the comprehensive complexity score and the adaptive threshold. The complexity level is determined by a value, including a first complexity level and a second complexity level; a pruning rate is determined based on the complexity level; a candidate pruning window set is generated based on the pruning rate; the optimal pruning window in the candidate pruning window set is selected based on power inspection calibration data; a lightweight network is trained for the optimal pruning window, the training including feature fitting pre-training and task adaptation fine-tuning; the optimal pruning window is marked according to a parameter masking mechanism, and the lightweight network is dynamically switched according to the marking; the power equipment defect identification is performed on the input image based on the dynamically switched lightweight network. This application achieves adaptive adjustment of the model calculation path according to the complexity of the input image through dynamic pruning and lightweight network replacement mechanism based on scene complexity, thereby significantly reducing redundant calculation and inference latency while ensuring the accuracy of power equipment defect identification, overcoming the efficiency and accuracy imbalance caused by the inability of existing static methods to dynamically optimize. Attached Figure Description

[0072] Figure 1 This is a schematic diagram of the dynamic pruning process of a large-scale power model;

[0073] Figure 2 This is a schematic diagram of the window filtering process that minimizes the performance degradation of tasks in various scenarios.

[0074] Figure 3 This is a diagram illustrating a dynamic pruning strategy;

[0075] Figure 4 This is a schematic diagram of a dynamic pruning device for a large-scale power model. Detailed Implementation

[0076] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it is to be understood that various forms of implementation of the present disclosure are intended and should not be limited to the embodiments set forth herein. Rather, the embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.

[0077] Please refer to Figures 1-3 As shown, this application provides a dynamic pruning method for large power models, which is applied to the field of power inspection to solve the contradiction between high computing power requirements and low hardware resources in resource-constrained power inspection scenarios for large visual language models.

[0078] The architecture of this application is built around the closed-loop logic of "complexity perception and dynamic decision-making compensation", integrating three core functional modules. Each module forms a collaborative working mechanism through data interaction and control signals.

[0079] The first module is the input image complexity evaluation module. As the core decision-making unit of the architecture, this module extracts global information entropy, abnormal pixel ratio, illumination uniformity, and semantic complexity features from the image, calculates a comprehensive complexity score through weighted fusion, and adaptively classifies the image into low and high complexity levels using the K-Means clustering algorithm. This module features lightweight computation and fast evaluation, enabling millisecond-level complexity identification on edge devices, providing accurate decision signals for subsequent dynamic pruning.

[0080] The second module is a dynamic Transformer pruning engine, which automatically matches the corresponding pruning rate based on the complexity level signal and performs continuous layer pruning on consecutive Transformer blocks in LVLM. Low-complexity images are inferred quickly with a lightweight structure using a high pruning rate, while high-complexity scenes retain the core feature extraction capability with a low pruning rate, realizing on-demand allocation of computing resources.

[0081] The third module is the lightweight network replacement and accuracy compensation module. This module addresses the accuracy loss problem of the pruned model and adapts the FFN and SwiGLU lightweight networks for low / high complexity scenarios respectively. Through a two-stage training of "feature fitting pre-training + task fine-tuning", the lightweight network learns the feature mapping relationship of the pruned layer, restoring the model accuracy while reducing the amount of computation, and supporting unified deployment in multiple scenarios.

[0082] Finally, the LVLM model optimized by dynamic pruning and lightweight network replacement can be directly deployed on the inspection edge terminal to achieve complexity-aware adaptive and efficient inference.

[0083] like Figure 1 and Figure 2 The method includes:

[0084] S101. Obtain input images from power inspection edge devices.

[0085] Power system inspection edge devices include resource-constrained equipment such as drone edge boxes or substation terminals. These devices are used to collect images of power equipment, such as transmission lines, substations, or distribution networks, in unmanned intelligent power system inspections. Input images include typical power defects such as insulator cracks, conductor erosion, hardware corrosion, foreign object attachment, or tower tilting. Image acquisition is achieved through the edge device's camera or sensors, ensuring real-time transmission of image data to the processing unit.

[0086] S102. Perform a multi-dimensional complexity evaluation on the input image to generate a comprehensive complexity score. The multi-dimensional complexity evaluation includes calculating image information entropy, abnormal pixel ratio, illumination uniformity, and semantic complexity, and weightedly fusing image information entropy, abnormal pixel ratio, illumination uniformity, and semantic complexity to generate a comprehensive complexity score.

[0087] Image information entropy is used to measure the randomness of the overall gray-level distribution of an image, reflecting the richness of texture details and the degree of background clutter. The calculation formula is as follows:

[0088]

[0089] in, The percentage of pixels with gray level i (i∈[0,255]) in the entire image is used to quantify the randomness of the image gray level distribution.

[0090] The abnormal pixel ratio is calculated based on the characteristic that power defects often manifest as localized grayscale anomalies. It quantifies the proportion of pixels in the image that deviate from the normal grayscale range, and the formula is as follows:

[0091]

[0092] in, For grayscale values ​​exceeding Number of pixels in the range ( σ is the average gray level of the entire image, M×N is the standard deviation of the gray level of the entire image, and M×N is the total number of pixels in the image.

[0093] Illumination uniformity is used to reflect the uniformity of illumination distribution in images of power equipment. The calculation formula is as follows:

[0094]

[0095] in, The number of pixels with a grayscale value ≥ 220 represents the highlight area, and M×N is the total number of pixels in the image.

[0096] Semantic complexity is evaluated using a lightweight network to assess the semantic difficulty of a sample. The calculation formula is as follows:

[0097]

[0098] in, The label is one-hot encoded only if the input image belongs to the c-th type of defect. =1, other categories C represents the total number of categories of defects in power equipment. This is the predicted probability that the output sample belongs to the c-th type of defect.

[0099] Image information entropy, abnormal pixel ratio, illumination uniformity, and semantic complexity are standardized. Then, a weighted fusion of these standardized components is performed using learnable hyperparameters to generate a comprehensive complexity score. The calculation formula is as follows:

[0100]

[0101] in For learnable hyperparameters, satisfying Through model training, the weights of each indicator can be adaptively optimized, so that the scoring results can accurately reflect the actual difficulty of power defect identification.

[0102] The evaluation process is implemented through the input image complexity evaluation module, which features lightweight computation and fast evaluation. It can achieve millisecond-level complexity recognition on edge devices, providing accurate decision signals for dynamic pruning.

[0103] To achieve adaptive pruning control of large-scale power vision language models on edge devices, this application proposes an intelligent quantization modeling method driven by input image complexity.

[0104] This method integrates four types of features: image information entropy, abnormal pixel ratio, illumination uniformity, and lightweight network semantic feedback, to construct a unified complexity evaluation system. Finally, it uses the K-Means clustering algorithm to analyze 1000 randomly sampled data points from a large-scale power equipment inspection dataset, achieving adaptive classification of complexity levels and providing a quantitative basis for dynamic pruning strategies. To comprehensively and accurately characterize the visual complexity and semantic discrimination difficulty of power equipment inspection images, given the characteristics of power defect scenarios such as 'equipment being susceptible to illumination interference, defects often exhibiting local abnormal features, and global texture clutter and semantic ambiguity directly affecting recognition results,' this application selects four core indicators—image information entropy, abnormal pixel ratio, illumination uniformity, and semantic complexity—to construct a multi-dimensional evaluation framework.

[0105] In the scenario of power equipment inspection, the higher the entropy value, the more complex the texture changes contained in the image, thus increasing the difficulty of visually identifying defects; conversely, images with simple backgrounds and regular equipment features have lower entropy values ​​and are easier to identify.

[0106] The higher the percentage of abnormal pixels, the more abnormal pixels there are in the image. If the percentage of abnormal pixels is too high, such as due to severe dirt or complex background interference, it will increase the difficulty of feature selection by the model.

[0107] The lower the value of the illumination uniformity index, the more uniform the illumination, the easier it is to expose defect features, and the easier it is to identify; the higher the value, the larger the proportion of the highlight area, which masks defect features and increases the difficulty of identification.

[0108] When the semantic complexity Lce(x) value is high, it indicates that the lightweight network has great uncertainty in classifying the image, that is, the category boundary of the sample at the semantic level is blurred, and the model needs deeper feature extraction to achieve accurate discrimination.

[0109] After standardization, the above four features are weighted and fused to obtain a unified comprehensive complexity score, thereby achieving a multi-dimensional assessment of the complexity of power equipment inspection images.

[0110] S103. Determine the adaptive threshold using the K-Means clustering algorithm based on the comprehensive complexity score.

[0111] The K-Means clustering algorithm scores the overall complexity of 1000 randomly sampled data points from a large-scale power line inspection dataset. Unsupervised clustering analysis is performed, and the boundary of complexity level is automatically determined. The number of clusters, K=2, is set on the sample set, resulting in two cluster centers. (Cluster centers of low-complexity samples) and (High-complexity sample cluster centers), and satisfying .

[0112] Using the median of the two cluster centers as the unique threshold for complexity classification, the formula is:

[0113]

[0114] This threshold can adaptively fit the distribution characteristics of complexity scores in the sample set, avoiding the adaptation bias of a fixed threshold for samples in different scenarios, thereby improving the stability and generalization of complexity classification.

[0115] This threshold can adaptively fit the distribution characteristics of complexity scores in the sample set, avoiding the adaptation bias of a fixed threshold for samples in different scenarios, thereby improving the stability and generalization of complexity classification.

[0116] Based on a threshold T, all input samples are divided into two complexity ranges, corresponding to different model invocation strategies: Low complexity range: Use a lightweight model for fast recognition; High complexity range: It calls upon a high-precision model to perform deep feature extraction and fine recognition.

[0117] This hierarchical mechanism can significantly reduce average computational overhead while ensuring recognition accuracy, achieving a dynamic balance between efficiency and performance.

[0118] S104. Determine the complexity level based on the comprehensive complexity score and the adaptive threshold. The complexity level includes the first complexity level and the second complexity level.

[0119] The first complexity level corresponds to the low complexity range, that is... The first level of complexity indicates a simple image background, regular equipment features, and easily identifiable defects, such as an image of an insulator on a sunny day without any obstructions; the second level of complexity corresponds to the high complexity range, i.e. This indicates that the image is obstructed, severely interfered with, and difficult to identify defects, such as a power transmission line image with overlapping hardware on a rainy day.

[0120] This hierarchical mechanism divides all input samples into two complexity ranges based on a threshold T, corresponding to different model invocation strategies, thereby achieving a dynamic balance between efficiency and performance.

[0121] S105. Determine the pruning rate based on the complexity level.

[0122] like Figure 3 As shown, pruning rate This is the ratio of the number of Transformer layers to be pruned to the total number of LLM layers. It is preset based on the computing power constraints of edge devices and the real-time requirements of power line inspection tasks, and its selectable range is 0.2-0.5. When the complexity level is the first complexity level (low complexity scenario), a higher pruning rate is adopted. A larger window size is appropriate because in such scenarios, the features of power equipment are clear and the defects are singular, resulting in a lower dependence of the model on detailed features. When the complexity level is the second level (high complexity scenario), a moderate pruning rate is adopted. This corresponds to a smaller window size because device features are severely occluded and interfered with in such scenarios, and the model needs to rely on feature fusion at more levels.

[0123] This step utilizes a dynamic pruning engine to achieve on-demand allocation of computing resources.

[0124] Visual Language Models (LVLMs) typically employ a three-tier architecture: visual encoder - cross-modal adapter - large language model. The majority of computational effort is concentrated in the stacked Transformer layers within the LLM. Different Transformer layers contribute differently to power equipment defect analysis tasks; directly applying uniform or random pruning will lead to uncontrollable accuracy loss.

[0125] The core idea of ​​this engine is to use the performance of power defect identification task as the sole evaluation metric, measure the importance of each continuous layer window of the large language model through calibration data, and automatically filter out removable "low contribution windows".

[0126] The specific strategies are as follows:

[0127] For low-complexity inspection scenarios (such as single device, no obstruction), more redundant layers are removed by a higher pruning rate, significantly reducing inference latency. For high-complexity scenarios (such as multiple overlapping devices, severe weather), only a small number of non-core layers are removed by a lower pruning rate, strictly controlling the accuracy loss within an acceptable range for engineering. By linking with the aforementioned image complexity assessment module, a dynamic adaptive scheduling mechanism of "complexity → optimal pruning rate window" is realized, enabling the pruning scheme to automatically adjust with changes in the inspection environment.

[0128] S106. Generate a set of candidate pruning windows based on the pruning rate.

[0129] like Figure 3 As shown, window size The calculation formula is:

[0130]

[0131] in, This represents the total number of layers in the LLM. This is the floor function.

[0132] When the complexity level is first, a first-size window set is generated. This first-size window set is generated by sliding the starting index through all consecutive layer combinations. The window size is determined by the complexity level of the low-complexity scenario. Based on the total number of LLM layers To define a range, generate all possible consecutive layer windows by sliding the starting index k:

[0133] The range of values ​​for the starting index k is: The candidate window set is as follows:

[0134]

[0135] in, This is the window size for low-complexity scenarios.

[0136] This collection contains all the combinations of large-size continuous layers, providing a high pruning window option for low-complexity scenarios.

[0137] When the complexity level is second level, a second-size window set is generated. This second-size window set is generated by sliding the starting index through all consecutive layer combinations, and the window size is... Similarly, the range of values ​​for the starting index k is: The candidate window set is as follows:

[0138]

[0139] This set focuses on combinations of small-sized continuous layers, ensuring more refined pruning window selection for high-complexity scenes. The generation of candidate windows strictly follows the mapping mechanism from scene complexity to pruning rate, ensuring a high degree of matching between the candidate window set and scene features.

[0140] To ensure that the pruning window is deeply adapted to the complexity features of different scenarios, this application constructs independent candidate pruning window sets for low-complexity and high-complexity scenarios respectively. By sliding traversal, all continuous layer combinations that meet the corresponding window size are generated, providing a comprehensive candidate space for subsequent optimal window selection.

[0141] The specific generation rules are as follows:

[0142] Scene adaptability of window generation: The generation of candidate pruned windows strictly follows the mapping mechanism of "scene complexity → pruning rate → window size". Low-complexity scenes correspond to large windows under high pruning rates, and high-complexity scenes correspond to small windows under low pruning rates. The generation processes of the two types of windows are independent of each other to avoid cross-interference between pruning requirements of different scenes and ensure the matching degree between the candidate window set and scene features.

[0143] Completeness and non-repetition of candidate windows: Both candidate sets cover all combinations of consecutive layers, ensuring that the subsequent screening process can traverse all potential "low-contribution layer windows" without the risk of missing the optimal solution. At the same time, by generating sets for different scenarios, the screening of low-complexity scenarios focuses on "large window efficiency gain", while high-complexity scenarios focus on "small window accuracy preservation", providing a solid foundation for differentiated pruning strategies.

[0144] S107. Select the optimal pruning window from the candidate pruning window set based on power inspection and calibration data.

[0145] like Figure 3 As shown, power line inspection and calibration data are filtered into subsets through a window. The construction process begins by randomly selecting 5000 samples from a large-scale power line inspection dataset. Based on clustering results and a threshold T, these samples are divided into low-complexity and high-complexity intervals. Then, 500 samples are randomly selected from the low-complexity interval, and 500 samples are randomly selected from the high-complexity interval, resulting in a total of 1000 samples. This ensures a balanced proportion of samples in the two scenarios.

[0146] Determine the accuracy of defect identification Average crossover ratio and reasoning delay As an evaluation metric, the original unpruned model was recorded in Benchmark performance, including benchmarks for low-complexity scenarios. , , and benchmarks for high-complexity scenarios , , .

[0147] Set the maximum accuracy loss threshold for different scenarios, for low-complexity scenarios. Highly complex scenarios Candidate windows for low-complexity scenarios Remove The corresponding continuous layer constructs a pruning model ,exist Tested on a low-complexity subset , , Calculation accuracy loss and positioning accuracy loss Preferred and Choose the smallest window if the delay is similar. The smallest window is the optimal window. .

[0148] Candidate windows for high-complexity scenarios Remove The corresponding continuous layer constructs a pruning model ,exist Tested on high-complexity subsets , Calculation accuracy loss and positioning accuracy loss Preferred and The smallest window is selected if the positioning accuracy is similar. The smallest window is the optimal window. .

[0149] This screening mechanism is implemented through a dynamic pruning engine, ensuring that the pruning plan is automatically adjusted as the inspection environment changes.

[0150] To ensure that the optimal window selection results closely match actual power inspection scenarios, this application constructs a data system encompassing diverse scenarios and selects subsets through window selection. We conducted practical tests and evaluations on candidate windows for both low-complexity and high-complexity scenarios, and selected the window with the smallest performance degradation for each scenario.

[0151] Window Filtering Subset The build process is as follows:

[0152] First, 5000 samples are randomly selected from a large-scale power line inspection dataset. Based on the determined clustering results and threshold T, these 5000 samples are divided into low-complexity intervals by inputting the image complexity evaluation module. ) and high complexity intervals ( );

[0153] Then, 500 samples were randomly selected from the low-complexity interval, and 500 samples were randomly selected from the high-complexity interval, forming a total of 1000 samples. This ensures that the sample proportions of the two types of scenarios are balanced and that the typical features of their respective intervals are covered.

[0154] The low-complexity scenario subset includes easily identifiable scenarios such as unobstructed single devices, no defects, or single obvious defects; the high-complexity scenario subset includes difficult-to-identify scenarios such as multiple overlapping devices, severe environmental interference, and minor defects. Both subsets are labeled with defect category and location information to ensure that the evaluation indicators can be quantified.

[0155] To meet the engineering requirements of power line inspection, three core evaluation indicators were identified:

[0156] Defect identification accuracy ( ): The proportion of correctly identified defective samples out of the total number of samples; the average crossover ratio (CRO). ): The mean intersection-union ratio (IUU) of the defect detection bounding box and the ground truth bounding box, measuring the localization accuracy; inference delay ( ): The time taken from input to output for a single sample.

[0157] The window filtering steps include:

[0158] Record the original unpruned model in The benchmark performance was determined; the maximum accuracy loss threshold for each scenario was set; the accuracy loss of candidate windows was tested and calculated; and the scenario-based filtering rules prioritized the window that met the threshold and had the best performance.

[0159] S108. Train a lightweight network for the optimal pruning window. The training includes feature fitting pre-training and task adaptation fine-tuning.

[0160] When the complexity level is first level, the lightweight network adopts a basic feedforward network architecture, which includes a linear transformation and the ReLU activation function. The core expression is:

[0161]

[0162] in, The input features for the pruning window, , This is the weight matrix that can be learned during network training.

[0163] , For learnable bias terms, For the input feature dimension, As an intermediate feature dimension, To output feature dimensions, and To ensure consistency in feature dimensions.

[0164] When the complexity level is second-order, the lightweight network adopts an enhanced gated linear unit architecture, which includes parallel linear transformation and Sigmoid gating mechanism. The core expression is:

[0165]

[0166] in, , For learnable weight matrix, This is an element-wise multiplication operation. This is the Sigmoid activation function.

[0167] The training data consists of 100,000 power line inspection image samples to build an initial sample library, covering multiple inspection scenarios and eight typical power line defects. The comprehensive complexity score is calculated through the intelligent quantification modeling module for scenario complexity. The samples were then selected based on a threshold T. 20,000 samples were randomly selected from the high-complexity samples and 20,000 samples were randomly selected from the low-complexity samples to form an initial training dataset of 40,000 samples. Data augmentation strategies were then used to expand the dataset to 64,000 samples.

[0168] Feature fitting pre-training uses the mean squared error loss function to calculate the difference between the lightweight network output and the pruned window features, expressed as:

[0169]

[0170] in, This represents the lightweight network currently being trained; N=32 represents the number of feature pairs in a single batch. It is the square of the L2 norm.

[0171] Task adaptation fine-tuning combined with the cross-entropy loss function optimizes the accuracy of lightweight networks in identifying defects in power equipment. The joint loss function expression is as follows:

[0172]

[0173] in, , LCE is the cross-entropy loss for defect identification; y is the true label of the sample.

[0174] During training, the parameters of the original large visual language model are frozen except for the lightweight network. Scene-specific inference chains are constructed, with low-complexity scenes being... Highly complex scenarios are This ensures consistency in feature dimensions.

[0175] After training, scenario-specific calibration and verification are performed. For low-complexity scenarios, the FFN output must be consistent with... The KL divergence of the window output should be ≤0.1, and the defect identification accuracy should be ≥95%; high-complexity scenarios need to ensure... Output and The KL divergence of the window output is ≤0.1, and the defect identification accuracy is ≥95%.

[0176] Under the constraint of freezing the parameters of the original visual language large model except for the lightweight network, this application conducts independent training on the adapted lightweight network for the LVLM pruning structure for low and high complexity scenarios. Through the two-stage mechanism of "feature fitting pre-training + task adaptation fine-tuning", it ensures that the two types of lightweight networks accurately inherit the power domain feature transformation logic of the LVLM pruning window in the corresponding scenario, and avoids feature transmission discontinuity caused by pruning.

[0177] Construction of training data and feature pairs:

[0178] An initial sample library was constructed using 100,000 power inspection image samples, covering multiple inspection scenarios such as transmission lines, substations, and distribution networks, and including eight typical power defects such as insulator cracks, conductor ablation, hardware corrosion, foreign object attachment, and tower tilting.

[0179] Calculate the overall complexity score for each of the 100,000 initial samples. And select samples based on the threshold T determined by clustering: 20,000 records were randomly selected from the high-complexity sample. 20,000 samples were randomly selected from the low-complexity samples to form an initial training dataset of 40,000 samples. The two types of samples correspond to different LVLM pruning structure requirements.

[0180] The initial 40,000 samples were then expanded to 64,000 samples using data augmentation strategies such as random flipping, brightness adjustment, and Gaussian blur, while keeping the sample complexity attribute unchanged.

[0181] The enhanced samples are input into the original unpruned LVLM according to the scene type, and the "input-output feature pairs" of the corresponding pruning window are recorded. All samples are labeled with defect category and location coordinates to provide label support for subsequent scene-specific task loss calculation:

[0182] High pruning rate window for low-complexity LVLM in low-complexity scenarios Record window preceding fixed layer Output characteristics With subsequent fixed layers of the window Input features , forming a set of feature pairs For adaptation Training the FFN network;

[0183] For high-complexity scenarios, low-pruning window input features are used in high-complexity LVLMs. With output features , forming a set of feature pairs )}, used for adaptation Training the SwiGLU network.

[0184] Parameter freezing and scenario-specific inference link isolation:

[0185] For LVLM pruning structures in low-complexity and high-complexity scenarios, independent training paths are constructed and corresponding parameters are frozen: for low-complexity scenarios, the appropriate pruning structures will be adapted to different scenarios. The LVLM is split into "preceding fixed layer" "Pruning window" "Subsequent fixed layer" ",freeze and All weight parameters are set to trainable only for the parameters of the FFN network to be trained;

[0186] Highly complex scenarios will be adapted The LVLM is split into "preceding fixed layer" "Pruning window" "Subsequent fixed layer" ",freeze and All weight parameters are set to trainable only for the parameters of the SwiGLU network to be trained.

[0187] Constructing scenario-specific reasoning chains:

[0188] Low complexity scenarios are " "High-complexity scenarios are " This ensures that the feature dimensions of the two types of links are consistent, and that the gradient is only backpropagated to the corresponding lightweight network without affecting the parameters of other layers in the LVLM.

[0189] Scene-specific calibration and verification:

[0190] After training, for the LVLM pruning structures in low-complexity and high-complexity scenarios, subsets are selected in the window respectively. Two-dimensional verification is conducted: For low-complexity scenes, the feature level must ensure that the FFN output is consistent with... The KL divergence of the window output should be ≤0.1 to ensure a high degree of consistency in feature distribution; at the task level, it is necessary to guarantee that... "The accuracy rate of defect identification in the link is ≥95%;"

[0191] In high-complexity scenes, the feature level needs to ensure that the SwiGLU output is consistent with... The KL divergence of the window output should be ≤0.1; the task level must guarantee that " "The accuracy rate of defect identification in the link is ≥95%."

[0192] If a certain scenario verification fails to meet the standard, append corresponding type samples from the remaining samples in the initial sample library that have not participated in training to ensure balanced sample coverage, and re-execute the "data augmentation - two-stage training" process for this scenario until the performance meets the adaptation requirements of the corresponding LVLM pruning structure.

[0193] S109. Mark the optimal pruning window according to the parameter masking mechanism and dynamically switch the lightweight network.

[0194] Construct a binary mask matrix, which assigns zero to the layer positions corresponding to the optimal pruning window in the binary mask matrix and assigns one to the non-pruning layer positions.

[0195] For all Transformer layers of the LLM (the total number of layers is ), construct mask matrices by scenario. The mask matrix corresponding to the low-complexity scenario assigns zero to the layer positions covered by the optimal pruning window uniformly and assigns one to the remaining non-pruning layers; the mask matrix corresponding to the high-complexity scenario similarly assigns zero to the layer positions of the optimal pruning window uniformly and assigns one to the remaining layers.

[0196] The mask matrix is stored in the memory of the edge device in binary format, and the start index start and end index end of the continuous zero-value window are pre-stored in the metadata.

[0197] During the forward propagation process, identify the continuous zero-value window in the binary mask matrix, skip the original Transformer layer calculation of the continuous zero-value window, and send the input features to the lightweight network for processing; in the initialization configuration stage, read the currently activated mask matrix and metadata, obtain the continuous zero-value window [start, end], and set the current layer number i = 0.

[0198] When i < start or i > end, the current layer is a non-pruning layer, and the complete calculation of the Transformer block is executed.

[0199] When i = start, skip the original calculations of all layers in the [start, end] interval, send the output features of the i = start - 1 layer as a whole to the corresponding lightweight network, and the output features are passed to the i = end + 1 layer.

[0200] Adopt a single-backbone dual-lightweight network deployment architecture, pre-load the lightweight network parameters, and dynamically switch the mask matrix and network call pointer according to the complexity level; when the scene complexity of the input image changes, the system calculates the comprehensive complexity score in the image preprocessing stage of the inference process , and output the complexity level according to the threshold T. Subsequently, load the mask matrix corresponding to the scenario, update the window index record, synchronously activate the matching lightweight network. The switching process only involves memory data reading and pointer assignment, and the time consumption is at the millisecond level.

[0201] This mechanism realizes the real-time adaptation of the model structure without modifying the model parameters or reconstructing the structure.

[0202] Construction, storage, and scenario mapping of the mask matrix:

[0203] For all Transformer layers of the LLM (the total number of layers is ), construct binary mask matrices for different scenarios. The core is to mark the complete pruning window through "continuous 0 values" to clarify the unique correspondence between the "window - lightweight network".

[0204] Among them, the low-complexity scenario corresponds to the mask matrix , which is a binary array with a length of [[ID=十七]] . The layer positions covered by the determined optimal pruning window are uniformly assigned 0, and the remaining non-pruning layers are assigned 1; the high-complexity scenario corresponds to the mask matrix . Similarly, the layer positions of the determined optimal pruning window are uniformly assigned 0, and the remaining layers are assigned 1. The two types of mask matrices are stored in the edge device memory in binary format. The "start index start and end index end of the continuous 0 value window" are pre-stored in the metadata of the mask matrix to avoid repeated traversing the matrix to find the window position during the inference process and improve the pruning window recognition efficiency.

[0205] Computation control logic in forward propagation: During the forward propagation process of the model for inference, the core is "identifying the continuous 0 value window → uniformly invoking the lightweight network".

[0206] In the initialization configuration stage, read the currently activated mask matrix ( or ) and the corresponding metadata, obtain the "continuous 0 value window [start, end]", and set the current layer number i = 0; when i < start or the "further" part of S109 continues:

[0207] When i < start or i > end, the current layer is a non-pruning layer, M[i] = 1, and the current layer performs the complete calculation of the Transformer block according to the normal process, passes the calculated feature vector to the next layer, and at the same time updates the current layer number i = i + 1;

[0208] It should be noted that there is an unclear "十七" in the original text which might be an error. I translated it as "seventeen" based on speculation. You may need to check and correct it if necessary.When i=start, the system skips the original calculation steps of all layers in the interval [start, end] without checking the value of M[i] layer by layer. The output feature Fin of layer i=start-1 is sent to the corresponding lightweight network. After the lightweight network completes the feature processing, the output feature vector is directly passed to layer i=end+1, and the output feature dimension is consistent with the input dimension of layer end+1 to ensure that the feature transmission is continuous and uninterrupted. Then the current layer number i=end+1 is updated, and the calculation of the remaining non-pruned layers continues until all Transformer layers have been processed.

[0209] Dynamic switching mechanism of the mask matrix:

[0210] When the scene complexity of the input image changes, the system can complete the synchronous switching of "mask matrix - window information - lightweight network" during the image preprocessing stage of the inference process to ensure real-time scene adaptation.

[0211] First, a complexity assessment is performed, using intelligent scene complexity quantification modeling to calculate a comprehensive complexity score for the input image. The system outputs a complexity level based on a threshold T. Then, a switch is executed. The system loads the corresponding scene's mask matrix from the edge device's memory based on the complexity level, simultaneously reads the "continuous 0-value window [start, end]" from the matrix's metadata, updates the window index record, synchronously activates the lightweight network matching the scene, and updates the network call pointer in the feature processing chain. The entire switch process involves only reading memory data and assigning pointer values, without complex computational logic, and takes milliseconds, far below the real-time inference threshold of power inspection edge devices, thus having no impact on inference fluency.

[0212] The parameter masking mechanism, through its design of "uniform replacement of continuous 0-value windows," has the core advantage of strong engineering deployment and scalability: the mask matrix is ​​decoupled from window information and lightweight network calling logic, allowing for flexible adjustment of pruning windows or replacement of lightweight networks without the need to reconstruct the model or retrain the original LVLM, thus adapting to the iterative needs of power inspection scenarios.

[0213] S110. Power equipment defect identification is performed on the input image based on a dynamically switched lightweight network.

[0214] The trained lightweight network processes the features of the input image and outputs the category and location information of power equipment defects based on the processed features; the defect identification process achieves low-latency response on the edge device.

[0215] The final defect identification is accomplished through an optimized LVLM model, which integrates dynamic pruning and lightweight network replacement mechanisms to ensure efficient and accurate output of defect results in resource-constrained edge environments. This model can identify typical power defects such as insulator cracks and conductor ablation, and provide location information to support inspection decisions.

[0216] To achieve efficient inference and scene adaptation capabilities on edge devices, this application designs a deployment architecture of 'single backbone + dual lightweight networks'.

[0217] In the LLM backbone network, the weight parameters of Transformer layers that are not jointly labeled by the pruning windows of low-complexity and high-complexity scenarios are stored uniformly for use by both scenarios; the two lightweight networks are preloaded into memory when the device starts up, forming lightweight knowledge modules that can be used immediately.

[0218] During inference, the system automatically activates a lightweight network that is suitable for the current scene based on the scene complexity evaluation results of the input image.

[0219] When the evaluation result is a low-complexity scenario, the basic FFN is called to replace the high-pruning-rate window to complete the feature transformation; when the evaluation result is a high-complexity scenario, the enhanced SwiGLU is called to replace the low-pruning-rate window to complete the feature transformation.

[0220] Since both lightweight networks are pre-loaded into memory, only the pointer addresses of network calls need to be updated when switching scenes, resulting in low switching latency and no impact on the real-time performance of inference. This deployment mechanism only requires additional storage of the parameters of the two lightweight networks, which is negligible compared to the storage requirements of the original model. At the same time, because the computational cost of the lightweight networks is much lower than that of the pruned windows, the total inference latency of the entire model can meet the real-time requirements of power line inspection edge devices, ultimately achieving a dynamic balance between accuracy and efficiency, ensuring that power line inspection tasks can be completed efficiently and accurately even in resource-constrained edge environments.

[0221] Please refer to Figure 4 The present application also provides a dynamic pruning device for a large-scale power model, comprising:

[0222] The acquisition module 201 acquires input images from the power inspection edge device;

[0223] Evaluation module 202 performs multi-dimensional complexity evaluation on the input image to generate a comprehensive complexity score. The multi-dimensional complexity evaluation includes calculating image information entropy, abnormal pixel ratio, illumination uniformity and semantic complexity, and weightedly fusing the image information entropy, the abnormal pixel ratio, the illumination uniformity and the semantic complexity to generate the comprehensive complexity score.

[0224] Clustering module 203 determines an adaptive threshold using the K-Means clustering algorithm based on the comprehensive complexity score;

[0225] The grading module 204 determines the complexity level based on the comprehensive complexity score and the adaptive threshold, wherein the complexity level includes a first complexity level and a second complexity level.

[0226] The pruning rate module 205 determines the pruning rate based on the complexity level.

[0227] Window module 206 generates a set of candidate pruning windows based on the pruning rate;

[0228] Optimization module 207 filters the optimal pruning window from the candidate pruning window set based on power inspection calibration data;

[0229] Training module 208 trains a lightweight network for the optimal pruning window, the training including feature fitting pre-training and task adaptation fine-tuning;

[0230] The switching module 209 marks the optimal pruning window according to the parameter masking mechanism and dynamically switches the lightweight network according to the marking.

[0231] The identification module 210 identifies power equipment defects in the input image based on the dynamically switched lightweight network.

[0232] Optionally, the evaluation module 202 performs a multi-dimensional complexity evaluation on the input image to generate a comprehensive complexity score, including:

[0233] The image information entropy, the proportion of abnormal pixels, the illumination uniformity, and the semantic complexity are standardized.

[0234] The comprehensive complexity score is generated by weighting and fusing the standardized image information entropy, the proportion of abnormal pixels, the illumination uniformity, and the semantic complexity using learnable hyperparameters; the learnable hyperparameters are adaptively optimized during the model training process.

[0235] Optionally, the window module 206 generates a candidate pruning window set based on the pruning rate, including:

[0236] When the complexity level is the first complexity level, a first size window set is generated, which is generated by sliding the starting index to traverse all consecutive layer combinations;

[0237] When the complexity level is the second complexity level, a second-size window set is generated, which is generated by sliding the starting index to traverse all consecutive layer combinations.

[0238] Optionally, the training module 208 trains a lightweight network for the optimal pruning window, including:

[0239] When the complexity level is the first complexity level, the lightweight network adopts a basic feedforward network architecture, which includes a linear transformation and a ReLU activation function.

[0240] When the complexity level is the second complexity level, the lightweight network adopts an enhanced gated linear unit architecture, which includes parallel linear transformation and Sigmoid gating mechanism.

[0241] Optionally, the training module 208 training includes feature fitting pre-training and task adaptation fine-tuning, including:

[0242] The feature fitting pre-training uses the mean squared error loss function to calculate the difference between the lightweight network output and the pruned window features;

[0243] The task adaptation fine-tuning, combined with the cross-entropy loss function, optimizes the accuracy of lightweight networks in identifying defects in power equipment.

[0244] Optionally, the switching module 209 marks the optimal pruning window according to a parameter masking mechanism, and dynamically switches the lightweight network according to the marking, including:

[0245] Construct a binary mask matrix, in which the layer position corresponding to the optimal pruning window is assigned a value of zero, and the non-pruning layer position is assigned a value of one;

[0246] During the forward propagation, consecutive zero-value windows in the binary mask matrix are identified, the original Transformer layer calculation of the consecutive zero-value windows is skipped, and the input features are fed into the lightweight network for processing.

[0247] A single-backbone dual-lightweight network deployment architecture is adopted, the lightweight network parameters are preloaded, and the mask matrix and network call pointer are dynamically switched according to the complexity level.

[0248] Optionally, the recognition module 210 performs power equipment defect recognition on the input image based on the dynamically switched lightweight network, including:

[0249] The input image is processed using a lightweight network that has been trained.

[0250] Based on the processed features, output the category and location information of power equipment defects;

[0251] The defect identification process is implemented with low latency on the edge device.

[0252] This application also provides an electronic device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method described above.

[0253] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the above-described method.

[0254] The above description of the embodiments is provided to enable those skilled in the art to understand and apply this application. Those skilled in the art will readily make various modifications to the above embodiments and apply the general principles described herein to other embodiments without inventive effort. Therefore, this application is not limited to the above embodiments, and any improvements and modifications made to this application based on the disclosure thereof should be within the scope of protection of this application.

Claims

1. A dynamic pruning method for a large-scale power model, characterized in that, include: Input images are obtained from power line inspection edge devices; A multi-dimensional complexity evaluation is performed on the input image to generate a comprehensive complexity score. The multi-dimensional complexity evaluation includes calculating image information entropy, abnormal pixel ratio, illumination uniformity, and semantic complexity, and weighted fusion of the image information entropy, the abnormal pixel ratio, the illumination uniformity, and the semantic complexity to generate the comprehensive complexity score. An adaptive threshold is determined using the K-Means clustering algorithm based on the comprehensive complexity score. The complexity level is determined based on the comprehensive complexity score and the adaptive threshold, and the complexity level includes a first complexity level and a second complexity level; The pruning rate is determined based on the complexity level. A set of candidate pruning windows is generated based on the pruning rate; The optimal pruning window in the candidate pruning window set is selected based on power inspection and calibration data. A lightweight network is trained for the optimal pruning window, and the training includes feature fitting pre-training and task adaptation fine-tuning. The optimal pruning window is marked according to the parameter masking mechanism, and the lightweight network is dynamically switched according to the marking. The input image is used to identify power equipment defects using the dynamically switched lightweight network.

2. The method according to claim 1, characterized in that, Perform a multi-dimensional complexity evaluation on the input image to generate a comprehensive complexity score, including: The image information entropy, the proportion of abnormal pixels, the illumination uniformity, and the semantic complexity are standardized. The comprehensive complexity score is generated by weighting and fusing the standardized image information entropy, the proportion of abnormal pixels, the illumination uniformity, and the semantic complexity using learnable hyperparameters; the learnable hyperparameters are adaptively optimized during the model training process.

3. The method according to claim 1, characterized in that, The step of generating a candidate pruning window set based on the pruning rate includes: When the complexity level is the first complexity level, a first size window set is generated, which is generated by sliding the starting index to traverse all consecutive layer combinations; When the complexity level is the second complexity level, a second-size window set is generated, which is generated by sliding the starting index to traverse all consecutive layer combinations.

4. The method according to claim 1, characterized in that, Training a lightweight network for the optimal pruning window includes: When the complexity level is the first complexity level, the lightweight network adopts a basic feedforward network architecture, which includes a linear transformation and a ReLU activation function. When the complexity level is the second complexity level, the lightweight network adopts an enhanced gated linear unit architecture, which includes parallel linear transformation and Sigmoid gating mechanism.

5. The method according to claim 1, characterized in that, The training includes feature fitting pre-training and task adaptation fine-tuning, including: The feature fitting pre-training uses the mean squared error loss function to calculate the difference between the lightweight network output and the pruned window features; The task adaptation fine-tuning, combined with the cross-entropy loss function, optimizes the accuracy of lightweight networks in identifying defects in power equipment.

6. The method according to claim 1, characterized in that, The optimal pruning window is marked according to a parameter masking mechanism, and the lightweight network is dynamically switched according to the marked window, including: Construct a binary mask matrix, in which the layer position corresponding to the optimal pruning window is assigned a value of zero, and the non-pruning layer position is assigned a value of one; During the forward propagation, consecutive zero-value windows in the binary mask matrix are identified, the original Transformer layer calculation of the consecutive zero-value windows is skipped, and the input features are fed into the lightweight network for processing. A single-backbone dual-lightweight network deployment architecture is adopted, the lightweight network parameters are preloaded, and the mask matrix and network call pointer are dynamically switched according to the complexity level.

7. The method according to claim 1, characterized in that, The power equipment defect identification is performed on the input image using the dynamically switched lightweight network, including: The input image is processed using a lightweight network that has been trained. Based on the processed features, output the category and location information of power equipment defects; The defect identification process is implemented with low latency on the edge device.

8. A dynamic pruning device for a large-scale power model, characterized in that, include: The acquisition module acquires input images from the power inspection edge device; The evaluation module performs a multi-dimensional complexity evaluation on the input image to generate a comprehensive complexity score. The multi-dimensional complexity evaluation includes calculating image information entropy, abnormal pixel ratio, illumination uniformity, and semantic complexity, and weightedly fuses the image information entropy, the abnormal pixel ratio, the illumination uniformity, and the semantic complexity to generate the comprehensive complexity score. The clustering module uses the K-Means clustering algorithm to determine an adaptive threshold based on the comprehensive complexity score; The grading module determines the complexity level based on the comprehensive complexity score and the adaptive threshold, wherein the complexity level includes a first complexity level and a second complexity level. The pruning rate module determines the pruning rate based on the complexity level. The window module generates a set of candidate pruning windows based on the pruning rate; The optimization module filters the optimal pruning window from the candidate pruning window set based on power inspection and calibration data; The training module trains a lightweight network for the optimal pruning window, and the training includes feature fitting pre-training and task adaptation fine-tuning. The switching module marks the optimal pruning window according to the parameter masking mechanism and dynamically switches the lightweight network according to the marking. The identification module identifies power equipment defects in the input image based on the dynamically switched lightweight network.

9. The apparatus according to claim 8, characterized in that, The evaluation module performs a multi-dimensional complexity evaluation on the input image to generate a comprehensive complexity score, including: The image information entropy, the proportion of abnormal pixels, the illumination uniformity, and the semantic complexity are standardized. The comprehensive complexity score is generated by weighting and fusing the standardized image information entropy, the proportion of abnormal pixels, the illumination uniformity, and the semantic complexity using learnable hyperparameters; the learnable hyperparameters are adaptively optimized during the model training process.

10. The apparatus according to claim 8, characterized in that, The window module generates a set of candidate pruning windows based on the pruning rate, including: When the complexity level is the first complexity level, a first size window set is generated, which is generated by sliding the starting index to traverse all consecutive layer combinations; When the complexity level is the second complexity level, a second-size window set is generated, which is generated by sliding the starting index to traverse all consecutive layer combinations.

11. The apparatus according to claim 8, characterized in that, The training module trains a lightweight network for the optimal pruning window, including: When the complexity level is the first complexity level, the lightweight network adopts a basic feedforward network architecture, which includes a linear transformation and a ReLU activation function. When the complexity level is the second complexity level, the lightweight network adopts an enhanced gated linear unit architecture, which includes parallel linear transformation and Sigmoid gating mechanism.

12. The apparatus according to claim 8, characterized in that, The training module training includes feature fitting pre-training and task adaptation fine-tuning, including: The feature fitting pre-training uses the mean squared error loss function to calculate the difference between the lightweight network output and the pruned window features; The task adaptation fine-tuning, combined with the cross-entropy loss function, optimizes the accuracy of lightweight networks in identifying defects in power equipment.

13. The apparatus according to claim 8, characterized in that, The switching module marks the optimal pruning window according to a parameter masking mechanism, and dynamically switches the lightweight network according to the marking, including: Construct a binary mask matrix, in which the layer position corresponding to the optimal pruning window is assigned a value of zero, and the non-pruning layer position is assigned a value of one; During the forward propagation, consecutive zero-value windows in the binary mask matrix are identified, the original Transformer layer calculation of the consecutive zero-value windows is skipped, and the input features are fed into the lightweight network for processing. A single-backbone dual-lightweight network deployment architecture is adopted, the lightweight network parameters are preloaded, and the mask matrix and network call pointer are dynamically switched according to the complexity level.

14. The apparatus according to claim 8, characterized in that, The recognition module performs power equipment defect recognition on the input image based on the dynamically switched lightweight network, including: The input image is processed using a lightweight network that has been trained. Based on the processed features, output the category and location information of power equipment defects; The defect identification process is implemented with low latency on the edge device.

15. An electronic device, characterized in that, It includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method as described in any one of claims 1-7.

16. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed in a computer, causes the computer to perform the method described in any one of claims 1-7.