During UAV inspections of transmission lines, inspectors often encounter long distance and obstructed targets. However, existing detection algorithms tend to be less accurate when trying to detect these targets. Existing algorithms perform inadequately in handling long-distance and occluded targets, lacking effective detection capabilities for small objects and complex backgrounds. Therefore, we propose an improved YOLOv8-based YOLO-T algorithm for detecting multiple targets on transmission lines, optimized using transfer learning. Firstly, the model is lightweight while ensuring detection accuracy by replacing the original convolution block in the C2f module of the neck network with Ghost convolution. Secondly, to improve the target detection ability of the model, the C2f module in the backbone network is replaced with the Contextual Transformer module. Then, the feature extraction of the model is improved by integrating the Attention module and the residual edge on the SPPF (Spatial Pyramid Pooling-Fast). Finally, we introduce a new shallow feature layer to enable multi-scale feature fusion, optimizing the model detection accuracy for small and obscured objects. Parameters and GFLOPs are conserved by using the Add operation instead of the Concat operation. The experiment reveals that the enhanced algorithm achieves a mean detection accuracy of 97.19% on the transmission line dataset, which is 2.03% higher than the baseline YOLOv8 algorithm. It can also effectively detect small and occluded targets at long distances with a high FPS (98.91 frames/s).