Lightweight Configuration Method for Real-Time Power Grid Detection Model in Edge Computing Environment

By acquiring the real-time resource status of edge devices and identifying targets in inspection images, a lightweight detection model configuration scheme is dynamically selected, solving the problem of the imbalance between accuracy and efficiency under fixed configuration, and achieving efficient and stable operation of edge detection.

CN123114586APending Publication Date: 2026-11-17STATE GRID SHANGHAI MUNICIPAL ELECTRIC POWER CO
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611600836.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-16
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In existing edge detection solutions, fixed model configurations are difficult to adapt to differences in detection targets and dynamic fluctuations in edge resources, resulting in an imbalance between accuracy and efficiency. They cannot maintain detection accuracy when high precision is required, and cannot avoid inference delays and device overheating caused by excessive computational overhead.

Method used

By acquiring real-time resource status information of edge devices and target recognition of current inspection images, a lightweight detection model configuration scheme is dynamically selected, the input resolution is adjusted, and the model configuration pool is updated when the reliability of the detection results is low, thus forming a closed-loop optimization of the configuration.

Benefits of technology

It achieves dynamic adaptation of lightweight model configuration to real-time power grid detection scenarios and resource status, improves the overall efficiency of edge detection, and ensures detection accuracy and resource utilization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114586A_ABST
    Figure CN123114586A_ABST
Patent Text Reader

Abstract

This invention discloses a lightweight configuration method for a real-time power grid detection model in an edge computing environment, relating to the field of image recognition technology. The method includes: acquiring real-time resource status information and the current inspection image from edge devices; performing target recognition to obtain detection target information; selecting a target configuration scheme from a lightweight model configuration pool based on the detection target information and real-time resource status information; calling the lightweight detection model corresponding to the target configuration scheme; performing inference on the current inspection image; and outputting defect detection results. The method also includes dynamically adjusting the input resolution of the lightweight detection model; and updating the lightweight model configuration pool by using the current inspection image, defect detection results, and real-time resource status information as feedback samples when the reliability is lower than a preset reliability threshold. This invention effectively improves the dynamic adaptability of lightweight model configuration to real-time power grid detection scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image recognition technology, and more specifically to a lightweight configuration method for a real-time power grid detection model for edge computing environments. Background Technology

[0002] In the field of power grid equipment inspection, deep learning-based target detection technology has been widely applied to the automatic identification of typical defects such as insulator damage, wire clamp overheating, and missing pins. Power grid inspection involves a large number of edge devices such as drones and line inspection robots, which are usually deployed in the field or in areas without network coverage. The detection model needs to be deployed directly at the edge to achieve real-time inference, avoiding the bandwidth consumption and data security risks caused by uploading massive inspection images to the cloud. Existing technologies typically use lightweight model structure design or model compression to simplify the detection model, so that the model maintains acceptable detection accuracy while reducing the number of parameters and computational complexity, thereby meeting the constraints of limited computing resources and storage capacity of edge devices.

[0003] However, existing edge detection solutions typically generate fixed, lightweight model configurations that, once deployed, do not adjust to changes in the operating environment. In actual power grid inspections, detecting minute cracks in insulator strings requires high input resolution, while assessing the condition of structural components such as bolts and crossarms can be done at lower resolutions, resulting in significantly different accuracy requirements for the detection targets. Simultaneously, the available computing power and real-time power consumption of edge devices fluctuate dynamically with operating conditions. Fixed-configuration lightweight models may lack sufficient accuracy when facing high-precision targets, while under resource constraints, excessive computational overhead may lead to increased inference latency or even overheating. This contradiction between fixed configurations and dynamic requirements and resources makes it difficult for existing solutions to achieve an optimal balance between detection accuracy, real-time response, and continuous operation capability. Summary of the Invention

[0004] This invention provides a lightweight configuration method for real-time power grid detection models for edge computing environments, aiming to solve the technical problem in the prior art where fixed model configurations are difficult to adapt to differences in detection targets and dynamic fluctuations in edge resources, resulting in an imbalance between accuracy and efficiency.

[0005] In view of the above problems, the present invention provides a lightweight configuration method for a real-time power grid detection model for edge computing environments, including: Acquire real-time resource status information and current inspection images of edge devices, perform target recognition on the current inspection images, and obtain the detection target information; Based on the detection target information and real-time resource status information, a target configuration scheme is selected from the lightweight model configuration pool, the lightweight detection model corresponding to the target configuration scheme is called, inference is performed on the current inspection image, and the defect detection result is output. The input resolution of the lightweight detection model is dynamically adjusted based on the reliability of the defect detection results, the degree of scene change in the current inspection image, and real-time resource status information. When the reliability is lower than the preset reliability threshold, the current inspection image, defect detection results and real-time resource status information are used as feedback samples to update the lightweight model configuration pool.

[0006] One or more technical solutions provided in this invention have at least the following technical effects or advantages: This invention provides a lightweight configuration method for real-time power grid detection models in edge computing environments. First, it acquires real-time resource status information and current inspection images from edge devices, performs target recognition on the current inspection images to obtain detection target information, providing a data foundation for subsequent configuration selection and inference. Second, based on the detection target information and real-time resource status information, a target configuration scheme is selected from a lightweight model configuration pool. The corresponding lightweight detection model is then invoked to infer the current inspection image, outputting defect detection results, thus achieving dynamic adaptation of model configuration to detection targets and resource status. Third, based on the reliability of defect detection results, the degree of scene change in the current inspection image, and real-time resource status information, the input resolution of the lightweight detection model is dynamically adjusted to optimize the resource utilization efficiency of edge devices while ensuring detection accuracy. Finally, when the reliability is lower than a preset reliability threshold, the current inspection image, defect detection results, and real-time resource status information are used as feedback samples to update the lightweight model configuration pool, forming a closed-loop optimization of configuration. Through the above scheme, this invention can achieve dynamic adaptation of lightweight model configuration to real-time power grid detection scenarios and resource status, effectively improving the overall performance of edge detection. Attached Figure Description

[0007] Figure 1 A schematic diagram of the overall logic of the lightweight configuration method for the real-time power grid detection model for edge computing environments provided in this embodiment of the invention; Figure 2 This is a schematic diagram illustrating the process of selecting a target configuration scheme from the lightweight model configuration pool in the lightweight configuration method for real-time power grid detection models in edge computing environments provided in this embodiment of the invention. Detailed Implementation

[0008] This invention provides a lightweight configuration method for real-time power grid detection models for edge computing environments, which addresses the technical problem of imbalance between accuracy and efficiency caused by the difficulty of adapting fixed model configurations to differences in detection targets and dynamic fluctuations in edge resources in existing technologies.

[0009] Examples, such as Figure 1 As shown, this invention provides a lightweight configuration method for a real-time power grid detection model for edge computing environments, the method comprising: S100: Acquire real-time resource status information and current inspection image of edge devices, perform target recognition on the current inspection image, and obtain the detection target information.

[0010] In power grid inspection scenarios, edge devices are deployed in the field or in areas without network coverage. Their available computing power, available memory, and current power consumption fluctuate dynamically with the device's operating status and task load, and the resource capabilities of different edge devices vary significantly. Furthermore, the current inspection image may contain different types of power grid equipment, each with different requirements for detection accuracy. If the real-time resource status of the edge devices and the detection target information in the current inspection image cannot be accurately perceived, subsequent steps cannot adapt the model configuration selection based on resource conditions and detection needs. Therefore, it is necessary to obtain the real-time resource status information of the edge devices and the detection target information of the current inspection image to provide a data foundation for the dynamic selection of lightweight model configurations.

[0011] Step S100 in the method provided in this embodiment of the invention includes: Obtain the available computing power, available memory, and current power consumption of edge devices as real-time resource status information; The system acquires the current inspection images collected by the edge devices, inputs the current inspection images into a preset object recognition network, and identifies the equipment type labels and defect type labels of the power grid equipment. Associate the equipment type label and the defect type label as the target information for detection.

[0012] First, obtain the available computing power, available memory, and current power consumption of the edge device as real-time resource status information. Available computing power refers to the amount of computing resources currently available for deep learning inference on the edge device, reflecting the device's current computing capacity, measured in mega-instructions per second (MIPS) or floating-point operations per second (FLOPS). Available memory refers to the amount of memory currently available for model loading and inference on the edge device, reflecting the device's current available storage resources, measured in megabytes (MB). Current power consumption refers to the real-time power consumption of the edge device in its current operating state, reflecting the device's energy consumption status, measured in watts (W).

[0013] Specifically, the available computing power, available memory, and current power consumption values ​​are read from the operating system resource management interface or hardware monitoring module of the edge device at the current moment, and these three values ​​are used as real-time resource status information. This real-time resource status information characterizes the edge device's computing resource capacity, storage resource capacity, and energy consumption status for model inference at the current moment.

[0014] For example, at a certain moment, the edge device reads through the operating system interface that the current available computing power is 100 GFLOPS, the available memory is 2048 MB, and the current power consumption is 5W. Then the real-time resource status information is: available computing power 100 GFLOPS, available memory 2048 MB, and current power consumption 5W.

[0015] Secondly, the current inspection image collected by the edge device is acquired and input into a pre-set object recognition network to identify the equipment type label and defect type label of the power grid equipment. The current inspection image refers to the raw image data collected at the current moment by the camera device mounted on the edge device, which contains the power grid equipment to be inspected. The equipment type label is identification information used to identify the category to which the power grid equipment in the current inspection image belongs. The defect type label is identification information used to identify the type of defect present in the power grid equipment in the current inspection image.

[0016] Specifically, the raw image data acquired at the current moment is obtained from the image acquisition interface of the edge device and used as the current inspection image. The pre-set object recognition network is a deep learning network model pre-trained using historical inspection image data and corresponding equipment type and defect type labels as training data. The current inspection image is input into the pre-set object recognition network, which performs forward inference calculations on the current inspection image and outputs the equipment type labels of the power grid equipment contained in the current inspection image and the corresponding defect type labels of the equipment.

[0017] The pre-built object recognition network is constructed using an improved YOLOv8-based target detection network. This improved YOLOv8 target detection network comprises a backbone network, a feature fusion network, and a detection head, connected sequentially. The backbone network extracts multi-scale features from the input inspection image, outputting feature maps at different scales. The feature fusion network employs a feature pyramid structure to fuse feature maps at different scales, enhancing the detection capability for multi-scale targets. The detection head outputs device type labels, defect type labels, and corresponding defect location bounding boxes for each detected target based on the fused feature maps.

[0018] The backbone network employs depthwise separable convolutions instead of standard convolutions to reduce parameter and computational costs. Convolutional Block Attention (CBAM) modules are embedded at the ends of the backbone network and key locations in the feature fusion network. Attention weights are generated through sequentially executed channel and spatial attention sub-modules, weighting the feature maps for both channel and spatial dimensions, enabling the network to focus on the feature responses of device and defect regions. The backbone network contains multiple convolutional modules and a C2f module, a cross-stage local feature fusion module used to maintain gradient information flow while reducing computational cost. The feature fusion network uses a path aggregation network structure, upsampling, downsampling, and concatenating the multi-scale feature maps output from different layers of the backbone network to generate a fused multi-scale feature map. The detection head predicts the target category and bounding box location at multiple scales, with each scale containing convolutional and fully connected layers.

[0019] The training dataset for the object recognition network comes from historical images of power grid drone inspections, a public power equipment dataset, and a transmission line equipment image database constructed using image sample augmentation methods. The historical images of power grid drone inspections are original images of various power grid equipment and their defects collected by edge devices during historical inspections. The training dataset covers image samples under different lighting conditions, weather conditions, shooting angles, and equipment types. Each image sample in the training dataset is labeled using an image annotation tool, including equipment type labels, defect type labels, and defect location bounding boxes for each power grid device in the image. Equipment type labels include insulator strings, clamps, pins, bolts, and crossarms. Defect type labels include burst defects, overheating defects, missing defects, and loosening defects. After annotation, the training dataset is divided into a training set, a validation set, and a test set according to a preset ratio: 70% for the training set, 20% for the validation set, and 10% for the test set.

[0020] During training, image samples from the training set are input into the improved YOLOv8 object detection network. Multi-scale feature extraction is performed by the backbone network, followed by multi-scale feature fusion by the feature fusion network. The detection head outputs predicted device type labels, predicted defect type labels, and predicted defect location bounding boxes for each detected target. A multi-task loss function is used to calculate the loss between the predicted results and the labeled ground truth values. This multi-task loss function includes bounding box regression loss, classification loss, and confidence loss. The bounding box regression loss measures the positional deviation between the predicted defect location bounding box and the labeled defect location bounding box, calculated using the CIoU loss function. The classification loss measures the class deviation between the predicted device type label and the predicted defect type label and the labeled ground truth values, calculated using the cross-entropy loss function. The confidence loss measures the deviation between the predicted confidence score and the labeled ground truth value, calculated using the binary cross-entropy loss function. The bounding box regression loss, classification loss, and confidence loss are weighted and summed to obtain the total loss value. The parameters of the improved YOLOv8 object detection network are iteratively updated using the backpropagation algorithm and an optimizer. The AdamW optimizer is used as the optimizer, with the initial learning rate set to the first learning rate. The learning rate is dynamically adjusted during training using a cosine annealing learning rate scheduling strategy.

[0021] The convergence condition for the object recognition network is as follows: the network is considered convergent when the total loss value decreases by less than a preset change threshold for multiple consecutive training epochs. The preset change threshold is 1%. During training, the network is validated using a validation set after each training epoch, and the average detection accuracy on the validation set is calculated. When the average detection accuracy on the validation set no longer improves for multiple consecutive training epochs, training is terminated early, and the network parameters with the highest average detection accuracy on the validation set are selected as the final parameters of the preset object recognition network.

[0022] For example, the current inspection image is input into a preset object recognition network. After forward inference calculation, the object recognition network outputs an equipment type label as an insulator string and a defect type label as a burst defect. The insulator string is the power grid equipment identified in the current inspection image, and the burst defect is the defect category corresponding to the insulator string.

[0023] Finally, the equipment type label and defect type label are associated as the detection target information. Detection target information refers to the combined information formed after establishing a correspondence between the equipment type label and the defect type label, used to characterize the type of power grid equipment identified in the current inspection image and the category of its defects. The correspondence between the equipment type label and the defect type label is established in the form of key-value pairs, that is, a mapping is established from the equipment type label to the defect type label, and the combined information after establishing the correspondence is used as the detection target information. The detection target information is used in subsequent steps to determine the detection accuracy requirements based on the equipment type and to determine the detection focus based on the defect type. For example, if the equipment type label is insulator string and the defect type label is burst defect, associating the insulator string with the burst defect forms the detection target information. This detection target information indicates that there is a burst defect in the insulator string in the current inspection image, and subsequent steps will use this to determine the detection accuracy requirements for the insulator string.

[0024] In this embodiment of the invention, by acquiring the available computing power, available memory, and current power consumption of the edge device as real-time resource status information, subsequent steps can adapt the model configuration selection based on the actual resource status of the edge device, avoiding inference failure or device overheating due to insufficient resources. By acquiring the current inspection image and identifying the device type label and defect type label, subsequent steps can determine the corresponding accuracy requirements based on the category of the current detection target. By associating the device type label and defect type label with the detection target information, subsequent steps can obtain a complete description of the detection target.

[0025] S200: Based on the detection target information and real-time resource status information, select the target configuration scheme from the lightweight model configuration pool, call the lightweight detection model corresponding to the target configuration scheme, perform inference on the current inspection image, and output the defect detection result.

[0026] In this embodiment of the invention, based on the real-time resource status information and detection target information of the edge device, a target configuration scheme matching the current detection scenario and resource conditions needs to be selected from multiple candidate lightweight model configurations. The corresponding lightweight detection model is then invoked to perform inference on the current inspection image to output defect detection results. If model configurations are selected solely based on experience or fixed rules, it is difficult to achieve a dynamic balance between detection accuracy, inference latency, and resource consumption. Furthermore, to ensure the continuous and stable operation of the edge device, the lightweight detection model needs to complete the inference task under limited resource conditions. Therefore, it is necessary to dynamically select a target configuration scheme from a pre-generated lightweight model configuration pool based on real-time resource status information and detection target information, and invoke the corresponding lightweight detection model to perform inference on the current inspection image to output defect detection results, thereby achieving dynamic adaptation of model configuration to the detection scenario and resource status.

[0027] Step S200 in the method provided in this embodiment of the invention includes: The lightweight model configuration pool is generated in the following ways: Obtain the basic detection model, establish the data dependencies between the functional units in the basic detection model, and determine the adjustable units, dependent units, and sensitive units; Structural equivalence processing is performed on the adjustable unit to identify the convolutional layers and batch normalization layers connected in sequence in the adjustable unit. The convolutional kernel parameters and bias parameters of the convolutional layer are fused with the scaling parameters and translation parameters of the batch normalization layer into equivalent single convolutional layer parameters. The equivalent single convolutional layer parameters are then used to replace the sequentially connected convolutional layers and batch normalization layers to obtain the first candidate lightweight model configuration. Redundant units are reduced in the adjustable units of the first candidate lightweight model configuration. The importance score of each convolutional channel is determined based on the weight parameter distribution characteristics and activation response characteristics of each convolutional channel. Convolutional channels with importance scores lower than a preset threshold are deleted. The deleted model is fine-tuned and trained to obtain the second candidate lightweight model configuration. Numerical precision adaptation is performed on the adjustable units in the second candidate lightweight model configuration. The quantization scaling factor and zero offset of each layer are determined according to the distribution range of the weight parameters and the distribution range of the activation values ​​of each network layer. The floating-point parameters are mapped to low-bit integer parameters to obtain the third candidate lightweight model configuration. Perform computation graph fusion on the adjustable units in the third candidate lightweight model configuration, and merge multiple computation units that can be executed continuously and meet the equivalence conditions into a fused computation unit to obtain the fourth candidate lightweight model configuration; The dependent units are kept in sync with the adjustable units, and a retention ratio lower limit, accuracy lower limit or replacement limit is set for sensitive units. The configurations of the first candidate lightweight model, the second candidate lightweight model, the third candidate lightweight model and the fourth candidate lightweight model are saved as a lightweight model configuration pool.

[0028] First, the basic detection model is obtained, and the data dependencies between its functional units are established to identify adjustable units, dependent units, and sensitive units. The basic detection model refers to a pre-built deep learning model for power grid equipment defect detection; it is a complete, un-lightweighted standard detection model. A functional unit is a module in the basic detection model with independent data processing capabilities, including but not limited to convolutional layers, batch normalization layers, activation layers, pooling layers, and fully connected layers. Data dependencies refer to the transmission relationship between input and output data between functional units; that is, the output data of one functional unit serves as the input data of another. Adjustable units are functional units whose structural parameters can be changed during model lightweighting, including convolutional layers with adjustable channel counts and fully connected layers with adjustable widths. Dependent units are functional units that have data dependencies on adjustable units and require synchronous updates after adjustments to the adjustable units to ensure data dimension matching. Sensitive units are functional units that significantly impact detection accuracy and require protection conditions during lightweighting.

[0029] The basic detection model is constructed using an improved YOLOv8 object detection network. This network structure consists of a backbone network, a neck network, and a detection head connected sequentially. The backbone network performs multi-scale feature extraction on the input current inspection image, employing a CSPDarkNet53 structure and incorporating a C2f module. The C2f module achieves higher feature extraction efficiency by optimizing gradient flow and reducing redundant parameters. The backbone network also includes a spatial pyramid pooling module to enhance multi-scale feature extraction capabilities. The neck network uses a path aggregation network-feature pyramid network structure, fusing feature maps of different scales through top-down and bottom-up path aggregation to enhance the model's multi-scale detection capabilities. The detection head employs a decoupled head structure, separating the regression and classification branches to predict the defect location bounding box and defect category of the detected target, respectively. The regression branch outputs the coordinate information of the defect location bounding box, while the classification branch outputs the defect category and its corresponding reliability. The detection head uses an anchorless mechanism to directly predict the target's center point coordinates, width, and height. The basic detection model serves as the original model for subsequent lightweight processing. Through operations such as structural equivalence processing, redundant unit reduction, numerical accuracy adaptation, and computational graph fusion, multiple candidate lightweight model configurations are generated and stored in the lightweight model configuration pool for dynamic selection.

[0030] Specifically, the basic detection model is traversed and analyzed. Starting from the model input layer, the connection relationships and data transmission relationships between each functional unit are recorded sequentially according to the data transmission order in the forward inference process, establishing data dependencies between functional units. Based on the role of each functional unit in the model and the ease of adjustment, functional units whose structural parameters can be changed are identified as adjustable units. Functional units with direct or indirect data transmission relationships with adjustable units, and whose parameters need to be updated synchronously after adjustment by adjustable units, are identified as dependent units. By inputting a validation dataset into the basic detection model, the contribution of each functional unit to the detection accuracy is calculated, and functional units with a contribution higher than a preset contribution threshold or those undertaking key feature extraction tasks are identified as sensitive units.

[0031] The validation dataset is derived from a historical image database of power grid equipment inspections. This database is compiled from image data from multiple sources, including raw image data of various power grid equipment and their defects collected by edge devices during historical inspections, image data from public power equipment datasets, and image data acquired by image acquisition equipment under different lighting conditions, weather conditions, and shooting angles. After aggregating the image data from these sources, the images are first screened for quality, removing blurry and unidentifiable image samples. Then, image annotation tools are used to annotate each image sample, including equipment type labels, defect type labels, and defect location bounding boxes for each power grid device in the image. All annotated image samples are then aggregated to form a complete dataset. The complete dataset is divided into a training dataset, a validation dataset, and a test dataset according to a preset ratio. The training dataset is used for model training and fine-tuning, the validation dataset is used to calculate the importance score of each convolutional channel, the detection accuracy evaluation value, and the setting of preset thresholds, and the test dataset is used for final performance evaluation. The validation dataset and the training dataset originate from the same complete dataset, have the same distribution, and do not overlap. The image samples in the validation dataset do not participate in the learning and updating of model parameters; they are only used to evaluate the model's performance on unseen samples. The preset ratio is 70% for the training dataset, 20% for the validation dataset, and 10% for the test dataset.

[0032] For example, the base detection model uses the YOLOv8 object detection network. The data flow of this model is traversed to establish data dependencies between functional units. The C2f module in the backbone network contains multiple Bottleneck structures. The number of channels in the convolutional layers within a Bottleneck structure can be adjusted, thus identifying this convolutional layer as an adjustable unit. The first convolutional layer in a given Bottleneck structure has 128 output channels. This output data serves as the input data for the second convolutional layer in the same Bottleneck structure. The number of input channels for the second convolutional layer must match the number of output channels for the first convolutional layer. Therefore, when the number of output channels for the first convolutional layer is adjusted from 128 to 64, the number of input channels for the second convolutional layer must be updated synchronously from 128 to 64. This second convolutional layer is the dependent unit. In the spatial pyramid pooling layer at the end of the backbone network, this layer fuses multi-scale features through pooling operations of different scales. It is a key layer for the model to obtain the global receptive field. Since its contribution to detection accuracy exceeds a preset contribution threshold, it is identified as a sensitive unit.

[0033] Secondly, structural equivalence processing is performed on the adjustable unit to identify the convolutional layers and batch normalization layers connected in sequence in the adjustable unit. The convolutional kernel parameters and bias parameters of the convolutional layer are fused with the scaling parameters and translation parameters of the batch normalization layer into equivalent single convolutional layer parameters. The equivalent single convolutional layer parameters are then used to replace the sequentially connected convolutional layers and batch normalization layers to obtain the first candidate lightweight model configuration.

[0034] Structural equivalence processing refers to merging multiple sequentially executed and functionally combinable computational units into a single computational unit without altering the input-output mapping relationship of functional units. Convolutional layers are network layers in the basic detection model used to extract image features. They perform sliding window calculations on the input feature map using convolutional kernels to output a feature map. The kernel parameters are learnable weight parameters in the convolutional layer, and the bias parameters are learnable bias terms. Batch normalization layers are network layers in the basic detection model used to standardize the distribution of input data. They normalize the input data using scaling and translation parameters.

[0035] Specifically, the adjustable units are traversed to identify whether sequentially connected convolutional layers and batch normalization layers exist within them. When sequentially connected convolutional layers and batch normalization layers are detected, the kernel parameters and bias parameters of the convolutional layers are obtained, as are the scaling and translation parameters of the batch normalization layers. The kernel parameters, bias parameters, scaling parameters, and translation parameters are then fused according to the mathematical equivalence transformation relationship between the convolutional layers and batch normalization layers to generate equivalent parameters for a single convolutional layer. The specific fusion calculation method is as follows: using the standard convolutional layer and batch normalization layer fusion formula, the scaling and translation parameters of the batch normalization layers are multiplied or added to the corresponding terms transformed from the convolutional layer parameters to obtain the fused equivalent kernel parameters and equivalent bias parameters. The fused equivalent kernel parameters and equivalent bias parameters are then used as the parameters of a single convolutional layer, replacing the original sequentially connected convolutional layers and batch normalization layers with this single convolutional layer. After performing the above processing on all the sequentially connected convolutional layers and batch normalization layers in the adjustable unit, the resulting basic detection model is recorded as the first candidate lightweight model configuration.

[0036] For example, an adjustable unit contains a convolutional layer and a batch normalization layer connected in sequence. The convolutional layer contains 3×3 convolutional kernel parameters and a bias parameter; the batch normalization layer contains scaling and translation parameters. The convolutional kernel parameters and bias parameters are fused with the scaling and translation parameters of the batch normalization layer according to the fusion formula, resulting in equivalent kernel parameters and equivalent bias parameters for a single 3×3 convolutional layer. These equivalent kernel parameters and equivalent bias parameters replace the original convolutional layer and batch normalization layer. After this replacement, a first candidate lightweight model configuration is obtained. In this first candidate lightweight model configuration, the sequentially connected convolutional layer and batch normalization layer have been fused into a single convolutional layer, reducing computational cost.

[0037] Next, redundant units are reduced in the adjustable units of the first candidate lightweight model configuration. The importance score of each convolutional channel is determined based on the weight parameter distribution characteristics and activation response characteristics of each convolutional channel. Convolutional channels with importance scores lower than a preset threshold are deleted. The deleted model is then fine-tuned to obtain the second candidate lightweight model configuration.

[0038] Redundant unit reduction refers to the process of identifying and removing redundant convolutional channels from the model that contribute little to the detection results. A convolutional channel is the feature output dimension corresponding to a single convolutional kernel in a convolutional layer; a convolutional layer contains multiple convolutional channels. Weight parameter distribution characteristics refer to the statistical distribution characteristics of the weight parameters in a convolutional channel, including the average absolute value of the weight parameters. Activation response characteristics refer to the statistical distribution characteristics of the activation values ​​output by a convolutional channel on the input sample, including the average absolute value of the activation values. Importance score is a quantitative value used to measure the contribution of a convolutional channel to the model's detection results. A preset threshold is a pre-defined threshold for determining the importance score; when the importance score of a convolutional channel is lower than this threshold, the convolutional channel is considered a redundant channel. Fine-tuning training refers to retraining the model for a short period using training data after deleting redundant units to recover the detection accuracy lost due to the deletion of convolutional channels.

[0039] The preset threshold is set based on the following: Statistical analysis of the importance scores of each convolutional channel is performed using the validation dataset. The importance scores are then ranked from highest to lowest, and the threshold is determined according to a preset channel retention ratio. Specifically, the validation dataset is input into the current model, and after calculating the importance score of each convolutional channel, all convolutional channel importance scores are ranked from highest to lowest. The channel retention ratio is set to 50% to 70%, and the importance score value at the boundary of the sorted channel retention ratio is taken as the preset threshold. The channel retention ratio is predetermined based on the resource constraints and detection accuracy requirements of the target edge device. The higher the resource constraint, the lower the channel retention ratio, and the higher the preset threshold, resulting in more channels being deleted. Furthermore, the preset threshold can also be determined by performing a grid search on the validation dataset for different threshold values, selecting the threshold that achieves the optimal balance between detection accuracy and computational cost. Once determined, the preset threshold remains fixed during subsequent fine-tuning training and does not change with training iterations.

[0040] Specifically, samples from the validation dataset are input into the first candidate lightweight model configuration to obtain the activation values ​​of each convolutional channel on the validation dataset. For each convolutional channel, the average absolute value of the weight parameters is calculated as the weight parameter distribution feature of that convolutional channel. The average absolute value of the activation values ​​of that convolutional channel on the validation dataset is calculated as the activation response feature of that convolutional channel. The average absolute value of the weight parameters is multiplied by the average absolute value of the activation values ​​to obtain the importance score of that convolutional channel. The importance scores of each convolutional channel are compared with a preset threshold, and convolutional channels with importance scores lower than the preset threshold are removed from the first candidate lightweight model configuration. After removal, the removed model is fine-tuned using the training set. The fine-tuning training uses a preset small learning rate, and the number of training epochs is less than the number of basic training epochs.

[0041] After each training epoch, the validation dataset is input into the current model for forward inference calculation to obtain the model's total loss value on the validation dataset. The total loss value of the current training epoch is compared with the total loss value of the previous training epoch to calculate the rate of decrease in the loss value. When the rate of decrease in the loss value is less than a preset change threshold for three consecutive training epochs, the model is considered to have converged, and fine-tuning training stops. The preset change threshold is 1%. Additionally, a maximum number of training epochs can be set as an auxiliary convergence condition. When fine-tuning training reaches the maximum number of training epochs, training stops regardless of whether the loss value continues to decrease, to prevent overfitting. The maximum number of training epochs is 50.

[0042] For example, a convolutional layer contains 32 convolutional channels. The average absolute values ​​of the weight parameters and the average absolute values ​​of the activation values ​​for each convolutional channel are obtained. The average absolute value of the weight parameters for a given convolutional channel is 0.15, and the average absolute value of the activation values ​​is 0.20. Multiplying these two values ​​yields an importance score of 0.03 for that convolutional channel. A preset threshold of 0.05 is used; since the importance score of 0.03 is lower than the preset threshold, the convolutional channel is considered redundant and deleted. After performing the above judgment and deletion operations on all convolutional channels, the model after deletion is fine-tuned using the training dataset. The learning rate for fine-tuning is set to 1 / 10 of the base learning rate, and the training epochs are 10. After convergence, a second candidate lightweight model configuration is obtained.

[0043] Then, numerical precision adaptation is performed on the adjustable units in the second candidate lightweight model configuration. The quantization scaling factor and zero offset of each layer are determined according to the distribution range of the weight parameters and the distribution range of the activation values ​​of each network layer. The floating-point parameters are mapped to low-bit integer parameters to obtain the third candidate lightweight model configuration.

[0044] Numerical precision adaptation refers to the process of quantizing parameters in the model from high-precision numerical format to low-bit integer parameters. The quantization scaling factor is a scaling factor used to map floating-point numbers to low-bit integer numbers. The zero-point offset is the shift amount used to map floating-point numbers to low-bit integer numbers. Floating-point parameters are model parameters stored in high-precision floating-point format, while low-bit integer parameters are model parameters stored in low-bit integer format.

[0045] Specifically, statistical analysis is performed on the weight parameters and activation values ​​of each network layer in the second candidate lightweight model configuration to obtain the distribution range of weight parameters and activation values ​​for each network layer. The weight parameter distribution range refers to the interval between the minimum and maximum values ​​of the weight parameters, and the activation value distribution range refers to the interval between the minimum and maximum values ​​of the activation values. For each network layer, the weight quantization scaling factor is calculated based on the weight parameter distribution range, the activation quantization scaling factor is calculated based on the activation value distribution range, and the zero-point offset is calculated based on the minimum value of the weight parameter distribution range. Using a linear quantization formula, the floating-point weight parameters and floating-point activation values ​​of each network layer are mapped to low-bit integer parameters according to the corresponding quantization scaling factor and zero-point offset. The model obtained after the mapping is recorded as the third candidate lightweight model configuration.

[0046] For example, the weight parameters of a certain convolutional layer range from a minimum of -0.5 to a maximum of 0.8, and the activation values ​​range from a minimum of 0 to a maximum of 6.0. Based on the weight parameter range of -0.5 to 0.8, the weight quantization scaling factor for this layer is calculated to be 0.005, and the zero-point offset is 100. Based on the activation value range of 0 to 6.0, the activation quantization scaling factor for this layer is calculated to be 0.024, and the zero-point offset is 0. The floating-point weight parameters and floating-point activation values ​​of this convolutional layer are then mapped to 8-bit integer parameters according to the aforementioned quantization scaling factor and zero-point offset, resulting in the quantized third candidate lightweight model configuration.

[0047] Subsequently, computational graph fusion is performed on the adjustable units in the third candidate lightweight model configuration. Multiple computational units that can be executed consecutively and satisfy equivalence conditions are merged into a single fused computational unit, resulting in the fourth candidate lightweight model configuration. Computational graph fusion refers to the process of merging multiple computational units in a computational graph that can be executed consecutively and satisfy equivalence conditions into a single computational unit without changing the computation result. The equivalence condition means that the computation results of multiple consecutive computational units are mathematically strictly equal to the computation result of a single fused computational unit. A computational unit refers to a basic operation node in a computational graph. A fused computational unit is a single computational unit formed by merging multiple consecutively executed computational units.

[0048] Specifically, the computation graph of the third candidate lightweight model configuration is traversed to identify whether there are multiple computational units in the computation graph that can be executed consecutively and satisfy equivalence conditions. The equivalence condition is determined by the following criteria: the execution effect of multiple computational units in series is mathematically strictly equal to the execution effect of a single fused computational unit, and the fusion operation does not change the dimensional information in the data stream. When multiple computational units that satisfy the equivalence condition are identified, the computational operations of these computational units are merged into a single computational operation according to the execution order of the computation graph, and the merged computational unit is taken as the fused computational unit. After completing the above fusion process on all multiple computational units in the computation graph of the third candidate lightweight model configuration that satisfy the equivalence condition, the resulting model is recorded as the fourth candidate lightweight model configuration.

[0049] For example, the computation graph of the third candidate lightweight model configuration contains convolutional layers, batch normalization layers, and activation layers executed sequentially. The output of the convolutional layer serves as the input of the batch normalization layer, and the output of the batch normalization layer serves as the input of the activation layer. The three computational units are executed consecutively, and the computation result after being fused into a single computational unit is mathematically strictly equal to the computation result of executing the three computational units sequentially, satisfying the equivalence condition. The convolutional layer, batch normalization layer, and activation layer are fused into a single fused computational unit, which performs equivalent convolutional computation, normalization computation, and activation computation. After completing the fusion process for all multiple computational units that satisfy the equivalence condition, the fourth candidate lightweight model configuration is obtained.

[0050] Finally, the dependent units are kept synchronized with the adjustable units, and the retention ratio lower limit, accuracy lower limit or replacement limit are set for the sensitive units. The configurations of the first candidate lightweight model, the second candidate lightweight model, the third candidate lightweight model, and the fourth candidate lightweight model are saved as a lightweight model configuration pool.

[0051] Synchronous updates refer to adjusting the structural parameters of dependent units when the structural parameters of the adjustable unit change, ensuring that the output data dimension of the dependent units remains consistent with the input data dimension of subsequent functional units. The minimum retention ratio refers to the minimum proportion of channels that a sensitive unit must retain during lightweighting to the original number of channels. The minimum accuracy limit refers to the lowest detection accuracy value that a sensitive unit is allowed to achieve during lightweighting. Replacement restrictions are protective constraints that prohibit the replacement or deletion of sensitive units.

[0052] Specifically, when performing any one or more of the above lightweighting processes on the adjustable unit, if the structural parameters of the adjustable unit change, the structural parameters of dependent units that have a data dependency relationship with the adjustable unit are updated synchronously according to the changed structural parameters of the adjustable unit, so that the output data dimension of the dependent unit matches the input data dimension of the subsequent functional units. During the lightweighting process on the model, for functional units identified as sensitive units, at least one of the following protective constraints is set: a retention ratio lower limit, a precision lower limit, or a replacement restriction. The retention ratio lower limit is that the number of convolutional channels retained in the sensitive unit must not be less than 50% of the original number of channels. The precision lower limit is that the detection precision of the sensitive unit on the validation dataset must not be less than 98% of the original detection precision. The replacement restriction prohibits any form of deletion or structural replacement of sensitive units. After completing the above processing, the first candidate lightweight model configuration, the second candidate lightweight model configuration, the third candidate lightweight model configuration, and the fourth candidate lightweight model configuration are saved as a lightweight model configuration pool.

[0053] For example, the input data of a dependent unit originates from the output data of an adjustable unit. If the number of channels in the adjustable unit is adjusted from 32 to 16, the dimension of the input data for the dependent unit changes. Based on the adjusted channel count of 16 for the adjustable unit, the number of input channels for the dependent unit is synchronously updated to 16 to ensure data dimension matching. A sensitive unit is a feature extraction layer at the end of the backbone network. A retention ratio lower limit of 50% is set for this sensitive unit, meaning the number of convolutional channels retained for this sensitive unit must not be less than half of the original number of channels; a precision lower limit of 98% is set, meaning the detection precision of this sensitive unit on the validation dataset must not be less than 98% of the original detection precision; and a replacement restriction is set to prohibit any form of deletion or structural replacement of this sensitive unit. The first candidate lightweight model configuration, the second candidate lightweight model configuration, the third candidate lightweight model configuration, and the fourth candidate lightweight model configuration are saved as a lightweight model configuration pool. This pool contains four candidate configurations with different computational overheads and detection capabilities.

[0054] Based on this, such as Figure 2 As shown, based on the detection target information and real-time resource status information, a target configuration scheme is selected from the lightweight model configuration pool, including: Obtain the detection accuracy evaluation value, inference latency evaluation value, and resource consumption evaluation value of each candidate lightweight model configuration in the lightweight model configuration pool; The accuracy preference coefficient is determined based on the target detection information, and the latency preference coefficient and resource preference coefficient are determined based on the real-time resource status information. The detection accuracy evaluation value, inference latency evaluation value, and resource consumption evaluation value of each candidate lightweight model configuration are weighted by the accuracy preference coefficient, latency preference coefficient, and resource preference coefficient, respectively. The weighted calculation results of each candidate lightweight model configuration are then fused to obtain the comprehensive fit of each candidate lightweight model configuration. The candidate lightweight model configuration with the highest overall fit is selected as the target configuration scheme.

[0055] First, obtain the detection accuracy evaluation value, inference latency evaluation value, and resource consumption evaluation value for each candidate lightweight model configuration in the lightweight model configuration pool, including: Obtain a preset validation dataset, input the validation dataset into the lightweight detection model corresponding to each candidate lightweight model configuration, and obtain the detection accuracy of each lightweight detection model on the validation dataset as the evaluation value of the detection accuracy of each candidate lightweight model configuration. Based on real-time resource status information, the inference speed of each candidate lightweight model configuration is simulated to obtain the inference latency of each candidate lightweight model configuration on the edge device, which is used as the inference latency evaluation value of each candidate lightweight model configuration. Obtain the number of parameters for each candidate lightweight model configuration, and calculate the memory usage of each candidate lightweight model configuration on the edge device based on the number of parameters, which serves as the resource usage evaluation value for each candidate lightweight model configuration.

[0056] First, a pre-set validation dataset is obtained. This dataset is then input into the lightweight detection model corresponding to each candidate lightweight model configuration. The detection accuracy of each lightweight detection model on the validation dataset is obtained and used as the evaluation value for the detection accuracy of each candidate lightweight model configuration. The pre-set validation dataset refers to a collection of image samples prepared in advance to evaluate the detection performance of the candidate lightweight model configurations. This validation dataset can be the same dataset used to calculate the convolutional channel importance score. Each image sample in the validation dataset includes labeled device type, defect type, and defect location bounding box. Detection accuracy refers to the degree to which the lightweight detection model correctly detects defect targets on the validation dataset, expressed as average detection accuracy. Average detection accuracy is a comprehensive evaluation metric obtained by averaging the detection accuracy of each defect category.

[0057] Specifically, for each candidate lightweight model configuration in the lightweight model configuration pool, the corresponding lightweight detection model is loaded into the edge device or simulation environment. Each image sample from the validation dataset is sequentially input into the lightweight detection model for forward inference computation to obtain the predicted defect category, predicted defect location bounding box, and corresponding reliability for each image sample. The prediction results for each image sample are compared with the labeled ground truth, and the detection accuracy of each image sample is calculated according to the standard evaluation rules in the object detection field. The average detection accuracy of all image samples is taken to obtain the average detection accuracy of the candidate lightweight model configuration on the validation dataset. The average detection accuracy value is used as the detection accuracy evaluation value of the candidate lightweight model configuration. The above operations are performed for each candidate lightweight model configuration in the lightweight model configuration pool to obtain the detection accuracy evaluation value for each candidate lightweight model configuration.

[0058] For example, the preset validation dataset contains 2000 labeled images of power grid equipment. The lightweight model configuration pool includes a first candidate lightweight model configuration, a second candidate lightweight model configuration, a third candidate lightweight model configuration, and a fourth candidate lightweight model configuration. For the first candidate lightweight model configuration, after loading the corresponding lightweight detection model, the 2000 validation image samples are sequentially input into the model. The model outputs the predicted defect category, the predicted defect location bounding box, and the corresponding reliability for each image. The prediction results for each image are compared with the labeled ground truth, and the average detection accuracy of the model on the 2000 image samples is calculated to be 92.5%. This 92.5 is used as the detection accuracy evaluation value for the first candidate lightweight model configuration. Similarly, the detection accuracy evaluation values ​​for the second candidate lightweight model configuration are calculated to be 90.1, the third candidate lightweight model configuration to be 88.7, and the fourth candidate lightweight model configuration to be 91.8.

[0059] Secondly, inference speed simulations are performed on each candidate lightweight model configuration based on real-time resource status information to obtain the inference latency of each candidate lightweight model configuration on the edge device, which serves as the inference latency evaluation value for each candidate lightweight model configuration. The inference latency evaluation value is a numerical value used to quantify the time required for a candidate lightweight model configuration to complete one inference operation on the edge device. Inference speed simulation refers to the process of estimating inference latency based on the computational load of the candidate lightweight model configuration and the available computing power of the edge device.

[0060] Specifically, for each candidate lightweight model configuration in the lightweight model configuration pool, the total computational cost of that candidate lightweight model configuration is first obtained, expressed in floating-point operations. The number of floating-point operations is the total number of floating-point operations required for the model to complete one forward inference operation, reflecting the computational complexity of the model. Available computing power is extracted from the real-time resource status information obtained from S100, expressed in millions of instructions per second or floating-point operations per second, reflecting the computing power currently available from the edge device. The total number of floating-point operations for the candidate lightweight model configuration is divided by the available computing power to obtain an estimated inference latency value, which is used as the inference latency evaluation value for that candidate lightweight model configuration. The above calculation is performed for each candidate lightweight model configuration in the lightweight model configuration pool to obtain the inference latency evaluation value for each candidate lightweight model configuration.

[0061] For example, the total number of floating-point operations configured for the first candidate lightweight model is 5 × 10⁻⁶. 9 The available computing power value in the real-time resource status information is 100 GFLOPS, or 100 × 10⁻⁶ GFLOPS. 9 Inference latency estimate = (5 × 10^6 times / second). 9 ) / (100×10 9 =0.05 seconds = 50 milliseconds, so 50 milliseconds is taken as the inference latency evaluation value for the first candidate lightweight model configuration. Similarly, the inference latency evaluation value for the second candidate lightweight model configuration is 30 milliseconds, the inference latency evaluation value for the third candidate lightweight model configuration is 20 milliseconds, and the inference latency evaluation value for the fourth candidate lightweight model configuration is 40 milliseconds.

[0062] Next, the number of parameters in each candidate lightweight model configuration is obtained. Based on the number of parameters, the memory usage of each candidate lightweight model configuration on the edge device is calculated, serving as the resource consumption evaluation value for each candidate lightweight model configuration. The number of parameters refers to the total number of all learnable parameters in the candidate lightweight model configuration, reflecting the model's storage complexity. Memory usage refers to the amount of storage space required for the candidate lightweight model configuration to run in the edge device's memory, reflecting the degree to which the model consumes the edge device's storage resources.

[0063] Specifically, for each candidate lightweight model configuration in the lightweight model configuration pool, the number of parameters for each network layer is read from the model structure description information of that configuration. The number of parameters for all network layers is added together to obtain the total number of parameters for that candidate lightweight model configuration. Based on the total number of parameters, the memory footprint of that candidate lightweight model configuration on the edge device is calculated. The memory footprint equals the total number of parameters multiplied by the number of bytes of storage occupied by each parameter. The number of bytes of storage occupied by each parameter is determined by the numerical precision format of the parameters in the model; when the parameters use a 32-bit floating-point format, each parameter occupies 4 bytes. The calculated memory footprint is used as the original memory footprint of that candidate lightweight model configuration.

[0064] After calculating the memory usage of all candidate lightweight model configurations, the maximum memory usage in each configuration is obtained as the baseline memory usage. For each candidate lightweight model configuration, a normalized resource usage evaluation value is obtained. The normalization formula is: Resource usage evaluation value = Original memory usage / Baseline memory usage × 100. The resource usage evaluation value is a dimensionless value, ranging from 0 to 100.

[0065] For example, the total number of parameters configured for the first candidate lightweight model is 6 × 10. 6 There are 1 parameter, which uses a 32-bit floating-point format. Each parameter occupies 4 bytes, and the memory usage is 6 × 10^6 bytes. 6 ×4=24×10 6 Bytes, or 24MB. The total number of parameters configured for the second candidate lightweight model is 4 × 10^6 bytes. 6 The third candidate lightweight model has a total of 3 × 10 parameters, with a memory footprint of 16MB. 6 The fourth candidate lightweight model has a total of 5 × 10 parameters, with a memory footprint of 12MB. 6 The first candidate lightweight model has a memory usage of 20MB. The maximum memory usage among all candidate lightweight model configurations is 24MB, which is used as the baseline memory usage. The resource usage evaluation value for the first candidate lightweight model configuration is 24 / 24 × 100 = 100. The resource usage evaluation value for the second candidate lightweight model configuration is 16 / 24 × 100 ≈ 67. The resource usage evaluation value for the third candidate lightweight model configuration is 12 / 24 × 100 = 50. The resource usage evaluation value for the fourth candidate lightweight model configuration is 20 / 24 × 100 ≈ 83. A higher resource usage evaluation value indicates that the memory usage of that candidate lightweight model configuration is closer to the maximum value, meaning higher resource consumption.

[0066] Secondly, the accuracy preference coefficient is determined based on the target detection information, and the latency preference coefficient and resource preference coefficient are determined based on the real-time resource status information, including: Obtain the equipment type label from the target information. Based on the equipment type label, query the preset equipment type-precision preference coefficient mapping table to obtain the precision preference coefficient. Among them, insulator strings and clamps correspond to the first precision preference coefficient, and bolts and crossarms correspond to the second precision preference coefficient. The first precision preference coefficient is higher than the second precision preference coefficient. Obtain the available computing power, available memory and current power consumption values ​​from the real-time resource status information. When the available computing power is lower than the computing power threshold, the available memory is lower than the memory threshold, or the current power consumption is higher than the power consumption threshold, determine the latency preference coefficient and resource preference coefficient as high-weight states. When the available computing power is not lower than the computing power threshold, the available memory is not lower than the memory threshold, and the current power consumption is not higher than the power consumption threshold, the latency preference coefficient and resource preference coefficient are determined to be in a low-weight state.

[0067] First, obtain the equipment type label from the target information. Then, query the preset equipment type-precision preference coefficient mapping table based on the equipment type label to obtain the precision preference coefficient. Among them, insulator strings and clamps correspond to the first precision preference coefficient, and bolts and crossarms correspond to the second precision preference coefficient. The first precision preference coefficient is higher than the second precision preference coefficient.

[0068] The equipment type label is an identifier used to determine the category of power grid equipment in the current inspection image, obtained by the pre-set object recognition network in S100. The equipment type-accuracy preference coefficient mapping table is a pre-established data table recording the correspondence between each equipment type label and its accuracy preference coefficient. The accuracy preference coefficient is a weighted coefficient reflecting the degree of accuracy preference of the current detection target; a higher value indicates a higher requirement for detection accuracy, and its value ranges from 0 to 1. The first accuracy preference coefficient corresponds to insulator strings and clamps, while the second accuracy preference coefficient corresponds to bolts and crossarms. Defects in insulator strings and clamps have a significant impact on the safe operation of the power grid, requiring higher detection accuracy; therefore, the first accuracy preference coefficient is higher than the second accuracy preference coefficient.

[0069] Specifically, equipment type labels are extracted from the detection target information generated in S100. A pre-established equipment type-precision preference coefficient mapping table is obtained, which stores the mapping relationship between each equipment type label and its corresponding precision preference coefficient in key-value pairs. The equipment type label is used as the query keyword to search and match in the equipment type-precision preference coefficient mapping table, and the precision preference coefficient value corresponding to that equipment type label is extracted. When the equipment type label is an insulator string or clamp, the first precision preference coefficient is retrieved. When the equipment type label is a bolt or crossarm, the second precision preference coefficient is retrieved. The specific values ​​of the first and second precision preference coefficients are pre-set and stored in the mapping table according to the actual requirements for the detection precision of each equipment type in historical detections.

[0070] The method for establishing the equipment type-accuracy preference coefficient mapping table is as follows: Historical inspection image data and corresponding defect detection records are acquired. These records contain equipment type labels and their defect identification accuracy under different detection accuracy conditions. For each equipment type label, the defect identification accuracy variation curve under different detection accuracies is statistically analyzed to determine the minimum detection accuracy value required for that equipment type to meet the inspection requirements. Based on the minimum detection accuracy value required for each equipment type to meet the inspection requirements, and considering the impact of defects in each equipment type on the safe operation of the power grid, an expert scoring method is used to determine the accuracy preference coefficient corresponding to each equipment type. Specifically, defects in insulator strings and clamps have a greater impact on the safe operation of the power grid and require a higher detection accuracy value, corresponding to the first accuracy preference coefficient; defects in bolts and crossarms have a relatively smaller impact on the safe operation of the power grid and require a lower detection accuracy value, corresponding to the second accuracy preference coefficient. Each equipment type label and its corresponding accuracy preference coefficient are associated and stored in key-value pairs to generate the equipment type-accuracy preference coefficient mapping table.

[0071] For example, the device type label in the detection target information generated by S100 is insulator string. The device type-accuracy preference coefficient mapping table records that the first accuracy preference coefficient for insulator string is 0.8, the first accuracy preference coefficient for wire clamp is 0.75, the second accuracy preference coefficient for bolt is 0.5, and the second accuracy preference coefficient for crossarm is 0.45. Searching the mapping table using insulator string as the query keyword yields an accuracy preference coefficient of 0.8.

[0072] Secondly, obtain the available computing power, available memory and current power consumption values ​​from the real-time resource status information. When the available computing power is lower than the computing power threshold, the available memory is lower than the memory threshold, or the current power consumption is higher than the power consumption threshold, determine the latency preference coefficient and resource preference coefficient as high-weight states.

[0073] The computing power threshold is a pre-set critical value used to determine whether the available computing power is sufficient. It is determined based on the minimum computing power required for each candidate lightweight model configuration to complete one forward inference computation. The total number of floating-point operations of all candidate lightweight model configurations in the lightweight model configuration pool is counted, and the minimum available computing power required to meet the preset inference latency limit is calculated. This value is used as the computing power threshold.

[0074] The memory threshold is a pre-defined critical value used to determine whether available memory is sufficient. It is determined based on the memory usage required for each candidate lightweight model configuration to run on the edge device. The memory usage of all candidate lightweight model configurations in the lightweight model configuration pool is statistically analyzed, and the maximum value is taken as the baseline memory usage. Then, the memory overhead of the edge device's operating system is considered, and the baseline memory usage is added to the operating system's memory overhead. The sum of these values ​​is used as the memory threshold.

[0075] The power consumption threshold is a pre-set critical value used to determine whether the current power consumption is too high. It is determined based on the hardware thermal design parameters and battery power capacity of the edge device. The maximum safe power consumption value of the edge device under continuous full-load operation or the maximum power consumption value that the cooling system can withstand is obtained. This maximum safe power consumption value is multiplied by a preset safety factor, and the result is used as the power consumption threshold. The safety factor ranges from 0.7 to 0.9, used to reserve power consumption margin to ensure the stability and security of the edge device's long-term operation.

[0076] Among them, the high-weight state refers to the state in which the latency preference coefficient and the resource preference coefficient have a high weight in the multi-objective evaluation. In this state, the influence of the inference latency and resource consumption dimensions on the comprehensive fit calculation is higher than that of the detection accuracy dimension.

[0077] Specifically, available computing power, available memory, and current power consumption are extracted from the real-time resource status information obtained from S100. The available computing power is compared to a preset computing power threshold, the available memory is compared to a preset memory threshold, and the current power consumption is compared to a preset power consumption threshold. When the available computing power is lower than the computing power threshold, it indicates that the edge device's current computing power is insufficient, and inference latency will become the main bottleneck, requiring priority to reduce computational overhead. When the available memory is lower than the memory threshold, it indicates that the edge device's current storage resources are strained, and memory usage will become the main limiting factor, requiring priority to reduce memory usage. When the current power consumption is higher than the power consumption threshold, it indicates that the edge device's current power consumption is too high, requiring priority to reduce computational load to reduce power consumption. If any one of the above three conditions is met, the edge device is determined to be in a resource-strained state.

[0078] When the edge device is determined to be in a state of resource shortage, the degree of deviation is calculated based on the available computing power, available memory and current power consumption. The highest level is selected from the three levels of deviation, and the coefficient value corresponding to the level is read from the preset latency preference coefficient table and resource preference coefficient table.

[0079] The latency preference coefficient table and resource preference coefficient table are constructed as follows: Based on the hardware performance parameters of the edge devices and the real-time requirements of the inspection task, latency preference coefficients and resource preference coefficients are pre-set for different resource status levels. Hardware performance parameters include the maximum available computing power, maximum available memory, and maximum secure power consumption of the edge devices. Real-time requirements include the maximum allowable inference latency for the inspection task.

[0080] Specifically, when edge device resources are abundant, inference latency and resource consumption have a relatively small impact on system operation, so the latency preference coefficient and resource preference coefficient are set to low values. When resources are under slight strain, the constraints on inference latency and resource consumption increase, so the latency preference coefficient and resource preference coefficient are set to values ​​higher than those under low-weight conditions. When resources are under moderate strain, the latency preference coefficient and resource preference coefficient are set to values ​​higher than those under slight strain. When resources are under severe strain, the latency preference coefficient and resource preference coefficient are set to values ​​higher than those under moderate strain. The specific coefficient values ​​for each level are determined through experimental calibration. That is, each candidate lightweight model configuration is run on the edge device, and the actual inference latency and resource consumption under different resource conditions are measured. The coefficient combination that allows the system to maintain detection accuracy as much as possible while meeting the upper limit requirement of inference latency is selected, and the selected coefficient combination is stored in the latency preference coefficient table and the resource preference coefficient table. The latency preference coefficient table and the resource preference coefficient table are pre-configured during system initialization and remain unchanged during system operation.

[0081] The degree of deviation can be divided into three levels: Level 1, Level 2, and Level 3.

[0082] The first level is considered slightly strained. Available computing power is below the computing power threshold with a deviation of less than 20%, or available memory is below the memory threshold with a deviation of less than 20%, or current power consumption is above the power consumption threshold with a deviation of less than 20%. Deviation is calculated as follows: Deviation = (Computing power threshold - Available computing power) / Computing power threshold, or Deviation = (Memory threshold - Available memory) / Memory threshold, or Deviation = (Current power consumption - Power consumption threshold) / Power consumption threshold. In this case, the latency preference coefficient and resource preference coefficient are the highest-weighted resource coefficients.

[0083] The second level is moderate stress. Available computing power is below the computing power threshold with a deviation of 20% or more but less than 50%, or available memory is below the memory threshold with a deviation of 20% or more but less than 50%, or current power consumption is above the power consumption threshold with a deviation of 20% or more but less than 50%. In this case, the latency preference coefficient is the second highest weighted latency coefficient, and the resource preference coefficient is the second highest weighted resource coefficient. The second highest weighted latency coefficient is greater than the first highest weighted latency coefficient, and the second highest weighted resource coefficient is greater than the first highest weighted resource coefficient.

[0084] The third level is considered severely strained. Available computing power is below the computing power threshold with a deviation of 50% or more; available memory is below the memory threshold with a deviation of 50% or more; or current power consumption is above the power consumption threshold with a deviation of 50% or more. In this case, the latency preference coefficient is the third highest weighted latency coefficient, and the resource preference coefficient is the third highest weighted resource coefficient. The third highest weighted latency coefficient is greater than the second highest weighted latency coefficient, and the third highest weighted resource coefficient is greater than the second highest weighted resource coefficient.

[0085] The specific coefficient values ​​for the three levels are pre-set based on the hardware characteristics of the edge devices and the real-time requirements of the inspection tasks, and the sum of the latency preference coefficient and the resource preference coefficient in each level is greater than the accuracy preference coefficient.

[0086] For example, the precision preference coefficient is 0.8. The preset latency preference coefficient table stores a latency preference coefficient of 0.05 for low-weight states, and 0.15 for the first level, 0.30 for the second level, and 0.50 for the third level in high-weight states. The preset resource preference coefficient table stores a resource preference coefficient of 0.02 for low-weight states, and 0.05 for the first level, 0.10 for the second level, and 0.20 for the third level in high-weight states. When the available computing power is 80 GFLOPS and the computing power threshold is 100 GFLOPS, the deviation amplitude = (100-80) / 100 = 20%, which belongs to the second level of moderate stress, with a latency preference coefficient of 0.30 and a resource preference coefficient of 0.10. When the available computing power is 50 GFLOPS and the computing power threshold is 100 GFLOPS, the deviation is (100-50) / 100=50%, which belongs to the third level of severe stress. The latency preference coefficient is 0.50 and the resource preference coefficient is 0.20.

[0087] Furthermore, when the available computing power is not lower than the computing power threshold, the available memory is not lower than the memory threshold, and the current power consumption is not higher than the power consumption threshold, the latency preference coefficient and resource preference coefficient are determined to be in a low-weight state. A low-weight state means that the latency preference coefficient and resource preference coefficient have relatively low weight in multi-objective evaluation. In this state, the influence of inference latency and resource consumption on the overall fit calculation is lower than that of detection accuracy.

[0088] Specifically, when three conditions are met simultaneously—the available computing power is higher than the computing power threshold, the available memory is higher than the memory threshold, and the current power consumption is lower than the power consumption threshold—the edge device is determined to be in a resource-sufficient state. When the edge device is determined to be in a resource-sufficient state, the coefficient values ​​corresponding to the low-weight state are read from the preset latency preference coefficient table and resource preference coefficient table. That is, the latency preference coefficient is the low-weight latency coefficient, and the resource preference coefficient is the low-weight resource coefficient. Furthermore, both the latency preference coefficient and the resource preference coefficient in the low-weight state are lower than the coefficient values ​​corresponding to any level in the high-weight state, and the sum of the latency preference coefficient and the resource preference coefficient is less than the precision preference coefficient.

[0089] For example, the real-time resource status information obtained by S100 is as follows: available computing power = 100 GFLOPS, available memory = 2048 MB, current power consumption = 5W. Computing power threshold = 100 GFLOPS, memory threshold = 1024 MB, power consumption threshold = 6W. Since all three conditions are met simultaneously, the latency preference coefficient and resource preference coefficient are determined to be in a low-weight state. The edge device is determined to be in a resource-sufficient state, and the latency preference coefficient and resource preference coefficient are determined to be in a low-weight state, with a corresponding latency preference coefficient of 0.05 and resource preference coefficient of 0.02.

[0090] Furthermore, the detection accuracy evaluation value, inference latency evaluation value, and resource consumption evaluation value corresponding to each candidate lightweight model configuration are weighted and calculated using accuracy preference coefficient, latency preference coefficient, and resource preference coefficient, respectively. The weighted calculation results of each candidate lightweight model configuration are then fused to obtain the comprehensive fit of each candidate lightweight model configuration. The comprehensive fit is a quantitative value used to comprehensively evaluate the overall performance of the candidate lightweight model configuration across the three dimensions of detection accuracy, inference latency, and resource consumption. A higher comprehensive fit indicates that the candidate configuration is better under the current detection scenario and resource conditions.

[0091] Specifically, for each candidate lightweight model configuration in the lightweight model configuration pool, the detection accuracy evaluation value, inference latency evaluation value, and resource consumption evaluation value of that candidate lightweight model configuration are obtained. The detection accuracy evaluation value is multiplied by an accuracy preference coefficient to obtain an accuracy-weighted value. The inference latency evaluation value is multiplied by a latency preference coefficient to obtain a latency-weighted value. The resource consumption evaluation value is multiplied by a resource preference coefficient to obtain a resource-weighted value. The accuracy-weighted value, latency-weighted value, and resource-weighted value are added together to obtain the overall fit of the candidate lightweight model configuration. The above weighting and fusion calculations are performed for each candidate lightweight model configuration in the lightweight model configuration pool to obtain the overall fit of each candidate lightweight model configuration.

[0092] For example, the lightweight model configuration pool contains four candidate lightweight model configurations with detection accuracy evaluation values ​​of 92.5, 90.1, 88.7, and 91.8, inference latency evaluation values ​​of 50 ms, 30 ms, 20 ms, and 40 ms, and resource usage evaluation values ​​of 100, 67, 50, and 83, respectively. The accuracy preference coefficient is known to be 0.8, the latency preference coefficient is 0.05, and the resource preference coefficient is 0.02. For the first candidate lightweight model configuration, the accuracy weighted value = 92.5 × 0.8 = 74.0, the latency weighted value = 50 × 0.05 = 2.5, the resource weighted value = 100 × 0.02 = 2.0, and the overall fit = 74.0 + 2.5 + 2.0 = 78.5. Similarly, the overall fit of the second candidate lightweight model configuration is 74.92, the overall fit of the third candidate lightweight model configuration is 72.96, and the overall fit of the fourth candidate lightweight model configuration is 77.10.

[0093] Finally, the candidate lightweight model configuration with the highest overall fit is selected as the target configuration. The target configuration refers to the candidate lightweight model configuration with the highest overall fit selected from the lightweight model configuration pool. This configuration will be used for inference on the current inspected image. For example, the first candidate lightweight model configuration has the highest overall fit of 78.5, so it is selected as the target configuration.

[0094] Furthermore, the lightweight detection model corresponding to the target configuration scheme is invoked to perform inference on the current inspection image and output the defect detection results, including: Load the corresponding lightweight detection model according to the target configuration scheme, and load the structural parameters and weight parameters in the target configuration scheme into the lightweight detection model; The current inspection image is input into the lightweight detection model. After forward inference calculation by the lightweight detection model, the defect category, defect location bounding box and corresponding reliability of each detected target in the current inspection image are output. Non-maximum suppression is performed on the bounding boxes at the defect locations to remove redundant bounding boxes with an overlap greater than a preset overlap threshold; The defect category, defect location bounding box, and corresponding reliability after nonmaximum suppression processing are associated as the defect detection result.

[0095] First, a lightweight detection model is loaded according to the target configuration scheme, incorporating the structural and weight parameters from the target configuration scheme. The lightweight detection model is a detection model instantiated according to the structural and weight parameters in the target configuration scheme, capable of performing inference. Structural parameters refer to the network structure configuration parameters of the lightweight detection model, including the type, order, number of input / output channels, and kernel size of each network layer. Weight parameters refer to the learnable parameter values ​​of each network layer in the lightweight detection model.

[0096] Specifically, the model structure description information and weight parameter data contained in the target configuration scheme are obtained. The network structure of the lightweight detection model is constructed in the memory of the edge device according to the network structure configuration in the model structure description information, including creating each network layer and establishing inter-layer connections. The weight parameter data from the target configuration scheme is loaded into the corresponding network layer in the constructed network structure according to the parameter loading requirements of the corresponding network layer, completing the instantiation of the lightweight detection model on the edge device.

[0097] For example, the target configuration is the first candidate lightweight model configuration, with the following structural parameters: 3 input channels, a backbone network containing 5 convolutional modules and 3 C2f modules, and the detection head outputting prediction results at 3 scales. The weight parameters of this configuration include the kernel parameters of each convolutional layer and the scaling and translation parameters of the batch normalization layer. In the edge device's memory, each network layer is created according to the above structural parameters, and inter-layer connections are established. The kernel parameters of each convolutional layer are loaded into the corresponding convolutional layer, and the scaling and translation parameters of the batch normalization layer are loaded into the corresponding batch normalization layer, thus completing the loading of the lightweight detection model.

[0098] Secondly, the current inspection image is input into the lightweight detection model. After forward inference calculation, the model outputs the defect category, defect location bounding box, and corresponding reliability for each detected target in the current inspection image. Forward inference calculation refers to the process where data starts from the input layer of the lightweight detection model, passes through each network layer sequentially, and finally yields the prediction result from the output layer. The defect category is a label used to identify the type of defect. The defect location bounding box is a rectangular box used to mark the location and extent of the defect in the image, represented by the coordinates of the center point, width, and height of the bounding box. The reliability is a quantitative value representing the lightweight detection model's confidence in the prediction result, ranging from 0 to 1.

[0099] Specifically, the current inspection image acquired by S100 is preprocessed and then input into the loaded lightweight detection model. The current inspection image enters from the input layer of the lightweight detection model and sequentially passes through the forward computation of each network layer, including convolution, batch normalization, activation, and pooling calculations. Finally, the prediction result is output from the detection head output layer. The prediction result includes the defect category, defect location bounding box, and corresponding reliability for each detected target. The defect location bounding box is represented by the x-coordinate of the center point, the y-coordinate of the center point, the width, and the height. The reliability is represented by a probability value between 0 and 1.

[0100] For example, the current inspection image is input into the lightweight detection model. After forward inference calculation, the detection head output layer outputs three prediction results. The first prediction result is a defect category of burst defect, with the center point of the defect location bounding box having an x-coordinate of 320, a y-coordinate of 240, a width of 60, a height of 80, and a reliability of 0.92. The second prediction result is a defect category of overheating defect, with the center point of the defect location bounding box having an x-coordinate of 150, a y-coordinate of 180, a width of 40, a height of 50, and a reliability of 0.78. The third prediction result is a defect category of missing defect, with the center point of the defect location bounding box having an x-coordinate of 500, a y-coordinate of 320, a width of 30, a height of 35, and a reliability of 0.65.

[0101] Next, non-maximum suppression (NMS) is applied to the bounding boxes at the defect locations, eliminating redundant bounding boxes with an overlap ratio exceeding a preset overlap threshold. NMS refers to the process of retaining the bounding box with the highest reliability and eliminating the remaining redundant bounding boxes when multiple candidate bounding boxes overlap at the same detection target. Overlap ratio is the ratio of the intersection area to the union area of ​​two bounding boxes. The preset overlap threshold is a pre-defined threshold for determining overlap. When the overlap ratio of two bounding boxes exceeds this threshold, the two bounding boxes are determined to be overlapping boxes targeting the same target, and the bounding box with higher reliability is retained while the bounding box with lower reliability is eliminated.

[0102] Specifically, all defect location bounding boxes and their corresponding reliability scores are obtained. The defect location bounding boxes are sorted in descending order of reliability, and the bounding box with the highest reliability is selected as the retained box. The overlap between the retained box and each other defect location bounding box is calculated sequentially; the overlap is equal to the intersection area of ​​the two bounding boxes divided by the union area. Defect location bounding boxes with an overlap higher than a preset overlap threshold are identified as redundant bounding boxes and removed. From the remaining defect location bounding boxes, the bounding box with the highest reliability is selected again as the retained box, and the above calculation and removal process is repeated until all defect location bounding boxes have been processed. The retained defect location bounding boxes and their corresponding defect categories and reliability scores are used as the result after non-maximum suppression processing.

[0103] For example, three defect location bounding boxes and their reliability scores are output: bounding box A has a reliability of 0.92, bounding box B has a reliability of 0.78, and bounding box C has a reliability of 0.65. After sorting by reliability, bounding box A with the highest reliability is selected as the retained box. The overlap between bounding box A and bounding box B is calculated to be 0.85, and the overlap between bounding box A and bounding box C is calculated to be 0.12. A preset overlap threshold of 0.5 is set. Since the overlap between bounding box A and bounding box B (0.85) is higher than the preset overlap threshold of 0.5, bounding box B is discarded. Since the overlap between bounding box A and bounding box C (0.12) is lower than the preset overlap threshold of 0.5, bounding box C is retained. The retained boxes A and C, along with their corresponding defect categories and reliability scores, are output.

[0104] Finally, the defect category, defect location bounding box, and corresponding reliability after non-maximum suppression processing are associated to form the defect detection result. The defect detection result is a combination of information formed by establishing the association between the defect category, defect location bounding box, and corresponding reliability after non-maximum suppression processing, and serves as the final detection output of the current inspection image.

[0105] Specifically, the bounding boxes of each defect location, retained after non-maximum suppression processing, are associated with their corresponding defect categories and reliability values. For each retained defect location bounding box, a correspondence is established between the bounding box, its corresponding defect category label, and its corresponding reliability value, forming a defect detection record. All defect detection records corresponding to the retained defect location bounding boxes are merged to form a complete defect detection result. For example, bounding box A has a defect category of burst defect, a center point x-coordinate of 320, a center point y-coordinate of 240, a width of 60, a height of 80, and a reliability of 0.92. Bounding box C has a defect category of missing defect, a center point x-coordinate of 500, a center point y-coordinate of 320, a width of 30, a height of 35, and a reliability of 0.65. This information is associated with the defect detection result, which contains two defect detection records: one for a burst defect in the insulator string with its location and reliability, and another for a missing defect in the insulator string with its location and reliability.

[0106] In this embodiment of the invention, a basic detection model is acquired and data dependencies between functional units are established. Four lightweight processing steps—structural equivalence, redundant unit reduction, numerical precision adaptation, and computational graph fusion—are performed on adjustable units to generate four candidate lightweight model configurations with different computational overhead and detection capabilities, which are then stored in a lightweight model configuration pool, achieving diverse generation of candidate configurations. By determining accuracy preference coefficients based on detection target information, and latency and resource preference coefficients based on real-time resource status information, the detection accuracy evaluation value, inference latency evaluation value, and resource usage evaluation value of each candidate lightweight model configuration are weighted and fused, and the configuration with the highest overall adaptability is selected as the target configuration scheme, achieving dynamic adaptation of model configuration to detection scenarios and resource states. By loading the corresponding lightweight detection model according to the target configuration scheme and performing forward inference calculation and non-maximum suppression processing on the current inspection image, defect detection results including defect category, defect location bounding box, and corresponding reliability are output. This invention effectively solves the problem that fixed model configurations are difficult to adapt to differences in detection targets and dynamic fluctuations in edge resources, improving the dynamic adaptability of lightweight model configurations to detection scenarios and resource states.

[0107] S300: Dynamically adjusts the input resolution of the lightweight detection model based on defect detection results, the degree of scene change in the current inspection image, and real-time resource status information.

[0108] In this embodiment of the invention, since the resource status of edge devices is dynamically changing and the scene content may change between consecutive frames, maintaining a fixed input resolution may lead to increased inference latency or even device overheating when resources are scarce, while causing unnecessary computational waste when the scene is stable and detection is reliable. Furthermore, when the confidence level of the detection result is low and the scene change is small, increasing the input resolution helps to obtain more image details and improve the accuracy of subsequent detections; however, when the scene change is significant, increasing the resolution may lead to a sharp increase in computational load. Therefore, it is necessary to dynamically adjust the input resolution of the lightweight detection model based on the defect detection results, the degree of scene change in the current inspection image, and real-time resource status information to achieve a real-time balance between detection accuracy and computational efficiency.

[0109] Step S300 in the method provided in this embodiment of the invention includes: The previous frame of the inspection image collected by the edge device is acquired, and the similarity index between the current inspection image and the previous frame of the inspection image is calculated as the degree of scene change. When the lowest reliability in the reliability of the defect detection result is lower than the first reliability threshold and the degree of scene change is lower than the first change threshold, the input resolution is adjusted to the first resolution, which is higher than the current resolution. When the available computing power is lower than the computing power threshold, the available memory is lower than the memory threshold, or the current power consumption is higher than the power consumption threshold, the input resolution will be adjusted to the second resolution, which is lower than the current resolution. When the reliability of the defect detection result is higher than the second reliability threshold and the degree of scene change is lower than the second change threshold, the input resolution is adjusted to the third resolution, which is lower than the current resolution.

[0110] First, the previous frame of the inspection image captured by the edge device is acquired. The similarity index between the current inspection image and the previous frame is calculated as a measure of the scene change level. The previous frame refers to the inspection image captured by the edge device before the current moment. The image similarity index is a numerical value used to quantify the content similarity between two frames, ranging from 0 to 1; the closer the value is to 1, the more similar the two frames are. The scene change level is a quantitative indicator used to characterize the magnitude of content change in the current inspection image relative to the previous frame; the closer the scene change level value is to 1, the smaller the scene change.

[0111] Specifically, the inspection image acquired in the previous moment is read from the image buffer of the edge device and used as the previous frame inspection image. The current inspection image and the previous frame inspection image are converted from the RGB color space to the grayscale color space respectively, resulting in the current grayscale image and the previous frame grayscale image. The structural similarity index is used as the image similarity metric to calculate the structural similarity index between the current grayscale image and the previous frame grayscale image.

[0112] The structural similarity index is calculated as follows: The mean luminance, variance luminance, and covariance between the current and previous grayscale images are calculated separately. The mean luminance is equal to the sum of the grayscale values ​​of all pixels in the image divided by the total number of pixels. The variance luminance is equal to the sum of the squares of the differences between the grayscale values ​​of each pixel and the mean luminance, divided by the total number of pixels. The covariance is equal to the product of the difference between the grayscale value of each pixel in the current grayscale image and its mean luminance, multiplied by the difference between the corresponding pixel's grayscale value and its mean luminance in the previous grayscale image, summed, and divided by the total number of pixels. Substituting the mean luminance, variance luminance, and covariance between the two images into the structural similarity index calculation formula yields the structural similarity index. The structural similarity index calculation formula is: Structural Similarity Index = (2 × First Mean Luminance × Second Mean Luminance + First Constant) × (2 × Covariance + Second Constant) / (First Mean Luminance ... 2 +Second average brightness 2 +First constant) / (First luminance variance +Second luminance variance +Second constant).

[0113] The first brightness mean refers to the average grayscale value of all pixels after the current inspection image is converted to grayscale, reflecting the overall brightness of the current frame. The second brightness mean refers to the average grayscale value of all pixels after the previous inspection image is converted to grayscale, reflecting the overall brightness of the previous frame. The first brightness variance refers to the dispersion of the grayscale values ​​of each pixel in the current frame's grayscale image relative to the first brightness mean, reflecting the richness of the image texture in the current frame. The second brightness variance refers to the dispersion of the grayscale values ​​of each pixel in the previous frame's grayscale image relative to the second brightness mean, reflecting the richness of the image texture in the previous frame. The first and second constant terms are preset minimum values ​​to avoid the denominator being zero.

[0114] For example, the previous frame of the inspection image is read from the image buffer of the edge device. After converting the current inspection image and the previous frame of the inspection image into grayscale images respectively, the average grayscale value of all pixels in the current grayscale image is calculated to obtain a first average brightness value of 120; the average grayscale value of all pixels in the previous frame of the grayscale image is calculated to obtain a second average brightness value of 118; the brightness variance of the current grayscale image is calculated to obtain a first brightness variance of 450; the brightness variance of the previous frame of the grayscale image is calculated to obtain a second brightness variance of 440, and the covariance of the two images is 430. The first constant and the second constant are both set to 0.01. Substituting the above values ​​into the structural similarity index calculation formula, the structural similarity index is calculated to be approximately 0.97. This structural similarity index of 0.97 is used as the degree of scene change; the closer the value is to 1, the more similar the two frames are and the smaller the scene change.

[0115] Secondly, when the reliability of the defect detection result is lower than the first reliability threshold and the scene change is lower than the first change threshold, the input resolution is adjusted to the first resolution, which is higher than the current resolution. The first reliability threshold is a pre-set critical value used to determine whether the reliability of the detection result is too low. When the reliability is lower than this threshold, it indicates that the current detection result is not credible enough, and the resolution needs to be increased to obtain more image details to improve subsequent detection results. The first change threshold is a pre-set critical value used to determine whether the scene change is sufficiently small. When the scene change is lower than the first change threshold, it indicates that the current image content is basically the same as the previous frame, and increasing the resolution will not cause a sudden increase in computation due to scene changes. The first resolution is an image size higher than the current input resolution.

[0116] The first reliability threshold is based on the lowest reliability statistical value of samples that were manually verified as correctly detected during historical inspections, and is pre-set in conjunction with the tolerance of power grid equipment defect detection for missed detection rates. The first variation threshold is pre-set based on the tolerance of power grid equipment defect detection for missed detections caused by sudden scene changes, and is pre-set in conjunction with the minimum scene stability requirement that the lightweight detection model can effectively improve detection accuracy after the input resolution is increased.

[0117] The first resolution is predetermined based on the maximum input size supported by the lightweight detection model and the minimum resolution requirement for image details of the defect to be detected. It is then progressively increased to the preset high resolution level based on the current input resolution. For example, if the maximum input size supported by the model is 1024×1024 pixels, the first resolution is set to 1024×1024 pixels; if the current resolution is 640×640 pixels, it is increased to 1024×1024 pixels.

[0118] Specifically, the reliability of each detected target is extracted from the defect detection results, and the minimum value is selected as the lowest reliability. The lowest reliability is compared with a first reliability threshold, and the degree of scene change is compared with a first change threshold. When the lowest reliability is lower than the first reliability threshold and the degree of scene change is lower than the first change threshold, the current detection result is deemed insufficiently reliable, but the scene content is stable, making it suitable to increase the input resolution to obtain more refined image features. The input resolution of the lightweight detection model is then adjusted to a first resolution, which is higher than the current resolution.

[0119] For example, the defect detection result output by S200 includes three detection targets with reliability values ​​of 0.92, 0.78, and 0.65, respectively, with a minimum reliability of 0.65. The first reliability threshold is 0.7, the scene change level is 0.97, and the first change threshold is 0.1. The minimum reliability of 0.65 is lower than the first reliability threshold of 0.7, and the scene change level of 0.97 is lower than the first change threshold of 0.1. Since both conditions are met, and the current input resolution is 640×640 pixels, the input resolution is adjusted to the first resolution of 1024×1024 pixels.

[0120] Furthermore, when the available computing power is lower than the computing power threshold, the available memory is lower than the memory threshold, or the current power consumption is higher than the power consumption threshold, the input resolution is adjusted to a second resolution, which is lower than the current resolution. The second resolution is an image size lower than the current input resolution.

[0121] Specifically, the available computing power is compared with a computing power threshold, the available memory is compared with a memory threshold, and the current power consumption is compared with a power consumption threshold. If any one of the following three conditions is met: available computing power is lower than the computing power threshold, available memory is lower than the memory threshold, or current power consumption is higher than the power consumption threshold, it is determined that the edge device's current resources are insufficient to support efficient inference at the current input resolution, and the resolution needs to be reduced to decrease computation and memory usage. The input resolution of the lightweight detection model is then adjusted to a second resolution, which is lower than the current resolution.

[0122] The second resolution is predetermined based on the minimum input size required for the lightweight detection model to maintain effective detection accuracy and the resource constraints of edge devices. It is gradually reduced to a preset low resolution level from the current input resolution. For example, if the minimum input size required for the model to maintain effective detection accuracy is 320×320 pixels, the second resolution is set to 320×320 pixels; if the current resolution is 640×640 pixels, it is reduced to 320×320 pixels.

[0123] For example, the available computing power in the real-time resource status information is 80 GFLOPS, and the computing power threshold is 100 GFLOPS. 80 GFLOPS is lower than 100 GFLOPS, which meets the resource shortage condition. The current input resolution is 640×640 pixels. Adjusting the input resolution to a second resolution of 480×480 pixels reduces the computational load and memory usage.

[0124] Finally, when the reliability of the defect detection result is higher than the second reliability threshold and the scene change is lower than the second change threshold, the input resolution is adjusted to the third resolution, which is lower than the current resolution. When the reliability is higher than the second reliability threshold and the scene change is lower than the second change threshold, it indicates that the current detection result is highly reliable and the scene content is stable. The input resolution can be reduced to reduce computational resource consumption without significantly affecting the detection accuracy.

[0125] The second reliability threshold is based on the reliability statistical distribution of samples with reliable detection results and stable scenarios in historical inspections, and is taken as the median or mean of the distribution. The second variation threshold is pre-set based on the highest scene variation tolerance limit that the lightweight detection model can maintain effective detection accuracy after the input resolution is reduced, combined with the frequency requirement of edge devices to reduce computing load when resources are tight.

[0126] The third resolution is determined in advance based on the minimum input size that the lightweight detection model can maintain effective detection accuracy, combined with the minimum resolution requirement of the current defect type for image details, and uses the minimum input size supported during model training as the lower limit.

[0127] Specifically, for burst defects in insulator strings and overheating defects in clamps, due to the small defect area and rich texture details, a relatively high resolution is required to retain sufficient edge and texture information. Therefore, a higher lower limit is set, such as no less than 320×320 pixels. For structural defects in bolts and crossarms, due to the larger defect area and obvious morphological features, the detection accuracy is less sensitive to resolution. Therefore, a lower lower limit can be set, such as no less than 224×224 pixels. The third resolution can be equal to the second resolution, or it can be further reduced to below the second resolution based on the stability and reliability level of the scene, but it must not be lower than the minimum input size supported during model training. The minimum input size supported during model training is determined by the downsampling factor in the model structure. For example, the backbone network of the YOLOv8 model contains 5 downsampling operations with a step size of 2, and the overall downsampling factor is 32. The input size must be a multiple of 32, and the minimum input size is 320×320 pixels or 224×224 pixels. The specific value of the third resolution is preset within the above constraints according to the actual detection task requirements and remains fixed during operation.

[0128] For example, suppose the minimum reliability for each detection target in the defect detection results is 0.92, the second reliability threshold is 0.85, the scene change level is 0.95, and the second change threshold is 0.1. The reliability of 0.92 is higher than the second reliability threshold of 0.85, and the scene change level of 0.95 is lower than the second change threshold of 0.1. The condition is met. Given that the current input resolution is 640×640 pixels, the input resolution is adjusted to a third resolution of 320×320 pixels.

[0129] In this embodiment of the invention, the similarity index of the previous frame of the inspection image is calculated as a measure of the degree of scene change, providing a quantitative basis for judging the dimension of scene change. When the reliability is below a first reliability threshold and the degree of scene change is below a first change threshold, the input resolution is increased. When the scene is stable and the detection result is unreliable, image details are added to improve subsequent detection accuracy. When resources are scarce, the input resolution is reduced, effectively reducing computation and memory usage, avoiding increased inference latency or device overheating due to insufficient resources. When the reliability is above a second reliability threshold and the degree of scene change is below a second change threshold, the input resolution is reduced, minimizing unnecessary computational resource consumption while ensuring detection accuracy. Through the above-mentioned multi-dimensional dynamic resolution adjustment mechanism, this invention achieves a real-time balance between detection accuracy and computational efficiency, improving the continuous operation capability of edge devices under resource-constrained conditions.

[0130] S400: When the defect detection result does not meet the preset quality conditions, the current inspection image, defect detection result and real-time resource status information are used as feedback samples to update the lightweight model configuration pool.

[0131] After the edge device completes defect detection on the current inspection image and dynamically adjusts the input resolution, if the defect detection result does not meet the preset quality conditions, it indicates that the current lightweight model configuration is insufficient to meet the inspection requirements in this detection scenario. If inference continues based solely on the current configuration without utilizing the detected sample, poor detection quality may still occur in similar scenarios later. Furthermore, the edge device will continuously encounter new scene distributions and defect patterns during long-term operation, and the fixed configuration pool cannot be updated adaptively. Therefore, it is necessary to upload the detected samples that do not meet the preset quality conditions as feedback samples to the central server, evaluate the effectiveness of each candidate lightweight model configuration, update the overall fit, generate an updated lightweight model configuration pool, and distribute it to the edge device to achieve continuous evolution of model configuration.

[0132] Step S400 in the method provided in this embodiment of the invention includes: When the lowest reliability among the various reliability values ​​corresponding to the defect detection result is lower than the preset reliability threshold, it is confirmed that the defect detection result does not meet the preset quality conditions, and the current inspection image, defect detection result and real-time resource status information are associated and stored as a feedback sample. Upload the feedback samples to the central server; In the central server, feedback samples are used to evaluate the configuration effectiveness of each candidate lightweight model configuration, and the detection accuracy of each candidate lightweight model configuration on the feedback samples is obtained as the feedback fit of each candidate lightweight model configuration. The overall fit of each candidate lightweight model configuration is updated based on the feedback fit of each candidate lightweight model configuration, and an updated lightweight model configuration pool is generated. The updated lightweight model configuration pool will be distributed to edge devices.

[0133] First, when the lowest reliability among the various reliability levels corresponding to the defect detection result is lower than a preset reliability threshold, it is confirmed that the defect detection result does not meet the preset quality conditions. The current inspection image, defect detection result, and real-time resource status information are then associated and stored as a feedback sample. The preset reliability threshold is a pre-set critical reliability value used to determine whether the defect detection result meets the preset quality conditions. The preset quality condition is that the lowest reliability among the various reliability levels corresponding to the defect detection result is not lower than the preset reliability threshold. The feedback sample is combined data formed by establishing the association between the current inspection image, defect detection result, and real-time resource status information, and is used for subsequent effectiveness evaluation of each candidate lightweight model configuration.

[0134] For example, the defect detection result includes three detection targets with reliability values ​​of 0.92, 0.78, and 0.65, respectively, with a minimum reliability of 0.65. The preset reliability threshold is 0.7. If the minimum reliability of 0.65 is lower than the preset reliability threshold of 0.7, it is confirmed that the defect detection result does not meet the preset quality conditions. The current inspection image, defect detection result, and real-time resource status information are associated and stored as a feedback sample.

[0135] The preset reliability threshold is a dynamic threshold, which is determined based on the detection target information. When the detection target information indicates that the current detection target is a Class I device, the preset reliability threshold is the first threshold value; When the detection target information indicates that the current detection target is a second type of device, the preset reliability threshold is the second threshold value; The first category of equipment consists of insulator strings or clamps, while the second category consists of bolts or crossarms. The first threshold value is higher than the second threshold value.

[0136] The first threshold is a preset reliability threshold for insulator strings and clamps, while the second threshold is a preset reliability threshold for bolts and crossarms. Defects in insulator strings and clamps have a significant impact on the safe operation of the power grid, requiring higher reliability requirements; therefore, the first threshold is higher than the second threshold.

[0137] Specifically, equipment type tags are extracted from the detection target information generated in S100. These tags are then matched against preset equipment classification rules to determine whether the current detection target belongs to Category 1 or Category 2 equipment. When the detection target information indicates that the current detection target is an insulator string or clamp, a preset reliability threshold is set as the first threshold value. When the detection target information indicates that the current detection target is a bolt or crossarm, a preset reliability threshold is set as the second threshold value. The specific values ​​of the first and second threshold values ​​are preset based on the actual reliability requirements for defect detection of various types of equipment in historical inspections, with the first threshold value being higher than the second threshold value.

[0138] For example, the device type label in the detection target information generated in S100 is insulator string. In the preset device classification rules, insulator strings belong to the first category of equipment, with a corresponding first threshold value of 0.7. Bolts belong to the second category of equipment, with a corresponding second threshold value of 0.5. If the current detection target is an insulator string, the preset reliability threshold is set to the first threshold value of 0.7. If the current detection target is a bolt, the preset reliability threshold is set to the second threshold value of 0.5. Since 0.7 is higher than 0.5, the reliability requirement for insulator strings is higher than that for bolts.

[0139] Secondly, the feedback samples are uploaded to the central server. The central server, a cloud-based computing device, possesses richer computing and storage resources than edge devices and is used to perform performance evaluation of candidate lightweight model configurations and update the configuration pool. Edge devices send feedback samples to the central server via wireless communication networks. The feedback samples carry the edge device's device identifier and the current version number of the lightweight model configuration pool when uploaded. For example, if an edge device uploads feedback samples to the central server via a 5G communication module, the uploaded data includes the edge device ID and the lightweight model configuration pool version number.

[0140] Next, in the central server, feedback samples are used to evaluate the configuration effectiveness of each candidate lightweight model configuration. The detection accuracy of each candidate lightweight model configuration on the feedback samples is obtained, serving as the feedback fit of each candidate lightweight model configuration. Configuration effectiveness evaluation refers to the process of testing and evaluating the detection performance of each candidate lightweight model configuration using feedback samples. Feedback fit is a numerical value used to quantify the detection accuracy of a candidate lightweight model configuration on the feedback samples; a higher feedback fit indicates that the candidate configuration performs better on the current feedback samples.

[0141] Specifically, after receiving feedback samples uploaded by edge devices, the central server extracts the current inspection image from the feedback samples. For each candidate lightweight model configuration in the lightweight model configuration pool, the lightweight detection model corresponding to the candidate configuration is loaded in the simulation environment of the central server. The current inspection image is input into the model for forward inference calculation to obtain the prediction result. The defect location bounding box in the prediction result is compared with the defect location bounding box in the feedback sample, and the overlap between the predicted bounding box and the ground truth bounding box is calculated. The calculation method of the overlap is the same as that in S200. When the overlap is greater than the preset overlap threshold, it is determined to be a correct detection. The detection accuracy is calculated based on the proportion of the number of correct detections to the total number of labeled defects. The detection accuracy is expressed as a percentage, and its numerical part is taken as the feedback fit of the candidate lightweight model configuration. The above evaluation operation is performed on each candidate lightweight model configuration in the lightweight model configuration pool to obtain the feedback fit of each candidate lightweight model configuration.

[0142] For example, the lightweight model configuration pool contains four candidate lightweight model configurations. The central server extracts the current inspection image from the feedback samples and loads the lightweight detection models corresponding to the four candidate configurations to perform inference on the current inspection image. The detection accuracy of the first candidate configuration is 92.5%, and the feedback fit is 92.5. The detection accuracy of the second candidate configuration is 90.1%, and the feedback fit is 90.1%. The detection accuracy of the third candidate configuration is 88.7%, and the feedback fit is 88.7%. The detection accuracy of the fourth candidate configuration is 91.8%, and the feedback fit is 91.8%.

[0143] Then, based on the feedback fit of each candidate lightweight model configuration, the overall fit of each candidate lightweight model configuration is updated, generating an updated lightweight model configuration pool. The overall fit is a quantitative value used to comprehensively evaluate the overall performance of candidate lightweight model configurations across three dimensions: detection accuracy, inference latency, and resource consumption.

[0144] Specifically, for each candidate lightweight model configuration in the lightweight model configuration pool, the current overall fit and feedback fit are obtained. The feedback fit and the current overall fit are then weighted and fused to obtain the updated overall fit. The weighted fusion method is as follows: Updated overall fit = Current overall fit × First smoothing coefficient + Feedback fit × Second smoothing coefficient, where the sum of the first and second smoothing coefficients is 1. The specific values ​​of the first and second smoothing coefficients are pre-set based on the system's confidence level for historical evaluations and the latest feedback. The above update operation is performed on each candidate lightweight model configuration in the lightweight model configuration pool, and the updated candidate lightweight model configurations and their corresponding updated overall fits are saved to generate an updated lightweight model configuration pool.

[0145] For example, the first candidate configuration currently has an overall fit of 78.5 and a feedback fit of 92.5. The first smoothing coefficient is 0.7, and the second smoothing coefficient is 0.3. The updated overall fit = 78.5 × 0.7 + 92.5 × 0.3 = 82.70. The second candidate configuration currently has an overall fit of 74.92 and a feedback fit of 90.1. The updated overall fit = 74.92 × 0.7 + 90.1 × 0.3 = 79.47. The third candidate configuration currently has an overall fit of 72.96 and a feedback fit of 88.7. The updated overall fit = 72.96 × 0.7 + 88.7 × 0.3 = 77.68. The fourth candidate configuration currently has an overall fit of 77.10 and a feedback fit of 91.8. The updated overall fit score is 77.10 × 0.7 + 91.8 × 0.3 = 81.51. Save the four candidate configurations and their updated overall fit scores to generate an updated lightweight model configuration pool.

[0146] Finally, the updated lightweight model configuration pool is distributed to the edge devices. The central server sends the updated lightweight model configuration pool to the corresponding edge devices via a wireless communication network. After receiving the updated lightweight model configuration pool, the edge devices store it in their local memory, replacing the original lightweight model configuration pool, for configuration selection in subsequent detection tasks. For example, the central server distributes an updated lightweight model configuration pool containing four candidate configurations and their updated comprehensive fit to the edge devices via a 5G communication module. After receiving it, the edge devices store the updated lightweight model configuration pool in their local memory for configuration selection in the next frame of the inspection image.

[0147] In this embodiment of the invention, when the minimum reliability is lower than a preset reliability threshold, the current inspection image, defect detection results, and real-time resource status information are associated and stored as feedback samples, realizing automated collection of feedback samples. The feedback samples are uploaded to the central server, providing a data source for cloud-based performance evaluation. The feedback samples are used to evaluate the performance of each candidate lightweight model configuration, obtaining the feedback fit, thus quantifying the performance of candidate configurations on real feedback samples. The overall fit of each candidate lightweight model configuration is updated based on the feedback fit, enabling continuous optimization of the configuration pool according to actual detection feedback. The updated lightweight model configuration pool is then distributed to edge devices, completing a full closed loop from edge detection to cloud evaluation and edge deployment. This invention achieves closed-loop optimization and continuous evolution of the lightweight model configuration pool, enabling model configurations to adaptively update with changes in actual detection scenarios, effectively improving the detection adaptability and reliability of edge devices during long-term operation.

[0148] Through the specific implementation methods described above, the embodiments of the present invention achieve the following technical effects: This invention provides a lightweight configuration method for real-time power grid detection models in edge computing environments. By acquiring real-time resource status information of edge devices and detection target information of the current inspection image, a target configuration scheme matching the current detection requirements and resource conditions is dynamically selected from a lightweight model configuration pool for inference. This allows the model configuration to adaptively adjust based on device type labels and real-time resource status, effectively solving the problem that fixed model configurations are difficult to adapt to differences in detection targets and dynamic fluctuations in edge resources. During inference, the input resolution is dynamically adjusted based on the reliability of defect detection results, the degree of scene change, and real-time resource status information, optimizing the resource utilization efficiency of edge devices while ensuring detection accuracy. When the reliability is lower than a preset threshold, the current inspection image, defect detection results, and real-time resource status information are used as feedback samples to update the lightweight model configuration pool, achieving closed-loop optimization and continuous evolution of the configuration. This invention can dynamically adapt the optimal inference configuration according to different detection targets and the real-time status of edge devices, improving the resource utilization efficiency of edge devices while ensuring detection accuracy, effectively enhancing the dynamic adaptability of lightweight model configuration to detection scenarios and resource status, and improving the overall performance of edge detection.

[0149] It should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for lightweight configuration of a power grid real-time detection model for edge computing environments, characterized in that, The method includes: Acquire real-time resource status information and current inspection images of edge devices, perform target recognition on the current inspection images, and obtain detection target information; Based on the detection target information and the real-time resource status information, a target configuration scheme is selected from the lightweight model configuration pool, the lightweight detection model corresponding to the target configuration scheme is called, inference is performed on the current inspection image, and the defect detection result is output. The input resolution of the lightweight detection model is dynamically adjusted based on the defect detection results, the degree of scene change in the current inspection image, and the real-time resource status information. When the defect detection result does not meet the preset quality conditions, the current inspection image, the defect detection result, and the real-time resource status information are used as feedback samples to update the lightweight model configuration pool.

2. The edge computing environment-oriented power grid real-time detection model lightweight configuration method of claim 1, wherein, Acquire real-time resource status information and current inspection images of edge devices, perform target recognition on the current inspection images to obtain target detection information, including: The available computing power, available memory, and current power consumption of the edge device are obtained as the real-time resource status information. The current inspection image collected by the edge device is acquired, and the current inspection image is input into a preset object recognition network to identify the equipment type label and defect type label of the power grid equipment. The device type label and the defect type label are associated as the detection target information.

3. The edge computing environment-oriented power grid real-time detection model lightweight configuration method of claim 1, wherein, The lightweight model configuration pool is generated in the following ways: Obtain the basic detection model, establish the data dependencies between the functional units in the basic detection model, and determine the adjustable units, dependent units, and sensitive units; The adjustable unit is subjected to structural equivalence processing. The convolutional layer and batch normalization layer connected in sequence in the adjustable unit are identified. The convolutional kernel parameters and bias parameters of the convolutional layer are fused with the scaling parameters and translation parameters of the batch normalization layer into equivalent single convolutional layer parameters. The equivalent single convolutional layer parameters are used to replace the sequentially connected convolutional layer and batch normalization layer to obtain the first candidate lightweight model configuration. Redundant units are reduced in the adjustable units of the first candidate lightweight model configuration. The importance score of each convolutional channel is determined based on the weight parameter distribution characteristics and activation response characteristics of each convolutional channel. Convolutional channels with importance scores lower than a preset threshold are deleted. The deleted model is fine-tuned and trained to obtain the second candidate lightweight model configuration. Numerical precision adaptation is performed on the adjustable units in the second candidate lightweight model configuration. The quantization scaling factor and zero offset of each layer are determined according to the distribution range of the weight parameters and the distribution range of the activation values ​​of each network layer. The floating-point parameters are mapped to low-bit integer parameters to obtain the third candidate lightweight model configuration. The adjustable units in the third candidate lightweight model configuration are subjected to computation graph fusion, which merges multiple computation units that can be executed continuously and meet the equivalence conditions into a fused computation unit to obtain the fourth candidate lightweight model configuration. The dependent units are kept in sync with the adjustable units, and a retention ratio lower limit, a precision lower limit, or a replacement restriction is set for the sensitive units. The first candidate lightweight model configuration, the second candidate lightweight model configuration, the third candidate lightweight model configuration, and the fourth candidate lightweight model configuration are saved as a lightweight model configuration pool.

4. The edge computing environment-oriented power grid real-time detection model lightweight configuration method of claim 1, wherein, Based on the detection target information and the real-time resource status information, a target configuration scheme is selected from the lightweight model configuration pool, including: Obtain the detection accuracy evaluation value, inference latency evaluation value, and resource consumption evaluation value of each candidate lightweight model configuration in the lightweight model configuration pool; The accuracy preference coefficient is determined based on the detection target information, and the latency preference coefficient and resource preference coefficient are determined based on the real-time resource status information. The detection accuracy evaluation value, inference latency evaluation value, and resource consumption evaluation value corresponding to each candidate lightweight model configuration are weighted and calculated using the accuracy preference coefficient, the latency preference coefficient, and the resource preference coefficient, respectively. The weighted calculation results of each candidate lightweight model configuration are then fused to obtain the comprehensive fit of each candidate lightweight model configuration. The candidate lightweight model configuration with the highest overall adaptability is selected as the target configuration scheme.

5. The edge computing environment-oriented power grid real-time detection model lightweight configuration method of claim 4, wherein, Obtain the detection accuracy evaluation value, inference latency evaluation value, and resource consumption evaluation value for each candidate lightweight model configuration in the lightweight model configuration pool, including: Obtain a preset verification dataset, input the verification dataset into the lightweight detection model corresponding to each candidate lightweight model configuration, and obtain the detection accuracy of each lightweight detection model on the verification dataset as the detection accuracy evaluation value of each candidate lightweight model configuration. Based on real-time resource status information, the inference speed of each candidate lightweight model configuration is simulated to obtain the inference latency of each candidate lightweight model configuration on the edge device, which is used as the inference latency evaluation value of each candidate lightweight model configuration. Obtain the number of parameters configured for each candidate lightweight model, and calculate the memory usage of each candidate lightweight model configured on the edge device based on the number of parameters, which serves as the resource usage evaluation value for each candidate lightweight model configuration.

6. The edge computing environment-oriented power grid real-time detection model lightweight configuration method of claim 4, wherein, Determining an accuracy preference coefficient based on the detection target information, and determining a latency preference coefficient and a resource preference coefficient based on the real-time resource status information, including: Obtain the device type label from the target information, and query the preset device type-precision preference coefficient mapping table according to the device type label to obtain the precision preference coefficient. Among them, the insulator string and the clamp correspond to the first precision preference coefficient, and the bolt and the crossarm correspond to the second precision preference coefficient. The first precision preference coefficient is higher than the second precision preference coefficient. Obtain the available computing power value, available memory value, and current power consumption value from the real-time resource status information. When the available computing power value is lower than the computing power threshold, the available memory value is lower than the memory threshold, or the current power consumption value is higher than the power consumption threshold, determine that the latency preference coefficient and the resource preference coefficient are in a high-weight state. When the available computing power value is not lower than the computing power threshold, the available memory value is not lower than the memory threshold, and the current power consumption value is not higher than the power consumption threshold, the latency preference coefficient and the resource preference coefficient are determined to be in a low-weight state.

7. The edge computing environment-oriented power grid real-time detection model lightweight configuration method of claim 1, wherein, The lightweight detection model corresponding to the target configuration scheme is invoked to perform inference on the current inspection image and output the defect detection results, including: Load the corresponding lightweight detection model according to the target configuration scheme, and load the structural parameters and weight parameters in the target configuration scheme into the lightweight detection model; The current inspection image is input into the lightweight detection model. After forward inference calculation by the lightweight detection model, the defect category, defect location bounding box and corresponding reliability of each detected target in the current inspection image are output. Non-maximum suppression processing is performed on the bounding boxes at the defect locations to remove redundant bounding boxes with an overlap degree higher than a preset overlap threshold; The defect category, defect location bounding box, and corresponding reliability after nonmaximum suppression processing are associated with the defect detection result.

8. The edge computing environment-oriented power grid real-time detection model lightweight configuration method of claim 1, wherein, Based on the defect detection results, the degree of scene change in the current inspection image, and the real-time resource status information, the input resolution of the lightweight detection model is dynamically adjusted, including: The previous frame inspection image collected by the edge device is acquired, and the image similarity index between the current inspection image and the previous frame inspection image is calculated as the degree of scene change. Obtain the lowest reliability among the reliability values ​​corresponding to each detection target in the defect detection results. When the lowest reliability is lower than a first reliability threshold and the degree of scene change is lower than a first change threshold, adjust the input resolution to a first resolution, where the first resolution is higher than the current resolution. When the available computing power is lower than the computing power threshold, the available memory is lower than the memory threshold, or the current power consumption is higher than the power consumption threshold, the input resolution is adjusted to a second resolution, which is lower than the current resolution. When the minimum reliability is higher than the second reliability threshold and the degree of scene change is lower than the second change threshold, the input resolution is adjusted to the third resolution, which is lower than the current resolution. 9.The method of claim 1, wherein, When the defect detection result does not meet the preset quality conditions, the current inspection image, the defect detection result, and the real-time resource status information are used as feedback samples to update the lightweight model configuration pool, including: When the lowest reliability among the various reliability values ​​corresponding to the defect detection result is detected to be lower than the preset reliability threshold, it is confirmed that the defect detection result does not meet the preset quality conditions, and the current inspection image, the defect detection result, and the real-time resource status information are associated and stored as a feedback sample. The feedback sample is uploaded to the central server; In the central server, the configuration effectiveness of each candidate lightweight model configuration is evaluated using the feedback samples, and the detection accuracy of each candidate lightweight model configuration on the feedback samples is obtained as the feedback fit of each candidate lightweight model configuration. The overall fit of each candidate lightweight model configuration is updated based on the feedback fit of each candidate lightweight model configuration, and an updated lightweight model configuration pool is generated. The updated lightweight model configuration pool is distributed to the edge device.

10. The lightweight configuration method for a real-time power grid detection model for edge computing environments as described in claim 9, characterized in that, The preset reliability threshold is a dynamic threshold, and the dynamic threshold is determined based on the detection target information: When the detection target information indicates that the current detection target is a first type of device, the preset reliability threshold is a first threshold value; When the detection target information indicates that the current detection target is a second type of device, the preset reliability threshold is a second threshold value; The first type of equipment is an insulator string or clamp, and the second type of equipment is a bolt or crossarm. The first threshold value is higher than the second threshold value.