# EER-DETR: An Improved Method for Detecting Defects on the Surface of Solar Panels Based on RT-DETR
## 3 Algorithm
### Eer-Detr
#### 3.2.2 EHFPN  
Given that RT-DETR incurs high computational costs when processing multi-scale features, especially in real-time applications that require significant computing resources, there exists a considerable performance bottleneck. Therefore, this study proposes a new method aimed at optimizing this issue by introducing an efficient multi-scale convolution module [28] and a global heterogeneous kernel selection mechanism (EHFPN). The neck network of RT-DETR is designed as an efficient hybrid encoder (Efficient Hybrid Encoder), consisting of two key modules: the attention-based same-scale feature interaction module (AIFI) and the cross-scale feature fusion module (CCFF) [29]. The AIF module is mainly used to process the feature maps of the P5 layer. Compared with traditional multi-scale feature processing methods, this design significantly reduces computational costs and improves processing speed without affecting model performance. In terms of cross-scale feature fusion, the CCFR structure can be understood from the perspective of the YOLO architecture as similar to FPN or PAN, as depicted in Figure 4a, b. FPN effectively passes deep features to shallow layers, enhancing its understanding of key high-level information, while PAN plays an important role in the transition of information from shallow to deep layers, helping to improve the capture ability of detailed features. However, BiFPN performs more prominently when dealing with small objects. It enhances feature fusion efficiency by adding additional paths from high resolution to low resolution and further reduces computational burden by removing paths that only receive input from a single node. BiFPN [30] effectively integrates low-level and high-level features through skip connections, enabling the neural network to better understand the relationship between them. When the BiFPN network performs feature fusion, the feature maps of different resolutions have different contributions to the fusion input. Therefore, the BiFPN network uses the fast normalization fusion module for weighted feature fusion, as shown in Equation (5):  
\[\mathrm{O}=\sum_{i}\frac{w_{i}}{\epsilon+\sum_{j}w_{j}}\times I_{i} \tag{5}\]  
In the formula, \(\mathrm{O}\) represents the weighted fusion weight, \(w_{i}\) is the learning weight corresponding to the input feature \(I_{i}\), and it is ensured that \(w_{i}\geq 0\) through the activation function ReLU. And \(\epsilon\) represents the initial learning rate; to avoid data instability, it is usually set to 0.0001. Therefore, BiFPN can compensate for the potentially lost important information during feature extraction by the RT-DETR backbone network, ensuring that the initial features extracted directly from the backbone network can be effectively retained and further integrated to improve detection performance. This study designs a global heterogeneous kernel selection mechanism named EHFPN. At each level of the feature pyramid (P3-P5), different-sized convolution kernels are dynamically selected. For instance, the P5 layer uses [5; 7; 9], while the P4 layer uses [3; 5; 7]. Additionally, it combines the multi-scale efficient convolution module CSP-MSCB to capture cross-scale context information through parallel multi-branch convolution. The dynamic weights of EHFPN:  
\[w_{i}=\text{Softmax}(\text{A}(F_{i})),\text{ O}=\sum w_{i}\times F_{i} \tag{6}\]  
EHFPN features a multi-scale efficient convolution module and a global heterogeneous kernel selection mechanism. The research on the Trident network indicates that networks with larger receptive fields are more suitable for detecting larger objects. Conversely, smaller-scale targets benefit from smaller receptive fields. Therefore, in the FPN stage, we select different multi-scale convolution kernels for different scale feature layers to adapt and gradually obtain multi-scale perception field information. We draw on the multi-scale feature-weighted fusion in BIFPN and replace Concat with Add to reduce the number of parameters and computational cost.