Abstract
To address the challenges of insufficient robustness and limited feature extraction in photovoltaic module image segmentation under complex scenarios, we propose a high-precision PV module segmentation model (Pv-UNet) that integrates Transformer and improved U-Net architecture. The model introduces a MultiScale Transformer in the encoding path to achieve cross-scale feature correlation and semantic enhancement, combines residual structure with dynamic channel adaptation mechanism in the DoubleConv module to improve feature transfer stability, and incorporates an Attention Gate module in the decoding path to suppress complex background interference. Experimental data were obtained from UAV visible light images of a photovoltaic power station in Yuezhe Town, Qiubei County, Yunnan Province. Compared with U-Net, BatchNorm-UNet, and Seg-UNet, Pv-UNet achieved significant improvements in IoU, Dice, and Precision metrics to 97.69%, 93.88%, and 97.99% respectively, while reducing the Loss value to 0.0393. The results demonstrate that our method offers notable advantages in both accuracy and robustness for PV module segmentation, providing technical support for automated inspection and intelligent monitoring of photovoltaic power stations.
1. Introduction
Against the backdrop of the global energy structure’s continuous transition toward low carbonization, the installed capacity of clean energy represented by solar energy has grown rapidly. Endowed with advantages such as wide applicability, zero pollution, and abundant resources, photovoltaic (PV) power generation has achieved remarkable development in the new energy sector. As the primary energy-harvesting medium for solar energy, photovoltaic (PV) panels have been widely applied across various regions and scenarios. With the significant increase in the adoption rate and application scope of PV panels, achieving their automated management has become a practical industrial demand. The automatic, rapid, and accurate identification and segmentation of PV panels are crucial for estimating PV power generation, analyzing regional distribution and dynamic changes, and providing data support for government decision-making [1]. However, when defects occur on the surface of PV modules, their light-to-electricity conversion efficiency decreases significantly, manifesting as high-brightness features in infrared images. With the rapid advancement of unmanned aerial vehicle (UAV) and infrared imaging technologies, defect identification of PV modules based on image processing has become the most mainstream and efficient technical method to date [2]. To quickly and accurately locate defective modules in complex background environments, it is necessary to first achieve precise segmentation of PV panel regions [3]. Therefore, how to efficiently and accurately identify and extract PV modules from visible light images (as a preprocessing step) is a key link in realizing intelligent inspection, fault diagnosis (based on infrared images) [4], and operational optimization, which holds significant engineering application value.
In recent years, deep convolutional neural networks (CNNs) have been widely applied in the field of image segmentation. The U-Net network proposed by Ronneberger et al. [5] consists of three components: an encoder, a decoder, and skip connections. It can fuse feature information at different scales and levels, achieving excellent performance in fields such as autonomous driving, remote sensing image classification, and medical image processing. As a classic semantic segmentation model, U-Net can be trained with a relatively small dataset to realize rapid PV panel detection. However, due to the varying complexity of PV installation scenarios and numerous interfering factors, it exhibits large detection errors in large-area PV panel identification, prone to adhesion between adjacent PV panels, misidentification, and missed detection, resulting in low extraction accuracy [6]. Owing to its relatively simple network structure, its ability to extract features of PV panels with complex morphologies remains limited—a problem also highlighted in existing research on remote sensing image segmentation of PV panels [7]. To improve model performance, Res-UNet combines residual networks (ResNet) with U-Net, alleviating the performance degradation issue of deep networks and enhancing training stability. Nevertheless, in practical applications, it still faces challenges such as insufficient feature extraction capability and excessive parameter count. MobileNetV2 significantly reduces computational complexity by adopting depthwise separable convolutions and inverted residual structures, but its segmentation accuracy in complex scenarios remains inadequate [2]. Currently, PV module segmentation technology still confronts three key challenges: (1) Insufficient efficiency in multi-scale feature fusion, making it difficult to accurately handle complex morphologies such as fragmented modules; (2) Significant interference from complex backgrounds (e.g., mountainous vegetation and shadows), which easily leads to deviations in segmentation results; (3) Difficulty in balancing edge details and overall structure, challenging to maintain structural integrity while ensuring boundary accuracy. These issues restrict the in-depth development of PV module segmentation technology and provide a theoretical basis for the research of efficient algorithms [8].
To address the limitations of traditional convolutional neural networks (CNNs) in photovoltaic (PV) module identification and segmentation, such as insufficient feature extraction capability and high misjudgment rate, the Transformer architecture has gradually become a research hotspot in the field of computer vision due to the unique advantage of its Self-Attention mechanism in processing global contextual information [9]. This study introduces the Transformer model to expand the receptive field and enhance the ability of global feature modeling. By integrating multi-level and multi-scale feature information, a multi-scale feature-enhanced Transformer-based model is constructed. This approach aligns with the existing practical logic of “fusing Transformer with U-Net for remote sensing image extraction” [10] and also draws on the technical experience of U-Net-Transformer fusion in other segmentation fields (e.g., medical image segmentation) [11]. Specifically, feature maps with different downsampling rates (x2, x3, x4, x5) are fed into the MultiScale Transformer. Taking the deepest feature map x5 as the global reference, a cross-scale semantic correlation model is established visa a multi-level attention mechanism: feature maps at each scale serve as Queries (Q), while the deepest feature map acts as both Keys (K) and Values (V). Dynamic enhancement of multi-scale features is achieved via attention weighting. This mechanism effectively compensates for the deficiency of traditional U-Net in modeling global semantic correlations, enabling features in the encoding phase to capture local details while maintaining overall semantic consistency. The improved U-Net model based on this design not only retains the advantage of multi-scale feature fusion but also significantly enhances semantic modeling capability, feature discriminability, and task adaptability, making it more suitable for PV module segmentation tasks in complex scenarios.
2. Model Construction and Methods
2.1. MultiScale Transformer Module Design
To enhance U-Net’s semantic modeling capabilities, the MultiScale Transformer module is introduced into the encoding path.As shown in Figure 1. This module adopts a multi-head attention mechanism to dynamically weight multi-scale features. It thereby establishes cross-scale correlation between deep semantic information and shallow detail features. With input features (i = 2, 3, 4, 5), the deepest feature X5 serves as a global reference to construct a Query-Key-Value mapping. First, each scale feature undergoes sequence processing, flattening the spatial dimension (H × W) of the feature map to a sequence length L = H × W, resulting in sequence features Xi∈R(L × C) (where C represents the number of feature map channels). For the deepest feature X5, 1 × 1 convolutions generate keys (K) and values (V) with parameter matrices Wk∈R 512 × 64 and Wv∈R 512 × 64 (adjusting the channel number to 64 to accommodate an 8-head attention mechanism, each head having a dimension of 8).The shallow features (X2/X3/X4) are directly treated as queries (Q) (retaining their original sequence feature form) to interact with K (Key) and V (Value). Subsequently, 8-head multi-head attention calculation is performed between Q (from X2/X3/X4) and K/V (from X5), with the formula expressed as
where headᵢ = Attention (QWᵢQ, KWᵢK, VWᵢV) and Wo denotes the output projection matrix.
MultiHead (Q, K, V) = Concat (head1 …, head8) Wo
Figure 1.
Structure diagram of the Multi-scale Transformer.
After obtaining the attention output of each shallow feature, it is concatenated with the original sequence feature of the corresponding shallow layer (via residual connection) to preserve edge details. The fused sequence is then reshaped back to the spatial dimension (H × W × C) of the feature map, upsampled to match the resolution of the corresponding encoder layer, and finally fed back to the encoding path for subsequent feature fusion.
The Multi-Scale and Multi-Directional Transformer (MSMDFormer) enhances deep network representation learning capabilities through integrated multi-scale and multi-directional feature representation, enabling high-performance image interpretation [8]. Traditional Transformers using single-scale feature inputs face two challenges in photovoltaic scenarios: (1) Significant size differences between intact and fragmented modules lead to detail loss in smaller components; (2) Confusion between mountainous/vegetated backgrounds results in insufficient global semantic correlation [12]. Our MultiScale Transformer takes X5 as the only global reference (providing global semantic information), and uses cross-scale Q-K-V mapping to transmit X5’s semantic constraints to shallow features (X2/X3)—this ensures that X2/X3 can preserve component edge details (e.g., contours of fragmented modules) while avoiding background interference under X5’s guidance. For instance, in mountainous photovoltaic images, X5 locates the overall module cluster regions (global positioning), and X2 (the shallowest feature layer) refines the edge contours of modules (local detail) based on X5’s semantic guidance.
2.2. Enhancing the U-Net Architecture and Attention Gate Mechanism
The DoubleConv module of the traditional U-Net lacks residual connections. When processing 43,365 photovoltaic image samples, deep networks tend to suffer from gradient vanishing, which disrupts the feature propagation of fragmented modules [7]. To address this issue, this study introduces residual connections and a dynamic channel adaptation mechanism into the DoubleConv module. Meanwhile, 1 × 1 convolution is used for channel alignment, combined with dilated convolution (d = 2) to expand the receptive field. This design not only alleviates gradient vanishing in deep networks but also enhances the ability to capture features of small-sized modules, thereby specifically solving the engineering problem of “missing detection of modules” in photovoltaic inspection. The above improvement idea is consistent with the structural optimization logic of “improved U-Net for scenario-specific segmentation (e.g., steel structure corrosion segmentation)” [13]. Specifically, the main path of the module adopts a Conv-BN-ReLU structure with dilated convolution to extract detailed features, the Shortcut path completes channel alignment through 1 × 1 convolution, and the output features are defined as:
where Fmain_adapt represents the features from the main path after hollow convolution and dynamic channel weighting, and Fshort denotes the features from the shortcut path after 1 × 1 convolution channel alignment. The decoding path incorporates an Attention Gate mechanism, which takes the skip feature Fskip from the encoding path and the decoding path’s up-sampled feature Fdec as inputs. This generates an attention weight map W to weight the skip feature, yielding Fskip_ag = Fskip ⊙ W, thereby achieving background suppression and component region focusing.
Fdouble = Fmain_adapt + Fshort
The Attention Gate performs weighted fusion and selective extraction of features from feature maps, enabling the model to focus on target areas while suppressing irrelevant or redundant information. Additionally, this module utilizes global or high-level semantic information to guide feature fusion, allowing the model to achieve more precise integration across specific regions and channels. The SMU activation function’s adaptive nature enables the Attention Gate to dynamically fuse features according to remote sensing target detection characteristics [14].
2.3. Model Structure
Figure 2 illustrates the overall architecture of Pv-UNet, while Figure 3 details its key components. The model features a U-shaped symmetric design, where the encoding path extracts multi-scale features and the decoding path reconstructs features with spatial localization. The synergy between the Scale Transformer and Attention Gate module significantly enhances segmentation accuracy and generalization performance. Figure 3 illustrates the integration structure of the -scale Transformer in the decoder of the improved U-Net: it takes 4 groups of multi-scale features (64/128/256/512 channels) output by the encoder as input. After concatenation, dimension reduction, and dilated convolution processing, fine-scale features (64/128 channels) serve as queries (Q), while coarse-scale features (512 channels) act as keys/values (K/V), and cross-scale correlations are established via multi-head attention. The output features are fed back to each decoder layer through residual connections, enabling “local-global” feature fusion. Combined with the attention gate (AG), this structure supports the accurate segmentation of modules.
Figure 2.
Pv-UNet network architecture.
Figure 3.
Key module details.
To address the challenges of “unstable feature propagation” and “complex background interference” in photovoltaic module segmentation, we implement residual-attention collaborative optimization on the U-Net core module. The DoubleConv module introduces residual connections and dynamic channel adaptation: When input/output channels differ, 1 × 1 convolution and bilinear interpolation are used to align dimensions. The main path combines ConvBNReLU with a 1 × 1 convolution (dilation factor d = 2) to extract features, while the final output Xout = Xmain + Xshortcut achieves effective mitigation of deep network gradient vanishing and enhances feature propagation for small photovoltaic fragments. To suppress complex background interference (e.g., mountains, buildings), an AttentionGate gating mechanism is embedded in the decoding path: Upsampled features G serve as guidance signals, while skip-connected features X act as target objects. Cross-channel linear transformation with Sigmoid activation generates an attention mask M, enabling dynamic feature selection Xattn = X ⊙ M. The residual module and attention gating work synergistically across encoding-decoding paths, forming a complete workflow of “stable feature propagation → background interference suppression → fine segmentation restoration”. Through nn.Module subclass encapsulation, the system ensures engineering reusability, providing a robust and accurate photovoltaic module segmentation solution.
2.4. Evaluation Metrics and Calculation Methods for Model Performance
To objectively evaluate the accuracy and completeness of PV module segmentation, this paper adopts the following mainstream semantic segmentation evaluation metrics: IoU (Intersection over Union), Dice Coefficient, and Precision. Meanwhile, the loss function (Loss) is used to measure the model’s fitting effect. The definitions of each metric are as follows [15]:
The Dice Coefficient is a commonly used evaluation metric in the field of image segmentation, often integrated with loss function design. Its core logic revolves around the overlap between predicted and ground truth regions, and while its formula is similar to that of IoU, their calculation methods differ. The Dice Coefficient aims to measure the similarity between the predicted segmentation regions and the ground truth segmentation regions, and it is essentially a set similarity metric. A value closer to 1 indicates a higher degree of overlap between the predicted and ground truth regions, corresponding to better segmentation performance; a value close to 0 means there is almost no overlap, indicating poor segmentation performance. It is more sensitive to scenarios with imbalanced samples (e.g., fragmented PV modules account for less than 5%), which can make up for IoU’s insufficiency in evaluating small-target segmentation and is suitable for detecting the missing detection rate of small fragmented modules. As shown in Equation (1):
Here, TP (True Positive) refers to pixels where both the prediction and reality are the target (e.g., photovoltaic modules); FP (False Positive) refers to pixels predicted as the target but actually in the background; FN (False Negative) refers to pixels that are actually the target but predicted as background.
IoU (Intersection over Union) directly measures the overlap between predicted and actual regions. Its core logic calculates the ratio of the intersection area between predicted positive regions and actual positive regions to their union area. A larger intersection area and smaller union area result in a higher IoU, indicating better segmentation performance. It directly measures the overlap between the predicted PV regions and the ground truth PV regions, and can intuitively reflect the problems of background misclassification (e.g., classifying vegetation as PV) and module missing detection. It is a core metric for segmentation tasks. As shown in Equation (2):
Precision (also known as accuracy or true rate) measures a model’s ability to ‘accurately identify targets’ by calculating the proportion of correctly predicted positive instances (e.g., photovoltaic modules) that actually belong to the target category. The core logic involves filtering out the reliability of predictions that are ‘truly the target’ from the model’s active predictions. Focusing on the proportion of pixels predicted as PV that are actually PV can accurately quantify the background interference suppression effect (e.g., the probability of vegetation being misclassified as PV in mountainous scenarios), which aligns with the engineering requirement of reducing false alarms in PV inspection. The formula is defined as shown in Equation (3):
3. Experimental Design and Result Analysis
3.1. Data Sources and Preprocessing
This study focuses on PV module region segmentation using visible light images, which serves as a critical preprocessing step for subsequent defect detection tasks. As mentioned in the Introduction, defects (e.g., hot spots) manifest as high-brightness features in infrared images—however, accurate localization of defective modules first requires precise segmentation of PV panel regions from complex backgrounds (vegetation, terrain, etc.), which is more efficiently achieved using high-resolution visible light images due to their superior spatial detail. The training dataset (PaddlePaddle PV panel defect dataset) includes both visible light and corresponding infrared images, but only the visible light counterparts were used for segmentation model training; the infrared images will be utilized in follow-up defect classification work.
The experiment was conducted on the noon of 13 June 2025, using a drone under clear weather conditions. A drone equipped with a visible light camera was utilized to capture images of photovoltaic (PV) panels. The images acquired by the visible light camera were compressed and transmitted back to the ground station via a data link, enabling real-time transmission of image signals. Specifically, the visible light camera has a resolution of 20 million pixels, the drone’s surveying and mapping flight altitude is 50 m, and the focal length of the onboard visible light camera is 24 mm. Since the collected PV module images cover multiple scenarios (e.g., mountainous areas, plains, rooftops, and water surfaces). Due to the fact that, the diversity of terrain and variations in weather conditions during data acquisition result in highly complex and diverse characteristics of the PV panels themselves (e.g., shape, arrangement, brightness) and background regions (e.g., vegetation, roads, power transmission lines, buildings, and foreign object intrusions) in the visible light images. The processing requirements of such complex remote sensing scenarios are highly consistent with the application scenarios of deep learning in the field of remote sensing classification [16]. The visible light images of PV panels are shown in Figure 4 and Figure 5.
Figure 4.
Visible light photovoltaic panel.
Figure 5.
Partial data set display.
The research area is located in Yuezhe Town, Qiubei County, Wenshan Prefecture, Yunnan Province. The dataset’s basic statistics are shown in Table 1. The dataset was constructed using visible light images collected by drones. After preprocessing operations including distortion correction, noise removal, and brightness equalization, the images were split into training and validation sets at a 9:1 ratio, totaling 43,365 samples. This dataset construction process referenced the data preprocessing logic of deep learning (convolutional networks) in remote sensing monitoring [17].
Table 1.
Basic Data Set Statistics.
3.2. Experimental Environment and Parameter Settings
The experiment was conducted on a Windows 11 system with an Intel i7-13700KF CPU and NVIDIA RTX 5070 GPU, using the PyTorch (2.1.0) framework. The input image size was 512 × 512, the initial learning rate was 0.001, the batch size was 10, and the training epochs were 20. Other parameters were set to default values. The experimental setup is detailed in Table 2.
Table 2.
Experimental Environment.
The collected data were manually annotated. The original images and their corresponding mask images were stored in two separate folders named “img” and “label”, respectively. Based on the image filenames, the dataset was split into a training set and a validation set at a ratio of 9:1, including 37,736 images in the training set and 5629 images in the validation set.
3.3. Comparative Analysis of Model Performance
To verify the superiority of PV-UNet, it was compared with classical models in the field of semantic segmentation (U-Net, BatchNorm-UNet, Seg-UNet) based on the four evaluation metrics (IoU, Dice, Precision, Loss) defined in Section 2.4. The results are presented in Table 3. Pv-UNet outperformed the competing models with an IoU of 97.69%, a Dice coefficient of 93.88%, and a Precision of 97.99%, while achieving the lowest Loss value of 0.0393. Notably, the performance comparison with Seg-UNet can be further explained by referencing existing ‘SegUNet improvement models’ (e.g., Hyper-SegUNet) [18].
Table 3.
Model Performance Comparison.
In the deep learning experiment for photovoltaic panel recognition, as shown in Figure 6, the comparison of training loss curves between BatchNorm-UNet, Seg-UNet, U-Net, and the improved model Pv-UNet demonstrates that Pv-UNet exhibits significant advantages through its efficient convergence, stable training process, and superior final fitting performance, providing an optimized technical solution for intelligent photovoltaic panel recognition. During the initial training phase (first 5 epochs), all models experienced rapid loss reduction, indicating their preliminary learning of task features and swift parameter adjustments. While Pv-UNet’s initial loss was comparable to other models, its convergence efficiency stood out. Compared to BatchNorm-UNet’s slight fluctuations and Seg-UNet’s gradual convergence, Pv-UNet rapidly compressed the loss and approached optimal parameter space, demonstrating structural advantages in feature learning and gradient propagation that accelerated core feature extraction. As training progressed (5–15th epochs), Pv-UNet maintained steady loss reduction with excellent stability, while BatchNorm-U-Net’s fluctuating loss reflected parameter adjustment uncertainties, Seg-UNet showed slower learning efficiency, and U-Net exhibited less smooth curves. The stable decline of Pv-UNet stems from its improved architecture’s continuous exploration and precise fitting of photovoltaic panel’s complex features, effectively avoiding gradient anomalies and local optima to ensure efficient training. During the training’s late phase (rounds 15–20), Pv-UNet demonstrated significantly lower and more stable loss compared to other models, while others showed higher losses despite convergence. This indicates Pv-UNet’s superior photovoltaic panel feature learning, precise segmentation recognition, and notable advantages in both generalization and accuracy. In practical applications, the low loss enables the model to better approximate real-world distributions, enhancing recognition accuracy and robustness, thereby establishing a solid technical foundation for photovoltaic panel monitoring and analysis.
Figure 6.
Comparison of training loss in different experiments. (Note: The legend shows four models (red: Pv-UNet; blue: U-Net; green: BatchNorm-UNet; orange: Seg-UNet). As shown, Pv-UNet maintains a loss below 0.06 with minimal fluctuations (standard deviation 0.004) after the fifth training round, demonstrating superior training stability and convergence efficiency).
The accuracy values of the four methods in Table 3 demonstrate that all achieved effective segmentation results. Compared with the U-Net network, the Pv-UNet model improved the union-intersect set, precision, and loss value by 0.65%, 0.81%, and 0.1373 respectively, while also outperforming the BatchNorm-UNet and Seg-UNet models in other aspects. When compared with the BatchNorm-UNet network, the Pv-UNet model showed improvements of 1.19%, 2.36%, 1.34%, and 0.0767 in the union-intersect set, Dice coefficient, precision, and loss value respectively. Against the Seg-UNet model, the Pv-UNet model demonstrated enhancements of 1.88%, 3.60%, 2.01%, and 0.0768 in the same metrics. Overall, the Pv-UNet model outperforms the other three methods in the table, delivering superior extraction results that significantly improve the accuracy of photovoltaic panel detection. The Pv-UNet model achieves the best performance in remote sensing image photovoltaic panel information extraction. From the perspective of model complexity, the parameter size of Pv-UNet in Table 3 is 15.2 M, slightly higher than that of the baseline U-Net (12.3 M) and Seg-UNet (14.7 M). The parameter increment mainly stems from the structural design of the Multi-scale Transformer module (approximately 2.1 M) and the improved DoubleConv module (approximately 0.6 M). Notably, with only a 3.4% increase in parameter size compared to Seg-UNet, Pv-UNet achieves an 1.88% improvement in the IoU metric, a 3.60% enhancement in the Dice metric, and a 0.0768 reduction in the Loss value, realizing an efficient balance between “accuracy improvement and complexity increase.
3.4. Melting Test
To validate the effectiveness of each module, we removed the residual double convolution, attention gate, and Transformer modules for comparison. As shown in Table 3, the multi-module collaboration achieved the best performance improvement, demonstrating the critical role of each structure in enhancing model performance.
This study conducted ablation experiments using photovoltaic panel remote sensing datasets. The experiments employed a control variable method, using the original Pv-UNet model (Baseline) as a benchmark. Residual double convolution, attention gate module, and Multi-scale Transformer were sequentially added to construct a Full-Model integrating all modules. By comparing performance metrics such as IOU, Dice, Precision, and Loss across different experimental groups, the roles of each module were clarified. As shown in Table 4, while the residual dual convolution module slightly reduces the Dice metric, it enhances model training stability and decreases Loss. The attention gating module effectively focuses on photovoltaic panel regions while suppressing background interference, further reducing Loss while improving IOU and Dice. The Full Model integrates these modules, demonstrating multi-module synergy. Compared to the +residual dual convolution model, it achieves 0.44% improvement in union-intersection ratio, 0.8% in Dice coefficient, 0.57% in precision, and 0.053% in Loss. Compared to the +attention gating model, it shows 0.32% improvement in union-intersection ratio and 0.44% in precision. Although the Dice coefficient slightly decreases, the Full Model demonstrates better convergence and robustness. Compared to the +Multi-scale Transformer model, the Full Model achieves 1.01% improvement in union-intersection ratio, 1.297% in Dice coefficient, and 0.0181% in Loss. Through ablation experiments, we not only clarify the impact of individual modules on model performance under the current Pv-UNet architecture and photovoltaic panel remote sensing dataset, but also validate the synergistic benefits of module combinations. This provides clear guidance for optimizing photovoltaic panel segmentation models, aligning with engineering requirements for balancing model stability and accuracy.
Table 4.
Fusion experiment results.
The ablation experiments not only clarified the performance and limitations of individual modules in the current Pv-UNet architecture with photovoltaic panel remote sensing data, but also demonstrated the potential of module combinations.
3.5. Visual Contrast Analysis
Figure 7 shows the segmentation results of different models on photovoltaic panel images. It can be seen that Pv-UNet accurately identifies component boundaries in complex backgrounds, and significantly reduces misclassification and omission.
Figure 7.
Comparison of different network segmentation results.
To validate the effectiveness of the Pv-UNet model in extracting photovoltaic panel information from remote sensing images, we conducted detection experiments on different land cover types using a test set partitioned from the original dataset. The segmentation results of U-Net, BatchNorm-UNet, Seg-UNet, and Pv-UNet are shown in Figure 7. U-Net tends to blur the edges of components with the background due to vegetation interference. BatchNorm-UNet exhibits discontinuities when capturing the edges of fragmented components. In contrast, Pv-UNet leverages the cross-scale feature correlation of MultiScale Transformer and the background suppression mechanism of Attention Gate to clearly distinguish component edges from mountain vegetation. In samples with high proportions of fragmented components, Seg-UNet shows significant missed detections for small fragments occupying less than 5% of the area. Pv-UNet utilizes the residual-DoubleConv module to ensure stable feature propagation, preserving the fine edge contours of fragmented components and preventing edge information loss caused by gradient vanishing. The PV-UNet network demonstrates superior segmentation results with more precise positioning and refined contours compared to other architectures, particularly excelling in challenging areas. This is attributed to our method’s enhanced feature extraction strategy: as network depth increases, we incorporate more convolutional blocks and integrate MultiScaleTransformer into the encoding path. By leveraging multi-scale feature outputs and using the deepest layer features as global references, the multi-head attention mechanism enables cross-scale correlation modeling, significantly improving global contextual dependencies during encoding. Additionally, we implement residual connections and dynamic channel adaptation in the U-Net DoubleConv module, while embedding an AttentionGate gating mechanism in the decoding path to mitigate gradient vanishing and suppress complex background interference. These innovations allow the network to better capture photovoltaic panel features while preserving fine details, thereby enhancing its feature extraction capabilities.
4. Discussion
The core of Pv-UNet’s ability to balance improved segmentation accuracy and low computational complexity lies in the precise adaptation of its module design to the “local edge regularity-global distribution aggregation” characteristics of PV modules. Traditional CNNs, constrained by fixed receptive fields, struggle to capture both types of features simultaneously. In contrast, the MultiScale Transformer proposed in this study constructs global semantic context using the deepest X5 feature map, rapidly locates the spatial distribution of PV module clusters via multi-head attention, and then refines edge details relying on the fine-scale X2/X3 features, forming a collaborative mechanism of “global guidance-local refinement” that effectively filters out background interference such as vegetation and terrain in mountainous scenarios. The Attention Gate generates a spatial attention mask M through cross-channel interaction between skip connections from the encoding path (containing edge details) and upsampled features from the decoding path (containing global semantics), assigning high weights to PV module regions and low weights to background regions. This achieves “selective activation in feature space”, which not only suppresses the interference of background pixels on IoU calculation but also avoids missed detection of PV modules. Consequently, the IoU metric is improved from 97.37% (with a single module) to 97.69% (with the Full Model), and the design logic aligns with the research paradigm of “Transformer-CNN fusion for real-time semantic segmentation” [19]. Although the residual structure leads to a slight increase in the number of parameters, it significantly alleviates the gradient vanishing problem and enhances training stability. Compared to the generalized architecture of the “improved U-Net Former for power equipment segmentation” proposed by Liu et al. [20]. Pv-UNet customizes a collaborative scheme of “MultiScale Transformer + Residual-DoubleConv + Attention Gate” targeting the “multi-scale and background-cluttered” characteristics of PV modules. It achieves an IoU of 97.69% on PV images from Qiubei County, Yunnan Province, outperforming the accuracy of the improved U-Net Former in similar energy equipment scenarios while adapting to the computational power requirements of UAV inspection terminals through a more optimal parameter count [21,22]. This highlights the core value of “scenario-oriented innovation” rather than “generalized architecture replication”. Future work can further explore model lightweighting and multi-modal fusion to meet real-time detection demands.
5. Conclusions
The proposed Pv-UNet model integrates Transformer architecture with an enhanced U-Net framework, leveraging cross-scale feature modeling, residual connections, and attention mechanisms to achieve high-precision segmentation of photovoltaic modules. Experimental results demonstrate its exceptional robustness in complex environments, with an IoU of 97.69% and a Loss value as low as 0.0393. The synergistic interaction among modules significantly improves segmentation accuracy and robustness, enabling precise and complete segmentation of PV panel regions and substantially outperforming existing deployed in Qiu Bei County’s smart monitoring system for photovoltaic power stations, this model shows promising engineering applications.
Author Contributions
K.J.: Participated in data collection and investigation, contributed to data processing, analysis, and wrote the manuscript. S.G.: Designed the framework of the research, mastered the conceptualization, given many suggestions for improving and modifying this paper. H.Y.: Given many suggestions for improving and modifying this paper. J.Z.: Contributed to data processing, visualization analysis. All authors have read and agreed to the published version of the manuscript.
Funding
This research was funded by National Natural Science Foundation of China (No. 62266026) and the Construction Project of the High-level Talent Recruitment and Cultivation Platform of Kunming University of Science and Technology (241120250041).
Data Availability Statement
The data used to support the findings of this study are as follows: the training dataset was the open-source photovoltaic panel defect dataset collated from the PaddlePaddle Dataset, which contains 2400 JPG-format photovoltaic panel images categorized into three defect types (Spot, Grid, and Crack). The validation dataset consists of high-resolution photovoltaic panel images obtained from Yuzhe Town, Qiubei County, Wenshan Zhuang and Miao Autonomous Prefecture, Yunnan Province, which were normalized to TIF format and cropped into a uniform dataset of 100 samples with a size of 256 × 256 pixels. The open-source dataset (from the PaddlePaddle Dataset) can be accessed through the official PaddlePaddle Dataset platform, while the self-collected validation dataset (from Qiubei County, Yunnan Province) is available from the corresponding author upon reasonable request, as specific public archiving links for this part of the data are not provided in the study. All data used in the study comply with relevant data usage regulations and do not involve privacy or ethical restrictions that would prevent data sharing.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Liu, W.Q. Research on the Segmentation Method of Photovoltaic Panels Based on High-Resolution Remote Sensing Images. Ph.D. Thesis, People’s Public Security University of China, Beijing, China, 2025. [Google Scholar] [CrossRef]
- Li, T. Research on a Photovoltaic Panel Hot Spot Detection Method Based on Image Recognition; Southeast University: Nanjing, China, 2023. [Google Scholar] [CrossRef]
- Wang, Y.J.; Huang, H.L.; Fu, L.; Han, J. Research on Fine Segmentation Method for Leather Surface Defects Based on Improved U-Net. J. Comput. Aided Des. Comput. Graph. 2024, 36, 413–422. Available online: https://link.cnki.net/urlid/11.2925.TP.20240304.1904.009 (accessed on 7 December 2025).
- Shen, L.X. Research on Photovoltaic Panel Fault Detection Algorithm Based on Deep Learning. Ph.D. Thesis, Taiyuan University of Science and Technology, Taiyuan, China, 2023. [Google Scholar] [CrossRef]
- Ren, X.W.; Han, X.; Zhong, Y.; He, L.F. Research on Photovoltaic Panel Image Segmentation Method Based on Improved U-Net Network. J. Shaanxi Univ. Sci. Technol. 2023, 41, 155–161. [Google Scholar] [CrossRef]
- Qiu, Y.Y.; Gao, G.W. A Lightweight Real-Time Semantic Segmentation Method Based on Improved UNet. Electron. Sci. Technol. 2025, 42, 1–9, in press. [Google Scholar] [CrossRef]
- Li, Q. Research on Photovoltaic Panel Remote Sensing Image Segmentation Algorithm Based on Deep Learning. Ph.D. Thesis, Qingdao University of Science and Technology, Qingdao, China, 2023. [Google Scholar] [CrossRef]
- Fei, J.N. Research on Solar Photovoltaic Panel Extraction Method Based on Improved U-Net. Ph.D. Thesis, Liaoning Technical University, Liaoning, China, 2023. [Google Scholar] [CrossRef]
- Huang, L.; Li, Y.S.; Tong, W.Y.; Zhang, S.Y.; Wang, Z.H. Remote Sensing Image Target Detection Algorithm Based on Improved Real-Time Detection Transformer. J. Comput. Appl. 2025, 45, 1–11. Available online: https://link.cnki.net/urlid/51.1307.TP.20251031.1450.004 (accessed on 7 December 2025).
- Yang, C.Y.; Wang, X.X. Extraction of Mangrove Remote Sensing Image Information Using U-Net Network Structure Model with Shuffle Transformer. J. Guilin Univ. Technol. 2025, 45, 355–363. Available online: http://kns.cnki.net/kcms/detail/45.1375.N.20250520.1644.004.html (accessed on 7 December 2025).
- Li, X.D.; Ding, P. Research on Lung Nodule Segmentation Method Based on U-Net Fused with Transformer. China Med. Devices 2024, 39, 31–36+98. Available online: https://kns.cnki.net/kcms2/article/abstract?v=uSrlZFhNZxKL-Fk6gWII4-KrGLaY4uncvq_xC5OvDAALN5CEYin4FRJXqxFwvVqTuNhSpnuMy0HUjdB6eGesXS_xfOvNNS1jEJ8oMAFpi3frFqKIEQmJup-eaDnbdclsjaHv_qhEZEc4HNFCMCRRzA5zL-pd-76kmjoEIBlyYKHRBw6_iwn2GA==&uniplatform=NZKPT&language=CHS (accessed on 7 December 2025).
- Yang, Y.T.; Li, L.L.; Liu, X.; Jiao, L.C.; Liu, F.; Mang, W.P. Image Recognition Based on Multi-Scale and Multi-Directional Transformer. Chin. J. Comput. 2025, 48, 249–265. Available online: https://link.cnki.net/urlid/11.1826.tp.20241012.1744.002 (accessed on 7 December 2025).
- Appelle, A.; Salvino, L.; Lynch, J.P. Pedestrian footstep localization using a deep convolutional network for time difference of arrival estimation. SPIE Digit. Libr. 2024, 12950, 148–156. [Google Scholar] [CrossRef] [Scilit]
- Wu, C.; Zou, Y.; Zhan, J. DA-U-Net: Densely Connected Convolutional Networks and Decoder with Attention Gate for Retinal Vessel Segmentation. In Proceedings of the 5th International Conference on Electrical Engineering, Control and Robotics (EECR 2019), Wuhan, China, 20–22 December 2019; pp. 430–436. [Google Scholar] [CrossRef]
- Wang, L.H.; Feng, R.; Sun, Y.X. Research on Wetland Remote Sensing Classification Based on Deep Learning. Geomat. Spat. Inf. Technol. 2025, 48, 110–113. Available online: https://kns.cnki.net/kcms2/article/abstract?v=uSrlZFhNZxLswj1lbOx75qf9EbXPVV2cPgv1w19fddCSbk6CpZlLCFkfj7geARkAf0NG7N82xpuRLts5pqv47Vgl5kyRF87IPZySmEyEW7ThpZAlr-R1aI-f3Q65sR5qhZ-yBHbf_UUS24dRmjP7d0xiLOtEA3LToVMLOnoXZ8yHdVChzNNK9A==&uniplatform=NZKPT&language=CHS (accessed on 7 December 2025).
- Nakai, K.; Hirate, Y.; Hiramatsu, T.; Kojima, K.; Wada, Y.; Nakajima, T.; Nakai, A. Use of shunt-side esCCO monitoring for hemodynamic management during hemodialysis as a novel approach for early detection of hypotension: A report of two cases. J. Artif. Organs 2025, 28, 631–635. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Li, Z.X. Real-Time Semantic Segmentation Method of Images Based on Transformer-CNN. Intell. Comput. Appl. 2025, 15, 155–161. [Google Scholar] [CrossRef]
- Zhao, H.; Li, J.X.; Zhang, N. UAV Photovoltaic Panel Segmentation Algorithm Based on Transformer-Enhanced U-Net. Comput. Eng. Appl. 2025, 61, 189–196. [Google Scholar] [CrossRef] [Scilit]
- Tan, L.; Fang, H.; Ding, P.; Wang, F.; Wei, Y.; Fu, Y. P300 Spatiotemporal Prior-Based Transformer-CNN for Auxiliary Diagnosis of PTSD. Brain Sci. 2025, 15, 1124. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Jiang, W.; Wang, J.; He, X. Interval multi-feature sparse transformer-CNN: A synergistic approach to precise and efficient spatio-temporal wind speed interval-value prediction. Appl. Soft Comput. 2025, 185, 113910. [Google Scholar] [CrossRef] [Scilit]
- Dai, Z.; Huang, H.; Jiang, Q.; Chen, Y. A “parallel” combined Transformer-CNN model using secondary decomposition for crude oil forecasting. Expert Syst. Appl. 2026, 299, 129968. [Google Scholar] [CrossRef] [Scilit]
- Wang, Y.; Shan, P.C.; Xie, G.; Zhao, Z.C.; Xie, X.L.; Hu, X. Application of an Improved U-Net Network for Semantic Segmentation of Infrared Images of Photovoltaic Panels. Control Eng. 2025, 1–10. [Google Scholar] [CrossRef]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).








