Lightweight defect detection model generation method, device and robot
By adopting a lightweight defect detection model generation method, the problems of redundant algorithm modules and insufficient computing resources in substation inspection are solved, and the collaborative complementarity and efficient recognition of multispectral images are realized, which is adapted to the real-time requirements of inspection robots.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA YANGTZE POWER
- Filing Date
- 2026-03-17
- Publication Date
- 2026-07-14
AI Technical Summary
Existing automated inspection methods in substations suffer from redundant algorithm modules, high integration complexity, difficulty in achieving feature collaboration and complementarity among multimodal data, and high computational requirements for large models of deep learning algorithms, making them unsuitable for effective deployment on robotic platforms.
A lightweight defect detection model generation method is adopted. A lightweight student model is trained by a knowledge distillation loss function. A lightweight convolution module and a channel attention module are combined to perform multispectral image preprocessing and feature extraction, so as to achieve synergistic complementarity and efficient recognition of multispectral images.
When edge computing power is limited, lightweight models can approach the performance of large network models, enabling efficient identification of substation equipment defects, reducing computing resource requirements, and adapting to the real-time requirements of inspection robots.
Smart Images

Figure CN122391076A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent defect detection technology for substation equipment, specifically relating to a lightweight defect detection model generation method, equipment, and robot. Background Technology
[0002] With the rapid development of society and the economy, the demand for electricity resources continues to grow. As a key node in the power system, the safety and stable operation of substation equipment are becoming increasingly important. Traditional manual inspection methods are no longer sufficient to meet the operation and maintenance needs of large-scale substations, while automated inspection technology based on wheeled robots is gradually becoming the industry mainstream. However, in practical applications, existing automated inspection methods still face significant technical bottlenecks: First, substation inspection tasks cover a wide variety of equipment types and complex defect morphologies. When faced with multispectral images, a comprehensive judgment must be made based on multiple imaging modes. Existing automated inspection methods typically design independent recognition models for a single imaging mode, resulting in redundant algorithm modules, high integration complexity, and difficulty in achieving feature synergy and complementarity between multimodal data.
[0003] Secondly, existing automated inspection methods generally employ deep neural network models, which can effectively replace manual inspections and save a significant amount of manpower. With the widespread use of robotic automated inspections in substations, the total workload of indoor and outdoor inspections in large substations is substantial, and the types of substation equipment are complex and varied. Different inspection needs require different identification methods and detection models. While large models in deep learning algorithms possess better recognition capabilities, they also require higher computing power and inference latency. In practical scenarios, the computing power of the robot itself is limited, while the robot's motion inspection demands high performance, making it impossible to use large-scale deep network models with high-performance algorithms. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a lightweight defect detection model generation method, equipment and robot to resolve the contradiction between the high precision requirements of inspection tasks and the limited computing power of robot platforms in the prior art.
[0005] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is: a lightweight defect detection model generation method, comprising the following steps: The original multispectral images of the substation equipment are acquired, and the original multispectral images are preprocessed to obtain optimized multispectral images. The optimized multispectral image is input into the pre-trained teacher model to generate soft labels for the teacher model and intermediate layer feature maps for the teacher model. Using the soft labels and intermediate layer feature maps of the teacher model as supervision information, a lightweight student model is trained through the knowledge distillation loss function to obtain a lightweight defect detection model. The lightweight student model is a lightweight network that integrates a lightweight convolution module and a channel attention module.
[0006] In a preferred embodiment, the step of preprocessing the original multispectral image to obtain an optimized multispectral image specifically includes: S1011. Separate the original multispectral image into a visible light channel image and a near-infrared channel image; S1012. Normalize the visible light channel image and the near-infrared channel image to obtain the first visible light channel image and the first near-infrared channel image. S1013. Perform contrast-limited adaptive histogram equalization processing on the first visible light channel image and the first near-infrared channel image respectively to obtain the second visible light channel image and the second near-infrared channel image. S1014. Weighted fusion of the second visible light channel image and the second near-infrared channel image is performed to obtain a fused image; S1015. Perform adaptive noise suppression based on the overall image variance on the fused image to obtain the optimized multispectral image.
[0007] In a preferred embodiment, in step S1012, when normalizing the visible light channel image and the near-infrared channel image, the image with a small pixel variance is first white balanced and then normalized. The normalization process maps the image pixel values to the [0,1] interval.
[0008] In a preferred embodiment, step S1015, which involves adaptive noise suppression of the fused image based on the overall image variance to obtain an optimized multispectral image, specifically includes: Noise assessment is performed on the fused image, and local variance of the image is calculated; If the local variance of the image is lower than a preset threshold, bilateral filtering is used to suppress noise in the fused image; if the local variance of the image is higher than or equal to the preset threshold, nonlocal mean filtering is used to suppress noise in the fused image. Guided filtering is used to process the noise-suppressed fused image to obtain an optimized multispectral image.
[0009] In a preferred embodiment, the soft labels of the teacher model are generated by temperature scaling of the original prediction output of the teacher model, and the soft labels are converted into the probability distribution of the teacher model using the Softmax function. .
[0010] In the preferred embodiment, the probability distribution of the teacher model is expressed as follows: ; in, This represents the probability distribution of the teacher model's output. This represents the original prediction output of the teacher model. Indicates temperature parameter, i Indicates the category.
[0011] In the preferred embodiment, the step of using the soft labels and intermediate layer feature maps of the teacher model as supervision information, and training a lightweight student model through a knowledge distillation loss function to obtain a lightweight defect detection model, specifically includes: S1031. Temperature-scale the original prediction output of the lightweight student model to generate soft predictions, and then convert the soft predictions into the probability distribution of the lightweight student model using the Softmax function. Based on soft labeling and soft prediction, the divergence loss is calculated, and the soft prediction distillation loss is obtained. S1032. Perform convolution and mean squared error loss calculation on the intermediate layer feature maps of the backbone network of the lightweight student model and the intermediate layer feature maps of the backbone network of the teacher model to obtain the intermediate layer feature distillation loss. S1033. Weighted summation of soft prediction distillation loss, intermediate layer feature distillation loss and cross-entropy loss to obtain the total loss function; S1034. Train a lightweight student model based on the total loss function to obtain a lightweight defect detection model.
[0012] In the preferred embodiment, the specific formula for calculating the soft-predictive distillation loss is as follows: ; in, , Indicates KL divergence; This represents the probability distribution output by the lightweight student model; This represents the probability distribution of the teacher model's output; Indicates temperature parameter, i Indicates the category.
[0013] In a preferred embodiment, the specific method for obtaining the intermediate layer characteristic distillation loss is as follows: Extract the same-scale layer and same-semantic layer features of the multi-scale feature pyramid network of the teacher model, and extract the same-scale layer and same-semantic layer features of the multi-scale feature pyramid network of the lightweight student model; The same-scale and same-semantic layer features of the lightweight student model multi-scale feature pyramid network are mapped to the same-scale and same-semantic layer features of the teacher model multi-scale feature pyramid network using 1×1 convolution. The intermediate layer feature distillation loss is obtained by summing the features of each layer of the teacher model network with the mean squared error loss of the mapped lightweight student model.
[0014] In a preferred embodiment, the formula for calculating the characteristic distillation loss of the intermediate layer is: ; in, This represents the characteristic distillation loss of the intermediate layer; Indicates the first Feature dimension diagram of the tiered teacher model; Indicates the first Feature dimension diagram of a lightweight student model; for convolution, To reduce the feature dimensions of the student model, For the feature dimensions of the teacher model, This indicates a lightweight student model. Dimensional feature map convolution mapping to the teacher model Dimensional feature map, used to align the dimensions and scales of network channels in the teacher network and student network.
[0015] In the preferred embodiment, the formula for calculating the total loss function is: ; in, To predict distillation losses using soft methods; This represents the characteristic distillation loss of the intermediate layer; Cross-entropy loss; for Weight parameters; for Weight parameters; for The weight parameters.
[0016] In a preferred embodiment, the lightweight convolution module includes the inverted residual structure of MobileNetV3 and the redundant feature elimination module of GhostNet.
[0017] In a preferred embodiment, the method further includes: performing sparse training on each network channel in the lightweight defect detection model based on the lightweight defect detection model, and pruning the lightweight defect detection model according to the learnable scalar gating of each network channel after sparse training.
[0018] In the preferred scheme, the lightweight defect detection model undergoes sparse training and pruning, as follows: Add learnable scalar gating to each convolutional layer of the lightweight defect detection model; A sparse regularization term is added to the knowledge distillation loss function to train the learnable scalar gate, and training continues until the learnable scalar gate converges stably. In the lightweight defect detection model, convolutional network channels with learnable scalar gating below a preset gating threshold are pruned.
[0019] The present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a program executable on the processor, and when the program is executed by the processor, the electronic device performs any of the methods described above.
[0020] The present invention also provides a substation inspection robot, including a robot body and a multispectral image acquisition module and an edge computing module disposed on the robot body, wherein the edge computing module is equipped with a lightweight defect detection model generated by any of the methods described above.
[0021] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method described above.
[0022] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method described above.
[0023] The present invention provides a lightweight defect detection model generation method, device, and robot, which have the following beneficial effects: 1. Under the condition of limited computing power at the edge, this invention transfers some of the prior information of defects identified by the algorithm of large model to the algorithm of lightweight small model. This enables the lightweight defect detection model to maintain high efficiency while being able to approach the performance of large network model as closely as possible, thereby achieving efficient identification of defects in substation equipment, optimizing the algorithm identification and inference time, and solving the contradiction between the high precision requirements of inspection tasks and the limited computing power of robot platforms in the prior art.
[0024] 2. A preprocessing workflow was designed for the imaging characteristics of multispectral images from substations. Through steps such as channel separation, normalization, contrast enhancement, weighted fusion, and adaptive noise suppression based on image variance, the synergistic complementarity of visible light and near-infrared channel features is achieved. This effectively eliminates interference from complex backgrounds, weakens the influence of noise, and highlights defect features, significantly improving the image quality of the input model. This provides a high-quality data foundation for subsequent defect detection, making the model more accurate in identifying defects in various substation equipment and more adaptable to different imaging environments and equipment types.
[0025] 3. The lightweight student model integrates the inverted residual structure of MobileNetV3 and the redundant feature elimination module of GhostNet, while introducing a channel attention module to enhance typical defect signals. This simplifies the network structure and reduces redundant computation while ensuring the model's feature representation capability. Combined with a bidirectional feature pyramid structure, it achieves multi-dimensional feature aggregation of defects at different scales, balancing lightweight computation and detection accuracy. This significantly reduces the model's demand for hardware computing power and storage resources, making it suitable for the edge computing deployment requirements of inspection robots.
[0026] 4. Based on the lightweight model, sparse training and dynamic channel pruning are performed. By adding learnable scalar gating to the convolutional layer, the model can autonomously determine which network channels to retain and prune, avoiding the blindness of manually setting the pruning ratio. After pruning, the number of model parameters and computational cost are further reduced, the inference efficiency is significantly improved, the algorithm recognition and inference time is effectively shortened, and it is adapted to the high real-time requirements of mobile inspection robots.
[0027] 5. The lightweight defect detection model of this invention can be directly deployed on the edge computing module of the inspection robot. The multispectral image acquisition method is compatible with various devices such as filter wheel cameras and snapshot array cameras, and is suitable for different application scenarios such as fixed monitoring and mobile inspection of substations. The model training and optimization process fully considers the actual factors such as the distribution of substation equipment defects and the real-time requirements of inspection tasks, so that the technical solution can be quickly implemented and adapted to the operation and maintenance needs of large-scale substations, effectively replacing traditional manual inspection, saving labor costs, and improving the intelligence and automation level of substation equipment inspection. Attached Figure Description
[0028] The accompanying drawings, which are provided to further illustrate the invention and constitute a part of this invention, do not constitute an undue limitation thereof. In the drawings: Figure 1 This is a flowchart of a defect detection model generation method provided in an embodiment of the present invention; Figure 2 A flowchart of a method for preprocessing an original multispectral image to obtain an optimized multispectral image, provided in an embodiment of the present invention; Figure 3 The flowchart of the method for obtaining a lightweight defect detection model by using soft labels and the intermediate layer feature map as supervision information and training the lightweight student model through the knowledge distillation loss function is provided in the embodiment of the present invention. Figure 4 This is a schematic diagram of the lightweight student model provided in an embodiment of the present invention; Figure 5 This is a schematic diagram of the inverted residual structure of MobileNetV3 provided in an embodiment of the present invention; Figure 6A schematic diagram of the redundant feature elimination module provided in an embodiment of the present invention; Figure 7 A flowchart of a defect detection model generation method provided as another exemplary embodiment of the present invention; Figure 8 This is a block diagram of the electronic device structure. In the diagram: Electronic device 20; Processor 21; Memory 22; Output interface 23; Communication interface 24; Antenna 25. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the invention.
[0030] This invention proposes a lightweight defect detection model generation method, electronic device, and robot. Under the condition of limited edge computing power, it transfers some of the defect prior information identified by the algorithm of large model to the algorithm of lightweight small model. This enables the lightweight defect detection model to maintain high efficiency while being as close as possible to the performance of large network model, realizing efficient identification of substation equipment defects, optimizing the algorithm identification and inference time, and solving the contradiction between the high precision requirements of inspection tasks and the limited computing power of robot platform in the prior art.
[0031] The technical solutions of the present invention will now be described in detail with reference to the accompanying drawings.
[0032] Example 1: like Figure 1 As shown, this embodiment provides a method for generating a defect detection model, which includes the following steps: S101. Acquire the original multispectral image of the substation equipment and perform image preprocessing on the original multispectral image to obtain the optimized multispectral image.
[0033] The multispectral image includes both visible light and infrared images.
[0034] In some embodiments, the multispectral image can be acquired using a multi-sensor beam splitter camera or by using a multi-sensor beam splitter camera equipped with an electromagnetic interference-resistant drone.
[0035] In some embodiments, the acquisition of the multispectral image can also be achieved using a filter wheel camera or a snapshot array camera, wherein the filter wheel camera is suitable for fixed monitoring and the snapshot array camera is suitable for mobile inspection.
[0036] In some embodiments, such as Figure 2As shown, the original multispectral image is preprocessed to obtain an optimized multispectral image, including: S1011. Separate the original multispectral image into a visible light channel image and a near-infrared channel image.
[0037] In some embodiments, the separation of the original multispectral image can be achieved through physical spectroscopic elements and sensor arrays.
[0038] S1012. Normalize the visible light channel image and the near-infrared channel image to obtain the first visible light channel image and the first near-infrared channel image.
[0039] Specifically, the visible light network channel image and the near-infrared network channel image are normalized, including: for images with small pixel variance in the visible light channel image and the near-infrared channel image, white balance is first performed, followed by normalization, to prevent color cast errors from being retained and compromising color fidelity. The visible light channel image and the near-infrared channel image are directly normalized to [0, 1] to eliminate scale differences between features, thereby accelerating model convergence and improving generalization ability.
[0040] S1013. Perform contrast-limited adaptive histogram equalization processing on the first visible light channel image and the first near-infrared channel image respectively to obtain the second visible light channel image and the second near-infrared channel image.
[0041] In some embodiments, performing contrast-limited adaptive histogram equalization on the first visible light channel image and the first near-infrared channel image respectively to obtain a second visible light channel image and a second near-infrared channel image includes: converting the first visible light channel image to the YUV color space, extracting the Y channel, and performing contrast-limited adaptive histogram equalization on the Y channel to enhance local contrast and avoid false colors. The first near-infrared channel image is directly subjected to contrast-limited adaptive histogram equalization to enhance thermal radiation texture features.
[0042] YUV is a color encoding method, where Y represents luminance and UV represents chromaticity components.
[0043] In some embodiments, the first visible light channel image and the first near-infrared channel image can be divided into multiple image blocks of size 8×8 pixels by limiting contrast adaptive histogram equalization processing. A local histogram is calculated for each image block, and an adjustable limiting parameter is introduced during contrast enhancement, with the value of the limiting parameter ranging from 2.0 to 8.0. This embodiment divides the image into multiple image blocks and performs histogram equalization processing separately for each image block to improve local low contrast in the image.
[0044] The value of this limiting parameter is positively correlated with the high-frequency gain coefficient of the image patch, and the high-frequency gain coefficient is inversely proportional to the local variance of the image patch.
[0045] Furthermore, this high-frequency gain coefficient is used to measure the distribution ratio of detailed texture (high-frequency signal) to smooth background (low-frequency signal) in a local area of the image.
[0046] The local variance of an image patch can be calculated using the following formula: ; in, Represents the local variance of an image patch. Represents pixels in an image block. Indicates the resolution within an image patch. This represents the average pixel value within an image patch.
[0047] This embodiment introduces a limiting parameter to avoid excessive image enhancement.
[0048] In some embodiments, the high-frequency gain coefficient G = k / , For local variance, the constraint parameter is c = 2 + 6 × (G / ).
[0049] For example, suppose a 500kV transformer image is generated, k=0.5, and the local variance is... =0.02, then G=25, if =4.72, then c=7.3.
[0050] Specifically, Reflects texture complexity, A larger value indicates richer texture in the image patch, and the corresponding k value needs to be small to suppress excessive image enhancement. A smaller value indicates a smoother background for the image patch, requiring a larger k value to enhance image details.
[0051] S1014. The second visible light channel image and the second near-infrared channel image are weighted and fused to obtain a fused image.
[0052] Specifically, before performing weighted fusion on the second visible light channel image, the second visible light channel image is converted into a grayscale image, which avoids interference from color information, highlights the fusion of texture and thermal radiation features, and reflects the characteristics of multispectral images.
[0053] The expression for the fused image is: ; in, and Indicates the weighting coefficient. This indicates that the second visible light channel image is a grayscale image. This represents the image from the second near-infrared channel. Indicates a fused image. , The value range is 0.2 to 0.5.
[0054] Among them, the weighting coefficient and The value is determined based on the ratio of the variance of the second visible light network channel image to the variance of the second near-infrared network channel image.
[0055] In this embodiment, the visible light channel image and the near-infrared channel image are first contrast-enhanced, and then the optimized visible light channel image and the near-infrared channel image are fused to obtain more comprehensive and robust defect features, providing high-quality input for the subsequent generation of a lightweight defect detection model.
[0056] S1015. Perform adaptive noise suppression based on the overall variance of the image on the fused image to obtain the optimized multispectral image.
[0057] Specifically, the process of performing adaptive noise suppression based on the overall image variance to obtain an optimized multispectral image includes: evaluating the noise of the fused image and calculating the local variance of the image; if the local variance of the image is lower than a preset threshold, using bilateral filtering to suppress noise in the fused image; if the local variance of the image is higher than or equal to the preset threshold, using nonlocal mean filtering to suppress noise in the fused image; and using guided filtering to process the noise-suppressed fused image to obtain the optimized multispectral image.
[0058] In some embodiments, the preset threshold can be set according to the needs of those skilled in the art.
[0059] Specifically, the nonlocal mean filtering finds similar regions in the image on a patch-by-pattern basis and filters out Gaussian noise in the image based on the average value of the similar regions.
[0060] Specifically, for each pixel in an image block, the neighborhood window of that image block is taken as a "reference block". All "candidate blocks" similar to the "reference block" are searched within the search window. The similarity weight between each candidate block and the reference block is calculated, and the denoised value of the pixel is obtained by weighted averaging.
[0061] For example, the search window is set to 21×21, the neighborhood window is set to 7×7, and the similarity weight is controlled by the smoothing intensity. The greater the smoothing intensity, the greater the similarity weight, and the smaller the smoothing intensity, the smaller the similarity weight. The smoothing intensity can be set to a range of 10~20.
[0062] In some embodiments, the diameter range of the bilateral filter can be set to 5 to 10, the variance of color similarity can be set to 75, and the variance of spatial distance can be set to 75.
[0063] The diameter of the bilateral filter is positively correlated with the variance of the image patch; the larger the variance of the image patch, the larger the diameter of the bilateral filter.
[0064] For example, in an insulator crack detection scenario, the limiting parameter of the contrast adaptive histogram can be set to 6 to enhance crack contrast; the diameter of the bilateral filter can be set to 5 to avoid blurring of the insulator edges.
[0065] For example, in the transformer hot spot detection scenario, the limiting parameter of the contrast adaptive histogram can be set to 2 to suppress thermal radiation noise; the smoothing intensity of the nonlocal mean filter can be set to 18 to eliminate thermal diffusion artifacts.
[0066] In this embodiment, guided filtering is applied to the noise-suppressed image to repair the edge blurring caused by the filtering, resulting in an optimized multispectral image.
[0067] In some embodiments, regions with local variance below a preset threshold are designated as low-variance regions. In low-variance regions, i.e., smooth areas such as the sky or a uniform surface, the gain coefficient is automatically increased to enhance contrast and prevent the image from becoming too flat. Regions with local variance above or equal to the preset threshold are designated as high-variance regions. In high-variance regions, i.e., areas rich in detail such as textures or edges, the gain coefficient is automatically decreased to prevent over-enhancement and noise amplification.
[0068] The bilateral filter in this embodiment has relatively low computational complexity and performs well in preserving edge information, making it suitable for real-time processing or large-scale datasets; while the non-local mean filter has higher computational complexity, performs better in denoising and preserving details, and requires more computational resources.
[0069] This embodiment improves the quality of the original multispectral image by performing image preprocessing, eliminating complex background interference, making defect features salient and minimizing noise interference, thereby ensuring that the subsequent lightweight defect detection model can efficiently and accurately identify defects in substation equipment.
[0070] S102. Input the optimized multispectral image into the pre-trained teacher model to generate the soft label of the teacher model and the intermediate layer feature map of the teacher model.
[0071] Specifically, the teacher model is usually a pre-trained model with a large number of parameters and strong performance.
[0072] In some embodiments, the teacher model employs a high-performance network architecture, such as ResNeXt-101+FPN, large variants of the Swing Transformer, and DINO v3, where the large variants of the Swing Transformer mainly include Swing-L and Swing-V2-G.
[0073] In some embodiments, the teacher model supports multi-network channel input, such as 4-network channel fusion, and the input of the teacher model is consistent with the input of the lightweight learning model.
[0074] Specifically, the soft labels of the teacher model are generated by temperature scaling of the original prediction output of the teacher model, and the soft labels are converted into the probability distribution of the teacher model through the Softmax function, the representative formula of which is as follows: ; in, This represents the probability distribution of the teacher model's output. This represents the original prediction output of the teacher model. Indicates temperature parameter, i Indicates the category.
[0075] In some embodiments, The value ranges from 3 to 6, and it linearly decays from 6 to 3 during the teacher model training process.
[0076] In some embodiments, the pre-trained teacher model is trained using a combination of classification loss, regression loss, and localization loss.
[0077] Specifically, first, a multispectral image is input, and random combination augmentation is used. In each training round, one or more combinations are randomly selected from Mixup, Mosaic, or Label Smoothing to process the multispectral image data. Mixup mixes two images proportionally and the labels are mixed synchronously; Mosaic stitches four images into one; Label Smoothing adjusts the confidence of the true label from 1.0 to 0.9.
[0078] Secondly, a classification loss is dynamically selected, choosing either classification cross-entropy loss or Focal loss. If the task involves a large number of categories with uneven distribution (i.e., a long-tail effect, such as a very small number of minority class samples out of 100 defect categories), Focal loss is used to calculate the predicted probability of the true class. Simultaneously, classification cross-entropy is used with added probability weights, i.e., the predicted probability of minority class samples is weighted, for example, weight = 1 / class frequency. Alternatively, classification cross-entropy with probability weights can be used directly, with the weights dynamically adjusted according to class frequency, for example, 0.5 weight for high-frequency classes and 2.0 weight for low-frequency classes. Regression loss is used to measure the difference in offset between the predicted bounding box and the ground truth bounding box. Localization loss is used to measure the overlap and positional deviation between the predicted bounding box and the ground truth bounding box.
[0079] Furthermore, a priority mechanism is used to update the probability weights of the classification loss, regression loss, and localization loss. The optimizer chosen is stochastic gradient descent with a momentum of 0.9, utilizing momentum to accelerate convergence, or weight decay optimization of Adam, which offers high training stability but slightly lower accuracy than stochastic gradient descent. Learning rate and scheduling are configured: stochastic gradient descent is set to 0.01, and weight decay optimization of Adam is set to 1e-4, prioritizing Cosine Annealing or Step LR.
[0080] Finally, limit the number of training epochs and batch size. Set the number of training epochs to 50-200 and the batch size to be set according to the GPU memory capacity to ensure that a single card can accommodate them.
[0081] S103. Using the soft labels of the teacher model and the intermediate layer feature maps of the teacher model as supervision information, the lightweight student model is trained through the knowledge distillation loss function to obtain the lightweight defect detection model.
[0082] The lightweight student model is a lightweight network that integrates a lightweight convolution module and a network channel attention module.
[0083] Specifically, this lightweight student model is a model with a small number of parameters and a simplified structure, with the goal of lightweight deployment.
[0084] Specifically, such as Figure 3 As shown, the lightweight student model is trained using the soft label and the intermediate layer feature map as supervision information, through a knowledge distillation loss function, to obtain a lightweight defect detection model, including: S1031. Temperature scaling is applied to the original prediction output of the lightweight student model to generate a soft prediction. Based on the soft label and the soft prediction, the divergence loss of the soft prediction is calculated to obtain the soft prediction distillation loss.
[0085] Specifically, the original prediction output of the lightweight student model is temperature-scaled to generate a soft prediction, which is then converted into the probability distribution of the lightweight student model using the Softmax function. The specific calculation formula is as follows: ; in, This represents the probability distribution output by the lightweight student model. This represents the raw prediction output of the teacher model. Indicates temperature parameter, i Indicates the category.
[0086] Based on the soft label and the soft prediction, the specific formula for calculating the distillation loss of the soft prediction is as follows: ; in, , This represents the KL divergence.
[0087] Specifically, this KL divergence is also known as relative entropy.
[0088] S1032. Perform convolution and mean squared error loss calculation on the intermediate layer feature maps of the backbone network of the lightweight student model and the intermediate layer feature maps of the backbone network of the teacher model to obtain the intermediate layer feature distillation loss.
[0089] Specifically, the formula for calculating the characteristic distillation loss of this intermediate layer is as follows: ; in, This represents the characteristic distillation loss of the intermediate layer. Indicates the first Feature dimension diagram of the tiered teacher model. Indicates the first Feature dimension diagram of the lightweight student model. for convolution, To reduce the feature dimensions of the student model, These are the feature dimensions of the teacher model. This indicates a lightweight student model. Dimensional feature map convolution mapping to the teacher model Dimensional feature map, used to align the dimensions and scales of network channels in the teacher network and student network.
[0090] S1033. The total loss function is obtained by weighted summation of the soft label distillation loss, the intermediate layer feature distillation loss, and the cross-entropy loss.
[0091] Specifically, the formula for calculating the total loss function is as follows: ; in, For soft prediction of distillation loss, This represents the characteristic distillation loss of the intermediate layer. For cross-entropy loss, for The weight parameters, for The weight parameters, for The weight parameters.
[0092] In some embodiments, , , .
[0093] In some embodiments, weight parameters , and The value can be updated according to the actual situation during the training of the lightweight model.
[0094] In some embodiments, the cross-entropy loss is used to measure the difference between the predicted output of the lightweight student model and the true discrete labels, ensuring that the lightweight student model does not deviate from the basic classification objective of the task when learning knowledge from the teacher model.
[0095] S1034. Based on the total loss function, train the lightweight student model to obtain the lightweight defect detection model.
[0096] This embodiment trains a lightweight student model using the total loss function, transferring the knowledge of a large, complex model to a lightweight small model. This allows the lightweight small model to maintain high efficiency while approaching the performance of the large model as closely as possible.
[0097] In some embodiments, the intermediate layer feature map of the backbone network of the lightweight student model is convolved with the intermediate layer feature map of the backbone network of the teacher model, and the mean squared error loss is calculated to obtain the intermediate layer feature distillation loss. This further includes: Features of the same-scale and same-semantic layers in the multi-scale feature pyramid network of the teacher model and the lightweight student model are extracted. A 1×1 convolution maps the same-scale and same-semantic layer features of the lightweight student model's multi-scale feature pyramid network to the same-scale and same-semantic layer features of the teacher model's multi-scale feature pyramid network. The intermediate layer feature distillation loss is obtained by summing the features of each layer of the teacher model network with the mean squared error loss of the mapped lightweight student model. The specific formula for calculating the intermediate layer feature distillation loss is as follows: ;in, for convolution, This represents the feature dimension of the multi-scale feature pyramid network layer in the lightweight student model. This represents the feature dimension of the multi-scale feature pyramid network layer in the teacher model. This indicates a lightweight student model. Dimensional feature map convolution mapping to the teacher model Dimensionality feature maps are used to align the network channel dimensions and scales of the multi-scale feature pyramid network layers in the teacher model and the lightweight student model. Indicates the first Feature dimension diagram of the multi-scale feature pyramid network layer of the layered teacher model. Indicates the first Feature dimension diagram of the multi-scale feature pyramid network layer of the lightweight student model.
[0098] This embodiment uses a bidirectional feature pyramid structure with cross-layer connections to achieve multi-dimensional feature aggregation of defects at different scales, thereby improving accuracy and robustness.
[0099] In some embodiments, the lightweight student model is a lightweight network that integrates a lightweight convolutional module and a network channel attention module. The structure of the lightweight student model is as follows: Figure 4 As shown.
[0100] In some embodiments, the lightweight convolutional module includes using the inverted residual of MobileNetV3 as the backbone structure, i.e., Inverted Residual + SE, introducing a Ghost module to replace the ordinary convolutional layers of the residual module to reduce redundant feature computation, and adding network channel attention (SE module) at key points to enhance typical defect signals. Feature fusion adopts Bi-FPN (lightweight) to achieve bidirectional multi-scale information flow. This embodiment balances lightweight computation and low latency while maintaining feature representation capabilities. The inverted residual structure of MobileNetV3 is as follows: Figure 5 As shown.
[0101] For example, the inverted residual structure of MobileNetV3 in this embodiment uses the standard MobileNetV3-small / large structure, and selects an adjustable width multiplier (such as 0.5, 0.75, 1.0) to control the parameters.
[0102] The selection of the adjustable width multiplier is set according to the actual needs of those skilled in the art. For example, the value of the width multiplier can be reduced in scenarios with high real-time requirements, and the value of the width multiplier can be increased in scenarios with high performance requirements.
[0103] Among them, scenarios with high real-time requirements refer to real-time obstacle avoidance by mobile inspection robots and parallel inspection by multiple devices, while scenarios with high performance requirements refer to precise identification of insulator damage and diagnosis of abnormal transformer oil temperature.
[0104] like Figure 4 As shown, each inverted residual block consists of: 1×1 pointwise convolution - 3×3 depthwise convolution → SE module (Squeeze-and-Excitation) → 1×1 pointwise linear convolution → residual concatenation if the input and output are the same. The 1×1 point convolution expands the number of input network channels to increase feature dimensions and provide richer feature representations for subsequent depthwise convolutions. The 3×3 depthwise convolution performs spatial convolution per network channel, significantly reducing computation while extracting local spatial features. The SE module compresses the spatial information of each network channel into a scalar (network channel mean) through global average pooling, capturing the global context at the network channel level. Two fully connected layers (FC) + ReLU + Hard-sigmoid generate network channel weights (0~1), which are then applied to the output features of the depthwise convolution at the network channel level (×), strengthening the network channel response of important defect features (such as insulator cracks and foreign objects) and suppressing redundant information. The 1×1 pointwise linear convolution projects the expanded number of network channels back to the original number of network channels, keeping the input and output network channels consistent and facilitating residual connections.
[0105] In the network layer sequence, the typical flow is convolutional layer → batch normalization (BN) layer → ReLU6 activation. ReLU6 follows BN and its function is to perform a non-linear transformation on the normalized data output by BN without affecting the bias processing. The bias is determined by the BN layer. Responsible for the BN layer. It replaces the bias function of convolutional layers. Removing bias does not affect model performance, simplifies calculation, improves efficiency, and avoids parameter redundancy.
[0106] The lightweight convolution module also includes a redundant feature elimination module, the structure of which is as follows: Figure 6 As shown, the structure of this redundant feature elimination module generates basic features for C' network channels using 1×1 convolutions, then generates redundant features for the remaining network channels (C-C') using a cheap linear operation, and finally concatenates them to obtain the complete output network channels. This cheap linear operation can be a depthwise convolution, a shift operation, or other lightweight convolutions.
[0107] For example, the compression ratio of the redundant feature elimination module is r=2, and C'=C / r, where C represents the number of network channels of the input and C' represents the number of network channels of the features after convolution of the input.
[0108] This embodiment generates redundant features through inexpensive linear operations, reducing redundant computations.
[0109] Specifically, the network channel attention module includes an SE module and an efficient network channel attention module (ECA). The Efficient Network Channel Attention module has simpler and faster parameters. It applies 1D convolutional layers to the global pooling vector to obtain the network channel weights, and adds an attention mechanism to each feature layer, especially in the middle and high layers, to emphasize significant network channel responses such as insulator cracks and foreign objects.
[0110] In 1D convolution, the kernel_size parameter specifies the length of the convolution kernel, which is the number of time steps or elements covered by the convolution window on the input sequence. The kernel_size parameter is automatically set according to the number of network channels.
[0111] In some embodiments, the lightweight student model structure also includes a bidirectional feature pyramid (Bi-FPN), where each Bi-FPN unit contains upsampling top-down fusion and downsampling bottom-up fusion paths, and feature fusion employs weighted summation followed by a 3×3 depthwise convolution for lightweight smoothing.
[0112] like Figure 4 As shown, this embodiment has three layers of Bi-FPN. The input of these three layers of Bi-FPN can be several scales of the inverted residual structure of MobileNetV3, such as P3, P4, and P5.
[0113] For example, the number of network channels in the bidirectional feature pyramid can be selected as 64, 88, 112, or 160. The selection of the number of network channels is set according to the actual needs of those skilled in the art. For example, the number of network channels can be reduced in scenarios with high real-time requirements and increased in scenarios with high performance requirements.
[0114] This embodiment enhances the feature map representation of multispectral images by setting up a lightweight backbone network that integrates the inverted residual structure of MobileNetV3 with the redundant feature elimination module of GhostNet.
[0115] Example 2: In another exemplary embodiment, such as Figure 7As shown, a defect detection model generation method is provided, which includes steps 104 to 107, as detailed below: Step 104: Obtain the original multispectral image of the substation equipment and perform image preprocessing on the original multispectral image to obtain the optimized multispectral image.
[0116] Step 105: Input the optimized multispectral image into the pre-trained teacher model to generate the soft label of the teacher model and the intermediate layer feature map of the teacher model.
[0117] Step 106: Using the soft labels of the teacher model and the intermediate layer feature maps of the teacher model as supervision information, train the lightweight student model through the knowledge distillation loss function to obtain the lightweight defect detection model.
[0118] In this embodiment, steps 104 to 106 are similar to steps 101 to 103 described above, and will not be repeated here.
[0119] Step 107: Based on the lightweight defect detection model, perform sparse training on each network channel in the lightweight defect detection model, and prune the lightweight defect detection model according to the learnable scalar gating of each network channel after training.
[0120] Specifically, a learnable scalar gate is added to each convolutional layer in the lightweight defect detection model; based on the knowledge distillation loss function, a sparse regularization term is added to the knowledge distillation loss function to train the learnable scalar gate, and the training continues until the learnable scalar gate stabilizes and converges. All network channels corresponding to learnable scalar gates that are less than the preset gate threshold are pruned. The pruned lightweight defect detection model is fine-tuned m times to recover the accuracy loss of the lightweight defect detection model.
[0121] For example, the preset gate threshold can be set to 1e-6. m can be set to 20~50. Both the gate threshold and m can be set according to the actual needs of those skilled in the art.
[0122] Furthermore, the expression for adding a sparse regularization term to the knowledge distillation loss function is as follows: ; in, This represents the combined loss of the training data labels, which consists of Focal loss, Smooth L1 loss, and GioU loss. Indicates L0 sparse regularization terms. This represents the computational constraint term. This represents the gated sparse weights, which increase linearly from 0 to 1e-4 to 1e-3 with the number of iterations. Indicates the weight of the computational parameters, based on The normalization value is 1e-6. This indicates the computational cost of the current pruning model. This indicates the computational cost of the currently retained pruning model.
[0123] Furthermore, Focus on precision in the early stages of training, and gradually reduce sparsity in the later stages. This is a secondary penalty item to ensure that the amount of computation is strictly controlled.
[0124] Furthermore, the learnable scalar gating achieves approximate binarization through continuous relaxation functions. The final output value of each convolutional layer in this lightweight defect detection model is the product of the learnable scalar gating and the original output value of the network channel. Specifically, when the learnable scalar gating is approximately zero, the output channel of the corresponding convolutional layer is pruned; when the learnable scalar gating is approximately 1, the output channel of the corresponding convolutional layer is retained. A learnable scalar gating close to zero indicates that the output channel of the corresponding convolutional layer has little impact on the output result and can be safely pruned. In this embodiment, by adding learnable scalar gating, the lightweight defect detection model can autonomously decide whether to retain or prune the output channel of the corresponding convolutional layer, avoiding the blindness of manually setting the pruning ratio.
[0125] This embodiment further optimizes the algorithm network model structure and uses dynamic network channel pruning technology to further reduce the model parameters in the lightweight defect detection model, thereby improving the algorithm capability and recognition efficiency of the lightweight defect detection model.
[0126] This invention, under the constraint of limited edge computing power, transfers some of the prior information of defects identified by large-scale algorithms to lightweight small-scale algorithms. This allows the lightweight defect detection model to maintain high efficiency while approaching the performance of large-scale network models as closely as possible, achieving efficient identification of substation equipment defects, optimizing algorithm identification and inference time, and resolving the contradiction between the high-precision requirements of inspection tasks and the limited computing power of robot platforms in existing technologies. The beneficial effects obtained by the method of this invention are shown in Table 1.
[0127]
[0128] In the embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, or methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules / units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or units may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of apparatuses or modules or units may be electrical, mechanical, or other forms.
[0129] The modules / units described as separate components may or may not be physically separate. The components shown as modules / units may or may not be physical modules; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules / units can be selected to achieve the objectives of the embodiments of the present invention, depending on actual needs. For example, the functional modules / units in the various embodiments of the present invention may be integrated into one processing module, or each module / unit may exist physically separately, or two or more modules / units may be integrated into one module / unit.
[0130] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0131] Example 3: This embodiment provides a substation inspection robot, including a robot body and a multispectral image acquisition module and an edge computing module disposed on the robot body. The edge computing module is equipped with a lightweight defect detection model generated by the above method.
[0132] This invention, under the condition of limited computing power at the edge, transfers some of the prior information of defects identified by large model algorithms to lightweight small model algorithms. This enables the lightweight defect detection model to maintain high efficiency while approaching the performance of large network models as closely as possible, achieving efficient identification of defects in substation equipment, optimizing algorithm identification and inference time, and resolving the contradiction between the high precision requirements of inspection tasks and the limited computing power of robot platforms in existing technologies.
[0133] Example 4: In one exemplary embodiment, this embodiment also provides an electronic device, including a memory and a processor, wherein the memory stores a program that can run on the processor, and when the program is executed by the processor, the electronic device performs any of the methods described in the above embodiments.
[0134] In one possible embodiment, such as Figure 8 As shown, the electronic device 20 also includes: an output interface 23 for outputting results; a communication interface 24 for transmitting communication signals; and an antenna 25 for transmitting or receiving signals.
[0135] Electronic devices can be, but are not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, smart cars, etc., while portable wearable devices can be smartwatches and smart bracelets, etc. It is understood that this method can also be applied to systems that include electronic devices and servers, and is implemented through the interaction between electronic devices and servers.
[0136] It should be noted that the processor 21 in this embodiment can be an image processing chip or an integrated circuit chip, capable of processing image signals. In implementation, each step of the above method embodiment can be completed by the integrated logic circuitry in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices. It can implement or execute the methods, steps, and logic block diagrams disclosed in this embodiment. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this embodiment can be directly implemented by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory; the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.
[0137] Those skilled in the art will understand that Figure 8The structure shown is merely a block diagram of a portion of the structure related to the present invention and does not constitute a limitation on the electronic device to which the present invention is applied. A specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0138] Example 5: In one exemplary embodiment, this embodiment also provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps in the above-described method embodiments.
[0139] Example 6: In one exemplary embodiment, this embodiment also provides a computer program product, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0140] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with relevant regulations.
[0141] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided by this invention can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided by this invention may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided by this invention may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0142] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with relevant regulations.
[0143] The descriptions of the processes or structures corresponding to the above figures each have their own emphasis. For parts of a process or structure that are not described in detail, please refer to the relevant descriptions of other processes or structures.
[0144] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for generating a lightweight defect detection model, characterized in that, Includes the following steps: The original multispectral images of the substation equipment are acquired, and the original multispectral images are preprocessed to obtain optimized multispectral images. The optimized multispectral image is input into the pre-trained teacher model to generate soft labels for the teacher model and intermediate layer feature maps for the teacher model. Using the soft labels and intermediate layer feature maps of the teacher model as supervision information, a lightweight student model is trained through the knowledge distillation loss function to obtain a lightweight defect detection model. The lightweight student model is a lightweight network that integrates a lightweight convolution module and a channel attention module.
2. The lightweight defect detection model generation method according to claim 1, characterized in that, The step of preprocessing the original multispectral image to obtain the optimized multispectral image specifically includes: S1011. Separate the original multispectral image into a visible light channel image and a near-infrared channel image; S1012. Normalize the visible light channel image and the near-infrared channel image to obtain the first visible light channel image and the first near-infrared channel image. S1013. Perform contrast-limited adaptive histogram equalization processing on the first visible light channel image and the first near-infrared channel image respectively to obtain the second visible light channel image and the second near-infrared channel image. S1014. Weighted fusion of the second visible light channel image and the second near-infrared channel image is performed to obtain a fused image; S1015. Perform adaptive noise suppression based on the overall image variance on the fused image to obtain the optimized multispectral image.
3. The lightweight defect detection model generation method according to claim 2, characterized in that, In step S1012, when normalizing the visible light channel image and the near-infrared channel image, the image with a small pixel variance is first white balanced and then normalized. The normalization process maps the image pixel values to the [0,1] interval.
4. The lightweight defect detection model generation method according to claim 2, characterized in that, In step S1015, adaptive noise suppression based on the overall variance of the image is performed on the fused image to obtain an optimized multispectral image, specifically including: Noise assessment is performed on the fused image, and local variance of the image is calculated; If the local variance of the image is lower than a preset threshold, bilateral filtering is used to suppress noise in the fused image; if the local variance of the image is higher than or equal to the preset threshold, nonlocal mean filtering is used to suppress noise in the fused image. Guided filtering is used to process the noise-suppressed fused image to obtain an optimized multispectral image.
5. The lightweight defect detection model generation method according to claim 1, characterized in that, The soft labels for the teacher model are generated by temperature scaling of the original prediction output of the teacher model, and then converted into the probability distribution of the teacher model using the Softmax function. .
6. The lightweight defect detection model generation method according to claim 5, characterized in that, The expression for the probability distribution of the teacher model is: ; in, This represents the probability distribution of the teacher model's output. This represents the original prediction output of the teacher model. Indicates temperature parameter, i Indicates the category.
7. The lightweight defect detection model generation method according to claim 1, characterized in that, The lightweight defect detection model is obtained by using the soft labels and intermediate layer feature maps of the teacher model as supervision information and training a lightweight student model through a knowledge distillation loss function. Specifically, this includes: S1031. Temperature-scale the original prediction output of the lightweight student model to generate soft predictions, and then convert the soft predictions into the probability distribution of the lightweight student model using the Softmax function. Based on soft labeling and soft prediction, the divergence loss is calculated, and the soft prediction distillation loss is obtained. S1032. Perform convolution and mean squared error loss calculation on the intermediate layer feature maps of the backbone network of the lightweight student model and the intermediate layer feature maps of the backbone network of the teacher model to obtain the intermediate layer feature distillation loss. S1033. Weighted summation of soft prediction distillation loss, intermediate layer feature distillation loss and cross-entropy loss to obtain the total loss function; S1034. Train a lightweight student model based on the total loss function to obtain a lightweight defect detection model.
8. The lightweight defect detection model generation method according to claim 7, characterized in that, The specific formula for calculating the soft-predictive distillation loss is as follows: ; in, , Indicates KL divergence; This represents the probability distribution output by the lightweight student model; This represents the probability distribution of the teacher model's output; Indicates temperature parameter, i Indicates the category.
9. The lightweight defect detection model generation method according to claim 7, characterized in that, The specific method for obtaining the intermediate layer characteristic distillation loss is as follows: Extract the same-scale layer and same-semantic layer features of the multi-scale feature pyramid network of the teacher model, and extract the same-scale layer and same-semantic layer features of the multi-scale feature pyramid network of the lightweight student model; The same-scale and same-semantic layer features of the lightweight student model multi-scale feature pyramid network are mapped to the same-scale and same-semantic layer features of the teacher model multi-scale feature pyramid network using 1×1 convolution. The intermediate layer feature distillation loss is obtained by summing the features of each layer of the teacher model network with the mean squared error loss of the mapped lightweight student model.
10. The lightweight defect detection model generation method according to claim 7, characterized in that, The formula for calculating the characteristic distillation loss of the intermediate layer is as follows: ; in, This represents the characteristic distillation loss of the intermediate layer; Indicates the first Feature dimension diagram of the tiered teacher model; Indicates the first Feature dimension diagram of a lightweight student model; for convolution, To reduce the feature dimensions of the student model, For the feature dimensions of the teacher model, This indicates a lightweight student model. Dimensional feature map convolution mapping to the teacher model Dimensional feature maps are used to align the dimensions and scales of network channels in the teacher network and student network.
11. The lightweight defect detection model generation method according to claim 7, characterized in that, The formula for calculating the total loss function is as follows: ; in, To predict distillation losses using soft methods; This represents the characteristic distillation loss of the intermediate layer; Cross-entropy loss; for Weight parameters; for Weight parameters; for The weight parameters.
12. The lightweight defect detection model generation method according to claim 1, characterized in that, The lightweight convolution module includes the inverted residual structure of MobileNetV3 and the redundant feature elimination module of GhostNet.
13. The lightweight defect detection model generation method according to claim 1, characterized in that, The method further includes: based on the lightweight defect detection model, performing sparse training on each network channel in the lightweight defect detection model, and pruning the lightweight defect detection model according to the learnable scalar gating of each network channel after sparse training.
14. The lightweight defect detection model generation method according to claim 13, characterized in that, The lightweight defect detection model undergoes sparsity training and pruning, as follows: Add learnable scalar gating to each convolutional layer of the lightweight defect detection model; A sparse regularization term is added to the knowledge distillation loss function to train the learnable scalar gate, and training continues until the learnable scalar gate converges stably. In the lightweight defect detection model, convolutional network channels with learnable scalar gating below a preset gating threshold are pruned.
15. An electronic device comprising a memory and a processor, characterized in that, The memory stores a program that can run on the processor, which, when executed by the processor, causes the electronic device to perform the method described in any one of claims 1 to 14.
16. A substation inspection robot, comprising a robot body and a multispectral image acquisition module and an edge computing module disposed on the robot body, characterized in that, The edge computing module is equipped with a lightweight defect detection model generated by the method described in any one of claims 1 to 14.