An unsupervised domain adaptation railway intrusion target detection model training method and system
By constructing a teacher-student detection model and combining it with discriminators in real and virtual feature spaces for domain adversarial training, and by using a local instance consistency processing unit to enhance cross-domain feature consistency of the same category, the problem of scene-level appearance deviation in cross-domain detection models in railway scenarios is solved, thereby improving the robustness and accuracy of the detection model.
Patent Information
- Application Number
- CN202611213411.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-11
- Publication Date
- 2026-11-06
AI Technical Summary
Existing technologies in railway scenarios exhibit significant performance degradation in cross-domain detection models across different lines, time periods, and weather conditions, making it difficult to effectively address scenario-level appearance deviations. In particular, detection accuracy decreases markedly under extreme scenarios such as fog, nighttime, rain, and snow.
An unsupervised domain-adaptive railway intrusion target detection model training method is adopted. By constructing a teacher-student detection model, domain adversarial training is carried out by combining a real feature space discriminator and a virtual feature space discriminator. The local instance consistency processing unit is used to enhance the cross-domain feature consistency of the same category, and a two-step cyclic consistency constraint is used to construct a bidirectional mapping closed loop to suppress scene-level appearance bias and retain structural semantic information.
Under the condition of no target domain annotation, the robustness of cross-domain railway intrusion target detection is significantly improved, the false detection and false detection rates are reduced, and the detection accuracy of the model is enhanced in different scenarios.
Smart Images

Figure CN123052309A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of railway safety detection technology, and in particular to a training method and system for an unsupervised domain-adaptive railway intrusion target detection model. Background Technology
[0002] With the rapid development of high-speed railways and urban rail transit in my country, the characteristics of high train operating speed, high scheduling density and strict safety redundancy requirements are becoming increasingly prominent. Once pedestrians, falling rocks, left-behind objects, intruding vehicles or other foreign objects appear in the track area and surrounding environment, it is very easy to cause major safety accidents such as train emergency stops and derailments.
[0003] Object detection is the core component of foreign object detection in computer vision. However, in actual railway deployment scenarios, the image features differ significantly across different lines, time periods, and weather conditions. The cost of re-collecting and labeling sufficient samples for each new deployment scenario is extremely high, resulting in severe performance degradation and insufficient generalization ability of the trained model when applied across different scenarios.
[0004] Therefore, Unsupervised Domain Adaptation (UDA) object detection technology has emerged. This type of technology only requires training with labeled source domain data and unlabeled target domain data to improve the model's adaptability in the target domain. Among them, the DATR algorithm for DETR series detectors is the current mainstream cross-domain object detection scheme. Its core idea is to extract image features and target query features through the Transformer detector, and reduce the differences between the source domain and the target domain from the overall distribution level of the dataset and the category prototype feature level, respectively: dataset-level alignment is used to alleviate the distribution differences between the two domains in terms of overall image style, background, weather, lighting, etc.; prototype alignment aggregates target features of the same category into category prototypes, promoting the convergence of prototypes of the same category in the source domain and the target domain, so as to enhance cross-domain category consistency.
[0005] Although the DATR algorithm improves cross-domain detection performance to some extent, it still has limitations: DATR only performs global alignment between the source and target domains in the original real image feature space. However, railway scenes contain a lot of domain-specific appearance information brought about by weather changes, lighting fluctuations, and differences in background structures (such as ballast, sleepers, and protective nets). This information is mixed in with the real image features, causing the global alignment process to incorporate irrelevant scene appearance differences into the learning process. It is difficult to effectively separate transferable structural semantic information and cannot solve the problem of scene-level appearance deviation. The detection accuracy drops significantly in extreme scenes such as fog, night, rain, and snow. Summary of the Invention
[0006] Therefore, it is necessary to provide an unsupervised domain-adaptive training method and system for railway intrusion target detection models to address the aforementioned technical problems. This invention can simultaneously suppress scene-level appearance bias and reduce noise under conditions without target domain annotation, while fully utilizing cross-domain shared structural semantic information to improve the robustness of cross-domain railway intrusion target detection.
[0007] The following technical solution is adopted in this specification: This specification provides a method for training an unsupervised, domain-adaptive railway intrusion target detection model, specifically including: Obtain the source domain image with category labeling information, and the target domain image without labeling information.
[0008] A teacher-student detection model is constructed, comprising a student detection branch and a teacher detection branch updated by exponential moving average. The student detection branch includes a Transformer-based detector backbone network and encoder, a local instance consistency processing unit connected in series at the decoder output, and a real feature space discriminator and a virtual feature space discriminator connected in parallel at the encoder output. The local instance consistency processing unit includes a prototype aggregation layer, a one-way feature matching layer, and a two-way mapping reconstruction layer.
[0009] The source domain image and the target domain image are used as input, and the category labeling information is used as training labels. The teacher-student detection model is iteratively trained until convergence to obtain the trained teacher-student detection model.
[0010] During the iterative training process, the student detection branch extracts encoded features from the source and target domain images through a backbone network and encoder, and outputs target query features through a decoder. These encoded features are then input into the real feature space discriminator for first-domain adversarial training. Simultaneously, the encoded features are mapped to a virtual latent space and input into the virtual feature space discriminator for second-domain adversarial training. Based on the results of the first and second domain adversarial training, global alignment constraints are constructed. The target query features are then input into a local instance consistency processing unit. A prototype aggregation layer obtains source and target domain category prototypes, and a one-way feature matching layer and a two-way mapping reconstruction layer execute single-step contrastive adversarial training and two-step cyclic consistency constraints to construct local alignment constraints. The parameters of the student detection branch are updated based on the detection loss, global alignment constraints, and local alignment constraints, and the parameters of the teacher detection branch are updated using an exponential moving average.
[0011] Furthermore, the target domain image includes at least domain-specific appearance features caused by changes in weather, lighting, or background structure; the category labeling information includes the foreign object category and the corresponding bounding box position; the foreign object category includes at least pedestrians, falling rocks, and vehicles.
[0012] Furthermore, the Transformer-based detector backbone network is a pre-trained DINO detector backbone network; the decoder adopts a hybrid query selection mechanism, which selects candidate positions from the encoder output and initializes the decoder input query by combining image content and spatial location information; the backbone network adopts ResNet or Swing Transformer.
[0013] Furthermore, the method for mapping encoded features to a virtual latent space specifically includes: Calculate the domain-invariant mean and domain-invariant standard deviation of the encoded features; for the predicted domain-invariant mean and domain-invariant standard deviation, perform a reparameterization operation to obtain virtual latent features. ; ; in, Let Gaussian random variable represent noise. For element-wise multiplication, It follows a normal distribution. It is an identity matrix.
[0014] Furthermore, the single-step comparative adversarial approach specifically refers to: A category-aware contrastive loss is constructed by using source domain category prototypes, target domain category prototypes, and global semantic anchors of the same category as positive sample pairs and different category prototypes as negative sample pairs, thereby enhancing the consistency of cross-domain instance features of the same category.
[0015] A prototype-level domain discriminator is introduced to perform domain adversarial training on the source domain category prototype and the target domain category prototype. This reduces the domain differences between the source and target domain category prototypes while maintaining class discriminability, thereby reducing false matching between small railway targets and ballast, sleepers, and shadow backgrounds.
[0016] Furthermore, the two-step cyclic consistency constraint specifically refers to: A first mapping network from the source domain to the target domain and a second mapping network from the target domain to the source domain are constructed. Based on the effective category set consisting of the same category with category prototypes in both the source and target domains, semantic consistency loss and cyclic reconstruction consistency loss are calculated. The semantic consistency loss constrains the mapped category prototype to be consistent with the opposite category prototype in the semantic space, and the cyclic reconstruction consistency loss constrains the reconstructed category prototype to be consistent with the original category prototype, so as to verify the reliability of the matching between the source and target domain instances and alleviate the accumulation of pseudo-label errors.
[0017] Furthermore, the global alignment constraint is obtained by weighted summation of the real spatial domain adversarial loss and the virtual spatial domain adversarial loss; the local alignment constraint is obtained by weighted summation of the single-step consistency loss and the two-step cyclic consistency loss.
[0018] This specification provides an unsupervised domain-adaptive railway intrusion target detection model training system, specifically including: The image acquisition module is used to acquire source domain images with category labeling information and target domain images without labeling information.
[0019] The model building module is used to build a teacher-student detection model. The teacher-student detection model includes a student detection branch and a teacher detection branch updated by exponential moving average. The student detection branch includes a Transformer-based detector backbone network and encoder, a local instance consistency processing unit connected in series on the decoder output side, and a real feature space discriminator and a virtual feature space discriminator connected in parallel on the encoder output side. The local instance consistency processing unit includes a prototype aggregation layer, a one-way feature matching layer, and a two-way mapping reconstruction layer.
[0020] The model training module is used to take the source domain image and the target domain image as input, use the category labeling information as training labels, and iteratively train the teacher-student detection model until convergence to obtain the trained teacher-student detection model.
[0021] This specification provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described above.
[0022] This specification provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described above.
[0023] The beneficial effects of this invention are as follows: Compared with the prior art, this invention sets up a real feature space discriminator and a virtual feature space discriminator in parallel on the encoder output side, and inputs the encoded features into both to perform first domain adversarial training and second domain adversarial training respectively. The introduction of the virtual latent space can separate domain-specific appearance information caused by weather, lighting, and background structure changes from the feature representation, thereby suppressing scene-level appearance bias while fully preserving cross-domain shared structural semantic information. By inputting the target query features into a local instance consistency processing unit containing a prototype aggregation layer, a unidirectional feature matching layer, and a bidirectional mapping reconstruction layer, the invention utilizes the original... The aggregation layer obtains the source and target domain category prototypes. Combined with the single-step contrast adversarial execution of the unidirectional feature matching layer, it can enhance the consistency of cross-domain instance features of the same category and reduce erroneous matching between small railway targets and ballast, sleepers, and shadow backgrounds. The two-step cyclic consistency constraint constructs a bidirectional mapping closed loop from the source domain to the target domain and from the target domain to the source domain. It can verify the reliability of instance matching on the effective category set and significantly reduce false detections and false misses caused by pseudo-label noise. Thus, without the need for target domain annotation, it achieves deep coupling of global scene alignment and local instance alignment, greatly improving the robustness of cross-domain railway intrusion target detection. Attached Figure Description
[0024] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings:
[0025] Figure 1 This is an overall flowchart of the present invention; Figure 2 This is an architecture diagram of a real-virtual hybrid global feature consistency scheme according to an embodiment of the present invention. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of this specification clearer, the technical solutions of the present invention will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments in this specification without creative effort are within the scope of protection of this invention.
[0027] This invention provides an unsupervised, domain-adaptive training method for a railway intrusion target detection model, comprising three steps: image acquisition, teacher-student detection model construction, and teacher-student detection model training. By paralleling real and virtual feature space discriminators after the encoder, domain adversarial training is conducted separately. Virtual latent space is used to separate domain-specific appearance information such as weather and lighting, suppressing scene-level bias while preserving cross-domain structural semantics. A local instance consistency processing unit utilizes a prototype aggregation layer to obtain source and target domain category prototypes. Combined with a one-step contrast adversarial process in a unidirectional feature matching layer, cross-domain feature consistency within the same category is strengthened, reducing mismatches between small targets and background elements such as ballast and sleepers. A two-step cyclic consistency constraint is used to construct a bidirectional mapping closed loop, verifying matching reliability on the effective category set, significantly reducing false positives and false negatives caused by pseudo-label noise. Finally, deep coupling of global and local alignment is achieved without target domain annotation, greatly improving the robustness of cross-domain railway foreign object detection.
[0028] The technical solutions provided by the various embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0029] A training method for an unsupervised, domain-adaptive railway intrusion target detection model, the overall process of which is as follows: Figure 1 As shown, it specifically includes: Step 1: Obtain the source domain image with category labeling information and the target domain image without labeling information.
[0030] Furthermore, the target domain image includes at least domain-specific appearance features caused by changes in weather, lighting, or background structure; the category labeling information includes the foreign object category and the corresponding bounding box location; the foreign object category includes at least pedestrians, falling rocks, and vehicles.
[0031] Step 2: Construct a teacher-student detection model. The teacher-student detection model includes a student detection branch and a teacher detection branch updated by exponential moving average. The student detection branch includes a Transformer-based detector backbone network and encoder, a local instance consistency processing unit connected in series on the decoder output side, and a real feature space discriminator and a virtual feature space discriminator connected in parallel on the encoder output side. The local instance consistency processing unit includes a prototype aggregation layer, a one-way feature matching layer, and a two-way mapping reconstruction layer.
[0032] Optionally, the Transformer-based detector backbone network is a pre-trained DINO detector backbone network; the decoder adopts a hybrid query selection mechanism, which selects candidate positions from the encoder output and combines image content and spatial location information to initialize the decoder input query; the backbone network adopts ResNet or Swing Transformer.
[0033] Step 3: Take the source and target domain images as input, use the category labeling information as training labels, and iteratively train the teacher-student detection model until convergence to obtain the trained teacher-student detection model.
[0034] During iterative training, the student detection branch extracts encoded features from the source and target domain images through a backbone network and encoder. These encoded features are then decoded by a decoder to obtain the target query features. The encoded features are input into the real feature space discriminator for first-domain adversarial training, and simultaneously mapped to a virtual latent space and input into the virtual feature space discriminator for second-domain adversarial training. Global alignment constraints are constructed based on the results of the first and second domain adversarial training. The target query features are input into a local instance consistency processing unit, and the prototype aggregation layer obtains the source and target domain category prototypes. A one-way feature matching layer and a two-way mapping reconstruction layer are used to execute single-step contrastive adversarial training and two-step cyclic consistency constraints, respectively, and local alignment constraints are constructed based on the execution results. The parameters of the student detection branch are updated based on the detection loss, global alignment constraints, and local alignment constraints, and the parameters of the teacher detection branch are updated using an exponential moving average.
[0035] Specifically, methods for mapping encoded features to a virtual latent space include: Calculate the domain-invariant mean and domain-invariant standard deviation of the encoded features; for the predicted domain-invariant mean and domain-invariant standard deviation, perform a reparameterization operation to obtain virtual latent features. ; ; in, Let Gaussian random variable represent noise. For element-wise multiplication, It follows a normal distribution. It is an identity matrix.
[0036] Specifically, the single-step contrastive adversarial method is as follows: using source domain category prototypes, target domain category prototypes and global semantic anchors of the same category as positive sample pairs, and using prototypes of different categories as negative sample pairs to construct a category-aware contrastive loss, thereby enhancing the consistency of cross-domain instance features of the same category.
[0037] A prototype-level domain discriminator is introduced to perform domain adversarial training on the source domain category prototype and the target domain category prototype. This reduces the domain differences between the source and target domain category prototypes while maintaining class discriminability, thereby reducing false matching between small railway targets and ballast, sleepers, and shadow backgrounds.
[0038] Specifically, the two-step cyclic consistency constraint is as follows: construct a first mapping network from the source domain to the target domain and a second mapping network from the target domain to the source domain; calculate the semantic consistency loss and the cyclic reconstruction consistency loss based on the effective category set consisting of the same category with category prototypes in both the source and target domains; the semantic consistency loss constrains the mapped category prototypes to be consistent with the opposite category prototypes in the semantic space, and the cyclic reconstruction consistency loss constrains the reconstructed category prototypes to be consistent with the original category prototypes, so as to verify the reliability of the matching between the source and target domain instances and alleviate the accumulation of pseudo-label errors.
[0039] Preferably, the global alignment constraint is obtained by weighted summation of the adversarial loss in the real spatial domain and the adversarial loss in the virtual spatial domain; the local alignment constraint is obtained by weighted summation of the single-step consistency loss and the two-step cyclic consistency loss.
[0040] Example To address the unique cross-domain error problem in railway scenarios, this embodiment constructs a teacher-student detection model consisting of a student branch detector and a teacher branch updated via EMA.
[0041] The student branch incorporates two complementary components: a Real-Virtual Hybrid Global Feature Consistency (RVGFC) scheme to suppress scene-level appearance biases, and a Local Instance Consistency (LIC) scheme to reduce instance-level correspondence noise. The teacher branch provides pseudo-labels for unlabeled target domain images, enabling supervised training of target domain samples. The training process consists of two phases. In the pre-training phase, the student branch optimizes using labeled source domain data and unlabeled target domain data under consistency regularization constraints. In the fine-tuning phase, the teacher branch generates progressively refined pseudo-labels and uses these pseudo-labels to further supervise the student branch's training on target domain samples.
[0042] like Figure 2 As shown, the real-virtual hybrid global feature consistency scheme includes a real feature space consistency constraint part and a virtual feature space consistency constraint part; wherein, the real feature space consistency constraint part is used to globally align the source domain and the target domain in the original image feature space, and its calculation formula is: ; ; in, Represents real image features, Represents a true feature spatial domain discriminator. Indicate the domain discrimination output, Representation domain predicts probability, This represents the Sigmoid function. Let N represent the domain label of the nth sample, and N represent the number of domain prediction units.
[0043] The virtual feature space consistency constraint is used to map backbone network features to a parameterized virtual feature space to suppress domain-specific appearance information and preserve cross-domain structural semantic information. Its calculation formula is as follows: ; ; ; in, Represents virtual latent features, and These represent the domain-invariant mean and standard deviation predicted by the virtual feature generator, respectively. Represents a Gaussian random variable. This indicates element-wise multiplication. This represents a virtual feature space domain discriminator. Indicates the source domain or the target domain.
[0044] Finally, the overall loss function of the real-virtual hybrid global feature consistency scheme is: ; in, and These represent the weight coefficients for the consistency loss in the real feature space and the consistency loss in the virtual feature space, respectively. This module reduces scene-level appearance deviations caused by different weather conditions, lighting, and background structures by simultaneously constraining both the real and virtual feature spaces.
[0045] The local instance consistency scheme includes a single-step consistency constraint and a two-step cyclic consistency constraint.
[0046] For the single-step consistency constraint, the target query features output by the detection decoder are first aggregated at the instance level according to the predicted category, resulting in the source domain category prototype and the target domain category prototype. For category c, its source domain category prototype, target domain category prototype, and global category prototype are denoted as follows: and ,in This represents the feature center of the category instance of the source domain samples in the current batch. This represents the feature center of the category instance of the target domain sample in the current batch. This represents the global semantic anchor point accumulated from prototypes of the same category during historical iterations. Using source domain prototypes, target domain prototypes, and global prototypes of the same category as positive sample pairs, and prototypes of different categories as negative sample pairs, a category-aware contrastive consistency constraint is constructed, and its contrastive loss is expressed as:
[0047] ; Where c represents the set of categories, and (|c|) represents the number of categories. This represents cosine similarity. The above loss is used to enhance the consistency of cross-domain instance features within the same category and to widen the gap between instance features from different categories.
[0048] Simultaneously, a prototype-level domain discriminator is introduced. It is used to determine whether the input prototype comes from the source domain or the target domain, and its domain adversarial loss is expressed as: ; in, This represents the probability that the prototype of the source domain category is identified as the source domain. This represents the probability that the target domain category prototype is classified as the source domain. Through adversarial training, the source and target domain category prototypes are made to weaken domain differences while maintaining class discriminative power. Therefore, the overall loss for the single-step consistency constraint is expressed as:
[0049] ; For two-step cyclic consistency constraints, a mapping network from the source domain to the target domain is further constructed based on single-step direct alignment. and the mapping network from the target domain to the source domain ,in B represents the prototype space of the source domain instance, and B represents the prototype space of the target domain instance.
[0050] First, map the source domain category prototypes to the target domain feature space, and then map the target domain category prototypes to the source domain feature space, resulting in: ; ; in, This represents the target domain space obtained by mapping the source domain category prototype. This represents the source domain space obtained by mapping the target domain category prototype.
[0051] Subsequently, the mapped prototype is restored to the original domain through reverse mapping, forming a closed-loop mapping process of "source domain—target domain—source domain" and "target domain—source domain—target domain". The cyclic reconstruction prototype is represented as follows: ; ; in, This represents the cyclic reconstruction result of the source domain category prototype after bidirectional mapping. This represents the cyclic reconstruction result of the target domain category prototype after bidirectional mapping.
[0052] Furthermore, a semantic consistency loss is constructed to ensure that the mapped category prototype remains consistent with the counterpart of the same category prototype in the semantic space: ; Furthermore, a cyclic reconstruction consistency loss is constructed to ensure that the class prototype after cyclic reconstruction remains consistent with the original class prototype: ; in, This represents the L2 norm distance.
[0053] Based on an effective set of source-target domain category prototype pairs The overall loss of the two-step cycle consistency constraint is expressed as: ; Finally, the overall loss of the local instance consistency module is expressed as: ; in, and These are the weight coefficients for single-step consistency constraints and two-step cyclic consistency constraints, respectively.
[0054] This specification provides an unsupervised domain-adaptive training system for a railway intrusion target detection model, including: The image acquisition module is used to acquire source domain images with category labeling information and target domain images without labeling information.
[0055] The model building module is used to build a teacher-student detection model. The teacher-student detection model includes a student detection branch and a teacher detection branch updated by exponential moving average. The student detection branch includes a Transformer-based detector backbone network and encoder, a local instance consistency processing unit connected in series on the decoder output side, and a real feature space discriminator and a virtual feature space discriminator connected in parallel on the encoder output side. The local instance consistency processing unit includes a prototype aggregation layer, a one-way feature matching layer, and a two-way mapping reconstruction layer.
[0056] The model training module takes source and target domain images as input, uses category labeling information as training labels, and iteratively trains the teacher-student detection model until it converges, thus obtaining the trained teacher-student detection model.
[0057] Specific limitations regarding the training system for an unsupervised domain-adaptive railway intrusion target detection model can be found in the limitations of the training method for an unsupervised domain-adaptive railway intrusion target detection model described above, and will not be repeated here. Each module in the aforementioned unsupervised domain-adaptive railway intrusion target detection model training system can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0058] This specification also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the methods described above.
[0059] This specification provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described above.
[0060] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided by this invention can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0061] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. A training method for an unsupervised, domain-adaptive railway intrusion target detection model, characterized in that, Specifically, it includes: Acquire source domain images of railway scenes with category labeling information, and target domain images without labeling information; A teacher-student detection model is constructed, including a student detection branch and a teacher detection branch. The student detection branch includes a Transformer-based detector backbone network and encoder, a local instance consistency processing unit connected in series on the decoder output side, and a real feature space domain discriminator and a virtual feature space domain discriminator connected in parallel on the encoder output side. The local instance consistency processing unit includes a prototype aggregation layer, a one-way feature matching layer, and a two-way mapping reconstruction layer. The source domain image and the target domain image are used as inputs, and the category labeling information corresponding to the source domain image is used as the training label. The teacher and student detection model is iteratively trained until convergence to obtain the trained teacher and student detection model. During the iterative training process, the student detection branch extracts encoded features from the source and target domain images through the backbone network and encoder, and outputs the target query features through the decoder. The encoded features are input into the real feature space discriminator for first-domain adversarial training. Simultaneously, the encoded features are mapped to a virtual latent space and input into the virtual feature space discriminator for second-domain adversarial training. Based on the results of the first and second domain adversarial training, a global alignment constraint is constructed. The target query features are input into the local instance consistency processing unit. The source and target domain category prototypes are obtained through a prototype aggregation layer. A one-way feature matching layer and a two-way mapping reconstruction layer are used to execute single-step contrastive adversarial training and two-step cyclic consistency constraints, respectively, to construct local alignment constraints. The parameters of the student detection branch are updated based on the detection loss, global alignment constraint, and local alignment constraint, and the parameters of the teacher detection branch are updated using an exponential moving average.
2. The training method for an unsupervised domain-adaptive railway intrusion target detection model as described in claim 1, characterized in that: The target domain image includes at least domain-specific appearance features caused by changes in weather, lighting, or background structure. The category labeling information includes the foreign object category and the corresponding bounding box location; the foreign object category includes at least pedestrians, falling rocks, and vehicles.
3. The training method for an unsupervised domain-adaptive railway intrusion target detection model as described in claim 1, characterized in that: The Transformer-based detector backbone network is a pre-trained DINO detector backbone network; the decoder adopts a hybrid query selection mechanism, which selects candidate positions from the encoder output and initializes the decoder input query by combining image content and spatial location information; the backbone network adopts ResNet or Swing Transformer.
4. The training method for an unsupervised domain-adaptive railway intrusion target detection model as described in claim 1, characterized in that, The method for mapping encoded features to a virtual latent space specifically includes: Calculate the domain-invariant mean and domain-invariant standard deviation of the encoded features; for the predicted domain-invariant mean and domain-invariant standard deviation, perform a reparameterization operation to obtain virtual latent features. ; ; in, Let Gaussian random variable represent noise. For element-wise multiplication, It follows a normal distribution. It is an identity matrix.
5. The training method for an unsupervised domain-adaptive railway intrusion target detection model as described in claim 1, characterized in that, The single-step comparative adversarial confrontation specifically refers to: Using source domain category prototypes, target domain category prototypes, and global semantic anchors of the same category as positive sample pairs, and using different category prototypes as negative sample pairs, a category-aware contrast loss is constructed to enhance the consistency of cross-domain instance features of the same category. A prototype-level domain discriminator is introduced to perform domain adversarial training on the source domain category prototype and the target domain category prototype. This reduces the domain differences between the source and target domain category prototypes while maintaining class discriminability, thereby reducing false matching between small railway targets and ballast, sleepers, and shadow backgrounds.
6. The training method for an unsupervised domain-adaptive railway intrusion target detection model as described in claim 1, characterized in that, The two-step cyclic consistency constraint is specifically as follows: A first mapping network from the source domain to the target domain and a second mapping network from the target domain to the source domain are constructed. Based on the effective category set consisting of the same category with category prototypes in both the source and target domains, semantic consistency loss and cyclic reconstruction consistency loss are calculated. The semantic consistency loss constrains the mapped category prototype to be consistent with the opposite category prototype in the semantic space, and the cyclic reconstruction consistency loss constrains the reconstructed category prototype to be consistent with the original category prototype, so as to verify the reliability of the matching between the source and target domain instances and alleviate the accumulation of pseudo-label errors.
7. The training method for an unsupervised domain-adaptive railway intrusion target detection model as described in claim 1, characterized in that: The global alignment constraint is obtained by weighted summation of real spatial domain adversarial loss and virtual spatial domain adversarial loss; the local alignment constraint is obtained by weighted summation of single-step consistency loss and two-step cyclic consistency loss.
8. A training system for an unsupervised, domain-adaptive railway intrusion target detection model, characterized in that, include: The image acquisition module is used to acquire source domain images with category labeling information and target domain images without labeling information; The model building module is used to construct a teacher-student detection model. The teacher-student detection model includes a student detection branch and a teacher detection branch updated by exponential moving average. The student detection branch includes a Transformer-based detector backbone network and encoder, a local instance consistency processing unit connected in series on the decoder output side, and a real feature space discriminator and a virtual feature space discriminator connected in parallel on the encoder output side. The local instance consistency processing unit includes a prototype aggregation layer, a one-way feature matching layer, and a two-way mapping reconstruction layer. The model training module is used to take the source domain image and the target domain image as input, use the category labeling information as training labels, and iteratively train the teacher-student detection model until convergence to obtain the trained teacher-student detection model.
9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the method described in any one of claims 1 to 7.
10. A computer device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described in any one of claims 1 to 7.
