A catenary positioning clamp defect detection method based on small sample metric learning
By using small-sample metric learning and an improved YOLOv5s target detection network, combined with the GhostNet network, rapid and accurate defect detection of contact wire positioning clamp nuts was achieved. This solved the problems of slow detection speed and sample imbalance in existing technologies, and improved detection efficiency and accuracy.
Patent Information
- Application Number
- CN202410716372.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2044-06-04
AI Technical Summary
Existing technologies struggle to quickly and accurately detect defects, especially minute defects, in contact wire positioning clamps. Furthermore, deep learning-based methods require a large number of training samples and have limited effectiveness in detecting imbalanced samples.
A few-shot metric learning method is adopted, which combines an improved YOLOv5s target detection network and a GhostNet network. The images of positioning clamps and bolts and nuts are extracted through a two-level cascade method. Different weights are assigned to samples of different support sets in the few-shot learning model. Metric learning is used to compare feature distances to achieve fast and accurate defect detection.
It improves the positioning speed and accuracy of small components of the overhead contact line, effectively detects defects in positioning clamp nuts, solves the problem of sample imbalance, and improves the accuracy and efficiency of detection.
Smart Images

Figure CN118485877B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent detection technology for high-speed rail images, specifically to a method for detecting defects in contact wire clamps based on small-sample metric learning. Background Technology
[0002] As the operational mileage of my country's electrified railways continues to increase, the failure of components due to external environment, operating conditions, manufacturing and construction factors is inevitable, leading to defects in the overhead contact system. Accurately and quickly detecting these defects is a prerequisite for eliminating potential safety hazards in high-speed rail power supply and a key focus of my country's overhead contact system operation and maintenance. Currently, there are two methods for detecting defects in the overhead contact system: manual inspection and automatic inspection. Manual inspection includes methods such as walking, using ladder trucks, and riding in vehicles, all of which rely on direct human observation of defects. Automatic inspection involves installing cameras and control devices on dedicated or operating vehicles to automatically photograph overhead contact system components as the vehicle moves. The human eye then identifies whether any components in the images show signs of failure, i.e., defects. Manual inspection allows for a "flat-push" inspection of the overhead contact system, but the actual overhead contact system is erected at a relatively high height, and factors such as light and distance make it difficult to effectively detect defects. While automatic inspection can provide high-definition imaging of defects (image spatial resolution up to 0.1mm), visual fatigue can easily occur from visually identifying anomalies in the images.
[0003] Therefore, accurately and quickly identifying catenary defects using computer vision methods is an inevitable trend in the development of automated catenary inspection. Based on the method of acquiring catenary defect features, computer vision-based defect detection can be divided into methods based on manual features and methods based on learned features. Methods based on manual features are generally heuristic; feature design largely relies on human experience and yields mostly low-level features with limited representational capabilities. Therefore, they are mainly used to detect specific defects, such as broken cantilever insulators and loose strands in the equipotential bonding conductor. Methods based on learned features typically utilize massive amounts of training samples and employ deep convolutional neural networks (DCNNs) to automatically learn high-level features of the target, showing better performance in component localization, defect feature representation, and defect identification.
[0004] Current research on defect detection technology for electrified railway catenary systems is extensive. The patent "A Method for Detecting Large-Scale Differentiated Components in High-Speed Railway Catenary Systems" (Publication No.: CN109840904A) proposes a method for detecting large-scale differentiated components by obtaining fine positioning frames of catenary components from an SSD positioning model; however, this method has limitations in detecting minute defects. The patent "A Method for Detecting Defects in High-Speed Railway Insulators Based on Knowledge Distillation" (Application No.: 202210714799.5) proposes a method for detecting defects in high-speed railway insulators based on knowledge distillation. This method uses unsupervised learning to detect catenary components, but requires selecting an appropriate threshold to effectively distinguish between positive and negative samples. Summary of the Invention
[0005] To overcome the shortcomings of existing technologies, this invention proposes a method for detecting defects in contact wire positioning clamps based on few-sample metric learning. This method is based on few-sample metric learning to detect whether there are missing or defective nuts in railway contact wire positioning clamps.
[0006] The objective of this invention can be achieved through the following technical solutions:
[0007] A method for detecting defects in contact wire clamps based on few-sample metric learning includes the following steps:
[0008] S1: Using a dedicated train inspection vehicle, images of the overhead contact line support and suspension device of high-speed railway are generated to construct an overhead contact line 4C image dataset including contact line positioning clamps and bolts and nuts. This dataset contains images of various working conditions and different perspectives, ensuring the diversity and coverage of the dataset to improve the generalization ability of the model.
[0009] S2: An improved YOLOv5s target detection network with a two-level cascade method is used to extract images of positioning clamps and bolts and nuts. First, the improved YOLOv5s network is used to perform preliminary target detection and positioning of the positioning clamps in the catenary 4C image dataset, and the positioning clamp images are extracted. Then, based on the positioning clamp images, the bolts and nuts are further located and their images are extracted to achieve more accurate target positioning.
[0010] S3: Establish a few-shot learning model based on metric learning, perform pre-training and meta-training respectively, and obtain a defect detection model based on few-shot learning with suitable pre-trained weights;
[0011] S4: Based on the bolt and nut images, select several normal samples and abnormal samples from the bolt and nut images as sample images, select a portion of each type of sample image as a training set for training the model, and use the remaining samples as a test set for testing and verification.
[0012] S5: Input the sample images in the test set into the defect detection model for defect detection;
[0013] S6: In the support set of the test set, the features extracted from the images of positioning clamps and bolts and nuts are combined with the features of each category to determine the feature prototypes of each category through metric learning, and different weights are assigned to the samples according to their feature distribution.
[0014] S7: By using feature distance measurement, the features of the sample to be tested are compared with the features of the support set samples in the test set;
[0015] S8: If the feature value of the sample to be tested is closer to the feature value of the normal sample, it is judged as normal; if it is closer to the feature value of the abnormal sample, it is judged as abnormal.
[0016] Furthermore, to improve the detection speed of the YOLOv5 object detection network, the GhostNet network is used to replace the YOLOv5 backbone network.
[0017] Furthermore, the key steps in establishing a defect detection model based on few-shot learning include:
[0018] S41: First, select the feature extraction module ResNet50 for the few-shot learning network based on metric learning, and pre-train the feature extraction network using the large dataset ImageNet;
[0019] S42: Subsequently, the few-shot metric learning network was meta-trained using the Mini-ImageNet dataset to adjust the model to meet the requirements of few-shot learning.
[0020] Furthermore, using a defect detection model based on few-shot metric learning, different weights are assigned to the support set samples during the testing phase. The specific steps for defect detection include:
[0021] S51: Input the support set samples and the sample to be detected in the test set, and simultaneously input the bolt and nut image samples into the feature extraction module to obtain the features of each support set sample and the features of the sample to be detected.
[0022] S52: By assigning different weights to different support set samples during the prototype calculation process based on the intra-class samples and the distances between samples of a certain class in the support set of the test set and samples of other classes, the feature prototypes of a certain class of support set samples are obtained.
[0023] The prototype network generates image prototypes for each category by averaging the feature vectors in the feature space of the support set samples. Essentially, it assigns the same weights to all samples.
[0024] However, even among samples of the same type, there are still differences. Some samples are more universal and representative, while others are of lower quality and less representative. The quality of the samples makes their contribution to the prototype calculation different.
[0025] Therefore, simply calculating the average value cannot accurately determine the prototype of a sample class. Assigning different weights to different samples better reflects the calculation of the prototype of a particular class, that is, the representative result within each class.
[0026] S53: By using the feature distance metric, the feature of the sample to be detected in S51 is compared with the feature prototype of the support set sample in S52. If the feature value of the sample image to be detected is closer to the feature value of the normal sample, the sample to be detected is judged to be normal. If the feature value of the sample image to be detected is closer to the feature value of the abnormal sample, the sample to be detected is judged to be abnormal, thus drawing the conclusion that it is a normal or abnormal sample.
[0027] Compared with the prior art, the present invention has the following technical effects:
[0028] (1) By lightweighting the target detection algorithm and using a two-level cascade method for target positioning, this invention can quickly and accurately capture images of positioning wire clamp nuts, thereby improving the positioning speed and accuracy of small components of the contact wire.
[0029] (2) Based on the problem of uneven positive and negative samples of contact wire component defects, the present invention adopts a method based on small sample metric learning, which can effectively utilize existing normal and abnormal sample images to detect whether the positioning clamp nut has defects.
[0030] (3) The method of the present invention improves the existing small sample learning network by assigning different weight coefficients to different support set samples, which can improve the scientific nature of prototype calculation. Attached Figure Description
[0031] Figure 1 This is a flowchart of the present invention;
[0032] Figure 2 This is a schematic diagram of the 4C system of the present invention;
[0033] Figure 3 Flowchart for locating and extracting bolts and nuts on positioning clamps in a two-level cascaded target detection model;
[0034] Figure 4 This is a flowchart of a defect detection process based on few-sample metric learning.
[0035] Figure 5 This refers to the weight changes of a certain type of sample during the prototype calculation process. Detailed Implementation
[0036] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the invention, any modifications, equivalent substitutions, improvements, etc., made by those skilled in the art to all other embodiments obtained without creative effort should be included within the protection scope of the present invention.
[0037] like Figure 1 As shown, a method for detecting defects in contact wire clamps based on few-sample metric learning includes the following steps:
[0038] S1: As Figure 2 The diagram shows a 4C system. A dedicated train inspection vehicle is used to image the support and suspension devices of the high-speed railway catenary. A 4C image dataset of the catenary, including the catenary positioning clamps and bolts and nuts, is constructed to form an image dataset containing various working conditions and different perspectives. This ensures the diversity and coverage of the dataset to improve the generalization ability of the model.
[0039] S2: As Figure 3 As shown, an improved YOLOv5s target detection network with a two-level cascade method is used to extract images of positioning clamps and bolts and nuts. First, the improved YOLOv5s network is used to perform preliminary target detection and positioning of the positioning clamps in the catenary 4C image dataset, and the positioning clamp images are extracted. Then, based on the positioning clamp images, the bolts and nuts are further located and their images are extracted to achieve more accurate target positioning.
[0040] To improve the detection speed of the YOLOv5 object detection network, the GhostNet network was used to replace the YOLOv5 backbone network.
[0041] S3: Establish a few-shot learning network based on metric learning. First, select the feature extraction module ResNet50 for the few-shot learning network and pre-train the feature extraction network using the large dataset ImageNet to obtain initial weights. Then, use the dataset Mini-ImageNet to perform meta-training on the few-shot learning network, adjust the model to adapt to the requirements of few-shot metric learning, and obtain a defect detection model based on few-shot metric learning with suitable pre-trained weights.
[0042] The training process involves dividing the 100 categories on Mini-ImageNet into 80 categories for the training set and 20 categories for the validation set. During training, 5 samples of the same category from 2-3 categories are randomly selected from the training set, and samples are randomly drawn from the training set. The distance between feature modules is compared to make classification judgments.
[0043] S4: Based on the bolt and nut images, select several normal samples and abnormal samples from the bolt and nut images as sample images, select a portion of each type of sample image as a training set for training the model, and use the remaining samples as a test set for testing and verification.
[0044] S5: Input the sample images in the test set into the defect detection model for defect detection;
[0045] S6: In the support set of the test set, the features extracted from the images of positioning clamps and bolts and nuts are combined with the features of each category to determine the feature prototypes of each category through metric learning, and different weights are assigned to the samples according to their feature distribution.
[0046] S7: By using feature distance measurement, the features of the sample to be tested are compared with the features of the support set samples in the test set;
[0047] S8: If the feature value of the sample to be tested is closer to the feature value of the normal sample, it is judged as normal; if it is closer to the feature value of the abnormal sample, it is judged as abnormal.
[0048] like Figure 4 As shown, a defect detection model based on few-sample metric learning is used, preferably selecting 5 normal samples and 5 abnormal samples from bolt and nut images as the support set; different weights are assigned to the support set samples in the testing phase, and the specific steps for defect detection include:
[0049] S51: Input the support set samples and the sample to be detected in the test set, and simultaneously input the bolt and nut image samples into the feature extraction module to obtain the features of each support set sample and the features of the sample to be detected.
[0050] Let the feature space be f(x) i ), x i Let f(·) be the i-th input image sample, and f(·) be the mapping corresponding to the feature extraction module;
[0051] S52: By assigning different weights to different support set samples during the prototype calculation process based on the intra-class samples and the distances between samples of a certain class in the support set of the test set and samples of other classes, the feature prototypes of a certain class of support set samples are obtained.
[0052] Different weights are assigned to the support set samples during the testing phase by calculating intra-class weights and inter-class weights respectively, specifically including:
[0053] like Figure 5 As shown, the numerical changes above each sample represent the changes in sample weights during prototype calculation. Adjusting the weight coefficients to account for the influence of samples within the same class yields a new prototype. A certain class of samples has K samples in its support set. For any sample, the intra-class weight is obtained based on the sum of the distances between the sample and other samples of the same class. The intra-class weight is calculated as shown in equation (1):
[0054]
[0055] In equation (1), w our This is the intra-class weight value. Let h(x) be the sum of the distances between the k-th sample and the other (K-1) samples in the class in the feature space, and let h(x) be the in-class weight calculation function, as shown in equation (2):
[0056]
[0057] like Figure 5 As shown, after adjusting the weight coefficients again to account for the influence of inter-class samples, a new prototype is obtained. For a certain class of samples, there are K samples in the support set (other classes have the same number of samples in their support sets). For any sample, the inter-class weight is obtained based on the sum of the distances between the sample and samples from other classes. The intra-class weight is calculated as shown in equation (3):
[0058]
[0059] In equation (3), w other This represents the inter-class weight value. Let g(x) be the sum of the distances in the feature space between the k-th sample and the K samples of the other classes, and g(x) be the inter-class weight calculation function, as shown in equation (4):
[0060]
[0061] By comprehensively considering the impact of intra-class and inter-class samples on the prototype's calculated weights, the final weight w i The calculation formula is as shown in equation (5):
[0062]
[0063] In equation (5), a and b are weight coefficients, and a + b = 1;
[0064] The features of the five support sets are projected onto the space and the prototype of each class is solved according to the weight coefficients. The representative prototype features of each class are determined by the distribution, and the calculation formula is as shown in equation (6):
[0065]
[0066] In equation (6), S k The set of supporting samples.
[0067] S53: The distance between the features of the sample to be tested in S51 and the feature prototypes of the support set samples in S52 is compared by using the feature distance metric, and the distance between the sample to be tested and the support set samples is calculated as shown in equation (7):
[0068]
[0069] If the feature value of the sample image to be detected is closer to the feature value of the normal sample, the sample to be detected is judged to be normal. If the feature value of the sample image to be detected is closer to the feature value of the abnormal sample, the sample to be detected is judged to be abnormal, thus drawing the conclusion that it is a normal or abnormal sample.
Claims
1. A method for detecting defects in contact wire clamps based on small-sample metric learning, characterized in that, The detection method includes the following steps: S1: Construct a 4C image dataset of the contact network, including contact network positioning clamps and bolts and nuts; S2: An improved YOLOv5s target detection network with a two-level cascade method is used to extract images of positioning clamps and bolts and nuts; S3: Establish a few-shot learning network based on metric learning, perform pre-training and meta-training respectively, and obtain a defect detection model based on few-shot metric learning with suitable pre-trained weights; S4: Based on the bolt and nut images, select several normal samples and abnormal samples from the bolt and nut images as sample images, select a portion of each type of sample image as a training set for training the model, and use the remaining samples as a test set for testing and verification. S5: Input the support set samples and the sample to be detected from the test set, and simultaneously input the bolt and nut image samples into the feature extraction module to obtain the features of each support set sample and the features of the sample to be detected. S6: In the support set of the test set, combining the features extracted from the images of positioning clamps and bolts / nuts, the feature prototypes of each category are determined through metric learning. Based on their feature distribution, different weights are assigned to the support set samples in the test phase by calculating intra-class weights and inter-class weights respectively; specifically including: A certain class of samples has K samples in its support set. For any sample, the intra-class weight is obtained based on the sum of the distances between the sample and other samples of the same class. The intra-class weight is calculated as shown in equation (1): ;(1) In equation (1), This is the intra-class weight value. Let be the sum of the distances in the feature space between the k-th sample and the other (K-1) samples in the same class. The function for calculating intra-class weights is shown in equation (2): ; (2) A certain class of samples has K samples in its support set. For any sample, the inter-class weight is obtained based on the sum of the distances between the sample and samples from other classes. The support sets of other classes also have K samples. The intra-class weights are calculated as shown in equation (3): ; (3) In equation (3), This represents the inter-class weight value. Let be the sum of the distances in the feature space between the k-th sample and the k samples of the other class. The function for calculating inter-class weights is shown in equation (4): ;(4) By comprehensively considering the impact of intra-class and inter-class samples on the prototype's calculated weights, the final weight w i The calculation formula is as shown in equation (5): ;(5) In equation (5), , These are the weighting coefficients, and a + b = 1; The features of the five support sets are projected onto the space and the prototype of each class is solved according to the weight coefficients. The representative prototype features of each class are determined by the distribution, and the calculation formula is as shown in equation (6): ;(6) In equation (6), The set of supporting samples; S7: By using feature distance measurement, the features of the sample to be tested are compared with the features of the support set samples in the test set; S8: If the feature value of the sample to be tested is closer to the feature value of the normal sample, it is judged as normal; if it is closer to the feature value of the abnormal sample, it is judged as abnormal.
2. The contact wire clamp defect detection method based on small-sample metric learning according to claim 1, characterized in that, The two-level cascading method specifically includes a first-level cascading and a second-level cascading. The first-level cascading performs target localization on the positioning clamps in the contact wire 4C image dataset and extracts the positioning clamp images. The second-level cascading, based on the positioning clamp images, performs target localization on the bolts and nuts and extracts the bolt and nut images.
3. The contact wire clamp defect detection method based on small-sample metric learning according to claim 2, characterized in that, To improve the detection speed of the YOLOv5 object detection network, the GhostNet network was used to replace the YOLOv5 backbone network.
4. The contact wire clamp defect detection method based on small-sample metric learning according to claim 3, characterized in that, The key steps in establishing a defect detection model based on few-sample metric learning include: S41: First, select the feature extraction module ResNet50 for the few-shot learning network based on metric learning, and pre-train the feature extraction network using the large dataset ImageNet; S42: Meta-training of few-shot metric learning networks using the Mini-ImageNet dataset.
Citation Information
Patent Citations
A method for detecting large-scale difference parts of a high-speed rail contact network
CN109840904A
A high-speed railway insulator defect detection method based on knowledge distillation
CN114998294B
