# RML-YOLO: An Insulator Defect Detection Method for UAV Aerial Images
## 2 Materials and Methods
### Design of Lightweight Multi-Scale Shared Detection Head  
Current object detection algorithms typically involve a vast number of parameters, which makes their deployment on devices such as drones difficult. In YOLOv8, its detection head uses independent detection heads on different feature levels. This architecture leads to low parameter utilization and high computational cost. The introduction of the FPN structure aims to predict objects of varying scales on specific feature maps. Each layer's detection head extracts features for classification and regression tasks. However, training a detection head requires ample samples of diverse scales. Due to FPN's inherent division of objects by scale, the samples in each layer of the neck component are imbalanced. This imbalance may cause overfitting when training the different detection heads separately.  
To address the aforementioned issues, we have designed a new detection head structure called the lightweight multi-scale shared detection head (LMSHead). Its structure is shown in Figure 3. The design begins with the application of partial convolution (PConv) [32] to extract features from multi-scale feature maps' output by the neck module. In PConv, standard convolution operations are applied only to a subset of input channels for spatial feature learning, while the remaining channels are passed through without modification. This mechanism enables enhanced feature extraction capability while maintaining low computational complexity. After that, a set of feature-sharing convolutional layers is used, which is iteratively used in each detection head. By sharing the convolutional layers, the model can further integrate the information between different detection layers to improve the robustness of feature extraction and reduce the number of parameters, and since the dataset is shared, the features at different scales can share the same object, which solves the problem of uneven distribution of objects at different scales and expands the data volume. The inner part of shared convolution consists of Conv, GroupNorm, and SiLU. Compared with batch normalization, GroupNorm overcomes the limitation of batch normalization in a small batch and distributed training and, at the same time, provides a more stable training process and a better generalization ability, assuming that the number of channels \(C\) is divided into \(G\) groups. The normalization calculation for each group is shown in Equation (8), where \(\mu\) and \(\sigma^{2}\) are the mean and variance of each set of channels, and \(\epsilon\) is a small constant to prevent division by zero errors from occurring.  
\[y_{gn}=\frac{y-\mu}{\sqrt{\sigma^{2}+\epsilon}} \tag{8}\]  
Given that object detection involves both classification and regression tasks, the regression task requires bounding boxes of different scales for objects of varying sizes. To accommodate this, we introduce a scaling factor that dynamically adjusts the object scales in the regression task. The scaling process formula is shown as Equation (9), where \(S_{i}\) represents the scaling factor for each feature layer, \(cv2(y_{i})\) denotes the convolution operation applied to the features from different layers, and \(Z_{i}\) represents the scaled feature map.  
\[Z_{i}=S_{i}\cdot cv2(y_{i}) \tag{9}\]  
The detection head designed in this paper improves the efficiency of the model to utilize the features of different layers and relieve the problem of uneven distribution of objects at different scales. This improvement leads to better multi-scale detection performance. Additionally, the incorporation of parameter-sharing convolutional layers not only reduces both the number of parameters and computational cost, but also maintains a high level of detection accuracy. As a result, the model achieves efficient and lightweight performance without sacrificing effectiveness.