The vision task of intelligent inspection of transmission lines is crucial to safety and stability of the power system. Although deep learning networks perform well on uniformly distributed training and test datasets, deviations in data distribution often degrade model performance in real-world applications. To solve this problem, a Training Method based on Contrastive Learning (TMCL) was proposed, aiming to enhance robustness of the model. Firstly, a benchmark test set, TLD-C (Transmission Line Dataset-Corruption), specially designed for transmission line scenario was constructed to evaluate the model’s robustness facing image corruption. Secondly, the model’s ability to distinguish different categories of features was improved by constructing positive and negative sample pairs that are sensitive to category features. Thirdly, a joint optimization strategy combining contrastive loss and cross-entropy loss was used to impose additional constraints on the feature extraction process, so as to optimize representation of the feature vectors. Finally, a Non-local Feature Denoising network (NFD) was introduced to extract features closely related to categories. Experimental results show that compared to the original method, the improved training method achieves an average precision improved by 3.40 percentage points on Transmission Line Dataset (TLD), and a relative Corruption Precision (rCP) increased by 4.69 percentage points on TLD-C dataset.