Defect image generation method and detection method for steel rail fastener elastic strip
By generating diverse fastener defect images and improved YOLOV8n model, the problem of sample imbalance and insufficient detection accuracy in fastener defect detection is solved, efficient and robust fastener defect detection is achieved, and rail transit safety is improved.
Patent Information
- Application Number
- CN202510586470.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2025-08-15
AI Technical Summary
The existing fastener defect detection methods have problems such as low efficiency, high missed detection rate and imbalance in sample acquisition, resulting in insufficient detection accuracy. Especially when the proportion of defective image samples is extremely low, it is difficult to achieve high-precision all-weather and full-line detection.
By obtaining fastener images in real scenes, marking mask images, generating diverse fastener defect images, and using CUT style migration model to build a high-quality training data set, combined with the improved YOLOV8n object detection model for detection, improving detection accuracy and efficiency.
It realizes high-precision and high-efficiency fastener defect detection, significantly improves the robustness and automation capabilities of the inspection, and can promptly detect multiple fastener defects to ensure the safety of rail transit.
Smart Images

Figure CN120495238A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of rail transportation technology, and in particular to a defect image generation method and a detection method for rail fastener spring bars. Background Art
[0002] The rail fastener system is an important component of the track structure in rail transit. It is responsible for fixing the position of the rails, transmitting train loads and buffering vibration and impact. The service status of the fasteners directly affects the stability of the track geometry, which in turn has an important impact on the smooth operation of the train and the safety of railway operations. However, during long-term use, the fasteners are prone to various defects such as broken, missing and offset spring bars due to factors such as the train's cyclic high-frequency load, ambient temperature changes, rain erosion and natural aging. If these defects are not discovered and handled in time, they may lead to track geometry deviations, train shaking and even derailment accidents. Therefore, timely and accurate detection of fastener defects is the key to ensuring rail transit safety and formulating maintenance plans.
[0003] Traditional fastener defect detection usually relies on manual inspections, which have problems such as low efficiency, high missed detection rate and strong subjectivity. It is difficult to meet the real-time detection needs of long-mileage, multi-category, high-precision, all-weather and full-line. With the development of machine vision technology, fastener defect detection methods based on computer vision have gradually become a mainstream choice. These methods use high-speed industrial cameras to collect fastener images and combine image processing technology for feature extraction and defect location. However, existing defect detection methods still face some challenges, especially in the acquisition of defect image samples. Due to the extremely low proportion of defective fasteners, the ratio of positive and negative samples is seriously unbalanced, which seriously affects the quality of the training data set and the accuracy of the detection model. In addition, existing methods for generating defect images mainly rely on traditional generative models, such as CycleGAN. These methods have certain limitations in the stability, efficiency and style consistency of image generation with real scenes, which further limits the improvement of defect detection accuracy. Summary of the Invention
[0004] The present invention provides a defect image generation method and a detection method for rail fastener spring bars, which improves the detection accuracy and efficiency of fastener defects. It can achieve high-precision, high-efficiency and robust defect detection in practical applications, and provide strong technical support for railway track safety.
[0005] The method for generating defect images of rail fastener spring clips comprises the following steps:
[0006] S1, acquiring fastener images: acquiring fastener images in real scenes, including defective fastener images and normal fastener images;
[0007] S2, marking the fastener mask image: using annotation tools to mark the normal fastener image, mark it as a fastener mask image, and define the categories of each component;
[0008] S3, generating defective fastener mask images: generating fastener mask images of different types of spring clip defects (shift, breakage, missing) through digital image processing technology (image rotation and pixel value modification);
[0009] S4, style transfer to generate defect images: normal fastener images in real scenes and acquired fastener mask images including different types of spring clip defects are processed with real style transfer to construct a rail fastener spring clip defect image dataset;
[0010] S5, constructing a training dataset: Based on the rail fastener spring clip defect image dataset, a training dataset is constructed by combining normal fastener images and defective fastener images in real scenes;
[0011] S6, building a defect detection model: using the improved YOLOV8n target detection model to build a spring clip defect detection model, and training the spring clip defect detection model using the training data set;
[0012] S7, defect detection: Defect detection is performed on the images of the fasteners to be inspected using the trained spring clip defect detection model to achieve defect detection of rail fastener spring clips.
[0013] Optionally, the marked fastener mask image in S2 includes:
[0014] S21, using a labeling tool to load a normal fastener image and perform mask marking: using the LabelMe labeling tool to load a normal fastener image obtained in a real scene and mark it as a fastener mask image;
[0015] S22, defining component categories: During the labeling process, each component in the fastener image is labeled as an independent category, including the spring bar, the upper surface of the bolt, the lower surface of the bolt, and the top surface of the rail;
[0016] S23, define background category: mark the track plate surface and the rail support platform as the same type of background category;
[0017] S24, display each category separately: Use different colors to display the parts marked as independent categories and the background category separately.
[0018] Optionally, generating a defective fastener mask image in S3 includes:
[0019] S31, generating a fastener mask image with spring clip offset: selecting the center point of the bolt top in the fastener mask image as the rotation center of the spring clip mask area, setting minimum and maximum spring clip offset angle thresholds, and randomly rotating the spring clip mask area clockwise or counterclockwise around the rotation center without exceeding the set thresholds to generate fastener mask images with different spring clip offset angles;
[0020] S32, generating a fastener mask image of a broken spring clip: setting the spring clip mask area in the fastener mask image as the area with the largest pixel value change, and starting from any one or both end points of the spring clip, randomly and continuously changing the spring clip mask pixel values of different ranges to the background pixel values below the spring clip, thereby generating a fastener mask image including different spring clip broken ranges;
[0021] S33, generating a mask image of a fastener with missing spring bars: changing all pixel values within the spring bar mask area in the fastener mask image to background pixel values below the spring bar, to generate a mask image of a fastener with missing spring bars.
[0022] Optionally, the generation of the defect image by style transfer in S4 includes:
[0023] S41, inputting images into the style transfer model: using a CUT-based style transfer model, inputting a normal fastener image in a real scene and a masked fastener image including different types of spring clip defects into the style transfer model;
[0024] S42, style transfer processing: The style transfer model performs style alignment on the input image and outputs an image of the elastic strip defect that is consistent with the style of the real scene;
[0025] S43, generating a defect image dataset: constructing a rail fastener spring clip defect image dataset by processing the generated spring clip defect images through style transfer.
[0026] Optionally, the CUT includes a generator, a discriminator, and a feature extractor. The generator adopts an encoder-decoder structure and is responsible for converting the style of the source domain image (including fastener mask images of different types of spring bar defects) into the style of the target domain image (normal fastener images in real scenes). The discriminator is responsible for determining whether the image generated by the generator belongs to the target domain. The feature extractor aligns the source domain and target domain features through contrast loss.
[0027] A detection method for a rail fastener spring clip defect image generation method is used to detect the above-mentioned rail fastener spring clip defect image generation method. The improved YOLOV8n target detection model includes:
[0028] Embedded coordinate attention mechanism: Embedded coordinate attention mechanism between the c2f module and SPPF module in the YOLOV8n model backbone structure;
[0029] Add lightweight modules: Replace the fourth traditional Conv module from the bottom up in the YOLOV8n model backbone structure and the c2f module in the neck structure with the lightweight modules GSConv module and VoVGSPCP module respectively;
[0030] Upgrade the bounding box loss function: Upgrade the bounding box loss function of the YOLOV8n model from CIoU to Wise-IoU.
[0031] Optionally, the loss function of the improved YOLOV8n target detection model includes a border loss function, a classification loss function and a confidence loss function.
[0032] Optionally, the border loss function is expressed as:
[0033]
[0034] Among them, L box is the border loss, γ and η are learning parameters, β is the outlier degree, and ρ 2 (b,b gt ) represents the predicted box b and the real box b gt The Euclidean distance of the center point is , c represents the diagonal length of the minimum bounding rectangle that can contain both the predicted box and the true box, and IoU is the intersection over union ratio.
[0035] Beneficial effects of the present invention:
[0036] The present invention effectively obtains fastener spring bar defects with diverse characteristics by randomly rotating the spring bar mask area in the fastener mask image and modifying the pixel value. In addition, the style conversion technology based on the CUT style transfer model is adopted to migrate the generated defect mask image to a highly consistent style with the fastener image in the real scene, generating a highly realistic rail fastener spring bar defect image dataset, solving the problem of scarce fastener defect samples and enriching the diversity of fastener defect types.
[0037] Through targeted training, the present invention solves the problem of low detection accuracy in traditional fastener defect detection models caused by the imbalanced distribution of positive and negative fastener sample categories, significantly improving the accuracy, efficiency and robustness of rail fastener spring bar defect detection. It has important practical application value and can greatly improve the automated detection capability of fastener defects in rail transit. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only for the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0039] Figure 1 A schematic flow chart of a defect image generation method according to an embodiment of the present invention;
[0040] Figure 2 A schematic diagram of defect image generation operation according to an embodiment of the present invention;
[0041] Figure 3 Schematic diagram of a CUT-based style transfer model according to an embodiment of the present invention;
[0042] Figure 4 A schematic diagram for comparing three defect image data of rail fastener spring bars according to an embodiment of the present invention;
[0043] Figure 5 A schematic flow chart of a method for detecting spring bar defects according to an embodiment of the present invention;
[0044] Figure 6 Schematic diagram of a spring bar defect detection model according to an embodiment of the present invention;
[0045] Figure 7 Schematic diagram comparing the training results of the spring clip defect detection model and the YOLOv8n model according to an embodiment of the present invention;
[0046] Figure 8 Schematic diagram comparing the detection performance of the spring bar defect detection model and the YOLOv8n model according to an embodiment of the present invention;
[0047] Figure 9 This is a schematic diagram of the detection effect of the defect detection model after training with the original training data set without style transfer according to an embodiment of the present invention;
[0048] Figure 10 This is a schematic diagram of the detection effect of the defect detection model after training with the training data set generated by style transfer in an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should also be noted that, in order to provide a more detailed description, the following embodiments are best and preferred embodiments, and those skilled in the art may also adopt other alternatives to implement the invention for some known technologies. Furthermore, the accompanying drawings are only for the purpose of describing the embodiments in more detail and are not intended to limit the present invention in any specific manner.
[0050] It should be noted that references in the specification to "one embodiment," "an embodiment," "an exemplary embodiment," "some embodiments," etc. indicate that the described embodiments may include specific features, structures, or characteristics, but not every embodiment necessarily includes such specific features, structures, or characteristics. In addition, when specific features, structures, or characteristics are described in conjunction with an embodiment, it is within the knowledge of persons skilled in the relevant art to implement such features, structures, or characteristics in conjunction with other embodiments (whether or not explicitly described).
[0051] In general, terms can be understood, at least in part, from their use in context. For example, depending at least in part on the context, the term "one or more" as used herein can be used to describe any feature, structure, or characteristic in the singular sense, or can be used to describe a combination of features, structures, or characteristics in the plural sense. Additionally, the term "based on" can be understood as not necessarily intended to convey an exclusive set of factors, but can instead, depending at least in part on the context, allow for the presence of other factors that are not necessarily explicitly described.
[0052] like Figures 1-10 As shown, the method for generating a defect image of a rail fastener spring bar includes the following steps:
[0053] S1, acquiring fastener images: acquiring fastener images in real scenes, including defective fastener images and normal fastener images;
[0054] S2, Marking the Fastener Mask Image: Use annotation tools to mark the normal fastener image as a fastener mask image and define the categories of each component, including:
[0055] (1) Use the labeling tool to load the normal fastener image and mark it as a mask: Use the LabelMe labeling tool to load the normal fastener image obtained in the real scene and mark it as a fastener mask image;
[0056] (2) Define component categories: During the annotation process, each component in the fastener image is marked as an independent category, including the spring bar, the upper surface of the bolt, the lower surface of the bolt, and the top surface of the rail;
[0057] (3) Define background categories: mark the track slab surface and the rail support platform as the same type of background category;
[0058] (4) Differentiate and display each category: Use different colors to distinguish between parts marked as independent categories and background categories.
[0059] S3, generating defective fastener mask images: Generate fastener mask images of different types of spring clip defects using digital image processing technology, specifically including:
[0060] (1) Generate a fastener mask image with spring clip offset: Select the center point of the bolt top in the fastener mask image as the rotation center of the spring clip mask area, set the minimum and maximum spring clip offset angle thresholds, and randomly rotate the spring clip mask area clockwise or counterclockwise around the rotation center without exceeding the set threshold to generate fastener mask images with different spring clip offset angles;
[0061] (2) Generating a fastener mask image with broken spring clips: The spring clip mask area in the fastener mask image is set as the area with the largest pixel value change. Starting from any end point or both ends of the spring clip, the spring clip mask pixel values in different ranges are randomly and continuously changed to the background pixel values below the spring clip, thereby generating a fastener mask image including different spring clip breakage ranges;
[0062] (3) Generate a mask image of a fastener with missing spring bars: Change all pixel values in the spring bar mask area of the fastener mask image to the background pixel values below the spring bar to generate a mask image of a fastener with missing spring bars.
[0063] S4, style transfer to generate defect images: Perform stylized transfer processing on normal fastener images in real scenes and fastener mask images with different types of spring clip defects to construct a dataset of rail fastener spring clip defect images. Specifically, it includes:
[0064] CUT is an unsupervised image-to-image translation method based on contrastive learning. Its core idea is to use contrastive learning to train a generative model that can extract features from the content image and compare them with the features of the style image, thereby achieving image style transfer.
[0065] The CUT model mainly consists of a generator, a discriminator and a feature extractor, such as Figure 3As shown in the figure, the generator adopts an encoder-decoder structure, which is responsible for converting the style of the source domain image (the mask image of the fastener containing different types of spring strip defects) into the style of the target domain image (the normal fastener image in the real scene). Through this structure, the generator can learn how to effectively transfer styles between different image domains. The discriminator is a convolutional neural network used to distinguish between the generated image and the target domain image. Its goal is to maximize the discrimination ability of the real image of the target domain while minimizing the discrimination ability of the generated image, thereby prompting the generator to generate more realistic images that are consistent with the style of the target domain. The feature extractor shares weights with the encoder of the generator and is used to extract multi-level features from the generated image and the target domain image. These features are then used to align the feature representations of the source domain and the target domain through a contrast loss function. The contrast loss function aims to narrow the distance between the generated image and the target domain image in the feature space, while pushing them further away from the source domain image, thereby achieving effective style transfer. Assuming there are two styles A and B, to convert style A to style B, A is the source domain and B is the target domain.
[0066] The fastener images obtained in real scenes are stored in the "train_B" folder, and the fastener mask images containing different types of spring defects obtained by image digital processing technology are stored in the "train_A" folder; the CUT-based style transfer model randomly selects fastener mask images from "train_A" and normal fastener images from "train_B", and uses both as model inputs at the same time; the generator converts the stressor image into the "fake_B" image with the target domain style, and calculates the adversarial loss through the discriminator to improve the realism and style consistency of the generated image; at the same time, the feature extractor extracts the fastener mask images from "train_A" and "fake _B” image, and calculate the contrast loss to ensure that the generated image is consistent with the target domain in style while retaining the core content of the source domain image. To further enhance the robustness of the model, the generator remaps the “fake_B” image back to the source domain style to generate the “rec_A” image, and uses the discriminator to evaluate its consistency with the original “train_A” image. The generation effect is optimized by combining the contrast learning mechanism, and the quality of the generated image is improved through continuous iteration. During the training process, the FID value is used as a key indicator to evaluate the effect of style transfer. The smaller the value, the higher the quality of the generated image and the closer it is to the distribution of the real image. Finally, the model outputs an image of elastic strip defects with the style of the real scene, such as Figure 4 As shown;
[0067] In a dataset of rail fastener clip defect images, different types of clip defects were generated by randomly rotating the clip mask region within the fastener mask image and modifying pixel values. These types include clip offset, clip breakage, and clip loss. Furthermore, a CUT-based style transfer model was used to transfer the style of the fastener mask images containing these different types of clip defects to the style of normal fastener images in real-world scenarios, thereby enhancing the diversity and authenticity of the training data. The dataset of rail fastener clip defect images generated using this method meets the requirement for a balanced ratio of positive and negative samples when training fastener defect detection models.
[0068] S5, constructing a training dataset: Based on the rail fastener spring clip defect image dataset, a training dataset is constructed by combining normal fastener images and defective fastener images in real scenes;
[0069] S6, building a defect detection model: using the improved YOLOV8n target detection model to build a spring clip defect detection model, and training the spring clip defect detection model using the training data set;
[0070] The detection method of the defect image generation method of the rail fastener spring clip is used to detect the defect image generation method of the rail fastener spring clip mentioned above. In the specific implementation: based on the YOLOv8n model, targeted improvements are made to construct a spring clip defect detection model and named it YOLOv8n-FDD. The YOLOv8n-FDD model structure is as follows Figure 6 As shown in the figure, the specific improvements are as follows: First, in order to improve the detection accuracy, the coordinate attention mechanism (CA) is embedded between the c2f module and the SPPF module in the YOLOv8n model backbone structure, so that the YOLOv8n-FDD model can focus more accurately on the key feature information in the fastener image, thereby optimizing the detection effect; Second, in order to improve the detection efficiency, the fourth bottom-up traditional Conv module in the YOLOv8n model backbone structure and the c2f module in the neck structure are replaced by lightweight modules GSConv module and VoVGSPCP module respectively, reducing the computational complexity of the YOLOv8n-FDD model and thus achieving model lightweighting; Finally, the bounding box loss function of the YOLOv8n model is upgraded from Complete Intersection over Union (CIoU) to Wise-IoU (WIoU), optimizing the generalization ability and overall detection performance of the YOLOv8n-FDD model when processing complex scenes;
[0071] The loss function of the YOLOv8n-FDD model consists of three parts: the bounding box loss function, the classification loss function, and the confidence loss function. The improved bounding box loss function is described by the following formula:
[0072]
[0073] Among them, L box is the border loss; γ, η are learning parameters, β is the outlier, which balances the gradient contribution of anchor boxes of different qualities during training; ρ 2 (b,b gt ) represents the predicted box b and the real box b gt c represents the diagonal length of the minimum bounding rectangle that can contain both the predicted box and the true box; IoU is the intersection over union ratio, which represents the ratio of the intersection area of the predicted box and the true box to the union area.
[0074] The overall detection performance of the model is evaluated from three aspects: detection accuracy, detection speed, and model size. The detection accuracy evaluation metrics used are precision (P), recall (R), and mean average precision (mAP), which are commonly used in the field of target detection. The detection speed is quantified using average detection time (ADT), which is defined as the average time the model spends processing each frame. The model size is defined as the memory space occupied by the saved model after final training.
[0075] The training dataset is used to train the YOLOv8n model and the improved YOLOv8n-FDD model for 300 epochs respectively. Figure 7 A comparison chart shows the training results of the YOLOv8n-FDD model for spring clip defect detection, which is based on the method of the present invention, and the YOLOv8n model. As can be seen, the mAP50 values of both models continue to improve with increasing epochs. For the first 35 epochs, the mAP50 values of the two models are almost identical. After the 35th epoch, the mAP50 value of the YOLOv8n-FDD model begins to surpass that of the YOLOv8n model. After the 100th epoch, the convergence rate of the two models slows down until they reach a stable state. Ultimately, the YOLOv8n-FDD model achieves a maximum mAP50 value of 0.961.
[0076] Figure 8This figure compares the detection performance of the spring clip defect detection model provided by the present invention with that of the YOLOv8n model. As can be seen, the YOLOv8n-FDD model achieves a mAP50 of 0.961 in terms of detection accuracy, a 2.1% improvement over YOLOv8n. In terms of detection speed, the YOLOv8n-FDD model achieves an ADT of 11ms, an approximately 8.3% improvement in detection rate over the YOLOv8n model. In terms of model size, the YOLOv8n-FDD model achieves a size of 6.0MB, a 3.2% reduction compared to the YOLOv8n model. In summary, the spring clip defect detection model provided by the present invention performs better in terms of detection accuracy, detection speed, and model scale.
[0077] In order to evaluate the impact of the training dataset before and after style transfer on the performance of the spring clip defect detection model, Figure 9 、 Figure 10 As shown, Figure 9 Represents the detection effect of the YOLOv8n-FDD model after training with the original training dataset without style transfer; Figure 10 Figure 2 shows the detection performance of the YOLOv8n-FDD model trained on a training dataset constructed from images of spring clip defects generated through style transfer. As can be seen, the YOLOv8n-FDD model achieves a confidence score of only 0.59 when detecting images with missing spring clip defects, while the confidence score of the YOLOv8n-FDD model improves to 0.85 when detecting images with missing spring clip defects. This demonstrates that the spring clip defect detection model trained on the style-transferred training dataset achieves better detection accuracy, but also reflects the fact that the original training dataset, without style transfer, suffers from a problem of reduced detection accuracy due to an imbalance of positive and negative samples.
[0078] The present invention encompasses any alternatives, modifications, equivalents, and solutions that fall within the spirit and scope of the present invention. To provide a thorough understanding of the present invention, specific details are described in detail below in connection with the preferred embodiments of the present invention, but those skilled in the art will be able to fully understand the present invention without these detailed descriptions. Furthermore, to avoid unnecessary confusion regarding the essence of the present invention, well-known methods, processes, procedures, components, and circuits have not been described in detail.
[0079] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.
Claims
1. A method for generating defect images of rail fastener spring bars, characterized in that: The following steps are involved: S1, acquiring fastener images: acquiring fastener images in real scenes, including defective fastener images and normal fastener images; S2, marking the fastener mask image: using annotation tools to mark the normal fastener image, mark it as a fastener mask image, and define the categories of each component; S3, generating defective fastener mask images: generating fastener mask images of different types of spring clip defects by digital image processing technology; S4, style transfer to generate defect images: normal fastener images in real scenes and acquired fastener mask images including different types of spring clip defects are processed with real style transfer to construct a rail fastener spring clip defect image dataset; S5, constructing a training dataset: Based on the rail fastener spring clip defect image dataset, a training dataset is constructed by combining normal fastener images and defective fastener images in real scenes; S6, building a defect detection model: using the improved YOLOV8n target detection model to build a spring clip defect detection model, and training the spring clip defect detection model using the training data set; S7, defect detection: Defect detection is performed on the images of the fasteners to be inspected using the trained spring clip defect detection model to achieve defect detection of rail fastener spring clips.
2. The method for generating defect images of rail fastener spring bars according to claim 1, characterized in that: The marked fastener mask image in S2 includes: S21, using a labeling tool to load a normal fastener image and perform mask marking: using the LabelMe labeling tool to load a normal fastener image obtained in a real scene and mark it as a fastener mask image; S22, defining component categories: During the labeling process, each component in the fastener image is labeled as an independent category, including the spring bar, the upper surface of the bolt, the lower surface of the bolt, and the top surface of the rail; S23, define background category: mark the track plate surface and the rail support platform as the same type of background category; S24, display each category separately: Use different colors to display the parts marked as independent categories and the background category separately.
3. The method for generating defect images of rail fastener spring bars according to claim 2, characterized in that: Generating the defective fastener mask image in S3 includes: S31, generating a fastener mask image with spring clip offset: selecting the center point of the bolt top in the fastener mask image as the rotation center of the spring clip mask area, setting minimum and maximum spring clip offset angle thresholds, and randomly rotating the spring clip mask area clockwise or counterclockwise around the rotation center without exceeding the set thresholds to generate fastener mask images with different spring clip offset angles; S32, generating a fastener mask image of a broken spring clip: setting the spring clip mask area in the fastener mask image as the area with the largest pixel value change, and starting from any one or both end points of the spring clip, randomly and continuously changing the spring clip mask pixel values of different ranges to the background pixel values below the spring clip, thereby generating a fastener mask image including different spring clip broken ranges; S33, generating a mask image of a fastener with missing spring bars: changing all pixel values within the spring bar mask area in the fastener mask image to background pixel values below the spring bar, to generate a mask image of a fastener with missing spring bars.
4. The method for generating defect images of rail fastener spring bars according to claim 3, characterized in that: The style transfer in S4 to generate defect images includes: S41, inputting images into the style transfer model: using a CUT-based style transfer model, inputting a normal fastener image in a real scene and a masked fastener image including different types of spring clip defects into the style transfer model; S42, style transfer processing: The style transfer model performs style alignment on the input image and outputs an image of the elastic strip defect that is consistent with the style of the real scene; S43, generating a defect image dataset: constructing a rail fastener spring clip defect image dataset by processing the generated spring clip defect images through style transfer.
5. The method for generating defect images of rail fastener spring bars according to claim 4, characterized in that: The CUT includes a generator, a discriminator, and a feature extractor. The generator adopts an encoder-decoder structure and is responsible for converting the style of the source domain image to the style of the target domain image. The discriminator is responsible for determining whether the image generated by the generator belongs to the target domain. The feature extractor aligns the source domain and target domain features through contrast loss.
6. A method for detecting a defect image generation method of a rail fastener spring clip, used for detecting the defect image generation method of a rail fastener spring clip according to any one of claims 1 to 5, characterized in that: The improved YOLOV8n target detection model includes: Embedded coordinate attention mechanism: Embedded coordinate attention mechanism between the c2f module and SPPF module in the YOLOV8n model backbone structure; Add lightweight modules: Replace the fourth traditional Conv module from the bottom up in the YOLOV8n model backbone structure and the c2f module in the neck structure with the lightweight modules GSConv module and VoVGSPCP module respectively; Upgrade the bounding box loss function: Upgrade the bounding box loss function of the YOLOV8n model from CIoU to Wise-IoU.
7. The detection method for generating defect images of rail fastener spring bars according to claim 6, characterized in that: The loss function of the improved YOLOV8n target detection model includes a bounding box loss function, a classification loss function, and a confidence loss function.
8. The detection method for generating defect images of rail fastener spring bars according to claim 7, characterized in that: The border loss function is expressed as: Among them, L box is the border loss, γ and η are learning parameters, β is the outlier degree, and ρ 2 (b,b gt ) represents the predicted box b and the real box b gt The Euclidean distance of the center point is , c represents the diagonal length of the minimum bounding rectangle that can contain both the predicted box and the true box, and IoU is the intersection over union ratio.