A defect sample generation method and system for a steel rail surface local defect scene

CN122928997APending Publication Date: 2026-10-16BEIJING YOUDAO DIGITAL INTELLIGENCE TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610974054.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-01
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

1.缺陷生成位置容易偏离钢轨表面的真实易发区域;

Benefits of technology

1)本发明通过有效钢轨表面约束模块构建类条件空间先验,使掉块缺陷和外物损伤缺陷分别受运行光带、光带核心区、非光带侧边区和偏好侧边区约束,提高缺陷生成位置与真实轨面结构的匹配度;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122928997A_ABST
    Figure CN122928997A_ABST
Patent Text Reader

Abstract

The present application belongs to the field of steel rail surface local defect generation, and specifically discloses a defect sample generation method and system for steel rail surface local defect scene, wherein the method takes a stable diffusion image repair model as a backbone network, fine-tunes through a low-rank adaptive branch, and introduces an effective steel rail surface constraint module VRSC, a conditional geometry decomposition module CGD and a physical guide rendering module PGR. The VRSC, CGD and PGR correspond to position constraint, geometry constraint and appearance constraint in steel rail surface defect generation respectively. Through the sequential cooperation of the VRSC, CGD and PGR, the diffusion generation process is jointly constrained in the order of structure to form, and form to texture, so that the generation process forms a closed loop of "first defining a reasonable position, then expanding the defect form, and finally correcting the physical appearance", avoiding the simple scene migration of the existing method only to the diffusion backbone.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of rail surface local defect generation technology, specifically to a defect sample generation method and system for rail surface local defect scenarios. Background Technology

[0002] Rail surface defect detection is a crucial aspect of intelligent operation and maintenance in rail transit. Due to factors such as on-site data collection conditions, defect occurrence probability, sample annotation costs, and uneven category distribution, the number of real rail surface defect samples is typically limited, especially for typical defects like chipping and foreign object damage, where sample scarcity is more prevalent. Insufficient samples directly restrict the training effectiveness and generalization ability of subsequent defect detection models. Therefore, constructing high-quality synthetic defect samples through generative models has become an important approach to improving rail surface defect detection capabilities.

[0003] While existing diffusion-based image generation methods can learn certain defect texture features, they still have significant shortcomings in rail surface scenes. First, the rail surface has a stable lateral structure: the central bright area corresponds to the running light band, while the lateral areas correspond to the non-light band rail surface and the edge background. Different types of defects have different reasonable occurrence areas, and relying solely on textual conditions, ordinary masks, or general spatial control information makes it difficult to reliably represent the true prior positions of the rail surface. Second, local defects on the rail surface are usually small in size. If the original seed mask or a fixed dilation mask is directly used for diffusion repair, the model easily converges to a few fixed geometric patterns, resulting in insufficient variation in the size, contour, and aspect ratio of the synthesized samples. Third, chipped defects are usually accompanied by local material loss, edge brightness transitions, and shadow variations consistent with the surrounding rail surface texture. Simply relying on the diffusion backbone for grayscale redrawing easily degenerates into dark patches, failing to represent the realistic sense of material loss.

[0004] In summary, the existing methods for generating local defects on the rail surface have the following problems: 1. The location of defects tends to deviate from the actual prone-to areas on the rail surface; 2. Insufficient variation in defect size, contour, aspect ratio, and boundary morphology results in limited geometric diversity of generated samples; 3. The "missing pieces" defect exhibits a lack of visual depth, insufficient transition between light and dark areas, and inconsistency in background texture. 4. Existing methods lack a technical solution for coordinating positional constraints, geometric constraints, and physical appearance constraints in a generation chain.

[0005] Therefore, there is a need for a defect sample generation method that can integrate the prior knowledge of rail surface structure, geometric laws of defect categories, and physical appearance constraints of material defects into the diffusion generation process without significantly increasing model complexity. Summary of the Invention

[0006] To address the problems existing in the prior art, this invention provides a method and system for generating defect samples for local defect scenarios on rail surfaces. This method uses a stable diffusion image repair model as the backbone network, performs fine-tuning through low-rank adaptation branches, and introduces a Valid Rail Surface Constraint (VRSC), a Class-aware Geometry Decomposition (CGD), and a Physics-guided Renderer (PGR) module, thus solving the problems mentioned in the background art.

[0007] To achieve the above objectives, the present invention provides the following technical solution: a method for generating defect samples for local defects on the surface of rails, comprising the following steps: S1. Obtain an image of the rail surface; S2, Effective Rail Surface Constraint VRSC: Performs structural analysis on normal rail surface images, uses column mean, column variance and effective width to estimate rail surface intervals, running light band intervals, light band core intervals, ordinary side intervals and preferred side intervals, and constructs class condition prior maps in combination with defect categories.

[0008] S3, Conditional Geometric Decomposition (CGD); S4. Coarsely generate defect images; S5, Physically Guided Rendering refines and generates defect samples.

[0009] Preferably, step S1 specifically includes: acquiring a normal rail surface image, a defect reference image, a defect seed mask corresponding to the defect reference image, and a defect category.

[0010] Preferably, step S2 specifically includes the following: Let the image of a normal rail surface be... Image height is Width is The brightness profile in the width direction Represented as: ; In the formula, and These represent the height and width of the image, respectively. Indicates the first Average brightness of the column; Based on the smoothed brightness profile, the operating light band range is obtained. its central position With width They are respectively: ; By proportionally cropping the central sub-region of the light band, the core region of the light band is obtained. : ; In the formula, The half-width ratio of the core region of the light band to the width of the light band; Let the rail surface area be Then the left and right non-center intervals are represented as: ; like If the condition is met, the left side is considered the preferred side region; otherwise, the right side is considered the preferred side region. A class condition prior graph is constructed by combining the defect categories.

[0011] Preferably, step S3 specifically includes the following: S31. Extract geometric features from the defect seed mask, construct a deterministic geometric signature based on area, perimeter, bounding box width, bounding box height, centroid position and defect category, and map the deterministic geometric signature to class conditional geometric transformation parameters. S32. Perform an affine transformation on the seed mask according to the class-conditional geometric transformation parameters to obtain the core mask, and construct an editable soft mask based on the distance transformation, the class-related morphological kernel, and the class-conditional prior graph.

[0012] Preferably, step S4 specifically includes: inputting noise latent variables, editable soft masks, latent variables corresponding to normal rail surface images, and text or category conditions into the stable diffusion image repair backbone network, and fine-tuning it through LoRA branches to obtain a coarsely generated defect image.

[0013] Preferably, step S5 specifically includes: when the defect category is a material missing defect, inputting the normal rail surface image, the coarsely generated defect image, the defect reference hint image, the original seed mask, the editable soft mask, the class conditional prior image, and the distance map into the Physical Guided Rendering (PGR) module, refining the coarsely generated result through fusion coefficients and darkening gating to obtain the final defect image; outputting the final defect image along with the corresponding defect mask and category label to constitute a rail surface defect training sample.

[0014] Preferably, the input to the physically guided rendering module includes a normal rail surface image. Coarsely generated defect images Defect reference diagram Original seed mask Editable soft mask Class conditional prior diagram and distance map Stack the input features to form a feature tensor. : ; In the formula, Indicates positive residual truncation; Input the feature tensor into the shallow rendering network , to obtain the fusion coefficient With darkening gating coefficient : ; Then construct candidate darkening results : ; Final rendering output Represented as: ; In the formula, Used to control the blending strength between the normal background and the candidate darkening result. Used to control the degree of local darkening.

[0015] On the other hand, to achieve the above objectives, the present invention also provides the following technical solution: a defect sample generation system for local defect scenarios on rail surfaces, the system comprising the following modules: The rail surface image acquisition module is used to acquire normal rail surface images, defect reference images, defect seed masks corresponding to the defect reference images, and defect categories. The Effective Rail Surface Constraint Module (VRSC) is used to perform structural analysis on normal rail surface images. It estimates rail surface intervals, running light band intervals, light band core intervals, ordinary side intervals, and preferred side intervals using column mean, column variance, and effective width, and constructs class condition prior maps in conjunction with defect categories.

[0016] The Class Conditional Geometry Decomposition (CGD) module is used to extract geometric features from the defect seed mask, construct a deterministic geometric signature based on area, perimeter, bounding box width, bounding box height, centroid position, and defect category, and map the deterministic geometric signature to class conditional geometric transformation parameters; perform an affine transformation on the seed mask according to the class conditional geometric transformation parameters to obtain the core mask, and construct an editable soft mask based on distance transformation, category-related morphological kernel, and class conditional prior graph; The coarse-generated defect image module is used to input noise latent variables, editable soft masks, latent variables corresponding to normal rail surface images, and text or category conditions into the stable diffusion image repair backbone network, and then fine-tune it through the LoRA branch to obtain the coarse-generated defect image. The Physically Guided Rendering (PGR) module is used to refine the coarsely generated defect image, the defect reference hint image, the original seed mask, the editable soft mask, the class conditional prior image, and the distance map when the defect category is a material missing defect. The PGR module refines the coarsely generated result through fusion coefficients and darkening gating to obtain the final defect image. The final defect image, along with the corresponding defect mask and category label, is output to form a training sample for rail surface defects.

[0017] The beneficial effects of this invention are: 1) This invention constructs a conditional space prior through an effective rail surface constraint module, so that the block drop defect and the foreign object damage defect are constrained by the running light band, the core area of ​​the light band, the non-light band side area and the preferred side area, respectively, thereby improving the matching degree between the defect generation location and the actual rail surface structure; 2) This invention transforms discrete seed masks into continuously adjustable geometric priors through a conditional geometric decomposition module, expanding the distribution of defect size, contour, aspect ratio, and boundary morphology, thereby improving the geometric diversity of the synthesized samples; 3) This invention generates blending coefficients and darkening gates for block-like defects through a physically guided rendering module, thereby enhancing the sense of local material detachment, edge light and dark transitions, and background texture consistency; 4) This invention enables the generation process to form a closed loop of “first defining a reasonable location, then expanding the defect morphology, and finally correcting the physical appearance” through the sequential collaboration of VRSC, CGD and PGR, avoiding the existing methods that only perform simple scene migration on the diffusion backbone. Attached Figure Description

[0018] Figure 1 This is a schematic diagram of the defect sample generation method for local defects on the rail surface in an embodiment of the present invention; Figure 2 This is a schematic diagram of the training framework for a defect sample generation method for local defects on the rail surface in an embodiment of the present invention. Figure 3 This is a schematic diagram of a defect sample generation system module for local defects on the rail surface in an embodiment of the present invention; Figure 4 This is a schematic diagram illustrating the structural analysis process of the effective rail surface constraint module in an embodiment of the present invention; Figure 5 This is a flowchart of the processing of the conditional geometry decomposition module in an embodiment of the present invention; Figure 6 This is a flowchart illustrating the input / output and rendering refinement process of the physical guided rendering module in this embodiment of the invention. In the diagram, 110 is the rail surface image acquisition module; 120 is the effective rail surface constraint module; 130 is the class conditional geometric decomposition module; 140 is the coarse generation defect image module; and 150 is the physically guided rendering module. Detailed Implementation

[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0020] This invention provides a technical solution: a defect sample generation method for local defect scenarios on rail surfaces, specifically a defect sample generation method based on prior knowledge of rail surface structure, conditional geometric decomposition, and physically guided rendering. This method is based on a stable diffusion inpainting backbone network, fine-tuned using LoRA, and introduces an effective rail surface constraint module (VRSC), a conditional geometric decomposition module (CGD), and a physically guided rendering module (PGR) into a unified training and inference process. The method steps, flow, and architecture are as follows: Figure 1 and Figure 2 As shown, it includes the following steps: S1. Obtain the rail surface image; obtain the normal rail surface image, the defect reference image, the defect seed mask corresponding to the defect reference image, and the defect category.

[0021] S2, Effective Rail Surface Constraint VRSC: Performs structural analysis on normal rail surface images, uses column mean, column variance and effective width to estimate rail surface intervals, running light band intervals, light band core intervals, ordinary side intervals and preferred side intervals, and constructs class condition prior maps in combination with defect categories.

[0022] Specifically, this includes the following: Let the normal rail surface image be... Image height is Width is The brightness profile in the width direction Represented as: ; In the formula, and These represent the height and width of the image, respectively. Indicates the first Average brightness of the column; Based on the smoothed brightness profile, the operating light band range is obtained. its central position With width They are respectively: ; By proportionally cropping the central sub-region of the light band, the core region of the light band is obtained. : ; In the formula, The half-width ratio of the core region of the light band to the width of the light band; Let the rail surface area be Then the left and right non-center intervals are represented as: ; like If the condition is met, the left side is considered the preferred side region; otherwise, the right side is considered the preferred side region. A class condition prior graph is constructed by combining the defect categories.

[0023] S3, Conditional Geometric Decomposition (CGD); specifically including the following: S31. Extract geometric features from the defect seed mask, construct a deterministic geometric signature based on area, perimeter, bounding box width, bounding box height, centroid position and defect category, and map the deterministic geometric signature to class conditional geometric transformation parameters. S32. Perform an affine transformation on the seed mask according to the class-conditional geometric transformation parameters to obtain the core mask, and construct an editable soft mask based on the distance transformation, the class-related morphological kernel, and the class-conditional prior graph.

[0024] S4. Coarsely generate defect image: Input the noise latent variable, editable soft mask, latent variable corresponding to the normal rail surface image, and text or category conditions into the stable diffusion image repair backbone network, and fine-tune it through LoRA branch to obtain the coarsely generated defect image. S5. Physically Guided Rendering (PGR) refines and generates defect samples: When the defect type is a material missing defect, the normal rail surface image, coarsely generated defect image, defect reference hint image, original seed mask, editable soft mask, class conditional prior image, and distance map are input into the Physically Guided Rendering (PGR) module. The coarsely generated result is refined through fusion coefficients and darkening gating to obtain the final defect image. The final defect image, along with the corresponding defect mask and category label, is output to form the rail surface defect training samples.

[0025] The input to the physically guided rendering module includes images of normal rail surfaces. Coarsely generated defect images Defect reference diagram Original seed mask Editable soft mask Class conditional prior diagram and distance map Stack the input features to form a feature tensor. : ; In the formula, Indicates positive residual truncation; Input the feature tensor into the shallow rendering network , to obtain the fusion coefficient With darkening gating coefficient : ; Then construct candidate darkening results : ; Final rendering output Represented as: ; In the formula, Used to control the blending strength between the normal background and the candidate darkening result. Used to control the degree of local darkening.

[0026] Example 2 Based on the defect generation method for local defects on rail surfaces in Example 1, during the training phase, given a normal rail surface image patch, a real defect reference image, and its mask, the normal rail surface image, seed mask, and conditional cues are input into the stable diffusion image repair backbone network. During training, the parameters of the text encoder and variational autoencoder are frozen, and only the LoRA branch in UNet is updated to reduce the amount of parameter updates and maintain the stable generation capability of the pre-trained diffusion model. VRSC and CGD first construct editable regions, and PGR then performs lightweight refinement on the coarsely generated results of block-type defects. During the inference phase, the same constraint logic is used to conditionally repair new normal rail surface image patches, and the generated defect image, defect mask, and category label are output simultaneously.

[0027] During the training phase, pseudo-paired samples can be constructed based on images of normal rail surfaces and real defect reference images. The training process includes the following steps: 1. Construct a class-conditional prior map based on normal rail surface images; 2. Construct the core region and editable soft mask based on the defect seed mask; 3. Input the normal rail surface image, editable soft mask, and condition information into the stable-diffusion-inpainting backbone network, and obtain the coarsely generated defect image through LoRA fine-tuning; 4. When the defect category is a block-dropping defect, the coarsely generated defect image is sent to the physical guided rendering module for refinement; 5. Optimize network parameters based on the joint loss function.

[0028] Furthermore, the parameters of the text encoder and variational autoencoder are frozen during training, and the parameters are updated only on the LoRA branch in UNet to reduce the amount of parameter updates and maintain the stable generation capability of the pre-trained diffusion model.

[0029] Furthermore, the joint loss function includes at least the diffusion noise prediction loss and the position constraint loss; for block-type defects, it also includes at least one of the following: rendering reconstruction loss, brightness consistency loss, fusion graph smoothing loss, statistical consistency loss, and category consistency loss.

[0030] During the inference phase, for a new normal rail surface image, the steps of structural analysis, class conditional prior graph construction, class conditional geometric decomposition, coarse generation, and rendering refinement are repeatedly executed to generate block defect samples or foreign object damage defect samples, and the corresponding masks and labels are output simultaneously.

[0031] The generated defect samples can be directly added to the rail surface defect training sample set for subsequent training of the rail surface defect detection model. This method expands the number of defect samples and improves the category and geometric distribution of the samples without significantly increasing the cost of collecting real defects.

[0032] Example 3 Based on the same inventive concept as the above-described method embodiments, this application also provides a defect sample generation system for localized defects on rail surfaces. This system can achieve the functions provided by the above-described method embodiments, such as... Figure 3 As shown, the system includes the following modules: Rail surface image acquisition module 110: used to acquire normal rail surface images, defect reference images, defect seed masks corresponding to the defect reference images, and defect categories.

[0033] The VRSC120 Effective Rail Surface Constraint Module is used to perform structural analysis on normal rail surface images. It estimates the rail surface interval, running light band interval, light band core interval, ordinary side interval, and preferred side interval using column mean, column variance, and effective width, and constructs a class condition prior map in combination with defect categories.

[0034] The rail surface image exhibits a stable structure in the width direction. The central bright area corresponds to the running light band formed by wheel-rail contact, while the areas on both sides are the non-light band rail surface and edge background. Different defect types have different reasonable occurrence areas: spalling defects are usually located near the center of the running light band, while foreign object damage defects appear more frequently in the non-light band areas and tend to be closer to the rail surface edges.

[0035] Based on this, this embodiment constructs a conditional space prior by performing brightness profile analysis on normal rail surface images. Figure 4 The main processing flow of this module is shown.

[0036] Let the image of a normal rail surface be... Image height is Width is The brightness profile in the width direction It can be represented as: ; In the formula, and These represent the height and width of the image block, respectively. Indicates the first The average brightness of the column. Based on the smoothed brightness profile, the operating light band range can be obtained. its central position With width They are respectively: ; Furthermore, by proportionally cropping the central sub-region of the light band, the core region of the light band is obtained. : ; In the formula, It is the half-width ratio of the core region of the light band to the width of the light band.

[0037] Let the rail surface area be Then the left and right non-central intervals can be expressed as: ; like If the left side is selected as the preferred side region, then the right side will be selected as the preferred side region.

[0038] Based on this, a surface mask is constructed. optical band mask optical core mask Standard side mask and preferred side mask When the defect category is a block drop defect, the class condition prior diagram is... It can be represented as: ; When the defect category is external damage defect, the class condition prior diagram It can be represented as: ; In the formula, This represents element-wise multiplication. Indicates the outer surface region of the light band. These represent the weights of the corresponding regions.

[0039] During the training phase, the position constraint loss is implemented using a residual ratio to suppress excessive changes in defects within invalid regions. Let the generated result be... ,but: ; In the formula, The loss function for the effective rail surface constraint module, This represents the class-conditional prior graph determined by the current category. Indicates an editable soft mask. To prevent extremely small positive numbers with a denominator of zero.

[0040] The Class Conditional Geometric Decomposition Module CGD130 is used to extract geometric features from the defect seed mask, construct a deterministic geometric signature based on area, perimeter, bounding box width, bounding box height, centroid position, and defect category, and map the deterministic geometric signature to class conditional geometric transformation parameters; perform an affine transformation on the seed mask according to the class conditional geometric transformation parameters to obtain the core mask, and construct an editable soft mask based on distance transformation, class-related morphological kernel, and class conditional prior graph.

[0041] Since surface defects on rails are typically small, directly inputting the original seed mask into the stable-diffusion-inpainting backbone network can easily cause the model to converge to a few fixed geometric patterns during training. Therefore, this embodiment performs conditional geometric reconstruction on the original seed mask to generate more varied core regions and editable regions. Figure 5 The processing flow of this module is shown.

[0042] Specifically, starting with the seed mask Extracting area ,perimeter , Width of the bounding box , Bounding box height and the position of the center of mass and in combination with defect categories Constructing geometric codes: ; In the formula, , and This is a 3D deterministic geometric signature obtained by mapping area, perimeter, bounding box size, centroid position, and class label. For ease of describing the mapping relationship of class condition parameters, let it be: ; In the formula, Representation and Category Related parameter mapping functions, Control horizontal scaling. Control vertical scaling. Control the lateral shearing.

[0043] Subsequently, an affine transformation is performed on the seed mask to obtain the core region. : ; The corresponding affine transformation matrix can be expressed as: ; In the formula, the translation term ensures that the deformation still revolves around the centroid of the seed mask, thus avoiding unconstrained drift. After the core region is determined, a soft weight distribution is generated based on the distance transformation. Let the pixel position be... The distance from the pixel to the core region is Then the soft weight can be expressed as: ; In the formula, This represents the diffusion width parameter associated with the defect category. Indicates an editable area.

[0044] Furthermore, the editable soft mask is determined jointly by the morphological expansion results of the core region and prior constraints: ; In the formula, Represents the morphological nucleus associated with the defect category. This represents the allowed region defined by the class-conditional prior graph.

[0045] The coarse-generated defect image module 140 is used to input noise latent variables, editable soft masks, latent variables corresponding to normal rail surface images, and text or category conditions into the stable diffusion image repair backbone network, and to obtain the coarse-generated defect image through LoRA branch fine-tuning.

[0046] During the forward diffusion process, the target defect image is mapped into latent variables by the encoder. At any moment The noise latent variable is expressed as: ;

[0047] In the formula, Indicates time The noise latent variable, Indicates the diffusion scheduler at time... The cumulative retention factor, This represents standard Gaussian noise.

[0048] For the stable-diffusion-inpainting backbone network, its input can be represented as a concatenation of noise latent variables, editable soft mask downsampling results, and normal image latent variables: ; In the formula, This represents a normal rail surface image block. It is an editable soft mask. This indicates a downsampling operation that matches the resolution of the latent variable. This represents channel-dimensional splicing. The basic noise prediction loss of the diffusion branch is defined as: ; In the formula, This indicates that the denoising network is at time... and text conditions The noise prediction results are as follows. This represents the square norm 2.

[0049] The total loss function can be expressed as: ; In the formula, For position constraint terms, and Corresponding to the physical consistency constraints and rendering losses of PGR, and The corresponding weights.

[0050] The Physically Guided Rendering (PGR150) module is used to refine the coarsely generated defect image, the defect reference hint image, the original seed mask, the editable soft mask, the class conditional prior image, and the distance map when the defect type is a material missing defect. The PGR module refines the coarsely generated result through fusion coefficients and darkening gating to obtain the final defect image. The final defect image, along with the corresponding defect mask and category label, is output to form a training sample for rail surface defects.

[0051] For defects like missing blocks, relying solely on the diffusion backbone for grayscale redrawing easily results in dark, closed areas, failing to realistically represent material gaps. Therefore, this embodiment includes a physically guided rendering module to refine the coarsely generated results for defects like missing blocks. Figure 6 The module's input / output and rendering refinement process are demonstrated.

[0052] The input to the physically guided rendering module includes images of normal rail surfaces. Coarsely generated defect images Defect reference diagram Original seed mask Editable soft mask Class conditional prior diagram and distance map The input features are stacked to form a feature tensor. : ; In the formula, This indicates that the positive residual is truncated.

[0053] Input the feature tensor into the shallow rendering network , to obtain the fusion coefficient With darkening gating coefficient : ; Then construct candidate darkening results : ; Final rendering output It can be represented as: ; In the formula, Used to control the blending strength between the normal background and the candidate darkening result. Used to control the degree of local darkening.

[0054] Furthermore, the rendering loss can be written as: ; In the formula, To render the reconstruction loss, For loss of light and dark consistency, For smoothing loss of the fusion graph, For the corresponding weights.

[0055] The physical consistency loss can be further written as: ; In the formula, For statistical consistency terms, This is a category consistency item.

[0056] Example 4: Three-Module Collaborative Mechanism In this invention, VRSC, CGD, and PGR correspond to the positional constraints, geometric constraints, and appearance constraints in the generation of surface defects on rails, respectively. These three constraints are not simply stacked together, but rather work in sequence from structure to morphology, and from morphology to texture, to jointly constrain the diffusion generation process.

[0057] VRSC first constrains the generation process from the perspective of the spatially feasible region. Rail surface images have a stable lateral structure, with running light bands, non-light band regions, and edge regions corresponding to different probability distributions of defect types. Without VRSC, the diffusion model might extend the defect probability distribution to invalid regions, leading to chips deviating from the light band, foreign object damage covering the bright light band, or defects crossing the rail surface boundary. VRSC essentially introduces a priori probability map to the defect generation location and limits the local redrawing area through an editable soft mask, ensuring that the generated residuals are mainly concentrated in the high-probability region corresponding to the current category.

[0058] CGD further expands the geometric distribution of defects within the reasonable spatial range given by VRSC. The morphological space covered by a small number of real masks is usually narrow. If the original masks are used directly for training, the model is prone to memorizing a few contours and producing geometric pattern collapse. CGD constructs geometric signatures through statistics such as area, perimeter, bounding box width and height, and centroid, and maps them to transformation parameters such as horizontal scaling, vertical scaling, and shearing according to the category, thereby increasing the coverage of boundaries, scale, and aspect ratio.

[0059] PGR, on the other hand, supplements physical appearance constraints on top of already determined location and geometry. The formation of rail spalling defects is usually accompanied by localized material detachment, resulting in imaging areas that appear as recessed regions, edge shadows, and light and shadow variations related to the surrounding rail surface texture. If only diffusion backbone redrawing is used, the generated result easily degenerates into localized dark patches, lacking the spatial lighting variations corresponding to material detachment. PGR uses a combination of normal image, coarsely generated image, reference defect cues, and soft masking to estimate fusion coefficients and darkening gates, resulting in outputs with more reasonable grayscale reduction and boundary transitions within the defect area.

[0060] The synergistic effect of these three elements can be summarized as follows: VRSC determines the defect generation location, CGD determines the defect generation geometry, and PGR determines the realism of the defect generation. Without VRSC, the model is prone to positional drift; without CGD, the model is prone to morphological uniformity; and without PGR, the model is prone to appearance distortion. Therefore, this invention is not a simple combination of diffusion backbone, LoRA, and general editing concepts, but rather a multi-layered prior collaborative generation method for constructing strong structural scenes on rail surfaces.

[0061] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0062] The terminology used in the embodiments of this invention is for the purpose of describing particular embodiments only and is not intended to limit the invention. The singular forms “a,” “the,” and “the” as used in the embodiments of this invention and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.

[0063] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0064] Depending on the context, the word "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection." Similarly, depending on the context, the phrase "if determination" or "if detection (of the stated condition or event)" can be interpreted as "when determination," "in response to determination," "when detection (of the stated condition or event)," or "in response to detection (of the stated condition or event)."

[0065] Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for generating defect samples for scenarios with localized defects on the surface of steel rails, characterized in that, Includes the following steps: S1. Obtain an image of the rail surface; S2, Effective Rail Surface Constraint VRSC: Perform structural analysis on normal rail surface images, use column mean, column variance and effective width to estimate rail surface intervals, running light band intervals, light band core intervals, ordinary side intervals and preferred side intervals, and construct class condition prior maps in combination with defect categories; S3, Conditional Geometric Decomposition (CGD); S4. Coarsely generate defect images; S5, Physically Guided Rendering refines and generates defect samples.

2. The defect sample generation method for local defect scenarios on rail surfaces according to claim 1, characterized in that: Step S1 specifically includes: acquiring a normal rail surface image, a defect reference image, a defect seed mask corresponding to the defect reference image, and a defect category.

3. The defect sample generation method for localized defects on rail surfaces according to claim 1, characterized in that: Step S2 specifically includes the following: Let the image of a normal rail surface be... Image height is Width is The brightness profile in the width direction Represented as: ; In the formula, and These represent the height and width of the image, respectively. Indicates the first Average brightness of the column; Based on the smoothed brightness profile, the operating light band range is obtained. its central position With width They are respectively: ; By proportionally cropping the central sub-region of the light band, the core region of the light band is obtained. : ; In the formula, The half-width ratio of the core region of the light band to the width of the light band; Let the rail surface area be Then the non-central intervals on the left and right are represented as: ; like If yes, then the left side will be the preferred side region; otherwise, the right side will be the preferred side region. And construct a class condition prior graph by combining the defect categories.

4. The defect sample generation method for localized defects on rail surfaces according to claim 1, characterized in that: Step S3 specifically includes the following: S31. Extract geometric features from the defect seed mask, construct a deterministic geometric signature based on area, perimeter, bounding box width, bounding box height, centroid position and defect category, and map the deterministic geometric signature to class conditional geometric transformation parameters. S32. Perform an affine transformation on the seed mask according to the class-conditional geometric transformation parameters to obtain the core mask, and construct an editable soft mask based on the distance transformation, the class-related morphological kernel, and the class-conditional prior graph.

5. The defect sample generation method for local defect scenarios on rail surfaces according to claim 1, characterized in that: In step S4, the specific steps include: inputting the noise latent variable, editable soft mask, latent variable corresponding to the normal rail surface image, and text or category conditions into the stable diffusion image repair backbone network, and fine-tuning it through the LoRA branch to obtain a coarsely generated defect image.

6. The defect sample generation method for local defect scenarios on rail surfaces according to claim 1, characterized in that: In step S5, specifically, when the defect category is a material missing defect, the normal rail surface image, the coarsely generated defect image, the defect reference hint image, the original seed mask, the editable soft mask, the class conditional prior image, and the distance map are input into the Physical Guided Rendering (PGR) module. The coarsely generated result is refined through fusion coefficients and darkening gating to obtain the final defect image. The final defect image, along with the corresponding defect mask and category label, is output to form a rail surface defect training sample.

7. The defect sample generation method for localized defects on rail surfaces according to claim 6, characterized in that: The input to the physically guided rendering module includes images of normal rail surfaces. Coarsely generated defect images Defect reference diagram Original seed mask Editable soft mask Class conditional prior diagram and distance map Stack the input features to form a feature tensor. : ; In the formula, Indicates positive residual truncation; Input the feature tensor into the shallow rendering network , to obtain the fusion coefficient With darkening gating coefficient : ; Then construct candidate darkening results : ; Final rendering output Represented as: ; In the formula, Used to control the blending strength between the normal background and the candidate darkening result. Used to control the degree of local darkening.

8. A system for generating defect samples for localized surface defects of rails according to any one of claims 1-7, characterized in that: The system includes the following modules: The rail surface image acquisition module (110) is used to acquire normal rail surface images, defect reference images, defect seed masks corresponding to the defect reference images, and defect categories. The effective rail surface constraint module VRSC (120) is used to perform structural analysis on normal rail surface images. It estimates the rail surface interval, running light band interval, light band core interval, ordinary side interval, and preferred side interval using column mean, column variance, and effective width, and constructs a class condition prior map in combination with defect categories.

9. Class Conditional Geometric Decomposition Module (CGD) (130): used to extract geometric features from the defect seed mask, construct a deterministic geometric signature based on area, perimeter, bounding box width, bounding box height, centroid position and defect category, and map the deterministic geometric signature to class conditional geometric transformation parameters; perform affine transformation on the seed mask according to the class conditional geometric transformation parameters to obtain the core mask, and construct an editable soft mask based on distance transformation, class-related morphological kernel and class conditional prior graph; The coarse-generated defect image module (140) is used to input noise latent variables, editable soft masks, latent variables corresponding to normal rail surface images, and text or category conditions into the stable diffusion image repair backbone network, and to obtain the coarse-generated defect image by fine-tuning through the LoRA branch. The Physically Guided Rendering Module (PGR) (150) is used to input the normal rail surface image, coarsely generated defect image, defect reference hint image, original seed mask, editable soft mask, class condition prior image and distance map into the Physically Guided Rendering Module (PGR) when the defect category is material missing type defect. The coarsely generated result is refined by the fusion coefficient and darkening gate to obtain the final defect image. The final defect image, along with the corresponding defect mask and category label, is output to form a training sample of rail surface defects.