Cross-line metro track defect classification method and system based on defect anchor attention

CN122990331APending Publication Date: 2026-10-27BEIJING JIAOTONG UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611232441.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-14
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

然而,在地铁跨线场景下,由于真正的缺陷区域只占图像中很小的一部分,而背景区域占据图像的绝大部分,对边缘分布的对齐实际上主要作用在背景统计上,反而可能对真正的缺陷条件分布造成扰动,导致在跨线评测中相对于不使用领域自适应的基线方法没有稳定提升,甚至在部分迁移方向上出现性能下降

Benefits of technology

[0046]维实际工程中模型在源线路训练、跨线部署性能显著下滑的核心难题,将物理退化机理先验显式注入缺陷查询,并通过缺陷锚定注意力使每个缺陷类别独立地从区块特征中提取与其物理形态相关的局部表征,使得缺陷条件分布在跨线条件下保持近似一致,从而在不使用任何目标线路标签的条件下显著提升了跨线识别精度;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122990331A_ABST
    Figure CN122990331A_ABST
Patent Text Reader

Abstract

The application discloses a cross-line subway track defect classification method and system based on defect anchor attention, comprising image acquisition and data set construction, image block feature sequence extraction, defect anchor feature and attention weight construction, source domain training optimization, cross-line reasoning and visual output. The application realizes zero-shot track defect recognition across lines under the condition of only using source line labels, and suppresses the interference of background domain deviation through defect anchor attention, thereby improving the recognition accuracy and interpretability of the model on new lines.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent operation and maintenance technology for urban rail transit infrastructure, specifically to a method and system for classifying defects in cross-line subway tracks based on defect-anchored attention. Background Technology

[0002] The operational safety and efficiency of a subway system are highly dependent on the service condition of infrastructure such as tracks, fasteners, sleepers, and ballast. With the rapid growth of urban rail transit operating mileage in my country, relying on manual nighttime inspections is no longer sufficient to meet the needs of large-scale, high-frequency track inspections. Therefore, various operating units have successively deployed intelligent track inspection vehicles based on line-scanning cameras to continuously collect high-resolution images covering rails, fasteners, sleepers, and ballast. These images, combined with deep learning models, automatically identify defects such as missing fastener clips, protruding fish-tail bolts, rail corrugation, and ballast frost heave.

[0003] However, in practical engineering, deep learning models trained on a single railway line often experience a significant drop in recognition accuracy when deployed to newly opened lines or other lines built at different times. This is because different lines exhibit objective differences in fastener types, track structures, power supply methods, inspection vehicle geometry, operational years, and surrounding trackside environments, leading to systematic domain shifts in the acquired images regarding background texture, lighting distribution, and the context surrounding defect appearance. Retraining the model by collecting and labeling tens of thousands of images from scratch for each new line would be prohibitively costly and time-consuming, and obtaining a sufficient number of labeled defect samples is difficult in the initial stages of newly opened lines.

[0004] Common approaches to address domain shift in existing technologies are based on distribution alignment-based domain adaptation methods, such as adversarial domain adaptation, deep correlation alignment, and conditional adversarial domain adaptation. These methods typically apply distribution alignment loss to the source and target domains at the block level or global average features to make the edge distributions of the two domains in the shared feature space more consistent. However, in subway crossing scenarios, since the actual defect area only occupies a small portion of the image while the background area occupies the majority, the alignment of the edge distribution actually mainly affects the background statistics, which may perturb the actual defect conditional distribution. This results in no stable improvement over baseline methods without domain adaptation in crossing evaluation, and even performance degradation in some migration directions. Furthermore, existing image classification structures based on self-attention or global pooling apply uniform weights to all spatial locations when aggregating block features, making it impossible to explicitly distinguish between defect areas and background areas, and thus difficult to maintain stable discrimination performance under crossing conditions.

[0005] Therefore, there is an urgent need for a track defect classification method and system that can utilize the strong representational capabilities of large-scale visual basic models, explicitly focus on the real defect area under cross-line conditions, suppress background domain offset interference, and not rely on any target domain line labels. Summary of the Invention

[0006] The present invention aims to provide a method and system for classifying defects in cross-line subway tracks based on defect-anchored attention, in order to solve the above problems.

[0007] In a first aspect, the technical solution of the present invention is: a method for classifying defects in cross-line subway tracks based on defect-anchored attention, comprising the following steps:

[0008] S1, Image Acquisition and Dataset Construction: Using a line-scanning camera installed on a subway inspection train, continuous scanning is performed along the track direction at equal spatial intervals during train operation to acquire track structure images covering the rails, fasteners, sleepers, and ballast area; images from different subway lines are collected and classified into three groups according to physical degradation mechanisms: track connection type, rail surface type, and concrete type, to construct a cross-line track defect image dataset;

[0009] S2, Image block feature sequence extraction: For each image in the cross-track defect image dataset, feature extraction is performed using a visual basic model with frozen parameters to obtain a block feature sequence composed of several image block features.

[0010] S3, Defect Anchoring Feature and Attention Weight Construction: A learnable defect query vector is configured for each defect category, and a learnable mechanism embedding vector is configured for each degradation mechanism group. Each defect query vector is added to the mechanism embedding vector corresponding to its respective degradation mechanism group to obtain the mechanism-enhanced defect query vector. The mechanism-enhanced defect query vector is then subjected to multi-head cross-attention operation with the block feature sequence to obtain the defect anchoring feature and corresponding attention weight distribution for each defect category.

[0011] S4, Source Domain Training Optimization: Input the defect anchoring features into independent linear classification heads that correspond one-to-one with the defect categories to obtain the prediction score for each defect category; Using the labeled samples of the source domain lines, with cross-entropy loss as the main objective and the mean of the pairwise cosine similarity of the attention weight distribution between defect queries as the diversity regularization term, jointly train the defect query vector, mechanism embedding vector, and attention projection parameters.

[0012] S5, Cross-line reasoning and visualization output; For newly acquired track images of the target domain line, without using any target domain line labels, directly execute S2~S3 to obtain the defect category prediction results and corresponding attention heatmaps; restore the attention heatmaps to the original image resolution by block grid and overlay them for display as the basis for on-site maintenance decisions;

[0013] S1 constructs a dataset of cross-track defect images and groups the defect categories according to physical degradation mechanisms, providing a data foundation and prior knowledge of degradation mechanisms for subsequent steps. S2 uses a visual base model with frozen parameters to extract block feature sequences from each image on the dataset constructed in S1. S3 uses the degradation mechanism group information divided in S1 to enhance the defect query vector through mechanism embedding vectors based on the block feature sequences output in S2, and performs multi-head cross-attention with the block feature sequences to obtain defect anchoring features and attention weight distribution. S4 uses the labeled samples of the source domain line in S1 to jointly train and optimize the defect query vector, mechanism embedding vector, and attention projection parameters using cross-entropy loss and diversity regularization terms based on the defect anchoring features output in S3. S5 directly reuses the feature extraction process of S2 and the defect anchoring attention forward operation of S3 for newly acquired track images of the target domain line. In the inference stage, the loss function training of S4 is not involved, and only the model parameters after convergence of S4 training are used to output the defect category prediction results and corresponding attention heatmaps.

[0014] Preferably, S1 specifically includes:

[0015] The cross-track defect image dataset includes at least two metro lines with different fastener types, different track structures, and / or different years of operation; each line constitutes an independent domain;

[0016] Track connection issues include, but are not limited to, missing fastener clips, protruding fishtail bolts, missing gauge blocks, and extruded iron pads; rail surface issues include, but are not limited to, abnormal light bands, rail corrugation, and rail tread wear; concrete issues include, but are not limited to, sleeper chipping, track bed cracking, and track bed frost heave.

[0017] Each image is uniformly scaled to a preset size and normalized according to the mean and variance used in the pre-training of the visual base model.

[0018] Preferably, S2 specifically includes:

[0019] The visual base model is a visual Transformer obtained through large-scale self-supervised pre-training, and its parameters are kept frozen throughout the training process of this method.

[0020] The block feature sequence is formed by arranging all image block feature vectors output by the visual base model without taking into account the classification labels, according to their spatial position in the image. The number of blocks is a preset value, and the dimension of each block feature vector is equal to the output feature dimension of the visual base model.

[0021] Preferably, S3 specifically includes:

[0022] Each defect query vector is initialized using a Gaussian distribution with zero mean and small standard deviation;

[0023] The mechanism embedding vector and the defect query vector are superimposed element by element;

[0024] Before the multi-head cross-attention operation, layer normalization is applied to the mechanism-enhanced defect query vector and the block feature sequence respectively. In the multi-head cross-attention, the attention score is calculated by scaling dot product, and the scaling factor is the reciprocal of the square root of the feature dimension of each attention head. The multi-head output is concatenated along the feature dimension and mapped by a linear projection matrix. The mechanism-enhanced defect query vector is then added to the output of the linear projection matrix through residual connection to obtain the defect anchoring feature.

[0025] Preferably, after S2 and before S3, a block feature enhancement step is also included:

[0026] The block feature sequence output by S2 is passed through a lightweight enhancement module containing layer normalization and feedforward sub-layer, and the enhanced block feature sequence is obtained through residual connection.

[0027] The feedforward sublayer contains two linear projections that maintain the same dimension, a GELU nonlinear activation, and a random deactivation with a deactivation probability not exceeding 0.1. The input and output of the feedforward sublayer are added together through a residual connection.

[0028] In S3, the block feature sequence that performs cross-attention with the defect query vector is replaced with the enhanced block feature sequence.

[0029] Preferably, the diversity regularization term in S4 is constructed in the following ways:

[0030] For each defect query vector, the attention weights of each attention head in the multi-head cross attention are maintained in the block position dimension, and the attention weights of each head are averaged in the head dimension to obtain the attention weight vector of the defect query.

[0031] The cosine similarity of the attention weight vectors corresponding to all defect queries is calculated pairwise, and the arithmetic mean of all different pairwise combinations is taken to obtain the value of the diversity regularization term.

[0032] The total training loss is the cross-entropy loss plus a diversity regularization term weighted by a positive weight coefficient; the positive weight coefficient ranges from 0.001 to 0.1.

[0033] Preferably, S5 specifically includes:

[0034] The target domain lines differ from the source domain lines in terms of fastener type, track structure, and / or service life, and the method does not receive any labels or images of the target domain lines during the training process;

[0035] The attention heatmap is generated as follows: the attention weights of each attention head in the multi-head cross-attention are taken in the block position dimension, the average of each head is taken, and the block is restored to the original image resolution according to the spatial position of the block in the original image. Then, it is combined with the original image in a pseudo-color overlay method for display.

[0036] Secondly, the present invention provides a defect classification system for cross-line subway tracks based on defect anchoring attention, including:

[0037] The image acquisition and dataset construction module is used to drive the line scanning camera installed on the subway inspection train to acquire track structure images, and classify the defect categories into three groups according to the physical degradation mechanism: track connection type, rail surface type and concrete type, to construct a cross-line track defect image dataset.

[0038] The feature extraction module is used to extract features from each orbital image using a visual base model with frozen parameters, resulting in a block feature sequence composed of features from several image blocks.

[0039] The defect anchoring attention module is used to configure the defect query vector and mechanism embedding vector, add the mechanism embedding vector to the corresponding defect query vector element by element, and perform multi-head cross attention on the mechanism-enhanced defect query vector and the block feature sequence, and output the defect anchoring features and attention weight distribution corresponding to each defect category.

[0040] The training optimization module is used to jointly optimize the defect query vector, mechanism embedding vector, and attention projection parameters by taking labeled samples of source domain lines as training data, weighting and summing the cross-entropy loss and the pairwise cosine diversity regularization term of the defect query attention weight as the total loss;

[0041] The cross-line inference and visualization output module is used to perform feature extraction, defect anchoring attention calculation, and defect classification on newly acquired track images of the target domain line without using any target domain labels. It obtains defect category prediction results and restores the attention weights to the original image resolution, superimposing them into an attention heatmap for output to the maintenance personnel's review terminal.

[0042] Thirdly, the present invention provides a non-transitory computer-readable storage medium for storing computer instructions, which, when executed by a processor, implement a defect classification method for cross-line subway tracks based on defect anchoring attention.

[0043] Fourthly, the present invention provides an electronic device, comprising: a processor, a memory, and a computer program; wherein the processor is connected to the memory, the computer program is stored in the memory, and when the electronic device is running, the processor executes the computer program stored in the memory to cause the electronic device to execute instructions for implementing a defect classification method for cross-line subway tracks based on defect anchoring attention.

[0044] Fifthly, the present invention provides a computer program product, including a computer program that, when run on one or more processors, is used to implement a defect classification method for cross-line subway tracks based on defect anchoring attention.

[0045] The beneficial effects of this invention are as follows:

[0046] The core challenge of significantly declining model performance during source line training and cross-line deployment in actual engineering is to explicitly inject the physical degradation mechanism prior into the defect query and use defect anchoring attention to enable each defect category to independently extract local representations related to its physical morphology from block features, so that the defect condition distribution remains approximately consistent under cross-line conditions, thereby significantly improving the cross-line recognition accuracy without using any target line labels.

[0047] (2) Under the premise that the visual basic model is completely frozen, this invention only trains the defect query vector, mechanism embedding vector and a small number of attention projection parameters. The model has a small number of trainable parameters and low training cost, which makes it easy to deploy quickly in the early stage of opening a new line.

[0048] (3) By using a pairwise cosine diversity regularization term, this invention avoids the collapse of the attention distribution of different defect queries into similar patterns, so that each defect query can stably focus on the typical spatial position of its corresponding defect type, thereby ensuring the separability and stability of the identification results.

[0049] (4) During the reasoning stage, the present invention outputs the attention heat map corresponding to each defect category. The attention heat map is directly mapped to the spatial position of the original image according to the block grid. It can serve as an interpretable basis for on-site maintenance personnel to manually review the prediction results, and facilitates the integration of the automatic identification results into the existing manual inspection workflow.

[0050] (5) This invention does not require access to any target line images or tags during the training phase, thus avoiding dependence on target line data collection and transmission. It meets the data isolation requirements between multiple operators and is easier to implement in real engineering scenarios involving multiple lines and multiple operators. Attached Figure Description

[0051] Figure 1 This is a schematic diagram of the process for classifying cross-line subway track defects based on defect anchoring attention, provided in an embodiment of the present invention.

[0052] Figure 2 A schematic diagram of the overall architecture of the cross-line subway track defect classification system based on defect anchoring attention provided in an embodiment of the present invention;

[0053] Figure 3 This is a detailed structural diagram of the defect anchoring attention module provided in an embodiment of the present invention;

[0054] Figure 4 Example image of a cross-track defect image dataset provided in an embodiment of the present invention;

[0055] Figure 5 This invention provides a horizontal comparison of attention heatmaps among different methods provided in the embodiments of the invention, demonstrating the attention distribution of different methods in different diseases;

[0056] Figure 6 A bar chart comparing the recognition performance of the method provided in this embodiment of the invention with a control method in six cross-line migration directions. Detailed Implementation

[0057] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. The embodiments of the present invention are not limited thereto.

[0058] Example 1

[0059] like Figure 1 The figure shows a defect classification method for cross-line subway tracks based on defect anchoring attention. Referring to Figure 2, it includes the following steps:

[0060] S1. Use a line scan camera to collect images of multiple lines and group them according to physical degradation mechanism to construct a cross-line track defect image dataset;

[0061] S2. Use the visual basic model with frozen parameters to extract features from each image to obtain a block feature sequence;

[0062] S3. Configure the defect query vector and mechanism embedding vector, perform mechanism superposition and multi-head cross attention to obtain defect anchoring features;

[0063] S4. Using labeled samples from the source domain, jointly optimize the cross-entropy loss and diversity regularization term;

[0064] S5. Directly infer the newly acquired images of the target domain line and output the defect category prediction results and attention heatmap.

[0065] like Figure 2 The figure shows a defect classification system for cross-line subway tracks based on defect anchoring attention, including:

[0066] (1) Image acquisition and dataset construction module, which is used to drive the line scanning camera installed on the subway inspection train to acquire track structure images, label each image according to the preset defect category, and divide the defect category into three groups according to the physical degradation mechanism: track connection type, rail surface type and concrete type, and construct cross-line track defect image dataset;

[0067] (2) Feature extraction module, used to extract features from each image using a visual basic model with frozen parameters, and output block feature sequence;

[0068] (3) Defect anchoring attention module, used to configure learnable defect query vectors and mechanism embedding vectors, perform mechanism embedding superposition and multi-head cross attention, and output defect anchoring features and attention weight distribution corresponding to each defect category;

[0069] (4) Training optimization module, used to jointly train the defect query vector, mechanism embedding vector and attention projection parameters with labeled samples of source domain lines, the loss function is the weighted sum of cross-entropy loss and diversity regularization term;

[0070] (5) Cross-line reasoning and visualization output module, used to perform the feature extraction and defect anchoring attention on the newly acquired images of the target domain line without using any target domain labels, to obtain the defect category prediction results and corresponding attention heatmaps, and output them to the maintenance personnel's review terminal.

[0071] Example 2

[0072] Referring to Figures 1 and 3, this Embodiment 2 provides a more detailed implementation method based on Embodiment 1:

[0073] Figure 3 The module includes (a) a block feature enhancement submodule, (b) a mechanism embedding and multi-head cross-attention submodule, and (c) a residual connection and independent classification head submodule.

[0074] Figure 4 The document includes (a) a diagram of the line scanning camera detection equipment and data collection for the three subway lines, and (b) a visual comparison of ten shared defect categories on the three lines.

[0075] S1. Three operating lines L1, L2, and L3 from a large domestic subway network were selected as data sources. The three lines use different types of fasteners, different track structures, and different geometric parameters of the inspection vehicles, and their operating years differ significantly. All three lines are equipped with intelligent inspection vehicles based on line scanning cameras, which continuously scan along the track direction at equal spatial intervals, outputting complete track structure images covering the left and right rails, fasteners, sleepers, and track bed (see Figure 4(a)).

[0076] From the original approximately 200,000 images, ten shared defect categories were selected that were present in all three lines (see reference). Figure 4 (b) and categorized according to physical degradation mechanisms: track connection type (missing elastic clips, protruding fishtail bolts, missing gauge blocks, extrusion of iron pads), rail surface type (abnormal light bands, rail corrugation, rail tread wear), and concrete type (sleeper spalling, ballast cracking, ballast heave). 10,000 images were retained for each line, with the mechanism group sample budgets being 4,000 / 3,500 / 2,500 respectively. Each image was uniformly scaled to 224×224 and normalized according to the mean and variance used in the pre-training of the visual basic model.

[0077] S2. The visual base model employs a self-supervised pre-trained visual Transformer (such as DINOv2ViT-B / 14), and its parameters remain frozen throughout the training process in this embodiment. For each pre-processed image... Extract the block feature sequence according to formula (1) ,in (Corresponding to a 16×16 block grid). .

[0078] S3, Defect Anchoring Features and Attention Weight Construction;

[0079] (1) Block feature enhancement: According to formula (2) Block feature enhancement is applied, the intermediate dimension of the feedforward sub-layer is equal to the input dimension, the activation function is GELU, and the random deactivation probability is 0.1, resulting in the enhanced block feature sequence.

[0080] (2) Query and Mechanism Embedding: Configuration A learnable defect query vector With 3 learnable mechanism embedding vectors All according to Initialization. The mechanism is embedded into the corresponding defect query according to formula (3) to obtain the mechanism-enhanced query vector. .

[0081] (3) Multi-headed cross-attention: for and Apply layer normalization separately, and then execute according to formulas (4) to (5). Scaling dot product cross attention for each head, feature dimension per head The defect anchoring feature is obtained by residual connection according to formula (6). .

[0082] S4, Source Domain Training Optimization;

[0083] (1) Independent classification head: According to formula (7), for each defect category Configure independent linear head Output a 10-dimensional score vector.

[0084] (2) Joint training: Calculate the cross-entropy loss on the source domain 5-fold cross-validation training set according to formula (8). Calculate the diversity regularization term according to formulas (9) to (10). The total loss is obtained by weighted summation according to formula (11). ,in The AdamW optimizer was used, with an initial learning rate of... Weight decay Batch size 64, gradient clipping norm 1.0, cosine annealing to zero, maximum training 150 epochs, validation loss early stopping patience=20, random seed 42.

[0085] (3) During the training process, the visual base model All parameters are frozen, and only training is performed. , The total number of trainable parameters is approximately 3.6M, including attention projection matrices, output projection matrices, PFE module parameters, and independent classifiers for each category.

[0086] S5. For newly acquired images of the target domain lines, without using any target domain labels, directly execute S2~S3 to obtain 10-dimensional scores; according to formula (12), take the category corresponding to the maximum score as the defect category prediction result; at the same time, take the attention weight corresponding to the category. The image is restored to the original resolution (e.g., 224×224) using a 16×16 block raster and output with pseudo-color overlay. As shown in Figure 5, the high-attention response area of ​​the method of the present invention is more stably anchored to the real defect morphology compared to the control method.

[0087] Performance Verification: Referring to Figure 6, in the six cross-line migration directions L1↔L2, L1↔L3, and L2↔L3, the method in this embodiment achieves a macro F1 score improvement of 9.3–15.3 percentage points, a weighted F1 score improvement of 5.2–14.7 percentage points, and a macro AUROC score improvement of 1.3–5.3 percentage points compared to baseline methods without domain adaptation (PatchMLP / PatchCNN / PatchTF). Simultaneously, it also achieves a stable improvement compared to distribution-aligned domain adaptation methods (DANN-patch / CORAL-patch / CDAN-patch). The online inference latency increases by only 0.7 ms (less than 3%) compared to the simplest mean pooling baseline, meeting the requirements for real-time inspection.

[0088] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A defect classification method for cross-line subway tracks based on defect-anchored attention, characterized in that, Includes the following steps: S1, Image Acquisition and Dataset Construction; Using line-scanning cameras installed on metro inspection trains, the train continuously scans along the track direction at equal spatial intervals during operation, collecting track structure images covering the rails, fasteners, sleepers, and ballast area. Images from different metro lines are collected and classified into three groups according to physical degradation mechanisms: track connection type, rail surface type, and concrete type, to construct a cross-line track defect image dataset. S2, Image block feature sequence extraction; For each image in the cross-track defect image dataset, feature extraction is performed using a visual base model with frozen parameters to obtain a block feature sequence composed of features from several image blocks. S3, Defect Anchoring Feature and Attention Weight Construction: A learnable defect query vector is configured for each defect category, and a learnable mechanism embedding vector is configured for each degradation mechanism group. Each defect query vector is added to the mechanism embedding vector corresponding to its respective degradation mechanism group to obtain the mechanism-enhanced defect query vector. The mechanism-enhanced defect query vector is then subjected to multi-head cross-attention operation with the block feature sequence to obtain the defect anchoring feature and corresponding attention weight distribution for each defect category. S4, source domain training optimization; The defect anchoring features are input into independent linear classification heads that correspond one-to-one with the defect categories to obtain the prediction score for each defect category. Using the labeled samples of the source domain lines, with cross-entropy loss as the main objective and the mean of the pairwise cosine similarity of the attention weight distribution between defect queries as the diversity regularization term, the defect query vector, mechanism embedding vector and attention projection parameters are jointly trained. S5, Cross-line reasoning and visualization output; For newly acquired track images of the target domain line, without using any target domain line labels, directly execute S2~S3 to obtain the defect category prediction results and corresponding attention heatmaps; restore the attention heatmaps to the original image resolution by block grid and overlay them for display as the basis for on-site maintenance decisions; S1 constructs a dataset of cross-track defect images and groups the defect categories according to physical degradation mechanisms, providing a data foundation and prior knowledge of degradation mechanisms for subsequent steps. S2 uses a visual base model with frozen parameters to extract block feature sequences from each image on the dataset constructed in S1. S3 uses the degradation mechanism group information divided in S1 to enhance the defect query vector through mechanism embedding vectors based on the block feature sequences output in S2, and performs multi-head cross-attention with the block feature sequences to obtain defect anchoring features and attention weight distribution. S4 uses the labeled samples of the source domain line in S1 to jointly train and optimize the defect query vector, mechanism embedding vector, and attention projection parameters using cross-entropy loss and diversity regularization terms based on the defect anchoring features output in S3. S5 directly reuses the feature extraction process of S2 and the defect anchoring attention forward operation of S3 for newly acquired track images of the target domain line. In the inference stage, the loss function training of S4 is not involved, and only the model parameters after convergence of S4 training are used to output the defect category prediction results and corresponding attention heatmaps.

2. The method for classifying defects in cross-line subway tracks based on defect-anchored attention as described in claim 1, characterized in that, S1 specifically includes: The cross-track defect image dataset includes at least two metro lines with different fastener types, different track structures, and / or different years of operation; each line constitutes an independent domain; Track connection issues include, but are not limited to, missing fastener clips, protruding fishtail bolts, missing gauge blocks, and extruded iron pads; rail surface issues include, but are not limited to, abnormal light bands, rail corrugation, and rail tread wear; concrete issues include, but are not limited to, sleeper chipping, track bed cracking, and track bed frost heave. Each image is uniformly scaled to a preset size and normalized according to the mean and variance used in the pre-training of the visual base model.

3. The method for classifying cross-line subway track defects based on defect anchoring attention as described in claim 1, characterized in that, S2 specifically includes: The visual base model is a visual Transformer obtained through large-scale self-supervised pre-training, and its parameters are kept frozen throughout the training process of this method. The block feature sequence is formed by arranging all image block feature vectors output by the visual base model without taking into account the classification labels, according to their spatial position in the image. The number of blocks is a preset value, and the dimension of each block feature vector is equal to the output feature dimension of the visual base model.

4. The method for classifying cross-line subway track defects based on defect-anchored attention as described in claim 1, characterized in that, S3 specifically includes: Each defect query vector is initialized using a Gaussian distribution with zero mean and small standard deviation; The mechanism embedding vector and the defect query vector are superimposed element by element; Before the multi-head cross-attention operation, layer normalization is applied to the mechanism-enhanced defect query vector and the block feature sequence respectively. In the multi-head cross-attention, the attention score is calculated by scaling dot product, and the scaling factor is the reciprocal of the square root of the feature dimension of each attention head. The multi-head output is concatenated along the feature dimension and mapped by a linear projection matrix. The mechanism-enhanced defect query vector is then added to the output of the linear projection matrix through residual connection to obtain the defect anchoring feature.

5. The method for classifying cross-line subway track defects based on defect anchoring attention as described in claim 1, characterized in that, The process, following S2 and preceding S3, also includes a block feature enhancement step: The block feature sequence output by S2 is passed through a lightweight enhancement module containing layer normalization and feedforward sub-layer, and the enhanced block feature sequence is obtained through residual connection. The feedforward sublayer contains two linear projections that maintain the same dimension, a GELU nonlinear activation, and a random deactivation with a deactivation probability not exceeding 0.

1. The input and output of the feedforward sublayer are added together through a residual connection. In S3, the block feature sequence that performs cross-attention with the defect query vector is replaced with the enhanced block feature sequence.

6. The method for classifying defects in cross-line subway tracks based on defect anchoring attention as described in claim 1, characterized in that, The methods for constructing diversity regularization terms in S4 include: For each defect query vector, the attention weights of each attention head in the multi-head cross attention are maintained in the block position dimension, and the attention weights of each head are averaged in the head dimension to obtain the attention weight vector of the defect query. The cosine similarity of the attention weight vectors corresponding to all defect queries is calculated pairwise, and the arithmetic mean of all different pairwise combinations is taken to obtain the value of the diversity regularization term. The total training loss is the cross-entropy loss plus a diversity regularization term weighted by a positive weight coefficient; the positive weight coefficient ranges from 0.001 to 0.

1.

7. The method for classifying cross-line subway track defects based on defect anchoring attention as described in claim 1, characterized in that, S5 specifically includes: The target domain lines differ from the source domain lines in terms of fastener type, track structure, and / or service life, and the method does not receive any labels or images of the target domain lines during the training process; The attention heatmap is generated as follows: the attention weights of each attention head in the multi-head cross-attention are taken in the block position dimension, the average of each head is taken, and the block is restored to the original image resolution according to the spatial position of the block in the original image. Then, it is combined with the original image in a pseudo-color overlay method for display.

8. A defect classification system for cross-line subway tracks based on defect-anchored attention, characterized in that, include: The image acquisition and dataset construction module is used to drive the line scanning camera installed on the subway inspection train to acquire track structure images, and classify the defect categories into three groups according to the physical degradation mechanism: track connection type, rail surface type and concrete type, to construct a cross-line track defect image dataset. The feature extraction module is used to extract features from each orbital image using a visual base model with frozen parameters, resulting in a block feature sequence composed of features from several image blocks. The defect anchoring attention module is used to configure the defect query vector and mechanism embedding vector, add the mechanism embedding vector to the corresponding defect query vector element by element, and perform multi-head cross attention on the mechanism-enhanced defect query vector and the block feature sequence, and output the defect anchoring features and attention weight distribution corresponding to each defect category. The training optimization module is used to jointly optimize the defect query vector, mechanism embedding vector, and attention projection parameters by taking labeled samples of source domain lines as training data, weighting and summing the cross-entropy loss and the pairwise cosine diversity regularization term of the defect query attention weight as the total loss; The cross-line reasoning and visualization output module is used to perform feature extraction, defect anchoring attention operation and defect classification on newly acquired track images of the target domain line without using any target domain labels, to obtain defect category prediction results, and restore the attention weights to the original image resolution to superimpose them into an attention heatmap for output to the maintenance personnel's review terminal.

9. A non-transitory computer-readable storage medium, characterized in that, A non-transitory computer-readable storage medium is used to store computer instructions that, when executed by a processor, implement the defect classification method for cross-line metro tracks based on defect anchoring attention as described in any one of claims 1 to 7.

10. An electronic device, characterized in that, include: The device includes a processor, a memory, and a computer program; wherein the processor is connected to the memory, the computer program is stored in the memory, and when the electronic device is running, the processor executes the computer program stored in the memory to cause the electronic device to execute instructions to implement the defect classification method for cross-line subway tracks based on defect anchoring attention as described in any one of claims 1 to 7.

11. A computer program product, characterized in that, Includes a computer program, which, when running on one or more processors, implements the defect classification method for cross-line metro tracks based on defect anchoring attention as described in any one of claims 1 to 7.