A photovoltaic panel surface defect detection method and system based on an improved D-FINE algorithm
By improving the D-FINE algorithm and designing a dynamic weight generator and a feature-enhanced convolution module, the feature extraction capability of the photovoltaic panel surface defect detection model is enhanced, solving the problems of low detection accuracy and high cost in existing photovoltaic panels, and realizing efficient and accurate photovoltaic panel defect detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HOHAI UNIV
- Filing Date
- 2025-09-22
- Publication Date
- 2026-06-26
AI Technical Summary
Existing photovoltaic panel inspection technologies struggle to accurately identify minute defects in complex environments and are costly, failing to meet the high-efficiency operation and maintenance needs of photovoltaic power plants.
An improved D-FINE algorithm is adopted, and a dynamic weight generator and a feature-enhanced convolution module are designed to enhance the feature extraction capability of the photovoltaic panel surface defect detection model. The improved model can accurately identify defects under strong light reflection and complex background.
It significantly improves the accuracy and efficiency of photovoltaic panel defect detection, reduces the false detection rate, meets the all-weather high-precision inspection needs of photovoltaic power plants, and provides technical support.
Smart Images

Figure CN121190852B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of defect detection, specifically to a method and system for detecting surface defects in photovoltaic panels based on an improved D-FINE algorithm. Background Technology
[0002] The accelerated global energy transition has fueled explosive growth in the photovoltaic (PV) industry. While PV panel inspection technology has been applied, existing solutions face significant bottlenecks: manual visual inspection is limited by subjective experience, resulting in high rates of missed and false detections and low efficiency; traditional machine vision struggles to handle complex scenarios such as uneven panel reflectivity and similar defect features, and its ability to identify minute defects is insufficient; infrared thermal imaging technology is costly and lacks sensitivity for detecting shallow surface defects. Currently, PV power plant operation and maintenance requirements for controlling power generation losses are becoming increasingly stringent, and manufacturers urgently need to reduce after-sales costs. However, existing inspection technologies suffer from multiple shortcomings in adaptability to complex environments, compatibility with multiple defect types, and cost control, failing to meet the industry's demands for large-scale development. Developing new inspection technologies that balance high precision, low cost, and environmental adaptability has become an urgent industry need to resolve the contradiction between efficiency and accuracy in panel defect detection. Summary of the Invention
[0003] To address the shortcomings of existing technologies, the present invention aims to provide a method and system for detecting surface defects of photovoltaic panels based on an improved D-FINE algorithm, which solves the problems of difficulty in extracting features and low recognition accuracy when facing reflective photovoltaic panels against complex backgrounds.
[0004] The technical solution of the present invention is as follows:
[0005] A method for detecting surface defects in photovoltaic panels based on an improved D-FINE algorithm includes the following steps:
[0006] (1) Construct a photovoltaic panel surface defect dataset based on photovoltaic panel surface defect images;
[0007] The LabelImg tool was used to annotate images of photovoltaic panel surface defects, resulting in a photovoltaic panel surface defect dataset. LabelImg is an open-source image annotation tool used for manually labeling objects in images.
[0008] (2) Improve the backbone network of the D-FINE model based on the feature dynamic enhancement mechanism;
[0009] The construction of the feature dynamic enhancement mechanism includes:
[0010] (2.1) Design a dynamic weight generator (DW) to generate channel-level attention weights for dynamically enhancing important features; the dynamic weights output by the dynamic weight generation module are used as inputs to the subsequent dynamic enhancement convolution module to participate in the feature dynamic enhancement operation.
[0011] (2.2) Design a feature dynamic enhancement convolution module, which obtains the dynamically enhanced features by multiplying the static features with the above dynamic weights element by element;
[0012] (2.3) Based on the feature dynamic enhancement convolution module described in step (2.2), replace the three standard convolution modules in Stage 1 of the original D-FINE model backbone network HGNetv2. After the above replacement is completed, generate the improved D-FINE model based on the original D-FINE model.
[0013] (3) Train the improved D-FINE model in step (2) based on the photovoltaic panel surface defect dataset described in step (1) to obtain a photovoltaic panel surface defect detection model;
[0014] (4) Based on the photovoltaic panel surface defect detection model obtained in step (3), the collected photovoltaic panel image is detected to determine the target defect in the photovoltaic panel image.
[0015] The dynamic weight generator in step (2.1) above captures channel statistics through global pooling, generating weights that are spatially invariant but adaptive to the channels, thereby enhancing important features;
[0016] The construction steps are as follows:
[0017] First, perform global average pooling on the original input image;
[0018] global_vet=GlobalAvgPool2d(x)
[0019] Where x is the original input image with size (B, C, H, W), where B represents the batch size, C represents the number of channels, H represents the image height, and W represents the image width; GlobalAvgPool2d(·) is the global average pooling operation; global_vet is the compressed feature vector with size (B, C, 1, 1); through spatial compression, from H×W to 1×1, global_vet captures the global statistical features of each channel, ignoring spatial details, thereby identifying which channels are more significant in the overall features;
[0020] Then, global_vet is used as input to the next two 1×1 convolutions to generate dynamic weights:
[0021] dynamic_weight = Sigmoid(Conv) 1×1 (ReLU(Conv 1×1 (global_vet))))
[0022] Among them, Conv 1×1 (·) represents a 1x1 convolution, and Sigmoid(·) and ReLU(·) are both activation functions;
[0023] The first 1×1 convolution performs dimensionality reduction and non-linear interaction on the channel features after global average pooling. The convolution kernel compresses the number of input channels from C to C / r, where r is the compression ratio. Then, the ReLU activation function is applied to introduce non-linear transformation and enhance the feature representation capability.
[0024] The second 1×1 convolution increases the dimensionality and assigns weights to the compressed features, restoring the number of channels from C / r to the original number of channels C. The Sigmoid function is used to generate channel attention weights of 0 to 1 to indicate the importance of each channel.
[0025] Finally, the dynamic weight is obtained and used as input for subsequent Feature Dynamic Enhanced Convolution (FDEConv) modules.
[0026] The construction steps of the feature dynamic enhancement convolutional module in step (2.2) above are as follows:
[0027] The dynamic weights generated by the dynamic weight generator are used as input and multiplied with the static features channel by channel to obtain the enhanced features;
[0028] enhanced_out=static_oute dynamic_weights
[0029] Where static_out represents static features, directly derived from a 3×3 standard convolution; e represents the channel-wise multiplication operation, i.e., Y b,c,i,j =X b,c,i,j ×W b,c Let X be the feature vector with dimensions (b, c, i, j), where b is the batch size, c is the number of channels, and i and j are the spatial coordinates; W be the dynamic weights with dimensions (b, c), where b is the batch size and c is the number of channels; and Y be the output features with dimensions (b, c, i, j), where b is the batch size, c is the number of channels, and i and j are the spatial coordinates. In essence, all spatial elements of each channel are multiplied by the corresponding channel's weight, ensuring the output size matches the input while avoiding multiplication with all channels, thus guaranteeing computational efficiency and feature representation capability.
[0030] Then, enhanced_out is used as input to BN(·) and ReLU(·) to generate enhanced dynamic features;
[0031] output=ReLU(BN(enhanced_out))
[0032] In this context, BN(·) is the normalization function, enhanced_out has strengthened important channels through dynamic weights, BN further suppresses noise, and ReLU focuses on key activation features, forming a pipeline of enhancement → purification → focusing.
[0033] The steps in step (3) above for obtaining the photovoltaic panel surface defect detection model include:
[0034] (3.1) Determine the training parameters, wherein the training parameters include batch size, learning rate, number of detection categories and maximum number of iterations;
[0035] (3.2) Input the photovoltaic panel surface defect dataset into the improved D-FINE model, calculate the gradient based on the loss function and backpropagation, and update the gradient in real time;
[0036] (3.3) When the maximum number of iterations is reached, the defect detection model is determined based on the iteration results.
[0037] The steps in step (4) above for detecting the acquired photovoltaic panel image include:
[0038] (4.1) Based on the photovoltaic panel surface defect dataset and the backbone of the improved D-FINE model, determine the feature map at a preset scale;
[0039] (4.2) Determine tensor data based on the feature map and the intermediate part of the improved D-FINE model;
[0040] (4.3) Input the tensor data into the output part of the improved D-FINE model, and calculate the gradient by combining the loss function and backpropagation to update the gradient in real time.
[0041] The present invention also discloses a photovoltaic panel surface defect detection system based on an improved D-FINE algorithm, which stores a computer program that, when executed by a processor, implements the steps of any of the methods described above.
[0042] The beneficial effects of this invention are:
[0043] This invention precisely addresses the core technical pain points of photovoltaic panel defect detection, significantly improving the effectiveness of feature extraction. Addressing the common technical challenges of strong light reflection interference and low grayscale contrast between defects and the background (such as microcracks, shallow spots, and minimal visual difference from the panel substrate) in outdoor photovoltaic panel operation, this invention improves the D-FINE model backbone network through a dynamic feature enhancement mechanism. This suppresses redundant features in areas of strong light reflection and adaptively enhances key features such as defect edges and textures, effectively overcoming the technical bottlenecks of "strong light masking defect features" and "defects overlapping with the background." This enhances the feature recognition of photovoltaic panel surface defects (especially low-contrast defects such as microcracks, scratches, and localized oxidation), providing a reliable feature foundation for subsequent accurate defect classification and localization.
[0044] High detection accuracy in complex environments reduces the risk of false positives and false negatives. In complex scenarios such as strong outdoor light and minor stains or oxidation spots on panel surfaces, traditional D-FINE models are prone to problems such as "misidentifying strong light areas as defects" and "missing microcracks" due to insufficient feature extraction. This invention, through a dynamic feature enhancement mechanism and collaborative optimization with a dedicated dataset, reduces the false positive rate of the improved detection model in strong light interference scenarios. It can meet the all-weather, high-precision defect inspection needs of photovoltaic power plants and provide accurate data support for early defect warning. Attached Figure Description
[0045] Figure 1 It is a graph of dynamic weight generator;
[0046] Figure 2 This is a diagram of a feature-dynamically enhanced convolutional module;
[0047] Figure 3 It is an improvement to the backbone network diagram. Detailed Implementation
[0048] The present invention will be further described below with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and should not be used to limit the scope of protection of the present invention.
[0049] A method for detecting surface defects in photovoltaic panels based on an improved D-FINE algorithm includes the following steps:
[0050] Step 1: Construct a photovoltaic panel surface defect dataset based on photovoltaic panel surface defect images.
[0051] The LabelImg tool was used to annotate images of surface defects on photovoltaic panels, resulting in a photovoltaic panel surface defect dataset. LabelImg is an open-source image annotation tool used for manually labeling objects in images.
[0052] Step 2: Improve the D-FINE model based on a dynamic feature enhancement mechanism
[0053] (2.1) Design a dynamic weight (DW) generator to generate channel-level attention weights for dynamically enhancing important features; the dynamic weights output by the dynamic weight generation module are used as input to the subsequent dynamic enhancement convolution module to participate in the feature dynamic enhancement operation.
[0054] like Figure 1 As shown, the Dynamic Weight (DW) generator generates channel-level attention weights for dynamically enhancing important features. The DW generation module outputs dynamic weights, which serve as input to subsequent dynamic enhancement convolutional modules for feature enhancement computation.
[0055] Dynamic weight generator:
[0056] By capturing channel statistics through global pooling, weights that are spatially invariant but adaptive to the channels are generated, thus enhancing important features.
[0057] The algorithm principle is as follows:
[0058] First, perform a global average pooling operation on the original input image.
[0059] global_vet=GlobalAvgPool2d(x)
[0060] Where x is the original input image with a size of (B, C, H, W), where B represents the batch size, C represents the number of channels, and H and W represent the height and width of the image. GlobalAvgPool2d(·) is the global average pooling operation; global_vet is the compressed feature vector with a size of (B, C, 1, 1). Through spatial compression (from H×W to 1×1), global_vet captures the global statistical features of each channel, ignoring spatial details. This identifies which channels are more significant in the overall features.
[0061] Then, global_vet is used as input to the next two 1×1 convolutions to generate dynamic weights:
[0062] dynamic_weight = Sigmoid(Conv) 1×1 (ReLU(Conv 1×1 (global_vet))))
[0063] Among them, Conv 1×1 (·) represents a 1x1 convolution, while Sigmoid(·) and ReLU(·) are both activation functions.
[0064] The first 1×1 convolution performs dimensionality reduction and non-linear interaction on the channel features after global average pooling. The convolution kernel compresses the number of input channels from C to C / r (where r is the compression ratio, usually 16). This is followed by a ReLU activation function, introducing a non-linear transformation to enhance feature representation.
[0065] The second 1×1 convolution performs dimensionality upscaling and weight allocation on the compressed features. The number of channels is restored from C / r to the original number of channels C. Channel attention weights of 0 to 1 are generated using the Sigmoid function to indicate the importance of each channel.
[0066] Finally, the dynamic weight is obtained and used as input for subsequent feature enhancement convolution (FDEConv) modules.
[0067] (2.2) Design a feature dynamic enhancement convolution module, which obtains the dynamically enhanced features by multiplying the static features with the above dynamic weights element by element;
[0068] Feature Dynamic Enhanced Convolution (FDEConv) module
[0069] like Figure 2 As shown, the Feature Dynamic Enhanced Convolution (FDEConv) module obtains dynamically enhanced features by performing element-wise multiplication of static features with the aforementioned dynamic weights.
[0070] Dynamically Enhanced Convolution (FDEConv) module;
[0071] The constructed feature-enhanced convolution module is a mechanism for enhancing feature representation capabilities through dynamic weights. Since standard convolution outputs fixed static features, the core lies in constructing a dynamic weight (DW) module to obtain dynamic weights, and then multiplying the static features with the dynamic weights channel by channel, thereby enhancing the feature representation capability.
[0072] The algorithm principle is as follows:
[0073] The dynamic weights generated by the aforementioned dynamic weight generator are used as input and multiplied with the static features channel by channel to obtain the enhanced features.
[0074] enhanced_out=static_oute dynamic_weights
[0075] Where static_out represents static features, directly derived from a 3×3 standard convolution; e represents the channel-wise multiplication operation, i.e., Y b,c,i,j =X b,c,i,j ×W b,c That is, all spatial location elements of each channel are multiplied by the corresponding channel weight, ensuring that the output size is consistent with the input, while eliminating the need to multiply by all channels, thus ensuring computational efficiency and feature representation capability.
[0076] Then, `enhanced_out` is used as input to BN(·) and ReLU(·) to generate enhanced dynamic features.
[0077] output=ReLU(BN(enhanced_out))
[0078] In this process, BN(·) is the normalization function, ReLU(·) is the activation function, enhanced_out has strengthened important channels through dynamic weights, BN further suppresses noise, and ReLU focuses on key activation features, forming a pipeline of "enhancement → purification → focusing".
[0079] (2.3) such as Figure 3 As shown, based on the feature dynamic enhancement convolution module described in step (2.2), the three standard convolution modules in Stage 1 of the original D-FINE model backbone network HGNetv2 are replaced. After the above replacement is completed, the improved D-FINE model is generated based on the original D-FINE model.
[0080] Step 3: Train the improved D-FINE model based on the photovoltaic panel surface defect dataset to obtain the photovoltaic panel surface defect detection model;
[0081] Determine the training parameters, including batch size, learning rate, number of detection categories, and maximum number of iterations.
[0082] The sample set of surface defects of the photovoltaic panel is input into the improved D-FINE model, and the gradient is calculated based on the loss function and backpropagation to update the gradient in real time.
[0083] In this embodiment, the sample set of surface defects on the photovoltaic panel is pre-divided into a training set, a validation set, and a test set. The portion corresponding to the training set is input into the improved D-FINE model. When the maximum number of iterations is reached, the defect detection model is determined based on the iteration results.
[0084] As an optional implementation, the photovoltaic panel surface defect sample set is divided into a training set, a validation set, and a test set. The corresponding portion of the training set is input into the improved D-FINE model to prepare pre-training weights. Weights pre-trained on large-scale image data or other similar tasks can be used. Training parameters are determined, such as batch size, learning rate, number of detection categories, and maximum number of iterations. Data augmentation methods are set, such as random cropping, translation, and rotation, to increase the model's generalization ability. A loss function suitable for the defect detection task is defined; commonly used methods include combinations of IOU loss functions and classification loss functions. Different weight coefficients are set to balance the loss of bounding box position and classification loss to improve model performance. During model training, the photovoltaic panel surface defect sample set is input into the improved D-FINE model. Gradients are calculated based on the loss function and backpropagation to update the gradient in real time. Training samples are iterated continuously until the maximum number of iterations is reached. During model evaluation, the model's performance on the defect detection task is evaluated using an independent validation set. The model's accuracy, recall, and F1 score are calculated to evaluate its performance in defect detection. Based on the evaluation results, training parameters and data augmentation methods are adjusted, and the above steps are repeated until optimal model performance is achieved. When the maximum number of iterations is reached and performance requirements are met, the weights and configuration of the defect detection model are saved. The model is then applied to a defect detection scenario; by inputting a new road image, the defect detection model can detect and mark defect regions in the image.
[0085] Based on the photovoltaic panel surface defect sample set and the backbone of the improved D-FINE model, a feature map of a preset scale is determined.
[0086] Tensor data is determined based on the feature map and the intermediate part of the improved D-FINE model;
[0087] The tensor data is input into the output of the improved D-FINE model, and the gradient is calculated by combining the loss function and backpropagation to update the gradient in real time.
[0088] As an optional implementation, training parameters are set as follows: batch size, learning rate, number of detection categories, and maximum number of iterations. Images from the training set of photovoltaic panel surface defect samples are input into the backbone network to obtain feature maps (feature size 32×32×2048). The feature maps are then input into a multi-scale feature fusion module for upsampling and feature fusion to obtain tensor data (tensor size 32×32×2048). The tensor data is input into the head part, and gradients are calculated based on the loss function and backpropagation. Gradient updates are performed in real time, and the network accuracy is verified using a validation set from the photovoltaic panel surface defect sample set. These steps are repeated until the set maximum number of iterations is reached. The improved D-FINE model then completes its learning, resulting in the photovoltaic panel defect detection model and weights.
[0089] Further, feature maps at a preset scale are determined, and the photovoltaic panel defect sample set is input into the backbone of the improved D-FINE model. In the backbone, operations such as convolution and pooling are used to gradually reduce the spatial size of the input image, extracting hierarchical feature maps. The preset scale of feature maps needed for defect detection is determined; multiple feature map scales can be selected to detect different defect sizes. Tensor data is determined; based on the feature maps, the feature maps are converted into tensor data through the intermediate part of the improved D-FINE model. In the intermediate part, operations such as convolution and fully connected layers can be used to further process the feature maps to extract higher-level feature representations. Gradients are calculated and updated, and the tensor data is input into the output part of the improved D-FINE model. In the output part, operations such as convolution and fully connected layers are typically used to map the tensor data to a preset number of classes. The difference between the predicted result and the actual label is calculated using a loss function. The gradient is calculated using the backpropagation algorithm, and the network parameters are updated based on the gradient. Optimization algorithms, such as stochastic gradient descent, are used to guide the gradient update process. The above steps are repeated until all samples are used to update the network parameters.
[0090] Specifically, before training, the improved D-FINE model requires adjusting the parameters to suit the characteristics of different sample sets, finding the optimal parameter values. This is crucial for the performance of the detection model and the training speed. The following are the hyperparameters set based on the defect sample set:
[0091] First, the batch size (BS) is set. Batch size refers to the number of samples in each iteration, which determines the direction of gradient descent. Generally, a larger BS results in faster network convergence but is prone to getting trapped in local optima, leading to poor model generalization; a smaller BS results in greater randomness, making the loss function prone to oscillations and difficult to converge. Therefore, after multiple rounds of parameter tuning, the optimal BS was found to be 16.
[0092] Setting the learning rate is a crucial hyperparameter in model training. It determines the step size of weight updates and balances convergence speed with convergence success. A learning rate that is too small results in small gradient descent steps and slow network convergence; a learning rate that is too high causes the loss function to oscillate. Typically, the learning rate is initialized to 0.001, and a variable learning rate is used to train the model.
[0093] The number of detection categories is set to the number of detection types involved in the model. The photovoltaic panel surface defect sample set involves three defect types: scratches, broken grids, and spots. Therefore, the number of detection categories is set to 3.
[0094] The maximum number of iterations (Max epochs) is set, which refers to the maximum number of times the model can be trained. After exceeding the maximum number of iterations, model training terminates and the weights are no longer updated. In this embodiment, it is set to 120.
[0095] Step 4: Based on the defect detection model, detect the acquired photovoltaic panel image to determine the target defects in the photovoltaic panel image.
[0096] As an optional implementation, the defect detection model is tested and validated using a validation set. The trained model is then evaluated to assess metrics such as accuracy and recall in defect detection on photovoltaic panel images. The accuracy and stability of the detection results can be improved by adjusting the model's threshold or using non-maximum suppression methods. The acquired photovoltaic panel image is input, and the defect detection model detects, locates, and marks target defects in the image.
[0097] For example, photovoltaic panel images are acquired from different locations, angles, and lighting conditions. Defects in the images are manually labeled using professional image processing software and saved as defect images. The defect image set is divided into training and validation sets. Image preprocessing is performed, including image size normalization, data augmentation (such as random cropping, flipping, and rotation), and normalization. The improved D-FINE model is trained using the training set. Appropriate hyperparameters, such as learning rate and batch size, are set, and the model is iteratively optimized using the training set. The trained model is tested and validated using the validation set. Evaluation metrics such as precision, recall, and F1 score are calculated to assess the model's performance on the defect detection task. The trained model is then applied to actual photovoltaic panel images.
[0098] Furthermore, by inputting an image of a photovoltaic panel, the model detects and locates target defects, and bounding boxes can be used to mark the location and size of the defects. The differences between the detection results and the labeled results are compared, and evaluation metrics are calculated to assess the system's accuracy and robustness.
[0099] Specifically, as an example of step four in this embodiment, the model was tested using a photovoltaic panel surface defect dataset: the mAP (average accuracy across all classes) improved from 0.83 to 0.87.
[0100] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for detecting surface defects in photovoltaic panels based on an improved D-FINE algorithm, characterized in that, Includes the following steps: (1) Construct a photovoltaic panel surface defect dataset based on photovoltaic panel surface defect images; (2) Improve the backbone network of the D-FINE model based on the feature dynamic enhancement mechanism; The construction of the feature dynamic enhancement mechanism includes: (2.1) Design a dynamic weight generator to generate channel-level attention weights for dynamically enhancing important features; the dynamic weights output by the dynamic weight generation module are used as input to the subsequent dynamic enhancement convolution module to participate in the feature dynamic enhancement operation. (2.2) Design a feature dynamic enhancement convolution module, which obtains the dynamically enhanced features by multiplying the static features with the above dynamic weights element by element; (2.3) Based on the feature dynamic enhancement convolution module described in step (2.2), replace the three standard convolution modules in Stage 1 of the backbone network HGNetv2 of the original D-FINE model. After the above replacement is completed, generate the improved D-FINE model based on the original D-FINE model. (3) Train the improved D-FINE model in step (2) based on the photovoltaic panel surface defect dataset described in step (1) to obtain the photovoltaic panel surface defect detection model; (4) Based on the photovoltaic panel surface defect detection model obtained in step (3), the collected photovoltaic panel images are detected to determine the target defects in the photovoltaic panel images; The dynamic weight generator in step (2.1) captures channel statistics through global pooling, generating weights that remain spatially unchanged but are adaptive to the channels, thereby enhancing important features; The construction steps are as follows: First, perform global average pooling on the original input image; Where x is the original input image with a size of (B, C, H, W), where B represents the batch size, C represents the number of channels, H represents the image height, and W represents the image width; GlobalAvgPool2d(·) is the global average pooling operation; global_vet is the compressed feature vector with a size of (B, C, 1, 1); through spatial compression, from H×W to 1×1, global_vet captures the global statistical features of each channel, ignoring spatial details, thereby identifying which channels are more significant in the overall features; Then, global_vet is used as input to the next two 1×1 convolutions to generate dynamic weights: Among them, Conv 1×1 (·) represents a 1x1 convolution, and Sigmoid(·) and ReLU(·) are both activation functions; The first 1×1 convolution performs dimensionality reduction and non-linear interaction on the channel features after global average pooling. The convolution kernel compresses the number of input channels from C to C / r, where r is the compression ratio. Then, the ReLU activation function is applied to introduce non-linear transformation and enhance the feature representation capability. The second 1×1 convolution increases the dimensionality and assigns weights to the compressed features, restoring the number of channels from C / r to the original number of channels C. The Sigmoid function is used to generate channel attention weights of 0 to 1 to indicate the importance of each channel. Finally, the dynamic weight (dynamic_weight) is obtained and used as input for subsequent feature-dynamically enhanced convolutional modules. The construction steps of the feature dynamic enhancement convolution module in step (2.2) are as follows: The dynamic weights generated by the dynamic weight generator are used as input and multiplied with the static features channel by channel to obtain the enhanced features; Among them, static_out represents static features, which are directly derived from a 3×3 standard convolution. This is a channel-by-channel multiplication operation, i.e. X is the feature vector with dimensions (b,c,i,j), where b is the batch size, c is the number of channels, and i and j are spatial coordinates; W is the dynamic weight with dimensions (b,c), where b is the batch size and c is the number of channels; Y is the output feature with dimensions (b,c,i,j), where b is the batch size, c is the number of channels, and i and j are spatial coordinates. This means that all spatial elements of each channel are multiplied by the corresponding channel's weight, ensuring that the output size is consistent with the input while avoiding multiplication with all channels, thus guaranteeing computational efficiency and feature representation capability. Then, enhanced_out is used as input to BN(·) and ReLU(·) to generate enhanced dynamic features; In this process, BN(·) is the normalization function, enhanced_out has strengthened important channels through dynamic weights, BN further suppresses noise, and ReLU focuses on key activation features, forming a pipeline of enhancement → purification → focusing.
2. The method for detecting surface defects of photovoltaic panels based on the improved D-FINE algorithm according to claim 1, characterized in that, The step of obtaining the photovoltaic panel surface defect detection model in step (3) includes: (3.1) Determine the training parameters, wherein the training parameters include batch size, learning rate, number of detection categories and maximum number of iterations; (3.2) Input the photovoltaic panel surface defect dataset into the improved D-FINE model, calculate the gradient based on the loss function and backpropagation, and update the gradient in real time; (3.3) When the maximum number of iterations is reached, the defect detection model is determined based on the iteration results.
3. The method for detecting surface defects of photovoltaic panels based on the improved D-FINE algorithm according to claim 1, characterized in that, The step of detecting the acquired photovoltaic panel image in step (4) includes: (4.1) Based on the photovoltaic panel surface defect dataset and the backbone of the improved D-FINE model, determine the feature map at a preset scale; (4.2) Determine tensor data based on the feature map and the intermediate part of the improved D-FINE model; (4.3) Input the tensor data into the output part of the improved D-FINE model, and calculate the gradient by combining the loss function and backpropagation to update the gradient in real time.
4. A photovoltaic panel surface defect detection system based on an improved D-FINE algorithm, wherein a computer program is stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.