Rail surface wear recognition method and device based on visual large model and knowledge distillation
By employing self-supervised training and multi-layer knowledge distillation techniques, the problems of insufficient accuracy and efficiency in on-board rail surface scratch detection have been solved, enabling efficient and accurate rail surface scratch identification in on-board systems and adapting to various working conditions.
Patent Information
- Application Number
- CN202611217378.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-12
- Publication Date
- 2026-11-27
AI Technical Summary
Existing deep learning-based methods for detecting track surface scratches struggle to balance accuracy and efficiency in real-time on-vehicle detection systems. Furthermore, the high cost of collecting and labeling track surface scratch samples leads to insufficient training data for the models.
A large visual model is trained by self-supervised training using unlabeled track surface images. The backbone network of the object detection network is initialized and fine-tuned using a small number of labeled samples. Combined with multi-layer knowledge distillation technology, a lightweight student model is obtained, realizing the transfer of global modeling capabilities and detection accuracy.
Without requiring a large number of labeled samples, it improves the accuracy and efficiency of on-board track surface scratch identification, meets real-time inspection requirements, reduces inference latency, and adapts to different track and lighting conditions.
Smart Images

Figure CN123181899A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of track surface inspection technology, and in particular to a method and apparatus for identifying track surface scratches based on a large visual model and knowledge distillation. Background Technology
[0002] Rails are critical load-bearing components of railway infrastructure, enduring long-term wheel-rail impact, material fatigue, temperature and humidity variations, and the complex environment of railway lines. The rail surface (i.e., rail face) is prone to localized damage such as abrasions, peeling, and wear. Rail face abrasions alter the wheel-rail contact state and can lead to stress concentration and material deterioration, posing a threat to the safe operation of the line. Therefore, timely and accurate identification of rail face abrasions is of significant engineering importance during onboard inspections, comprehensive line testing, and routine maintenance.
[0003] With the development of line scan cameras, high-speed imaging, and vehicle-mounted edge computing platforms, non-contact rail surface condition detection based on machine vision has gradually become an important means of rail inspection. This type of method typically involves acquiring continuous rail surface images using an inspection vehicle, and then utilizing deep learning-based image recognition algorithms to locate and classify suspected damaged areas, thereby improving inspection efficiency and reducing the burden of manual review.
[0004] However, existing deep learning-based track surface scratch detection methods still have the following problems: On the one hand, although conventional convolutional neural networks have automatic feature learning capabilities, their receptive field is limited, and their ability to uniformly model global track surface structure, long-distance texture relationships, and small-scale scratch details is insufficient; on the other hand, although large-scale visual models with a large number of parameters have stronger global relationship modeling capabilities, direct deployment in on-board real-time detection systems will bring inference latency and computational pressure, making it difficult to meet real-time requirements; in addition, the cost of collecting and labeling track surface scratch samples is high, and it is difficult to obtain sufficient labeled data for model training. Summary of the Invention
[0005] This invention provides a method for identifying track surface scratches based on a large visual model and knowledge distillation, to improve the accuracy and efficiency of onboard track surface scratch identification. The method includes: Obtain the track surface image to be identified; Input the track surface image to be identified into the student model obtained through knowledge distillation to obtain the track surface scratch identification result of the track surface image to be identified; The student model is obtained in the following way: Obtain an unlabeled track surface image dataset and an labeled track surface scratch image dataset; The visual large model was self-supervised and trained using an unlabeled track surface image dataset to obtain a feature extraction model. The backbone network of the first target detection network is initialized using the parameters of the feature extraction model, and the first target detection network is fine-tuned using the image dataset of labeled track surface scratches to obtain the teacher model; Using the output of the teacher model as a supervision signal, the second target detection network is subjected to multi-layer knowledge distillation using an image dataset labeled with track surface scratches to obtain the student model. The multi-layer knowledge distillation includes: output layer distillation for constraining the output distribution, feature layer distillation for constraining the intermediate feature expression, and relation layer distillation for constraining the internal structured relationships.
[0006] This invention also provides a track surface scratch recognition device based on a large visual model and knowledge distillation, to improve the accuracy and efficiency of on-board track surface scratch recognition. The device includes: The data acquisition module is used to: acquire the track surface image to be identified; The track surface scratch recognition module is used to: input the track surface image to be recognized into the student model obtained through knowledge distillation, and obtain the track surface scratch recognition result of the track surface image to be recognized; The student model is obtained in the following way: Obtain an unlabeled track surface image dataset and an labeled track surface scratch image dataset; The visual large model was self-supervised and trained using an unlabeled track surface image dataset to obtain a feature extraction model. The backbone network of the first target detection network is initialized using the parameters of the feature extraction model, and the first target detection network is fine-tuned using the image dataset of labeled track surface scratches to obtain the teacher model; Using the output of the teacher model as a supervision signal, the second target detection network is subjected to multi-layer knowledge distillation using an image dataset labeled with track surface scratches to obtain the student model. The multi-layer knowledge distillation includes: output layer distillation for constraining the output distribution, feature layer distillation for constraining the intermediate feature expression, and relation layer distillation for constraining the internal structured relationships.
[0007] This invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the above-described method for track surface scratch recognition based on a large visual model and knowledge distillation.
[0008] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method for track surface scratch recognition based on a large visual model and knowledge distillation.
[0009] This invention also provides a computer program product, which includes a computer program that, when executed by a processor, implements the above-described track surface scratch recognition method based on a large visual model and knowledge distillation.
[0010] Compared with existing technologies that struggle to balance accuracy and efficiency in track surface scratch recognition, this invention first uses unlabeled track surface images to perform self-supervised training on a large visual model. Then, it initializes the parameters of the backbone network of the target detection model based on a feature extraction model. By fine-tuning the target detection model, a teacher model is obtained. The output distribution, intermediate feature representation, and internal structured relationships of the teacher model are used as three layers of supervision signals to perform knowledge distillation on a lightweight student model. This allows the global modeling capabilities and detection accuracy of the large visual model to be transferred to the lightweight student model without requiring a large number of labeled samples. As a result, the student model simultaneously possesses high detection accuracy and low inference latency on the vehicle-mounted edge computing platform, meeting the requirements of real-time inspection. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. In the drawings: Figure 1 This is a flowchart of the track surface scratch recognition method based on visual large model and knowledge distillation in an embodiment of the present invention; Figure 2 This is an example image of training samples for marking track surface scratches in an embodiment of the present invention; Figure 3 This is an example diagram of the self-supervised pre-training process in an embodiment of the present invention; Figure 4 This is an example diagram illustrating the teacher model fine-tuning process in an embodiment of the present invention; Figure 5 This is an example diagram of the network structure of the student model in an embodiment of the present invention; Figure 6 This is an example diagram showing the results of track surface scratch identification in an embodiment of the present invention; Figure 7 This is a schematic diagram of a track surface scratch recognition device based on a large visual model and knowledge distillation in an embodiment of the present invention; Figure 8 This is another schematic diagram of the track surface scratch recognition device based on visual large model and knowledge distillation in an embodiment of the present invention. Detailed Implementation
[0012] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0013] Figure 1 This is a flowchart of a track surface scratch recognition method based on a large visual model and knowledge distillation, as described in an embodiment of the present invention. Figure 1 As shown, this method is implemented according to the following steps: Step 101: Obtain the track surface image to be identified; Step 102: Input the track surface image to be identified into the student model obtained through knowledge distillation to obtain the track surface scratch recognition result of the track surface image to be identified; The student model is obtained in the following way: Obtain an unlabeled track surface image dataset and an labeled track surface scratch image dataset; The visual large model was self-supervised and trained using an unlabeled track surface image dataset to obtain a feature extraction model. The backbone network of the first target detection network is initialized using the parameters of the feature extraction model, and the first target detection network is fine-tuned using the image dataset of labeled track surface scratches to obtain the teacher model; Using the output of the teacher model as a supervision signal, the second target detection network is subjected to multi-layer knowledge distillation using an image dataset labeled with track surface scratches to obtain the student model. The multi-layer knowledge distillation includes: output layer distillation for constraining the output distribution, feature layer distillation for constraining the intermediate feature expression, and relation layer distillation for constraining the internal structured relationships.
[0014] Compared with existing technologies that struggle to balance accuracy and efficiency in track surface scratch recognition, this invention first uses unlabeled track surface images to perform self-supervised training on a large visual model. Then, it initializes the parameters of the backbone network of the target detection model based on a feature extraction model. By fine-tuning the target detection model, a teacher model is obtained. The output distribution, intermediate feature representation, and internal structured relationships of the teacher model are used as three layers of supervision signals to perform knowledge distillation on a lightweight student model. This allows the global modeling capabilities and detection accuracy of the large visual model to be transferred to the lightweight student model without requiring a large number of labeled samples. As a result, the student model simultaneously possesses high detection accuracy and low inference latency on the vehicle-mounted edge computing platform, meeting the requirements of real-time inspection.
[0015] It should be noted that the specific network names in this embodiment are used to describe preferred implementation methods and do not limit the scope of protection of this invention.
[0016] In this embodiment of the invention, an image of the track surface to be identified is obtained.
[0017] For example, using a line scan camera or a high-speed area scan camera mounted on a vehicle-mounted inspection system, the surface of the rail is continuously scanned and imaged during the movement of the inspection vehicle to obtain grayscale or color images of the rail surface. The image resolution is determined according to the camera selection and the required inspection accuracy.
[0018] After acquiring the orbital plane image, the image is input into a pre-trained lightweight student model for forward inference.
[0019] In this embodiment of the invention, the track surface image to be identified is input into the student model obtained through knowledge distillation to obtain the track surface scratch identification result of the track surface image to be identified.
[0020] For example, the track surface image to be identified is input into the student model obtained through knowledge distillation. The student model outputs the bounding box coordinates, category confidence, and location information of each scratch target in the image. Suspected scratches with confidence exceeding the threshold are alerted or handed over to manual review, while samples with low confidence but high uncertainty are entered into the subsequent incremental data pool.
[0021] For example, the confidence threshold can be set between 0.5 and 0.8 depending on the actual application scenario.
[0022] The student model is obtained through several embodiments as follows.
[0023] In this embodiment of the invention, an unlabeled track surface image dataset and an labeled track surface scratch image dataset are obtained.
[0024] For example, track surface images are collected under different routes, lighting conditions, rail materials, and imaging conditions. Severely out-of-focus, occluded, and invalid images are removed to form a large-scale unlabeled track image dataset.
[0025] Figure 2 This is an example image of a training sample showing track surface scratches in an embodiment of the present invention.
[0026] For a small number of scratched samples in the unlabeled track image dataset, label the defect categories and bounding boxes to form a small labeled defect training set, such as... Figure 2 As shown, the blue rectangles indicate the marked track surface scratch areas. The dataset was expanded by randomly cropping the track surface areas, adjusting brightness and contrast, applying slight blurring, injecting noise, and scaling, to ensure the training data covered real-world inspection scenarios as comprehensively as possible, thus improving the model's adaptability to complex working conditions.
[0027] In this embodiment of the invention, an unlabeled track surface image dataset is used to perform self-supervised training on a large visual model to obtain a feature extraction model.
[0028] Self-supervised training can employ various self-supervised task paradigms. In one embodiment, the self-supervised training employs a contrastive learning task, a masked image modeling task, or a self-distillation task.
[0029] For example, a contrastive learning task can be used to learn discriminative representations by bringing the feature distance between different augmented views of the same image closer together and increasing the feature distance between different images.
[0030] Another example is the Masked Image Modeling (MIM) task, which randomly covers parts of the input image and trains the model to predict the content of the covered areas, thereby learning the local texture and structural information of the image.
[0031] Another example is the use of self-distillation tasks, such as the DINO framework, which achieves unsupervised representation learning through mutual learning between student and teacher branches, enabling the model to learn general visual representations of track surface texture, weld distribution, scratch edges, and background interference.
[0032] The goal of the self-supervised pre-training stage is not to directly output detection results, but to obtain a strong representation backbone network suitable for rail images.
[0033] Figure 3 This is an example diagram of the self-supervised pre-training process in an embodiment of the present invention. For example, as shown... Figure 3 As shown, the large visual model uses DINO (Self-Distillation with NO labels) v3.
[0034] Figure 3First, the unlabeled track surface image is augmented at multiple scales according to the global and local views, and then input into the ViT (Vision Transformer) backbone network in DINO v3. The student branch receives track surface images at different cropping scales (the patch token is converted into a high-dimensional vector through a fully connected layer, i.e., the image is converted into a sequence of tokens). The teacher branch updates the parameters of the student branch with the Exponential Moving Average (EMA) and outputs a stable representation. Through self-distillation loss, semantic consistency under different views is constrained, enabling the network to learn visual representations such as track surface texture, weld patterns, reflective areas, and scratch edges without manual annotation. To reduce the risk of feature degradation during long-term self-supervised training, Gram anchoring constraint is introduced to align the current feature relevance with the feature relevance of the anchored model, so that the pre-trained model retains both local texture details and global semantic structure. After pre-training, the ViT backbone network parameters are retained as the initial weights for the subsequent teacher model.
[0035] In this embodiment of the invention, the backbone network of the first target detection network is initialized using the parameters of the feature extraction model, and the first target detection network is fine-tuned using an image dataset of labeled track surface scratches to obtain the teacher model.
[0036] When fine-tuning on labeled abrasion samples, the sampling weight of low-contrast abrasion samples is increased, and the small target bounding box localization term is enhanced in the detection loss.
[0037] For example, for scratch samples with contrast below a preset threshold, their sampling weight is set to 1.5 to 2 times that of ordinary samples; at the same time, in the detection loss function, for small-scale scratch targets with an area smaller than the preset threshold (e.g., 32×32 pixels), the weight coefficient of their bounding box localization loss is increased to 1.2 to 1.5 times that of ordinary targets, so that the teacher model has a higher response to minor scratches, scratches with blurred edges, and suspected areas adjacent to welds.
[0038] By fine-tuning with labeled data, the teacher model gains strong defect localization and category discrimination capabilities. The selection of the teacher model's network structure is not primarily constrained by real-time deployment; instead, it mainly employs network structures with a large number of parameters and high detection accuracy.
[0039] In one embodiment, the first target detection network includes: a target detection head, and a multi-scale feature adaptation module disposed between the backbone network and the target detection head.
[0040] Figure 4 This is an example diagram illustrating the teacher model fine-tuning process in an embodiment of the present invention.
[0041] For example, such as Figure 4 As shown, the teacher model uses the DEIM v2 object detection framework. Figure 4 In the DEIM v2 framework, the ViT backbone obtained through self-supervised pre-training is used as the backbone network. The multi-scale feature adaptation module (i.e., Spatial Tuning Adapter, STA) is set between the backbone network and the object detection head to convert the single-scale high-dimensional semantic features output by the ViT backbone into multi-scale features suitable for object detection.
[0042] In one embodiment, the multi-scale feature adaptation module is used to convert the single-scale semantic features output by the backbone network into a multi-scale feature pyramid; the multi-scale feature pyramid contains feature maps of at least two resolutions for adapting to scratch detection at different scales.
[0043] Figure 4 In the middle, the multi-scale feature adaptation module adopts a single-scale to multi-scale feature adaptation structure, which upsamples and downsamples the low-resolution strong semantic features output by the ViT backbone and fuses them with lateral convolution features to form a multi-scale feature pyramid containing feature maps of at least two resolutions, in order to adapt to the target detection requirements with large scale differences in rail surface scratches.
[0044] The multi-scale feature pyramid can contain three feature maps of different resolutions, which are used to detect large-area scratches, medium-scale scratches, and small-scale scratches respectively. The multi-scale feature adaptation module upsamples and downsamples low-resolution strong semantic features and fuses them with lateral convolution features, so that the teacher model has a higher localization ability for small scratches, low-contrast scratches, and scratches with blurred edges.
[0045] Figure 4 Subsequently, multi-scale features are input into the Transformer detection encoder and simplified decoder. Convergence speed and candidate target supervision density are improved through end-to-end target query, ensemble matching loss, and Dense O2O (dense one-to-one) matching strategies. During fine-tuning on training samples annotated with track surface scratches, sampling weights are increased for low-contrast scratch samples, and the small target bounding box localization term is enhanced in the detection loss.
[0046] After the teacher model is trained, its output is used as a supervision signal to perform knowledge distillation on the lightweight student model.
[0047] In this embodiment of the invention, the output of the teacher model is used as a supervision signal, and a multi-layer knowledge distillation is performed on the second target detection network using an image dataset labeled with track surface scratches to obtain a student model; the multi-layer knowledge distillation includes: output layer distillation for constraining the output distribution, feature layer distillation for constraining the intermediate feature expression, and relation layer distillation for constraining the internal structured relationships.
[0048] Figure 5 This is an example diagram of the network structure of the student model in an embodiment of the present invention.
[0049] For example, such as Figure 5 As shown, an improved RT-DETR is used as a lightweight student target detection network. The class probability, target confidence, and bounding box distribution (with temperature-adjusted soft labels) output by the teacher model, as well as the intermediate feature response and internal relation matrix, are used as supervision signals. The student model is trained by three-layer co-distillation of output layer distillation, feature layer distillation, and relation layer distillation using labeled track surface scratch sample images. This enables the student model to achieve detection accuracy close to that of the teacher model while maintaining real-time reasoning ability.
[0050] In one embodiment, the second target detection network includes: a feature extraction network, an encoder, a decoder, and a multi-scale feature selection module disposed between the feature extraction network and the encoder.
[0051] Figure 5 In this model, the student model is based on RT-DETR and consists of a lightweight backbone network (i.e., a feature extraction network), an efficient hybrid encoder, an IoU-aware query selection module, and a Transformer decoder. The lightweight backbone network outputs track surface feature maps at multiple scales (C3, C4, and C5 are different convolutional layers used to extract features at different scales); the efficient hybrid encoder first performs cross-scale fusion on high-level features, and then supplements the global context through a lightweight self-attention or convolutional fusion module; the IoU-aware query selection module filters candidate queries from the encoder output that are more likely to contain scratch targets; the decoder regresses scratch bounding boxes layer by layer based on the candidate queries and outputs class confidence scores. To adapt to the rail scratch detection task, a multi-scale feature selection module for the track surface is set between the lightweight backbone network and the efficient hybrid encoder.
[0052] In one embodiment, the multi-scale feature selection module is used to assign learnable weights to the multi-scale features output by the feature extraction network, perform scale alignment and channel compression, and output multi-scale fusion features adapted to abrasion detection at different scales.
[0053] Figure 5In this module, the multi-scale feature selection module is located between the backbone network and the hybrid encoder. It calculates learnable weights for shallow high-resolution features, mid-level texture features, and deep semantic features, and then performs scale alignment and channel compression.
[0054] For example, the lightweight backbone network outputs track surface feature maps at three scales. The multi-scale feature selection module calculates the learnable weights of features at each scale, and outputs multi-scale fusion features of a unified dimension after weighted summation, scale alignment and channel compression. This allows the student model to retain both the edges of minor scratches and the global background semantics of the track surface with a small amount of computation.
[0055] To further enhance the detection capability for low-contrast, blurred-edge scratches, a defect edge enhancement branch is added as a bypass in the multi-scale feature selection module, such as... Figure 5 As shown.
[0056] In one embodiment, the second target detection network further includes a defect edge enhancement branch, which is set as a bypass of the multi-scale feature selection module, for extracting at least one of the local gradient features, high-frequency texture features, or edge response features of the input features, and performing gated fusion with the multi-scale fusion features output by the multi-scale feature selection module.
[0057] For example, the defect edge enhancement branch extracts edge responses from the input features using local gradients, high-frequency textures, or lightweight convolutions to obtain edge response feature maps. Then, it uses gated weights to control the intensity of edge information injection and fuses the extracted edge responses with the multi-scale fusion features output by the multi-scale feature selection module channel by channel. This makes the network more sensitive to low contrast, blurred boundaries, and slender abrasions, while avoiding over-enhancing of strong weld textures.
[0058] To prevent slender, scratched targets from being suppressed in early query filtering, a slender, scratched query retention strategy is set during the query selection and decoding phases, such as... Figure 5 As shown.
[0059] In one embodiment, the decoder of the second object detection network performs score compensation on the candidate query based on at least one of the aspect ratio of the candidate region and the continuity of local edges.
[0060] For example, the decoder compensates for the query score of suspected slender scratched regions based on at least one of the following: the aspect ratio of the candidate region (e.g., candidate regions with an aspect ratio greater than 3:1), the continuity of local edges, and the response heat of the teacher model to the candidate region. This increases the probability of slender, low-contrast candidate regions entering the decoder, thereby reducing the false suppression of minor scratched targets without significantly increasing the total number of queries.
[0061] It should be noted that the teacher model's response heat to candidate regions is only used to generate supervision signals or prior knowledge during the training phase. During the deployment and inference phase, the student model independently completes the query selection.
[0062] In the training loss design, a background interference reweighting term is added to suppress false defect interference. In one embodiment, the loss function of the second target detection network further includes a background interference reweighting term, used to adjust the negative sample constraint weights of easily confused background regions in the track surface image; the easily confused background regions are background regions whose similarity to the track surface scratch region is higher than a preset similarity.
[0063] For example, for background areas that are easily visually confused with scratched targets, such as weld seam areas, oil stain areas, reflective areas, and normal track surface texture areas, the feature similarity between these areas and the track surface scratched areas is calculated. When the similarity is higher than the preset similarity threshold, a negative sample constraint weight higher than that of the normal background areas is applied to this type of area, so that the model can produce a stronger suppression response to easily confused backgrounds during the training process.
[0064] The background interference reweighting term and the distillation adaptation term together constitute the loss function of the student model. The distillation adaptation term aligns student features with teacher features through a lightweight channel mapping layer, enabling the three-layer distillation to be performed in a feature space with consistent dimensions.
[0065] In the three-layer collaborative distillation training, output layer distillation is used to align classification confidence and bounding box distribution; feature layer distillation is used to guide the student model to learn abrasion edges, texture mutations and semantic region responses; relation layer distillation is used to convey the correlation between samples, channels or target queries, so that the student model can maintain high detection accuracy with low computational overhead.
[0066] In the output layer distillation: the class probabilities, target confidence and bounding box distribution output by the teacher model are temperature-adjusted to form soft labels; the student model learns these soft labels on the basis of regular detection supervision, so that it not only learns the hard categories labeled by humans, but also learns the confidence distribution of the teacher model for low-contrast scratches, suspected background and easily confused areas.
[0067] Specifically, the temperature parameters of the output layer distillation can be dynamically adjusted according to the training phase, enhancing soft distribution information in the early stage and gradually increasing the constraints on the real annotations in the later stage.
[0068] For example, in the early stages of distillation training, setting the temperature parameter to a higher value makes the class probability distribution output by the teacher model smoother, allowing the student model to learn the relative similarity information between classes. As training progresses, the temperature parameter value is gradually decreased, causing the supervision signal to gradually approach the true label distribution. Employing a dynamic temperature adjustment strategy can better guide the student model to focus on global class relationships in the early stages of training and on accurate hard-label supervision in the later stages.
[0069] In the intermediate feature layer distillation, feature layers in the teacher detection network corresponding to the scale of the student network are selected. The feature dimensions are aligned through channel mapping or lightweight adaptation layers, enabling the student model to learn the teacher model's responses to scratched edges, texture mutations, and track surface semantic regions. For low-level features, the focus is on constraining edge and texture details; for high-level features, the focus is on constraining the semantic differences between defective regions and background regions.
[0070] In relational distillation, sample relation matrices, channel relation matrices, or target query relation matrices are constructed for the teacher and student models. These matrices constrain the student model's ability to learn the teacher model's judgments regarding the correlations between different candidate defects, different channel responses, and different track surface regions. This relational distillation helps the student model establish consistent decisions between the global track surface structure and local defect details, reducing the probability of misclassifying welds or stains as scratches.
[0071] For example, the process of constructing the relationship matrix between samples is as follows: Within a training batch, the pairwise similarity (such as cosine similarity) between the feature vectors of each sample is calculated to form an N×N sample relationship matrix. The relationship matrix of the student model is constrained to be consistent with the relationship matrix of the teacher model, so that the student model can learn the teacher model's ability to judge the correlation structure between different samples.
[0072] In another example, the process of constructing the inter-channel relationship matrix is as follows: calculate the correlation between different channels in the feature map to constrain the student model's ability to learn the teacher model's judgment on the relationship between the responses of different channels.
[0073] In another example, the process of constructing the relation matrix between target queries is as follows: For the student model based on Transformer, the self-attention correlation matrix between each target query in the decoder is calculated, and its correspondence matrix with that of the teacher model is constrained to be consistent, so that the student model learns the collaborative search and inhibition relationship between each candidate query in the teacher model.
[0074] Figure 6 This is an example diagram showing the results of rail surface scratch identification in an embodiment of the present invention. Figure 6 As shown, the blue rectangle labeled "cashing_bad" indicates the area where the track surface scratches were identified.
[0075] In one embodiment, based on the scratch recognition results of the teacher model and the student model on the newly acquired track surface image, samples that meet any of the following conditions are selected from the newly acquired track surface image as incremental distillation samples: the confidence level of the scratch recognition result output by the teacher model is higher than a first threshold, and the confidence level of the scratch recognition result output by the student model is lower than a second threshold; the difference between the scratch recognition result output by the teacher model and the scratch recognition result output by the student model exceeds a preset distance threshold; the sample is determined to be an incremental distillation sample after manual review; the backbone network parameters of the student model are frozen, and the incremental distillation samples are used to perform incremental distillation training on the network layer parameters used for target detection output and feature adaptation in the student model to obtain a parameter-updated student model.
[0076] For example, after the student model is deployed to the vehicle-mounted inspection system, it continuously receives inspection images under new routes, new seasons, and new lighting conditions. It prioritizes selecting samples with high confidence (e.g., confidence level above 0.85) from the teacher model and low confidence (e.g., confidence level below 0.5) from the student model as incremental distillation data, ensuring that the selected samples have high learning value. After the newly acquired track surface images undergo forward inference by both the teacher and student models, the confidence level of the recognition results output by both models determines whether the sample meets the selection criteria.
[0077] Another example is to calculate the difference between the recognition results of the teacher model and the student model for the same image (such as the KL divergence of the output probability distribution or the bounding box localization deviation). When the difference exceeds a preset threshold, the sample is marked as a high-value incremental distillation sample.
[0078] During incremental distillation training, the backbone network parameters of the student model are frozen, and only the network layer parameters used for object detection output and feature adaptation, such as the detection head, query embedding, or lightweight adaptation module, are updated to avoid excessive computational overhead caused by repeated training of the entire model.
[0079] For example, using selected high-value incremental distillation samples, only the parameters of the detector head, query embedding, and distillation adaptation layer in the student model are updated with small-step gradients, while keeping the main parameters of the lightweight backbone network and encoder unchanged. The updated student model is then quickly validated and used to replace the deployed model, enabling the algorithm to adapt to varying operating conditions.
[0080] To avoid the computational overhead of frequent updates, incremental distillation training is executed on a condition-triggered basis.
[0081] In one embodiment, the incremental distillation training is triggered when the average confidence level of the student model for scratch recognition results of a preset number of consecutive track surface images is less than a preset threshold.
[0082] For example, when the average prediction confidence of the student model on N consecutive new scene images (e.g., N=100) is lower than a preset threshold (e.g., 0.6), the incremental distillation process is actively triggered to update the key components of the student model using the accumulated incremental distillation samples, so as to avoid the degradation of detection performance caused by changes in operating conditions.
[0083] In another example, incremental distillation training is triggered during gaps in the onboard inspection system's non-inspection operation state (such as when the train returns to the depot or stops), without affecting normal real-time inspection operations.
[0084] The track surface scratch recognition method based on visual large model and knowledge distillation proposed in this invention has at least the following beneficial effects: 1. First, perform self-supervised pre-training on a large number of unlabeled track images, and then fine-tune the teacher model using a small number of labeled scratch samples. This can alleviate the problem of scarce rail scratch samples and high labeling costs, and improve the generalization ability of the teacher model to different tracks, lighting and rail materials.
[0085] 2. Utilize a large visual model to construct a high-performance teacher model, enabling the teacher model to simultaneously focus on the global structure of the track surface and the details of local scratches, thereby improving the ability to identify scratch areas with low contrast, blurred edges, and small scale, and suppressing interference from false defects such as welds, oil stains, and reflections.
[0086] 3. Through collaborative knowledge distillation of the output layer, feature layer and relation layer, the discriminative ability of the teacher model is transferred to the lightweight student model. While maintaining high detection accuracy, the parameter scale and inference latency are reduced, making it more suitable for real-time deployment in vehicle inspection systems.
[0087] 4. An online incremental distillation mechanism is introduced, which can use new scene data continuously generated during actual inspections to update key components of the student model at low cost, enabling the model to adapt in a timely manner to changes in line switching, seasonal changes, imaging conditions, and rail material differences.
[0088] 5. The overall process of this method does not rely on a single fixed network structure. It can replace the self-supervised pre-trained network (network structure of the large visual model), the teacher detection network (network structure of the teacher model), or the student detection network (network structure of the student model) according to the computing power platform and detection accuracy requirements, and has good engineering adaptability and scalability.
[0089] This invention also provides a track surface scratch recognition device based on a large visual model and knowledge distillation, as described in the following embodiments. Since the principle behind this device is similar to that of the track surface scratch recognition method based on a large visual model and knowledge distillation, the implementation of this device can refer to the implementation of the track surface scratch recognition method based on a large visual model and knowledge distillation; repeated details will not be elaborated further.
[0090] Figure 7 This is a schematic diagram of a track surface scratch recognition device based on a large visual model and knowledge distillation in an embodiment of the present invention.
[0091] The data acquisition module 701 is used to: acquire the track surface image to be identified; The track surface scratch recognition module 702 is used to: input the track surface image to be recognized into the student model obtained through knowledge distillation, and obtain the track surface scratch recognition result of the track surface image to be recognized; The student model is obtained in the following way: Obtain an unlabeled track surface image dataset and an labeled track surface scratch image dataset; The visual large model was self-supervised and trained using an unlabeled track surface image dataset to obtain a feature extraction model. The backbone network of the first target detection network is initialized using the parameters of the feature extraction model, and the first target detection network is fine-tuned using the image dataset of labeled track surface scratches to obtain the teacher model; Using the output of the teacher model as a supervision signal, the second target detection network is subjected to multi-layer knowledge distillation using an image dataset labeled with track surface scratches to obtain the student model. The multi-layer knowledge distillation includes: output layer distillation for constraining the output distribution, feature layer distillation for constraining the intermediate feature expression, and relation layer distillation for constraining the internal structured relationships.
[0092] In one embodiment, the self-supervised training employs a contrastive learning task, a masked image modeling task, or a self-distillation task.
[0093] In one embodiment, the first target detection network includes: a target detection head, and a multi-scale feature adaptation module disposed between the backbone network and the target detection head; The multi-scale feature adaptation module is used to convert the single-scale semantic features output by the backbone network into a multi-scale feature pyramid. The multi-scale feature pyramid contains feature maps of at least two resolutions to adapt to scratch detection at different scales.
[0094] In one embodiment, the second target detection network includes: a feature extraction network, an encoder, a decoder, and a multi-scale feature selection module disposed between the feature extraction network and the encoder; the multi-scale feature selection module is used to assign learnable weights to the multi-scale features output by the feature extraction network, perform scale alignment and channel compression, and output multi-scale fusion features for adapting to scratch detection at different scales.
[0095] In one embodiment, the second target detection network further includes a defect edge enhancement branch, which is set as a bypass of the multi-scale feature selection module, for extracting at least one of the local gradient features, high-frequency texture features, or edge response features of the input features, and performing gated fusion with the multi-scale fusion features output by the multi-scale feature selection module.
[0096] In one embodiment, the decoder of the second object detection network performs score compensation on the candidate query based on at least one of the aspect ratio of the candidate region and the continuity of local edges.
[0097] In one embodiment, the loss function of the second target detection network further includes a background interference reweighting term, used to adjust the negative sample constraint weights of easily confused background regions in the track surface image; the easily confused background regions are background regions whose similarity to the track surface scratch region is higher than a preset similarity.
[0098] Figure 8 This is another schematic diagram of the track surface scratch recognition device based on visual large model and knowledge distillation in an embodiment of the present invention.
[0099] In one embodiment, such as Figure 8 As shown, Figure 7 The device also includes an online incremental distillation module 801, used for: Based on the scratch recognition results of the teacher model and the student model on the newly acquired track surface images, samples that meet any of the following conditions are selected from the newly acquired track surface images as incremental distillation samples: the confidence level of the scratch recognition result output by the teacher model is higher than the first threshold, and the confidence level of the scratch recognition result output by the student model is lower than the second threshold; the difference between the scratch recognition result output by the teacher model and the scratch recognition result output by the student model exceeds a preset distance threshold; and the sample is determined to be an incremental distillation sample after manual review. The backbone network parameters of the student model are frozen. Using the incremental distillation samples, incremental distillation training is performed on the network layer parameters used for target detection output and feature adaptation in the student model to obtain a student model with updated parameters.
[0100] In one embodiment, the incremental distillation training is triggered when the average confidence level of the student model for scratch recognition results of a preset number of consecutive track surface images is less than a preset threshold.
[0101] This invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the above-described method for track surface scratch recognition based on a large visual model and knowledge distillation.
[0102] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method for track surface scratch recognition based on a large visual model and knowledge distillation.
[0103] This invention also provides a computer program product, which includes a computer program that, when executed by a processor, implements the above-described track surface scratch recognition method based on a large visual model and knowledge distillation.
[0104] Compared with existing technologies that struggle to balance accuracy and efficiency in track surface scratch recognition, this invention first uses unlabeled track surface images to perform self-supervised training on a large visual model. Then, it initializes the parameters of the backbone network of the target detection model based on a feature extraction model. By fine-tuning the target detection model, a teacher model is obtained. The output distribution, intermediate feature representation, and internal structured relationships of the teacher model are used as three layers of supervision signals to perform knowledge distillation on a lightweight student model. This allows the global modeling capabilities and detection accuracy of the large visual model to be transferred to the lightweight student model without requiring a large number of labeled samples. As a result, the student model simultaneously possesses high detection accuracy and low inference latency on the vehicle-mounted edge computing platform, meeting the requirements of real-time inspection.
[0105] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0106] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0107] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0108] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0109] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for track surface scratch recognition based on a large visual model and knowledge distillation, characterized in that, include: Obtain the track surface image to be identified; Input the track surface image to be identified into the student model obtained through knowledge distillation to obtain the track surface scratch identification result of the track surface image to be identified; The student model is obtained in the following way: Obtain an unlabeled track surface image dataset and an labeled track surface scratch image dataset; The visual large model was self-supervised and trained using an unlabeled track surface image dataset to obtain a feature extraction model. The backbone network of the first target detection network is initialized using the parameters of the feature extraction model, and the first target detection network is fine-tuned using the image dataset of labeled track surface scratches to obtain the teacher model; Using the output of the teacher model as a supervision signal, the second target detection network is subjected to multi-layer knowledge distillation using an image dataset labeled with track surface scratches to obtain the student model. The multi-layer knowledge distillation includes: output layer distillation for constraining the output distribution, feature layer distillation for constraining the intermediate feature expression, and relation layer distillation for constraining the internal structured relationships.
2. The method as described in claim 1, characterized in that, The self-supervised training employs a contrastive learning task, a masked image modeling task, or a self-distillation task.
3. The method as described in claim 1, characterized in that, The first target detection network includes: a target detection head, and a multi-scale feature adaptation module disposed between the backbone network and the target detection head; The multi-scale feature adaptation module is used to convert the single-scale semantic features output by the backbone network into a multi-scale feature pyramid. The multi-scale feature pyramid contains feature maps of at least two resolutions to adapt to scratch detection at different scales.
4. The method as described in claim 1, characterized in that, The second target detection network includes: a feature extraction network, an encoder, a decoder, and a multi-scale feature selection module disposed between the feature extraction network and the encoder; the multi-scale feature selection module is used to assign learnable weights to the multi-scale features output by the feature extraction network, perform scale alignment and channel compression, and output multi-scale fusion features for adapting to scratch detection at different scales.
5. The method as described in claim 4, characterized in that, The second target detection network further includes a defect edge enhancement branch, which is set as a bypass of the multi-scale feature selection module. It is used to extract at least one of the local gradient features, high-frequency texture features, or edge response features of the input features, and to perform gated fusion with the multi-scale fusion features output by the multi-scale feature selection module.
6. The method as described in claim 4, characterized in that, The decoder of the second object detection network performs score compensation on the candidate query based on at least one of the aspect ratio of the candidate region and the continuity of local edges.
7. The method as described in claim 1, characterized in that, The loss function of the second target detection network also includes a background interference reweighting term, which is used to adjust the negative sample constraint weights of easily confused background regions in the track surface image; the easily confused background regions are background regions whose similarity to the track surface scratch region is higher than a preset similarity.
8. The method as described in claim 1, characterized in that, Also includes: Based on the scratch recognition results of the teacher model and the student model on the newly acquired track surface images, samples that meet any of the following conditions are selected from the newly acquired track surface images as incremental distillation samples: the confidence level of the scratch recognition result output by the teacher model is higher than the first threshold, and the confidence level of the scratch recognition result output by the student model is lower than the second threshold; the difference between the scratch recognition result output by the teacher model and the scratch recognition result output by the student model exceeds a preset distance threshold. The sample was determined to be an incremental distillation sample after manual verification; The backbone network parameters of the student model are frozen. Using the incremental distillation samples, incremental distillation training is performed on the network layer parameters used for target detection output and feature adaptation in the student model to obtain a student model with updated parameters.
9. The method as described in claim 8, characterized in that, The incremental distillation training is triggered when the average confidence level of the student model for scratch recognition results of a preset number of consecutive track surface images is less than a preset threshold.
10. A track surface scratch recognition device based on a large visual model and knowledge distillation, characterized in that, include: The data acquisition module is used to: acquire the track surface image to be identified; The track surface scratch recognition module is used to: input the track surface image to be recognized into the student model obtained through knowledge distillation, and obtain the track surface scratch recognition result of the track surface image to be recognized; The student model is obtained in the following way: Obtain an unlabeled track surface image dataset and an labeled track surface scratch image dataset; The visual large model was self-supervised and trained using an unlabeled track surface image dataset to obtain a feature extraction model. The backbone network of the first target detection network is initialized using the parameters of the feature extraction model, and the first target detection network is fine-tuned using the image dataset of labeled track surface scratches to obtain the teacher model; Using the output of the teacher model as a supervision signal, the second target detection network is subjected to multi-layer knowledge distillation using an image dataset labeled with track surface scratches to obtain the student model. The multi-layer knowledge distillation includes: output layer distillation for constraining the output distribution, feature layer distillation for constraining the intermediate feature expression, and relation layer distillation for constraining the internal structured relationships.
11. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method of any one of claims 1 to 9.
13. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the method of any one of claims 1 to 9.
