Photovoltaic module fault detection method and device based on YOLOv7
By introducing thermal infrared and temperature information fusion, shallow-deep information aggregation, and global context awareness modules into the YOLOv7 network, the accuracy and efficiency of photovoltaic module fault detection have been improved. This solves the problems of high false detection rate and low efficiency of traditional methods in complex environments, and achieves high-precision real-time fault detection.
Patent Information
- Application Number
- CN202610034884.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-12
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2046-01-12
AI Technical Summary
Existing photovoltaic module fault detection methods are insufficient in terms of detection accuracy and efficiency, making it difficult to meet the real-time monitoring needs in complex environments. In particular, the false detection rate is high in scenarios with multiple faults overlapping, and traditional manual inspection is inefficient and costly.
A photovoltaic module fault detection method based on YOLOv7 is adopted. By introducing a thermal infrared and temperature information fusion module, a shallow-deep information aggregation module, and a global context awareness module, a YOLOv7-tiny network is constructed. An improved attention mechanism is used for feature fusion and enhancement to generate multimodal features, thereby improving detection accuracy and anti-interference ability.
It improves detection accuracy and anti-interference capability in complex backgrounds and changing environments, and realizes high-precision fault detection. It is suitable for mobile or embedded platforms with limited computing resources, and meets the real-time and efficient inspection needs of photovoltaic power plants.
Smart Images

Figure CN121502490A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of target detection, in particular to a photovoltaic module fault detection method based on YOLOv7 and a device thereof. BACKGROUND
[0002] In recent years, the development and utilization of solar energy have been vigorously promoted, and the photovoltaic power generation industry has developed rapidly. However, under long-term operation and frequent adverse weather conditions, photovoltaic modules are prone to material fatigue, thermal stress concentration and mechanical damage, etc., which can lead to the formation of micro-cracks inside. This can not only cause a decrease in photoelectric conversion efficiency and power output attenuation, but also induce thermal spot effect and potential-induced degradation, etc. Therefore, how to achieve efficient and accurate fault detection in the operation and maintenance of large-scale photovoltaic power stations has become a problem to be solved.
[0003] Photovoltaic module fault detection is an important link to ensure the safe and stable operation of photovoltaic power generation systems. Traditional photovoltaic module inspection methods usually rely on manual visual inspection. However, these methods generally have low detection efficiency, strong subjectivity, high equipment cost, and long single-point time consumption, etc., and are difficult to meet the dual requirements of high detection accuracy (≥95%) and high processing efficiency (hundred pieces / hour) in industrial scenarios. With the continuous development of deep learning and convolutional neural networks, intelligent detection methods based on automatic learning of image features have gradually become the mainstream. Existing detection models based on deep learning have significantly improved in detection accuracy, but still have limited feature extraction capability and low detection efficiency, making it difficult to adapt to real-time monitoring needs in complex environments. Traditional methods have advantages in interpretability and simplicity, but have significant limitations in complex working conditions, large-scale and high real-time scenarios. For example, feature blurring caused by environmental temperature, light changes and other interference factors, high false detection rate of existing models in multi-fault superposition scenarios, and difficulty in simultaneously ensuring detection accuracy and processing efficiency during large-area photovoltaic module inspection.
[0004] Therefore, there is an urgent need for a photovoltaic module fault detection method based on YOLOv7 and a device thereof to solve one of the above technical problems. SUMMARY
[0005] The purpose of the present application is to provide a photovoltaic module fault detection method based on YOLOv7 and a device thereof, which can solve at least one of the above technical problems. The specific scheme is as follows: According to the specific embodiment of the present application, the present application provides a photovoltaic module fault detection method based on YOLOv7, comprising: constructing a data set containing photovoltaic module thermal infrared images and corresponding temperature matrices, and preprocessing; constructing a network based on YOLOv7-tiny; Wherein, a thermal infrared and temperature information fusion module is introduced into the backbone part of the network, a shallow-deep information aggregation module is introduced into the neck part of the network, and a global context perception module is introduced into the detection head part of the network. The network is trained using the data set to obtain a photovoltaic fault detection model. The thermal infrared image and the corresponding temperature matrix of the photovoltaic module to be detected are input into the photovoltaic fault detection model, and a fault detection result is output.
[0006] Further, the thermal infrared and temperature information fusion module comprises: The input thermal infrared image and temperature matrix are subjected to spatial alignment and normalization processing; Parallel image encoding branches and temperature encoding branches are used to extract spatial texture features and temperature distribution features, respectively; The extracted spatial texture features and temperature distribution features are subjected to channel splicing and convolution fusion; An improved convolution block attention module is used to adaptively enhance the channel and spatial dimensions of the fused features.
[0007] Further, the improved convolution block attention module comprises: A channel attention weight map is generated by processing and adding the features after global average pooling and global maximum pooling through a multilayer perceptron; The channel attention weight map is multiplied by the fused features to obtain channel enhanced features; After the channel enhanced features are subjected to global average pooling and global maximum pooling, they are spliced along the channel dimension, and a spatial attention weight map is generated through a convolution layer; The spatial attention weight map is multiplied by the channel enhanced features to output enhanced multi-modal feature maps.
[0008] Further, the shallow-deep information aggregation module comprises: Different receptive field context information of the input features is extracted in parallel using multi-scale convolution kernels, and the channel splicing is performed; A channel attention mechanism is introduced to model the saliency and adaptively weight the multi-scale features after splicing; The expression ability and diversity of the features are improved through a lightweight channel transformation module and a nonlinear activation function; The transformed features are stabilized by group normalization, and the aggregated features are output.
[0009] Further, the channel attention mechanism comprises: The input features are subjected to global average pooling to generate a channel description vector; The channel description vector is sequentially passed through a fully connected layer and an asymmetric activation function for nonlinear mapping; The mapped vector is activated by the Sigmoid function to generate the weight coefficients for each channel; The generated weight coefficients are multiplied by the original input features channel by channel to complete channel weighting.
[0010] Furthermore, the global context-aware module includes: Directional channel context branch and query-key value branch; where, The directional channel context branch performs one-dimensional global pooling on the input feature map in the horizontal and vertical directions to capture directional global dependencies. The query-key-value branch uses convolution operations to simulate the interaction between query, key and value in the attention mechanism and calculates spatial context weights. The output of the directional channel context branch and the output of the query-key value branch are used to perform operations to achieve global context modulation of the input features.
[0011] Furthermore, the directional channel context branch includes: One-dimensional average pooling is performed along the height and width directions of the input feature map to generate feature vectors in two directions. The feature vectors from the two directions are concatenated and then dimensionality reduced using convolution. The dimensionality-reduced features are split into horizontal features and vertical features; The dimensions of the horizontal and vertical features are recovered through convolution operations, and the directional channel attention weights are calculated for each spatial location.
[0012] Furthermore, the construction and preprocessing of the dataset includes: Collect infrared images and corresponding temperature matrix data of photovoltaic power plants; The collected data should be labeled, and the fault types should include at least junction box failure, component breakage, hot spots and bird droppings obstruction; Offline augmentation of labeled data can be performed by flipping, rotating, or cropping and splicing to expand the dataset size.
[0013] Furthermore, training the constructed network includes: The K-means clustering algorithm is used to re-cluster the sizes of the labeled boxes in the dataset to generate prior anchor boxes that match photovoltaic fault targets; The preprocessed training data is input into the network, and the prediction results are calculated through forward propagation. We combine localization loss, classification loss, and confidence loss for multi-task joint optimization, and update the network weights through backpropagation.
[0014] According to a specific embodiment of this application, this application also provides a photovoltaic module fault detection device based on YOLOv7, comprising: The data preparation module is used to construct and preprocess a dataset containing thermal infrared images and temperature matrices. The network construction module is used to construct a YOLOv7-tiny network that integrates the thermal infrared and temperature information fusion module, the shallow-deep information aggregation module, and the global context awareness module. The model training module is used to train the network constructed by the network construction module using the data provided by the data preparation module to obtain a photovoltaic fault detection model. The fault detection module is used to send the input data to be detected into the photovoltaic fault detection model and output the final fault location and classification results.
[0015] Compared with the prior art, the above-described solutions of this application have at least the following beneficial effects: 1. This application discloses a method and apparatus for photovoltaic module fault detection based on YOLOv7. A thermal infrared and temperature information fusion module (ITFM) is introduced at the front end of the backbone network. It performs dual-branch encoding using aligned infrared images and temperature matrices, and utilizes an improved attention mechanism for adaptive fusion and enhancement, generating spatial-channel co-optimized multimodal features. The deeply complementary fusion mechanism of this application's technical solution enables the model to simultaneously utilize texture and temperature distribution information, effectively mining the salient features of the fault area. This results in higher detection accuracy and stronger anti-interference capability when facing complex backgrounds and variable environments.
[0016] 2. This application discloses a method and apparatus for photovoltaic module fault detection based on YOLOv7. A shallow-deep information aggregation (SDA) module and a global context-aware (GCAM) module are introduced into the neck network and detection head, respectively. The SDA module aggregates contextual information from different receptive fields through multi-scale convolution and channel attention mechanisms, enhancing the feature representation of targets with varying scales. The GCAM module captures long-range directional dependencies through directional channel context branches and models spatial relationships using query-key-value branches, achieving global context modulation of the feature map. The synergistic effect of these two modules significantly improves the model's sensitivity and accuracy in perceiving and locating small and ambiguous targets.
[0017] 3. This application discloses a method and apparatus for photovoltaic module fault detection based on YOLOv7. Using the lightweight YOLOv7-tiny as the baseline network, by introducing carefully designed lightweight modules at key locations and focusing on computational efficiency in feature fusion and attention mechanisms, the detection accuracy is significantly improved with only a slight increase in the number of parameters and computational load. This makes the improved model still suitable for deployment on mobile or embedded platforms with limited computing resources, meeting the urgent need for real-time and efficient on-site inspection of photovoltaic power plants, and achieving a balance between lightweight and high precision. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings: Figure 1 This is a flowchart illustrating a method for photovoltaic module fault detection based on YOLOv7, as shown in an embodiment of this application.
[0019] Figure 2 This is a schematic diagram of the structure of a YOLOv7 network as shown in an embodiment of this application.
[0020] Figure 3 This is a schematic diagram of the structure of the thermal infrared and temperature information fusion module shown in an embodiment of this application.
[0021] Figure 4 This is a schematic diagram of the shallow-deep information aggregation module shown in an embodiment of this application.
[0022] Figure 5 This is a schematic diagram of the structure of a global context-aware module as shown in an embodiment of this application.
[0023] Figure 6 This is a schematic diagram illustrating the clustering results when the number of cluster centroids is 9, as shown in an embodiment of this application.
[0024] Figure 7 This is a schematic diagram illustrating the clustering results when the number of cluster centroids is 12, as shown in an embodiment of this application. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0026] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the application. The singular forms “a,” “said,” and “the” used in the embodiments of this application and the appended claims are also intended to include the plural forms, and “multiple” generally includes at least two unless the context clearly indicates otherwise.
[0027] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0028] It should be understood that although the terms first, second, third, etc., may be used in the embodiments of this application, these descriptions should not be limited to these terms. These terms are only used to distinguish the descriptions. For example, first may also be referred to as second without departing from the scope of the embodiments of this application, and similarly, second may also be referred to as first.
[0029] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that an article or device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such an article or device. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the article or device that includes said element.
[0030] The optional embodiments of this application are described in detail below with reference to the accompanying drawings.
[0031] like Figure 1 As shown, a method for photovoltaic module fault detection based on YOLOv7 includes: S1. Construct a dataset containing thermal infrared images of photovoltaic modules and their corresponding temperature matrices, and perform preprocessing.
[0032] A photovoltaic module fault dataset was constructed for training and testing. A drone equipped with an infrared thermal imager was used to autonomously fly over a large photovoltaic power plant along a preset route to collect thermal infrared images of the photovoltaic modules and their corresponding pixel-level temperature matrices. Each thermal infrared image covers one photovoltaic string. In this embodiment, each string contains 16 or 22 photovoltaic modules. Based on the PASCAL VOC dataset format, the LabelImg tool was used to finely annotate the 503 original images, generating corresponding label files for subsequent model training. Fault categories were defined as four types: junction box failure, module breakage, hot spots, and bird droppings obstruction.
[0033] In this embodiment, the various fault types and their corresponding numbers were statistically analyzed, as follows: 37 images of junction box faults; 79 images of component breakage faults; 299 images of component hot spot faults; and 88 images of bird droppings obstruction faults, totaling 503 images. 50 original images were reserved as a test set. The remaining 453 images underwent offline data augmentation through methods such as horizontal flipping, scaling, rotation, and cropping / stitching to expand the dataset size and improve the model's generalization ability. After augmentation, a total of 3859 images were obtained, which were divided into training and validation sets in a 4:1 ratio.
[0034] S2. Construct a network based on YOLOv7-tiny. For example... Figure 2 As shown, a thermal infrared and temperature information fusion module (ITFM) is introduced in the backbone of the network, a shallow-deep information aggregation module (SDA) is introduced in the neck of the network, and a global context awareness module (GCAM) is introduced in the detection head of the network.
[0035] This application provides a preferred technical solution: a thermal infrared and temperature information fusion module (ITFM), such as... Figure 3 As shown, it includes: The input thermal infrared image and temperature matrix are spatially aligned and normalized. The original thermal infrared image... and temperature matrix Spatial alignment is performed using bilinear interpolation, unifying the dimensions to the input dimensions (H×W) of the backbone network. And T, to ensure spatial consistency of subsequent feature encoding operations.
[0036] in, This indicates the thermal infrared image before alignment; This represents the temperature matrix before alignment. express OK A matrix of real numbers in columns; This represents the height of the original input image, i.e., the number of rows, which is the number of pixels in the vertical direction of the image; H represents the width of the original input image, i.e., the number of columns, which is the number of pixels in the horizontal direction of the image; W represents the number of rows of the backbone network input; W represents the number of columns of the backbone network input. This represents the aligned thermal infrared image; T represents the aligned temperature matrix.
[0037] Will Both T and T are linearly normalized. Let the pixel range of the infrared image be [ The temperature range is []. The normalized expression is: in, This represents the normalized thermal infrared image. This represents the normalized temperature matrix; This represents the thermal infrared image before normalization. This represents the temperature matrix before normalization. These represent the minimum and maximum values of the pixel range, respectively. These represent the minimum and maximum temperature ranges, respectively.
[0038] Parallel image coding and temperature coding branches, namely infrared and temperature branches, are used to extract spatial texture features and temperature distribution features, respectively. The normalized... and Two parallel lightweight convolutional encoding branches, CNN-I and CNN-T, are input respectively to extract spatial texture features and temperature distribution features. The CNN-I branch extracts spatial texture features through 3×3 convolution, batch normalization (BN), ReLU activation, and max pooling operations. The CNN-T branch extracts temperature distribution features through 1×1 convolution, batch normalization (BN), ReLU, and max pooling. . and The expression is: in, This represents the feature map output from the first stage of the infrared branch. This represents a 3×3 convolution; This represents the normalized input thermal infrared image; This represents the max pooling operation; This represents the feature map output of the second stage of the infrared branch; This represents the feature map output of the third stage of the infrared branch; This indicates the number of channels in the feature map output from the third stage of the infrared branch. The feature map representing the output of the first stage of the temperature branch; Represents a 1×1 convolution; This represents the normalized input temperature matrix; The feature map representing the output of the third stage of the temperature branch; The feature map representing the output of the second stage of the temperature branch; This represents the number of channels in the feature map output from the third stage of the temperature branch. This indicates the height of the output feature map, i.e., the number of rows; This indicates the width of the output feature map, i.e., the number of columns.
[0039] The extracted spatial texture features and temperature distribution features are then fused through channel concatenation and convolution. and Channel-dimensional concatenation is performed, and then fused using 1×1 convolutions and non-linear activations are applied to obtain... This process further compresses the channel dimension from 2C to C, effectively halving the number of channels and achieving modal information fusion while reducing redundancy. Subsequently, a 1×1 convolution is used for channel compression and initial fusion to obtain the feature map. The specific expression is as follows: in, C represents the normalized input temperature matrix; C represents the number of channels in the feature map after concatenating spatial and temperature features. This represents the spliced feature map; This represents the feature map after compression and fusion; This represents the activation function.
[0040] An improved convolutional block attention module is used to adaptively enhance the channel and spatial dimensions of the fused features.
[0041] This application provides a preferred technical solution, which introduces an improved convolutional block attention module (CBAM) to enhance the model's ability to perceive key regions and significant temperature differences. The CBAM sequentially performs channel attention and spatial attention calculations.
[0042] The features obtained after global average pooling and global max pooling are processed separately using a multilayer perceptron and then summed to generate a channel attention weight map. The channel attention weight map is multiplied with the fused features to obtain the channel-enhanced features. These channel-enhanced features are then concatenated along the channel dimension after undergoing global average pooling and global max pooling, and a spatial attention weight map is generated through a convolutional layer. Finally, the spatial attention weight map is multiplied with the channel-enhanced features to output the enhanced multimodal feature map.
[0043] In this embodiment, a shared multilayer perceptron (MLP) is used. Channel attention is processed by the MLP, which combines the features obtained from global average pooling and global max pooling, and then summed. The sum is then processed by a sigmoid function to generate a channel attention weight map. Spatial attention then enhances the features of the channel. After global average pooling and global max pooling, the data is concatenated along the channel dimension, and then a spatial attention weight map is generated by a 7×7 convolution and a sigmoid function. The final output is the feature modulated by dual attention. This provides a more discriminative multimodal input for subsequent networks. The specific expression is as follows: in, Represents the channel attention weight map; This represents the intermediate enhanced feature map after channel weighting; Represents the spatial attention weight map; This represents the enhanced multimodal feature map; This indicates an average pooling operation; This represents the maximum pooling operation; This represents a 7×7 convolution.
[0044] This application provides a preferred technical solution, such as Figure 4 As shown, the Shallow-Deep Information Aggregation Module (SDA) introduced at the neck of the network includes: Multi-scale convolutional kernels are used to extract contextual information from different receptive fields of the input features in parallel, followed by channel concatenation. First, convolutional layers of three different scales (3×3, 5×5, and 7×7) are used to extract features from the input features. The input feature map is then fed into these three parallel convolutional layers, which use the same number of input / output channels, thereby extracting features from different receptive fields. , , By concatenating the three features mentioned above along the channel dimension, a feature map with three times the number of channels is obtained. Subsequently, a 1×1 convolutional layer is immediately used to compress the channels of the concatenated features, reducing the number of channels to a preset dimension. Group normalization is then introduced to improve the model's stability and generalization ability under mini-batch training, achieving efficient fusion of multi-scale semantics and preparing for subsequent processing. The specific formula is shown below: in, Represents the feature map; This represents the features under the receptive field of a 3×3 convolution; This indicates the characteristics of the 5×5 sensory field. This indicates the characteristics of the 7×7 sensory field.
[0045] A channel attention mechanism is introduced to perform saliency modeling and adaptive weighting on the concatenated multi-scale features. For the features... Global average pooling (GAP) is performed to obtain the channel description vector. This vector is then passed sequentially through a first fully connected layer, an asymmetric activation function, and a second fully connected layer to obtain the corresponding weights. In this embodiment, the first fully connected layer serves to reduce dimensionality; the asymmetric activation function is ReLU; and the second fully connected layer is used to restore the channel dimension. The output of the second fully connected layer is activated by a sigmoid function, generating a channel attention weight vector ranging from 0 to 1.
[0046] The generated channel attention weight vector is combined with the multi-scale fused features. Perform channel-wise multiplication. Then, add the weighted features element-wise to the original input features of this module, i.e., perform residual connection, to obtain the channel-enhanced features. The technical solution presented in this application effectively preserves the original gradient flow and stabilizes the training process. The specific expression is as follows: in, This represents the channel enhancement feature, which is the output feature after combining channel attention and residual connection operations, i.e., the feature after channel enhancement. This represents the weight matrix of the first fully connected layer; This represents the weight matrix of the second fully connected layer; Represents the original input features; represents the Sigmoid function; GAP represents global average pooling.
[0047] The technical solution of this application embodiment captures the nonlinear relationship between channels through the first fully connected layer and performs dimensionality reduction to reduce computational load; the number of neurons in the second fully connected layer is restored to the original number of channels, and its output restores the channel dimension. The generated channel attention weight vector is multiplied channel-by-channel with the original multi-scale fusion features, so that the feature map of each channel is multiplied by the corresponding weight coefficient, realizing adaptive weighting, which can improve the ability to obtain information useful for fault identification, while suppressing redundant or noisy channels.
[0048] By using a lightweight channel transformation module and a non-linear activation function, the expressive power and diversity of features are enhanced. First, regularization is applied using a Dropout layer to prevent the network from relying on a few specific neurons, thereby enhancing the model's generalization ability. The features regularized by Dropout are then input into a lightweight shared multilayer perceptron (MLP) to perform cross-channel nonlinear mapping and feature transformation, resulting in further optimized features. The specific expression is: in, This indicates a feature that is optimized in one step.
[0049] The features are processed in one step using a 1×1 convolutional layer, adjusting their channel dimensions to the target size. The output of the 1×1 convolutional layer is then fed into a group normalization layer. GN (Group Normalization) effectively avoids the performance instability of batch normalization (BN) during mini-batch training by normalizing the channels by grouping them, thus significantly improving the model's generalization ability and training stability. The output of the group normalization layer is the final feature of this module. The data is then fed into the subsequent parts of the network for final target detection. The specific expression is: in, This represents the aggregated features.
[0050] This application provides a preferred technical solution, such as Figure 5 As shown, the Global Context Aware Module (GCAM) contains two parallel branches. Branch 1 is the directional channel context branch, specifically the Directional ChannelContext branch in this embodiment. Branch 2 is the query-key branch, specifically the QK branch in this embodiment, ultimately achieving feature modulation through computation. Branch 1 is used to model the one-dimensional structural information of the feature map in the horizontal and vertical directions. Branch 2, however, is independent of any specific direction and processes the global spatial context.
[0051] By employing a directional channel context branch, one-dimensional global pooling is performed on the input feature map in both the horizontal and vertical directions to capture directional global dependencies. This module enhances the model's ability to discriminate fault regions, especially weak targets, by jointly modeling directional global dependencies and spatial context relationships.
[0052] This application provides a preferred technical solution, employing directional channel context branching and using AvgPool and MaxPool to integrate global information. One-dimensional average pooling is performed along the height and width directions of the input feature map, generating feature vectors in two directions. The input feature map is denoted as M, and one-dimensional global average pooling and one-dimensional global max pooling are performed along the horizontal direction of the feature map. For the... c The first channel, the first h For each row, average pooling is performed, while max pooling takes the maximum value in that row, generating two feature vectors of dimension C×H×1. One-dimensional global average pooling and one-dimensional global max pooling are then performed along the vertical direction of the feature map. For the ... c The first channel, the first w For each column, average pooling is performed, while max pooling takes the maximum value in that column, generating two feature vectors with dimensions C×1×W.
[0053] The technical solution of this application embodiment adds and fuses the results of average pooling and max pooling in the same direction to combine overall statistical information and the most salient features, thereby obtaining enhanced horizontal and vertical feature vectors respectively. The directional pooling strategy in this embodiment can effectively aggregate long-range dependencies, help separate redundant backgrounds and enhance fault regions, and prioritize the location information of weak targets.
[0054] The two directional feature vectors are concatenated and then dimensionality is reduced by convolution.
[0055] The specific expression is: in, Indicates the input feature map of the th c The values of each channel at position (h,j) are summed, with the first summation term corresponding to horizontal pooling. Indicates the input feature map of the th c The values of each channel at position (i, w) are represented by the first term, and the second summation term corresponds to vertical pooling. f represents the output feature after dimensionality reduction. C, H, and W represent the number of channels, height, and width of the input feature map, respectively.
[0056] The dimensionality-reduced features are split into horizontal and vertical features, and dimensionality is restored through 1×1 convolutions for each. Finally, directional channel attention weights are calculated at each position (i,j). The horizontal features after dimensionality restoration are then selected. The vector in the i-th row , and vertical features vector in the j-th column After final feature adjustment through independent 1×1 convolutions, a two-dimensional directional channel attention weight map is generated. The weight value of each position combines the global dependency information of the row and column in which that position is located.
[0057] The specific expression is: in, This indicates that a 1×1 convolution operation is performed, i.e., feature adjustment is performed.
[0058] This application provides a preferred technical solution. Through branch 2, the query-key-value branch, convolutional operations are used to simulate the interaction between query, key, and value, calculating spatial context weights. The query-key-value branch is a parallel structure. One branch directly uses a 1×1 convolution to obtain a linear transformation result, generating value features and obtaining a value feature matrix. The other branch uses a 1×1 convolution and a sigmoid function to simplify the multiples of query and key, calculating an attention distribution to generate simplified query-key interaction weights, i.e., generating a QK attention weight matrix. The value feature matrix and the QK attention weight matrix are multiplied to aggregate the spatial context. The aggregated context information is then passed through a 1×1 convolutional layer, a batch normalization layer, and a ReLU activation function for nonlinear enhancement and transformation. Finally, the enhanced features are residually concatenated with the original input features to complete the processing within the branch. The resulting output is the spatial context feature map calculated by this branch, i.e., the feature map output by the query-key-value branch. The expression for the spatial context feature map is: in, This represents the enhanced feature vector output from the spatial context feature map at the i-th location; This represents the original input feature vector at the i-th spatial location, i.e., the features before processing by this attention module; This represents the weight matrix of the second linear transformation layer; This represents the weight matrix of the first linear transformation layer; This represents the total number of spatial locations in the input feature map; The feature x representing position j j After linear transformation W k The unnormalized attention score was calculated subsequently; The feature x representing position m m After linear transformation W kThe unnormalized attention score is calculated subsequently; m represents the index variable for traversing all spatial locations in the feature map; This represents the linear transformation weight matrix used to calculate the attention score.
[0059] The output of the directional channel context branch is processed in conjunction with the output of the query-key branch to achieve global context modulation of the input features. (Directional channel attention weight graph) and spatial context feature map After performing the Hadamard product, i.e., the element-wise multiplication operation of the broadcast, an enhanced feature map is obtained. Finally, the global context awareness module outputs an enhanced feature map that has been jointly modulated by the global and local contexts, which significantly improves the model's feature discrimination of fault areas, especially in scenarios with weak target information.
[0060] The network in this application uses YOLOv7-tiny as its basic framework. The backbone incorporates a thermal infrared and temperature information fusion module as the network's information entry point. This module aligns, fuses, and enhances the attention of the spatial texture features of the thermal infrared image with the quantized distribution features of the temperature matrix, providing richer and more complementary information from the source. This significantly improves the model's sensitivity and discriminative power for faults, especially temperature anomalies such as hot spots, fundamentally reducing the false detection rate. It solves the technical problem that in complex environments, such as those with varying lighting and background interference, it is difficult to clearly distinguish faulty areas from normal areas based solely on the texture information of thermal infrared images, easily leading to false detections and missed detections.
[0061] A shallow-deep information aggregation module is introduced in the neck area. Multi-scale convolution is used to extract features from different receptive fields in parallel, and channel attention is used for adaptive weighting. This allows for the simultaneous capture of details and context, focusing on the most effective feature channels. This addresses the technical problem in photovoltaic modules where targets such as microcracks and small hot spots have a small pixel ratio. In existing downsampling techniques, shallow localization information and deep semantic information are easily lost or difficult to effectively fuse, leading to poor small target detection performance.
[0062] The detection head incorporates a global context-aware module. Through a directional channel context branch, it captures long-range dependencies of feature maps in the horizontal and vertical directions, aiding in the accurate perception of target edges and orientation, thus improving localization accuracy. The query-key branch, using a simplified self-attention mechanism, calculates spatial context weights across all locations, ensuring that the judgment of each point incorporates global information. This addresses the technical challenge of fault regions often being intertwined with the background, making it difficult for models lacking a global perspective to accurately determine whether a local area is faulty and where its precise boundaries lie.
[0063] S3. Use the dataset to train the network and obtain a photovoltaic fault detection model.
[0064] This application provides a preferred technical solution, which uses the K-means algorithm to re-cluster the target boxes to generate prior anchor boxes that are more closely matched to the size of photovoltaic fault targets.
[0065] All bounding boxes in the training dataset are selected as samples. Depending on the number of YOLOHeads in the network, such as 3 or 4, the number of cluster centroids k is set to 9 or 12. Three YOLOHeads typically correspond to large, medium, and small scale feature maps, responsible for detecting large, medium, and small targets respectively. This is a very classic and common setup. Four YOLOHeads introduce finer-grained scale division, adding one more head to detect extremely small targets compared to three, further improving the detection capability for small targets. The number of YOLOHeads can be set according to actual needs; this application does not impose a limit on this.
[0066] In this embodiment, the examples illustrate a scenario with 3 YOLOHeads and 9 cluster centroids (k), and 4 YOLOHeads and 12 cluster centroids (k). Each YOLOHead requires a set of predefined prior anchor boxes as initial references for prediction, and the total number of anchor boxes is three times the number of YOLOHeads. The number of centroids (k) in K-means clustering is equal to the total number of anchor boxes in all YOLOHeads, ensuring that each prediction location generates a prior box size that best matches the dataset. Data points are iteratively assigned to the nearest centroid, and the centroid positions are updated until the centroids stabilize and no longer change. Finally, nine candidate box sizes are obtained: (5,5), (5,7), (7,5), (7,8), (8,11), (7,34), (11,65), (28,60), and (35,75). These anchor box sizes better match the actual shape and size distribution of faults such as small hot spots and large targets in component fragmentation in the dataset, providing a better initial reference for the model, which helps to accelerate training convergence and improve localization accuracy. When the number of cluster centroids k is set to 12, the candidate box sizes are: (0,10), (5,6), (5,7), (7,7), (6,8), (7,9), (9,13), (7,33), (11,65), (27,59), (33,69), (39,84). Clustering results, as shown... Figure 6 and Figure 7As shown in the diagram, each dot represents a sample bounding box from the training set. The origin corresponds to unique coordinates in the diagram, representing the width and length of the bounding box. The K-means algorithm divides the bounding boxes by their width and length. Dots of the same color represent bounding boxes with similar widths and lengths. Since their dimensions are similar, they are grouped together by the same color. In the diagram, X represents this color, which represents the average size of the boxes in this group. They are grouped together because their dimensions are similar, and the average value represents the average size of the boxes in this group: width and length. K=9 results in 9 groups; K=12 results in 12 groups; the number of groups corresponds to the number of X's.
[0067] S4. Input the preprocessed and enhanced training set of 3859 images into the constructed network. The network performs forward propagation, with the input data passing sequentially through the backbone network integrating the ITFM module, the neck network integrating the SDA module, and the detection head integrating the GCAM module. Finally, it outputs the prediction results of the target location, i.e., the bounding box coordinates, the category, and the presence confidence.
[0068] The network's predictions are compared with the ground truth labels to calculate the multi-task joint loss. In this embodiment, the loss functions include: localization loss, classification loss, and confidence loss. CIoU Loss is used to measure the difference in position and shape between the predicted bounding box and the ground truth bounding box, ensuring accurate box regression. Cross-entropy loss is used to measure the difference between the predicted fault category and the ground truth category. This is used to determine whether the predicted bounding box contains the target and the reliability of the prediction.
[0069] The calculated total loss gradient is propagated from the output layer to the input layer using the backpropagation algorithm, and all learnable parameters in the network, such as convolutional kernel weights and fully connected layer parameters in the attention mechanism, are updated using an optimizer such as Adam or SGD. This process is repeated iteratively until the model performance stabilizes on the validation set.
[0070] After training, the final photovoltaic fault detection model is obtained. In practical applications, the thermal infrared image of the photovoltaic module to be detected and its corresponding pixel-level temperature matrix are used as input. The input data first undergoes the same preprocessing procedure as during training, and then is fed into the trained photovoltaic fault detection model, namely the IGS-YOLO model. The model performs forward propagation calculations and finally outputs the fault detection results. Each fault detection result contains the following information: bounding box, representing the specific location of the fault in the image in pixel coordinates; category label, indicating the fault type; and confidence score, representing the model's assessment of the reliability of the detection result.
[0071] This application also provides a device for photovoltaic module fault detection based on YOLOv7, including: a data preparation module, a network construction module, a model training module, and a fault detection module.
[0072] In this embodiment, the data preparation module is responsible for the acquisition and preprocessing of multimodal data from photovoltaic modules. This module controls an infrared thermal imager mounted on a drone to automatically acquire thermal infrared images and temperature matrices along a preset flight path. The module has an embedded data preprocessing unit that can label and convert the raw data, and perform offline data augmentation operations (such as flipping, rotating, cropping, and stitching), ultimately generating structured training, validation, and test sets.
[0073] In this embodiment, the network construction module is responsible for defining and building the improved YOLOv7-tiny detection model. Based on the standard YOLOv7-tiny architecture, this module integrates three core sub-modules: a thermal infrared and temperature information fusion module, a shallow-deep information aggregation module, and a global context awareness module. This module instantiates these components through code to construct a complete, trainable network computation graph.
[0074] The model training module is responsible for driving the model's learning process. This module loads the dataset processed by the data preparation module and calls the model defined by the network building module. It includes a built-in K-means clustering program for calculating optimal anchor boxes. The module encapsulates the complete training loop, including forward propagation, loss calculation (using DSCIOU for localization loss), and combining classification and confidence losses, backpropagation, and parameter updates using the Adam optimizer. It also manages training strategies, such as partial network freezing, and is responsible for saving the optimal model weights.
[0075] Fault Detection Module: Responsible for model deployment and real-time inference. This module loads the final weight file produced by the model training module, deploys the trained model to computing devices such as ground servers or embedded platforms. It provides an application programming interface (API) to receive the thermal infrared image and temperature matrix to be detected, performs necessary preprocessing such as resizing and normalization, and then performs model inference. Finally, this module performs post-processing on the output predicted bounding boxes, such as non-maximum suppression, and provides clear fault detection results—location, category, and confidence level—either as a visual output or transmitted to the photovoltaic power plant intelligent operation and maintenance platform.
[0076] This application's embodiments verify the effectiveness of its technical solution through comparative experiments, comparing it with models such as YOLOv8-GD, YOLOv5-SC, LFS-Yolo, FAA-Yolo, GBM-YoLOv8, EL-LwNet, and SCNet. The comparative experiments used parameters, mAP50, mAP50:95, and FLOPs (computational cost) to measure the superior performance of the models.
[0077] Table 1 Comparison of Experimental Results The above comparisons show that the technical solution of this application achieves the best performance in all detection accuracy indicators, with mAP50 and mAP50:95 reaching 0.935 and 0.594 respectively, both exceeding the highest values of the current comparative methods. Compared with FAA-Yolo (mAP50 = 0.922, mAP50:95 = 0.589), which has the closest accuracy, the technical solution of this application improves the accuracy by 1.3 and 0.9 percentage points in the two indicators respectively. Compared with other technical solutions, the technical solution of this application maintains a stable advantage at high IoU thresholds, demonstrating a precise fitting ability to the target boundary. Based on the original YOLOv7-tiny, this application improves mAP50 by 17.5% and mAP50:95 by 21.7% while increasing the number of parameters by approximately 42.6% (from 16.2M to 23.1M) and the computational load by approximately 103% (from 56.8G to 115.2G).
[0078] In summary, the technical solution of this application introduces a thermal infrared image and temperature information fusion module (ITFM), combined with a shallow-deep information aggregation module (SDA) and a global context awareness module (GCAM), significantly enhancing the model's ability to detect four types of faults in photovoltaic module junction boxes: faults, cracks, hot spots, and shading. This is particularly effective for detecting small targets like hotspots, maintaining a lightweight design while significantly improving detection accuracy and robustness. The optimized design of feature representation and multi-scale information fusion in this application addresses these issues. Firstly, the introduced shallow-deep information aggregation module enhances the collaborative modeling capability of local structure and global context, effectively alleviating detection difficulties caused by complex backgrounds and varying target sizes. Secondly, the global context awareness module guides the strategy, enabling the network to dynamically focus on key target regions during training, thereby improving detection accuracy under conditions of small targets, shading, and low contrast. This method achieves a significant improvement in accuracy while reducing the number of parameters and computational cost, making it more competitive in high-accuracy applications such as photovoltaic panel fault detection. Furthermore, it demonstrates that the proposed structural optimization strategy can effectively improve detection performance without significantly increasing computational burden.
[0079] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0080] The units described in the embodiments of this application can be implemented in software or hardware. The names of the units are not, in some cases, limiting the scope of the unit itself.
Claims
1. A method for fault detection of photovoltaic modules based on YOLOv7, characterized in that, include: A dataset containing thermal infrared images of photovoltaic modules and their corresponding temperature matrices was constructed and preprocessed. Construct a network based on YOLOv7-tiny; Specifically, a thermal infrared and temperature information fusion module is introduced into the backbone of the network, a shallow-deep information aggregation module is introduced into the neck of the network, and a global context awareness module is introduced into the detection head of the network. The network is trained using the dataset to obtain a photovoltaic fault detection model; The thermal infrared image of the photovoltaic module to be detected and its corresponding temperature matrix are input into the photovoltaic fault detection model, and the fault detection results are output.
2. The method according to claim 1, characterized in that, The thermal infrared and temperature information fusion module includes: Spatial alignment and normalization are performed on the input thermal infrared image and temperature matrix; Spatial texture features and temperature distribution features are extracted using parallel image coding branches and temperature coding branches, respectively. The extracted spatial texture features and temperature distribution features are then combined by channel stitching and convolution fusion. An improved convolutional block attention module is used to adaptively enhance the channel and spatial dimensions of the fused features.
3. The method according to claim 2, characterized in that, The improved convolutional block attention module includes: The features obtained after global average pooling and global max pooling are processed and summed using a multilayer perceptron to generate a channel attention weight map. The channel attention weight map is multiplied by the fused feature to obtain the channel enhancement feature; The channel enhancement features are processed by global average pooling and global max pooling, then concatenated along the channel dimension, and a spatial attention weight map is generated by a convolutional layer. The spatial attention weight map is multiplied by the channel enhancement feature to output the enhanced multimodal feature map.
4. The method according to claim 1, characterized in that, The shallow-deep information aggregation module includes: Multi-scale convolutional kernels are used to extract contextual information of different receptive fields of the input features in parallel, and then channel concatenation is performed; A channel attention mechanism is introduced to perform saliency modeling and adaptive weighting on the spliced multi-scale features; The expressive power and diversity of features are enhanced by using a lightweight channel transformation module and a nonlinear activation function. Group normalization is used to stabilize the transformed features, and the aggregated features are output.
5. The method according to claim 4, characterized in that, The channel attention mechanism includes: Global average pooling is performed on the input features to generate channel description vectors; The channel description vector is then nonlinearly mapped through a fully connected layer and an asymmetric activation function. The mapped vector is activated by the Sigmoid function to generate the weight coefficients for each channel; The generated weight coefficients are multiplied by the original input features channel by channel to complete channel weighting.
6. The method according to claim 1, characterized in that, The global context awareness module includes: Directional channel context branch and query-key value branch; where, The directional channel context branch performs one-dimensional global pooling on the input feature map in the horizontal and vertical directions to capture directional global dependencies. The query-key-value branch uses convolution operations to simulate the interaction between query, key and value in the attention mechanism and calculates spatial context weights. The output of the directional channel context branch and the output of the query-key value branch are used to perform operations to achieve global context modulation of the input features.
7. The method according to claim 6, characterized in that, The directional channel context branch includes: One-dimensional average pooling is performed along the height and width directions of the input feature map to generate feature vectors in two directions. The feature vectors from the two directions are concatenated and then dimensionality reduced using convolution. The dimensionality-reduced features are split into horizontal features and vertical features; The dimensions of the horizontal and vertical features are recovered through convolution operations, and the directional channel attention weights are calculated for each spatial location.
8. The method according to claim 1, characterized in that, Constructing and preprocessing the dataset includes: Collect infrared images and corresponding temperature matrix data of photovoltaic power plants; The collected data should be labeled, and the fault types should include at least: junction box failure, component breakage, hot spots and bird droppings obstruction; Offline augmentation of labeled data can be performed by flipping, rotating, or cropping and splicing to expand the dataset size.
9. The method according to claim 1, characterized in that, Training the network includes: The K-means clustering algorithm is used to re-cluster the sizes of the labeled boxes in the dataset to generate prior anchor boxes that match photovoltaic fault targets; The preprocessed training data is input into the network, and the prediction result is calculated through forward propagation. We combine localization loss, classification loss, and confidence loss for multi-task joint optimization, and update the network weights through backpropagation.
10. An apparatus for implementing the YOLOv7-based photovoltaic module fault detection method as described in any one of claims 1-9, characterized in that, include: The data preparation module is used to construct and preprocess a dataset containing thermal infrared images and temperature matrices. The network construction module is used to construct a YOLOv7-tiny network that integrates the thermal infrared and temperature information fusion module, the shallow-deep information aggregation module, and the global context awareness module. The model training module is used to train the network constructed by the network construction module using the data provided by the data preparation module to obtain a photovoltaic fault detection model. The fault detection module is used to send the input data to be detected into the photovoltaic fault detection model and output the final fault location and classification results.
Citation Information
Patent Citations
Method and device for detecting abnormal temperature of power equipment
CN116523881A
Real-time high-precision traffic sign small target detection method based on improved YOLOv7-tiny
CN116778455A
Attention mechanism-based aerial image target detection method and system and related device
CN119107486A
Chimney detection method based on ai technology
US20250336194A1
Cited By
Traffic marking detection method and system for complex pavement environment
CN121982674A
A traffic marking detection method and system for complex road surface environment
CN121982674B
Power transformation facility anti-bird measure parameter dynamic adjustment system and method based on big data
CN121998437A
