# Enhanced Detection of Subway Insulator Defects Based on Improved YOLOv5
###### Abstract
[20] formulated a DE-YOLO detection network predicated on YOLOv5, advancing the accuracy of complex background insulation extraction, but its efficacy did not satisfy real-time detection criteria. In machine learning, loss functions quantify the disparity between a model's predictions and actual data. Altering these functions can enhance the accuracy and bolster the robustness of various models. [PERSON] et al. [21] innovated within this space by modifying YOLOv5 algorithm's loss function, implementing dynamic weight adjustments for positive and negative samples to heighten the detection accuracy, albeit at the expense of a reduced detection speed. [PERSON] et al. [22] introduced an approach that incorporated a triple attention mechanism into the network, employing Complete IoU (CIoU) Loss as the network regression loss function to expedite network convergence. However, this methodology has yet to achieve the benchmarks necessary for real-time detection, indicating a need for further refinements. Subway insulators, predominantly situated in tunnel environments, present a unique challenge for defect inspection due to the constrained inspection windows--typically in the early hours--and the need for the immediate replacement of defective units upon detection. This practice renders the accumulation of a substantial defective insulator image dataset for training purposes challenging. Compounding this, the elevated humidity levels common in southern locales and the prevalent foggy conditions within tunnels further complicate inspection efforts. Addressing these multifaceted challenges, this study pioneers the construction of a partial contact network model, meticulously mirroring the subway line's actual structure and dimensions. This innovative approach facilitates the generation of both normal and defective insulator samples, thereby mitigating the issue of sample insufficiency. To enhance the model's applicability in adverse weather conditions, the dataset is augmented through the integration of a fogging algorithm [23], ensuring adaptability in fog-prevalent scenarios. Furthermore, acknowledging the necessity for sample equilibrium during model training, the study introduces a Balanced Loss (BL) function [24]. This strategic function assigns differential weighting to various sample categories--positive, negative, challenging, or straightforward--thereby optimizing the model's attentiveness to positive and particularly elusive samples. This method effectively addresses the prevalent imbalance among diverse sample types. In the final phase of enhancement, the incorporation of a lightweight GhostNet module [25] and Efficient Channel Attention Network (ECA-Net) [26] channel attention mechanism proves instrumental. This dual integration not only curtails the network's computational demands but also significantly accelerates the detection velocity, all without compromising the fidelity of image information capture. Simultaneously, the model's propensity for redundant information is minimized, leading to an improvement in the detection accuracy concerning diminutive targets. Pollution, flashover, etc., can also affect the normal operation of insulators. However, for insulator pollution and flashover conditions, their datasets will be more difficult to obtain due to their much lower probability of occurring in the subway system. However, if sufficient datasets can be obtained, the present method will still be applicable.