Photovoltaic panel anomaly detection method based on improved mask R-CNN network
By improving the Mask R-CNN network and combining UAV image acquisition with deep learning image analysis, the problem of low recognition accuracy and efficiency of photovoltaic panel anomaly detection in complex backgrounds was solved, achieving efficient and accurate crack and dirt detection, and improving the stability and power generation efficiency of the photovoltaic system.
Patent Information
- Application Number
- CN202410783936.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2044-06-18
AI Technical Summary
Existing technologies have low accuracy and efficiency in detecting anomalies in photovoltaic panels under complex backgrounds, making it difficult to detect early or minute cracks and dirt.
An improved Mask R-CNN network is adopted, which introduces a positional channel attention mechanism and expands the dataset. It combines UAV image acquisition and deep learning image analysis, uses high-definition UAV image acquisition and deep learning image analysis to expand the number of positive samples, performs image preprocessing and feature extraction, and improves the model's generalization ability and recognition accuracy.
It enables efficient and accurate identification of cracks and dirt on photovoltaic panels in complex backgrounds, improving the model's recognition accuracy and efficiency, and enabling timely detection of early anomalies to ensure the stable operation and power generation efficiency of the photovoltaic system.
Smart Images

Figure CN118674702B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of photovoltaic power generation technology, and in particular to a method for detecting anomalies in photovoltaic panels based on an improved neural network. Background Technology
[0002] In the photovoltaic (PV) energy sector, with the widespread deployment of PV systems, their maintenance and efficiency optimization have become a focus of research and industry attention. As a core component, the performance of PV panels directly affects the power generation efficiency of the entire system. However, PV panels are susceptible to anomalies such as cracks and dirt during long-term operation. These anomalies not only reduce the power generation efficiency of the PV panels but may also shorten their lifespan. Therefore, developing an efficient and accurate PV panel anomaly detection technology is particularly important. Traditional detection methods mainly rely on manual visual inspection and simple electrical tests. These methods are not only time-consuming and labor-intensive but also difficult to detect early or minor anomalies. With the development of deep learning technology, using high-precision image recognition technology to automatically detect cracks and dirt on the surface of PV panels provides a more efficient and accurate solution. This method not only improves the efficiency and accuracy of detection but also allows for early detection of problems, enabling timely maintenance or replacement, ensuring the stable operation of the PV system and maximizing power generation efficiency.
[0003] Currently, the technical challenges in using high-precision image recognition technology based on neural networks to automatically detect cracks and dirt on the surface of photovoltaic panels include low accuracy and efficiency in identifying abnormal data in complex backgrounds. Summary of the Invention
[0004] To address the aforementioned problems, this invention provides a photovoltaic panel anomaly detection method based on an improved Mask R-CNN network. The method specifically comprises:
[0005] S1. Establish an abnormal dataset for photovoltaic panels: Collect data to construct a sample set, expand the number of positive samples, and expand the dataset;
[0006] S2. Preprocess the photovoltaic panel image by converging the initial image contour L and image edge N to obtain the converged edge E. Use morphological closing operation to fill the breaks in the contour line of the converged edge E to obtain an image C containing the edge contour of the photovoltaic panel. Use mean filtering to optimize the image C to obtain a single-channel edge feature grayscale image.
[0007] S3. Improve the Mask R-CNN network to obtain the improved Mask R-CNN network, specifically:
[0008] First, the input of the Mask R-CNN network was adjusted from 3 channels to 4 channels;
[0009] Then, a positional channel attention mechanism is introduced before the backbone network of the Mask R-CNN network, using the RGB three-channel image and the feature map output by the positional channel attention mechanism as the four-channel image input of the improved Mask R-CNN network;
[0010] S4. Train the improved Mask R-CNN network using the photovoltaic panel anomaly dataset until the network meets the requirements, and then use the improved Mask R-CNN network to detect anomalies in photovoltaic panels.
[0011] The beneficial effects of the method described in this invention are as follows:
[0012] 1) By combining high-definition drone image acquisition and deep learning image analysis, it is possible to efficiently and accurately identify anomalies such as cracks and dirt on photovoltaic panels.
[0013] 2) The use of manual intervention and image processing techniques to expand the number of positive samples effectively increased the diversity of the dataset and improved the generalization ability of the model.
[0014] 3) Image transformation techniques (such as rotation, scaling, and flipping) are used to further enrich the training data and enhance the model's ability to identify anomalies under different conditions.
[0015] 4) Introducing a positional channel attention mechanism in Mask R-CNN: The design of the positional channel attention mechanism in this invention adopts a channel-based processing approach, which improves image processing efficiency and feature extraction capabilities, and enhances the model's accuracy in identifying abnormal regions, especially in complex backgrounds. Attached Figure Description
[0016] Figure 1 This is a flowchart of a photovoltaic panel anomaly detection method based on an improved Mask R-CNN network in an embodiment of the present invention;
[0017] Figure 2 This is a flowchart of the image preprocessing process in an embodiment of the present invention;
[0018] Figure 3 This is a structural diagram of the location channel attention mechanism module in an embodiment of the present invention. Detailed Implementation
[0019] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the protection scope of the present invention.
[0020] This embodiment provides a photovoltaic panel anomaly detection method based on an improved Mask R-CNN network. A photovoltaic panel anomaly (cracks, dirt) dataset is established. A drone equipped with a high-definition camera is used to acquire high-definition images of the photovoltaic panel area from high altitude. The number of positive samples is expanded using manual intervention and image post-processing methods, and the dataset is expanded using scaling, rotation, and tilting. The photovoltaic panel images are preprocessed by using edge feature extraction modules of the Canny and LSD algorithms to extract features from the high-definition RGB images, obtaining single-channel edge feature grayscale images. The RGB three-channel images and the single-channel edge feature grayscale images are used as the four-channel image input to the network. Position attention and channel attention mechanisms are introduced to establish and train an improved Mask R-CNN photovoltaic panel anomaly image segmentation network. This method can effectively detect cracks and dirt on the surface of photovoltaic panels.
[0021] This embodiment provides a photovoltaic panel anomaly detection method based on an improved Mask R-CNN network. The steps of the method are as follows: Figure 1 As shown:
[0022] Step 1: Establish a dataset of photovoltaic panel anomalies (cracks, dirt). Use a drone equipped with a high-definition camera to collect high-definition images of the photovoltaic panel area from high altitude. Use manual intervention and image post-processing to expand the number of positive samples. Use scaling, rotation, tilting and other methods to expand the dataset.
[0023] Step 2, preprocess the photovoltaic panel image, the steps are as follows: Figure 2 As shown, on one hand, the Canny algorithm is used to preprocess the training set images, and the LSD line detection algorithm is used to further process the preprocessed images. Then, the K-means clustering algorithm is used to extract the image edge information N. On the other hand, the DeepLab network is used to segment the training set images and extract the initial image contour L. The image edge information N and the initial contour L converge according to the minimum distance principle to obtain the converged edge E. The converged edge E is accurately segmented, and morphological opening and closing operations are used to fill the breaks in the contour line of the converged edge E to obtain an image C containing the edge contour of the photovoltaic panel. Then, mean filtering is used to optimize image C to obtain a single-channel edge feature grayscale image.
[0024] Step 3: Using RGB three-channel images and single-channel edge feature grayscale images as the four-channel image input of the network, a position attention mechanism and a channel attention mechanism are introduced to construct the position and channel attention mechanism, and a modified Mask R-CNN photovoltaic panel abnormal image segmentation network is established and trained.
[0025] Step 1 specifically involves:
[0026] ① Collect data and construct a sample set:
[0027] Under varying lighting conditions, drones equipped with high-definition cameras were used to capture a large number of high-resolution images of the photovoltaic panel area from above. These images were then manually categorized into three types: images of photovoltaic panels without anomalies, images of photovoltaic panels with surface cracks, and images of photovoltaic panels with surface dirt, in order to construct an initial sample set.
[0028] ② Increase the number of positive samples:
[0029] Given that the number of anomalous photovoltaic panels (negative samples) far exceeds the number of anomalous (positive samples) images in the field acquisition, innovative methods can be used to expand the sample size. For cracked samples, images of various crack types can be designed and printed, then applied to the photovoltaic panels, and images can be reacquired to simulate crack conditions. For dirt samples, various "dirt effect" textures can be created and applied to the photovoltaic panel images on a computer to simulate the presence of dirt.
[0030] ③ Expand the dataset
[0031] Image transformation techniques are used to expand image datasets by generating new training samples by modifying existing images without actually increasing the number of original images. Techniques such as rotation, scaling, flipping, color adjustment, adding noise, and geometric transformations are used to significantly increase the diversity of the dataset, thereby improving the model's generalization ability and robustness in practical applications.
[0032] Step 2 specifically involves:
[0033] ① The edges of the photovoltaic panel image are extracted using the Sobel operator to obtain the initial contour L, and its calculation formula is as follows:
[0034]
[0035] Among them, g x-sobel This represents the horizontal gradient calculated using the Sobel operator, g. y-sobel This represents the vertical gradient calculated using the Sobel operator, f represents the image, x represents the x-coordinate of a pixel in the image, y represents the y-coordinate of a pixel in the image, θ represents the coefficient (in this embodiment, θ is set to 1), and z1-z9 represent the eight values in the neighborhood of the pixel after the Sobel operator calculation: z1 is the top left corner, z2 is the top right corner, z3 is the top right corner, z4 is the left side, z6 is the right side, z7 is the bottom left corner, z8 is the bottom right corner, and z9 is the bottom right corner.
[0036] ② Calculate the gradient for the 2×2 region of each pixel in the training image after edge extraction. Use the LSD (Line-Segment Detector) algorithm to extract lines within the region and calculate the gradients in the horizontal and vertical directions. The calculation formula is as follows:
[0037]
[0038] Where i(x,y) represents the value at point (x,y);
[0039] ③ After obtaining the gradient magnitude of all pixels, arrange the pixels with magnitudes higher than the given threshold ρ in descending order and divide them evenly into 1024 intervals. Take the first pixel of each interval as the seed point, and add adjacent pixels from this point to gradually expand the area of the region. Each region has an angle θ. r The initial value is the horizontal angle of the seed, and θ r In each iteration, the update follows the following rule, and the formula is as follows:
[0040]
[0041] Where, β j Represented as the horizontal angle of all pixels within this region;
[0042] The region is expanded using a region growing algorithm, and a minimum bounding rectangle containing all pixels in the region is constructed.
[0043] The resulting straight lines (further determined by the center and main direction of the rectangle; not all detected lines are needed, some non-target lines are filtered out based on the center and main direction of the rectangle) mainly fall into three categories: the first category (s1) and the second category (s2) are the outlines of the photovoltaic module, with their directions parallel to the length and width of the photovoltaic panel, respectively; the third category (s3) consists of noise and some irrelevant lines in the background area, and usually has the fewest lines among the three categories. Based on the characteristic that the length and width of the photovoltaic panel are parallel, all straight lines can be divided into three categories according to their angles. Using the LSD algorithm, the endpoint coordinates of all lines satisfying the conditions have been obtained, and the line angles can be calculated.
[0044]
[0045] Where y1, y2, x1, and x2 represent: ; Select two points in the line to calculate the angle between the line and the horizontal direction, where y1 is the ordinate of point 1, y2 is the ordinate of point 2, x1 is the abscissa of point 1, and x2 is the abscissa of point 2.
[0046] K-means clustering algorithm is used to cluster the lines based on their angle, and the three clusters with the smallest variance are selected. The total number of lines in each cluster is counted, and the cluster with the fewest lines is discarded, representing background noise. Secondary clustering is performed based on line length to eliminate the internal contour lines of the photovoltaic panel, retaining only the external contour as the edge N.
[0047] ④ The initial contour L and the edges N after K-means clustering are converged according to the minimum distance principle to obtain the convergent edge E. The convergent edge E has some breaks; morphological closing operations can be used to fill these breaks in the contour line, smoothing the boundary without changing the area. The closing operation of the structuring element B on set A involves first dilating A with B, and then eroding the dilated result with B, as shown below:
[0048] A⊕B={x,y|(B) xy ∩A≠Φ};
[0049]
[0050] ⑤ The mean filter is used to optimize the calculation results, resulting in the edge feature grayscale image g(x,y), M area The area of the filter window:
[0051]
[0052] Where f(x,y) represents the value at the point (x,y);
[0053] Step 3 specifically involves:
[0054] ① The input to the original Mask R-CNN network is an RGB image with 3 channels. In step 2, an edge feature grayscale image with 1 channel is obtained. The first convolutional kernel of the feature extraction backbone network is adjusted to 4, so that the input to the improved Mask R-CNN network is a 4-channel image, consisting of 3 channels of the RGB image and 1 channel of the edge feature grayscale image.
[0055] ② Introduce a location channel attention mechanism, the structure of which is shown in the figure below. Figure 3 As shown, the location channel attention mechanism in this embodiment will be named LCAM.
[0056] (Location Channel Attention Module),
[0057] To further improve the extraction effect of photovoltaic modules, the location and channel information of photovoltaic modules in the image are obtained. The input feature map x is divided into two main paths after entering the location channel attention. In the first location path, the input features are split and reduced in dimensionality, and global average pooling is performed. Two pooling kernels, (H, 1) and (1, W), are used to encode features for each channel along the horizontal and vertical directions, respectively. The output at height h of the nth channel can be represented as follows:
[0058]
[0059] Similarly, the output at the width w of the nth channel can be expressed as:
[0060]
[0061] Where h and w represent height and width respectively, with values ranging from 0 to H and 0 to W, and i and j represent traversal in the W and H directions respectively.
[0062] After global average pooling, a set of direction-aware feature maps is obtained. While acquiring the channel information of the feature vectors, spatial information is preserved in another direction, enabling the segmentation network to accurately locate the edge position of the photovoltaic module. This pair of feature maps is then fused and input into a 1×1 convolution to obtain intermediate feature maps Q that encode spatial information in the horizontal and vertical directions. E1 represents the convolution transformation function with a 1×1 kernel size, and [,] denotes cascaded connections. The specific process is as follows:
[0063] Q = Re LU(E1[O h O w ]);
[0064] The intermediate feature map Q is processed by a BN layer and a ReLU activation function, followed by a 1×1 convolution in the W and H directions. Finally, it is processed by a Sigmoid function to obtain a feature vector f with the same dimension as the input feature map. h and f w As shown below:
[0065] f h =Sigmoid(G h (Q h ));
[0066] fw = Sigmoid(Gw(Q) w ));
[0067] Q h and Q w G represents the feature maps in the H and W directions, respectively; h and G w These represent operations to convert them to the same number of channels. (The last part, "f", appears to be a typo and can be left as is.) h and f w Expanding these values separately as positional attention weights, the final output Y1 for the first route is as follows:
[0068] Y1(i,j)=f h (i)×f w (j);
[0069] The second approach captures richer semantic information by establishing relationships between feature maps from different channels. The input feature map x is processed using global average pooling and max pooling to obtain Y. avg and Y maxAfter passing through two fully connected layers to perform dimensionality increase and decrease operations, the output Y2 is obtained by inputting into the Sigmoid activation function, and the channel-dimensional output weights M are obtained by using the ReLU function. C The process is as follows:
[0070] Y2=Sigmoid(ω1(ω0(Y avg ))+ω1(ω0(Y max )));
[0071] M C =ReLU(ωY2);
[0072] Where ω0 and ω1 represent two shared input weights, Y0 represents the features at the input position channel before the attention mechanism, and finally the output feature map Y is obtained through residual connections. LCAM as follows:
[0073] Y LACM =Y1×Y2+Y0.
Claims
1. A photovoltaic panel anomaly detection method based on an improved Mask R-CNN network, characterized in that, The method includes the following steps: S1. Establish an abnormal dataset for photovoltaic panels: Collect data to construct a sample set, expand the number of positive samples, and expand the dataset; S2. Preprocess the photovoltaic panel image by converging the initial image contour L and image edge N to obtain the converged edge E. Use morphological closing operation to fill the breaks in the contour line of the converged edge E to obtain an image C containing the edge contour of the photovoltaic panel. Use mean filtering to optimize the image C to obtain a single-channel edge feature grayscale image. The method for obtaining the image edge N is as follows: S31, after calculating the gradient magnitude of the pixels of the initial contour L, the pixels are divided into intervals using a given threshold ρ, and the horizontal angle of all pixels in each region is obtained. S32. Expand the region using the region growing algorithm and construct the smallest bounding rectangle containing all pixels in the region; S33. Obtain the endpoint coordinates of all lines that meet the conditions using the LSD algorithm and calculate the line angles; S34. Cluster the lines using the K-means clustering algorithm with the line angles as features, and take the three clusters with the smallest variance; count the total number of lines in each class, discard the class with the fewest lines, perform secondary clustering with the line length as features, and retain only the outer contour as the image edge N; S3. Improve the Mask R-CNN network to obtain the improved Mask R-CNN network, specifically: First, the input of the Mask R-CNN network is adjusted from 3 channels to 4 channels: the first layer convolutional kernel of the backbone network of the Mask R-CNN network is adjusted to 4, so that the improved Mask R-CNN network becomes a four-channel image input; Then, a positional channel attention mechanism is introduced before the backbone of the Mask R-CNN network. The RGB three-channel image and the feature map output by the positional channel attention mechanism are used as the four-channel image input to the improved Mask R-CNN network. The specific operations performed in the positional channel attention mechanism are as follows: After the input feature map enters the positional channel attention, it splits into two paths. In the first path, the input features are split and reduced in dimensionality, and then global average pooling is performed. Two pooling kernels, (H, 1) and (1, W), are used to encode features for each channel along the horizontal and vertical directions, respectively. The two direction-aware feature maps are fused and then fed into a 1×1 convolution. After passing through a BN layer and a ReLU activation function, a 1×1 convolution is performed in the W and H directions. Then, the convolutions are passed through a Sigmoid function to obtain two feature vectors with the same dimension as the input features. The two vectors are then concatenated to obtain the output feature map. ; In the second route, the input feature map is subjected to global average pooling and max pooling operations to obtain the feature map. and feature map Feature map and feature map The data are then fused after passing through two fully connected layers, and then fed into a sigmoid activation function to obtain the output feature map. ; feature map and feature map After splicing, connect with the residual Add them together to obtain the output feature map. ; S4. Train the improved Mask R-CNN network using the photovoltaic panel anomaly dataset until the network meets the requirements, and then use the improved Mask R-CNN network to detect anomalies in photovoltaic panels.
2. The photovoltaic panel anomaly detection method based on an improved Mask R-CNN network according to claim 1, characterized in that, The method for obtaining the initial contour L of the image is as follows: the edges of the photovoltaic panel image are extracted using the Sobel operator to obtain the initial contour L.
3. The photovoltaic panel anomaly detection method based on the improved Mask R-CNN network according to claim 2, characterized in that, The residual connection Connect the input and output terminals.
Citation Information
Patent Citations
Photovoltaic panel defect diagnosis method based on edge detection convolutional neural network
CN113837994A
Defect detection method and defect detection device in industrial detection
CN116721098A
