A train visual positioning test case generation method and system

By training a model using a GAN-based image generation network, blurry images of different types and scenes are generated, solving the problem of incomplete test cases in existing technologies and improving the effectiveness and safety of train visual positioning testing.

CN115205595BActive Publication Date: 2025-12-30BEIJING JIAOTONG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210844044.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-18
Publication Date
2025-12-30
Estimated Expiration
2042-07-18

AI Technical Summary

Technical Problem

In existing technologies, deep learning-based train visual localization methods cannot generate test cases that meet the completeness requirements during testing, and image interference scenarios that occur infrequently and are difficult to reproduce in real environments are difficult to simulate, leading to a high risk of train localization errors.

Method used

By using a GAN-based image generation network, an image generation model is trained to generate blurred images of different types and scenes based on real-world images. Test cases are obtained through structural similarity screening to ensure the diversity and authenticity of the images.

Benefits of technology

The test cases were enriched, the completeness of the tests was improved, and the hidden dangers of the train visual positioning model were effectively exposed, reducing the risk of positioning errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115205595B_ABST
    Figure CN115205595B_ABST
Patent Text Reader

Abstract

The present application relates to a kind of train visual positioning test case generation method and system, belong to train positioning technical field, first acquire the real environment image around train, and according to fuzzy type is classified, with no fuzzy training image, any fuzzy type of fuzzy training image under the same scene and preset fuzzy type as input, with the corresponding fuzzy type of reconstruction fuzzy image as output, train the image generation network based on GAN, obtain image generation model;Then real no fuzzy image and target reference data are input into image generation model, generate target reconstruction fuzzy image, again delete target reconstruction fuzzy image with the structure similarity lower than set threshold value.This application can obtain various different types and different scenes of fuzzy image by image generation model, so as to enrich test case, solve the problem that existing technology cannot meet the completeness requirement of test and the frequency of obtained image is low and difficult to reproduce in real environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of train positioning technology, and in particular to a method and system for generating test cases for train visual positioning in motion-fuzzy scenarios. Background Technology

[0002] Train positioning is a crucial and critical technology in train operation control systems. Accurate, safe, and highly reliable train positioning technology is fundamental to ensuring safe train operation, maximizing efficiency, and providing optimal service.

[0003] Traditional train positioning relies on trackside equipment such as transponders, employing a combination of onboard relative position calculation and trackside absolute position correction. This requires deploying a large number of trackside devices, resulting in high construction and maintenance costs, unknown initial train positions, and low recovery efficiency after signal failures. In recent years, with the rapid development of artificial intelligence technology, visual positioning methods based on deep learning image recognition have become an effective means and a growing trend for train positioning. Currently, vision-based train positioning primarily involves training deep neural network models to recognize image information (such as extracting environmental image features or detecting and recognizing visual labels) and acquiring real-time position information to achieve accurate train positioning.

[0004] However, deep learning inherently lacks interpretability, and there's a possibility of producing erroneous results with high confidence levels, leading to serious consequences, such as the frequent accidents involving Tesla and Google self-driving cars in recent years. Train operation control systems are typical safety-critical systems, and ensuring positioning safety becomes a critical issue when applying deep learning-based train visual positioning technology to these systems. Rigorous testing can effectively expose problems and reveal potential pitfalls in the model, which is an important means of ensuring train positioning safety. Therefore, it is essential to conduct comprehensive testing of the deep learning-based visual positioning model before it is officially put into use.

[0005] One of the core issues in testing deep learning models for train visual localization is how to generate complete test images as test cases. In train visual localization testing, test images obtained from real-world environments suffer from uneven distribution, poor diversity, and high similarity. Directly using these images as test cases results in weak ability to expose problems and fails to meet the completeness requirements of the test. Typical scenarios that easily lead to train visual localization errors involve complex image interference, occur infrequently in real-world environments, and are difficult to reproduce.

[0006] Therefore, there is an urgent need in this field for a technical solution that can provide images that meet the completeness requirements of testing and reflect the real environment. Summary of the Invention

[0007] The purpose of this invention is to provide a method and system for generating test cases for train visual positioning. The method trains a GAN-based image generation network using real-world images of the train's surrounding environment to obtain an image generation model. The image generation model then generates blurred images and corresponding blur types based on the original unblurred images, thereby enabling the generation of various types and scenarios of blurred images. This solves the problems in existing technologies that fail to meet the completeness requirements of testing and that the obtained images have a low frequency of occurrence in real-world environments and are difficult to reproduce.

[0008] To achieve the above objectives, the present invention provides the following solution:

[0009] A method for generating test cases for train visual positioning, the method comprising:

[0010] Acquire images of the real-world environment surrounding the train;

[0011] The real environment images are classified according to their blur type to obtain several types of blur training images;

[0012] The image generation model is obtained by training an image generation network based on GAN, using an unblurred training image, a blurred training image of any blur type in the same scene, and a preset blur type as inputs, and reconstructing a blurred image and its corresponding blur type as outputs. The scene of the reconstructed blurred image is the same as the scene of the unblurred training image, and the blur type of the reconstructed blurred image is the same as the blur type of the blurred training image or the preset blur type.

[0013] The image generation model is input with a real unblurred image and target reference data to generate a target reconstructed blurred image and its corresponding blur type; the target reference data is a reference blurred image or a specified blur type; the reference blurred image is a blurred image with the same scene as the real unblurred image.

[0014] Calculate the structural similarity between the reconstructed blurred image of the target and the real unblurred image;

[0015] The target image with a structural similarity lower than a set threshold is reconstructed and then deleted to obtain test cases.

[0016] In some embodiments, the blur type includes blur angle and blur intensity.

[0017] In some embodiments, the step of training a GAN-based image generation network to obtain an image generation model, using an unblurred training image, a blurred training image of any blur type in the same scene, and a preset blur type as input, and reconstructing a blurred image and its corresponding blur type as output, specifically includes:

[0018] An unblurred training image T and a blurred training image R of any blur type in the same scene are input into a GAN-based image generation network; the GAN-based image generation network includes: a deconstructor, an encoder, a reconstructor, a discriminator, and an optimizer;

[0019] The content encoding Tc and fuzzy type encoding Tb of the unfuzzy training image T, and the content encoding Rc and fuzzy type encoding Rb of the fuzzy training image R are obtained using the destructor.

[0020] Set the preset fuzzy type I;

[0021] The encoder is used to map random noise into a fuzzy type code Ib that conforms to the preset fuzzy type I;

[0022] The reconstruction device is used to perform self-reconstruction and cross-reconstruction on the content encoding Tc and fuzzy type encoding Tb of the unfuzzy training image T, the content encoding Rc and fuzzy type encoding Rb of the fuzzy training image R, and the fuzzy type encoding Ib of the preset fuzzy type I, to obtain the reconstruction result.

[0023] The reconstruction result, the unambiguous training image T, and the ambiguous training image R are input into the discriminator to obtain the discrimination result;

[0024] Based on the discrimination results, calculate each loss function and perform backpropagation to obtain the gradient of the image generation network parameters;

[0025] The image generation network parameters are optimized using an optimizer based on the gradient, and the image generation model is obtained iteratively.

[0026] In some embodiments, the step of using the reconstructor to perform self-reconstruction and cross-reconstruction on the content code Tc and fuzzy type code Tb of the unfuzzy training image T, the content code Rc and fuzzy type code Rb of the fuzzy training image R, and the fuzzy type code Ib of the preset fuzzy type I to obtain a reconstruction result specifically includes:

[0027] The content encoding Tc and the fuzzy type encoding Tb of the unfuzzy training image T are input into the reconstructor for self-reconstruction to obtain the unfuzzy self-reconstructed image RebT.

[0028] The content encoding Rc and the fuzzy type encoding Rb of the fuzzy training image R are input into the reconstructor for self-reconstruction to obtain the fuzzy self-reconstructed image RebR.

[0029] The content encoding Tc of the unambiguous training image T and the fuzzy type encoding Rb of the fuzzy training image R are input into the reconstructor for cross-reconstruction to obtain the first cross-reconstructed image CrossT1.

[0030] The content encoding Tc of the unambiguous training image T and the fuzzy type encoding Ib of the preset fuzzy type I are input into the reconstructor for cross-reconstruction to obtain the second cross-reconstructed image CrossT2.

[0031] In some embodiments, calculating the loss functions based on the discrimination result specifically includes:

[0032] Calculate the reconstruction loss Loss(Reb) = 0.5 * (L1Loss(T, RebT) + L1Loss(R, RebR)); where L1Loss() is the basic loss function, RebT represents the unblurred self-reconstructed image, and RebR represents the blurred self-reconstructed image.

[0033] The discrimination loss Loss(Dis) is calculated as follows: Loss(Dis) = 0.25 * (L1Loss(Dis(T), Dis(RebT)) + L1Loss(Dis(R), Dis(RebR)) + L1Loss(Dis(R), Dis(CrossT1)) + L1Loss(I, Dis(CrossT2))); where Dis(T) is the discrimination result of the unfuzzy training image T, Dis(R) is the discrimination result of the fuzzy training image R, Dis(RebT) is the discrimination result of the unfuzzy self-reconstructed image, Dis(RebR) is the discrimination result of the fuzzy self-reconstructed image, Dis(CrossT1) is the discrimination result of the first cross-reconstructed image, and Dis(CrossT2) is the discrimination result of the second cross-reconstructed image.

[0034] In some embodiments, the step of inputting a real unblurred image and target reference data into the image generation model to generate a target reconstructed blurred image and the corresponding blur type specifically includes:

[0035] When the input is a real unblurred image and a reference blurred image, the reference blurred image is deconstructed by the deconstructor of the image generation model to obtain the first reference blurred type code;

[0036] The real, unblurred image is deconstructed using the deconstructor of the image generation model to obtain the real image content encoding;

[0037] By fusing the first reference blur type encoding and the real image content encoding through the reconstructor of the image generation model, a target reconstructed blur image with the same scene as the real unblurred image and the same blur type as the reference blur image is obtained.

[0038] The blur type of the target reconstructed blurred image is obtained through the discriminator of the image generation model;

[0039] When the input is a real, unblurred image and a specified blur type, a second reference blur type code is obtained based on the specified blur type.

[0040] The real, unblurred image is deconstructed using the deconstructor of the image generation model to obtain the real image content encoding;

[0041] By fusing the second reference blur type encoding and the real image content encoding through the reconstructor of the image generation model, a target reconstructed blur image with the same scene as the real unblurred image and the blur type is the specified blur type is obtained;

[0042] The blur type of the target reconstructed blurred image is obtained by the discriminator of the image generation model.

[0043] In some embodiments, the formula for calculating the structural similarity is:

[0044]

[0045] Where, μ x μ y σ is the average pixel value between the generated blurred image x and the real unblurred image y. x σ y W1 and W2 are constants set to prevent system instability when the denominator approaches 0. The standard deviation between the generated target reconstructed blurred image x and the real unblurred image y is the standard deviation between the target reconstructed blurred image x and the real unblurred image y.

[0046] In some embodiments, after deleting the target reconstructed blurry image with a structural similarity lower than a set threshold to obtain test cases, the method further includes:

[0047] Input the test cases into the visual positioning model of the train under test;

[0048] If the train visual positioning model can correctly identify the image information of the test case and correctly achieve train positioning, the test passes; otherwise, the test fails.

[0049] In some embodiments, classifying the real-world environment image according to blur type to obtain several blur training images of different blur types specifically includes:

[0050] The cepstral method is used to calculate the blur type of the real environment image;

[0051] Based on the fuzziness type, the real environment image is classified into several fuzziness types as fuzzy training images.

[0052] The present invention also provides a train visual positioning test case generation system, the system comprising:

[0053] The image acquisition unit is used to acquire images of the real environment surrounding the train;

[0054] A fuzzy classification unit is used to classify the real environment image according to the fuzziness type to obtain fuzzy training images of several fuzziness types;

[0055] The model training unit is used to train a GAN-based image generation network by taking an unblurred training image, a blurred training image of any blur type in the same scene, and a preset blur type as inputs, and reconstructing a blurred image and its corresponding blur type as outputs, to obtain an image generation model; the scene of the reconstructed blurred image is the same as the scene of the unblurred training image, and the blur type of the reconstructed blurred image is the same as the blur type of the blurred training image or the same as the preset blur type.

[0056] An image generation unit is used to input a real unblurred image and target reference data into the image generation model to generate a target reconstructed blurred image and a corresponding blur type; the target reference data is a reference blurred image or a specified blur type; the reference blurred image is a blurred image with the same scene as the real unblurred image.

[0057] A similarity calculation unit is used to calculate the structural similarity between the reconstructed blurred image of the target and the real unblurred image;

[0058] An image filtering unit is used to delete blurred images of targets with structural similarity below a set threshold, thereby obtaining test cases.

[0059] According to specific embodiments provided by the present invention, the present invention discloses the following technical effects:

[0060] This invention provides a method and system for generating test cases for train visual positioning. It acquires real-world images of the environment surrounding the train and classifies them according to fuzziness type. Using unfuzzy training images, fuzzy training images of any fuzziness type in the same scene, and preset fuzziness types as inputs, and reconstructed fuzzy images and their corresponding fuzziness types as outputs, a GAN-based image generation network is trained to obtain an image generation model. Then, real unfuzzy images and target reference data are input into the image generation model to generate target reconstructed fuzzy images and their corresponding fuzziness types. Structural similarity is calculated, and target reconstructed fuzzy images with structural similarity below a set threshold are deleted. This invention utilizes real-world images of the train's surrounding environment to train a GAN-based image generation network, obtaining an image generation model. This model generates various types and scenarios of fuzzy images, enriching the test cases and solving the problems of existing technologies failing to meet the completeness requirements of testing and the low frequency and difficulty in reproducing images in real-world environments. Attached Figure Description

[0061] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0062] Figure 1 The flowchart shows the train visual positioning test case generation method provided in Embodiment 1 of the present invention.

[0063] Figure 2 This is a schematic diagram of an image reconstruction process based on content space and fuzziness type, provided in Embodiment 1 of the present invention.

[0064] Figure 3 This is a schematic diagram illustrating the logical relationships between the modules in the GAN-based image generation network provided in Embodiment 1 of the present invention.

[0065] Figure 4 This is a schematic diagram of the framework structure of the GAN-based image generation network provided in Embodiment 1 of the present invention.

[0066] Figure 5 A detailed flowchart of the train visual positioning test case generation method provided in Embodiment 1 of the present invention.

[0067] Figure 6 This is a block diagram of the train visual positioning test case generation system provided in Embodiment 2 of the present invention. Detailed Implementation

[0068] 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.

[0069] The purpose of this invention is to provide a method and system for generating test cases for train visual positioning. The method trains a GAN-based image generation network using real-world images of the train's surrounding environment to obtain an image generation model. The image generation model then generates blurred images and corresponding blur types based on the original unblurred images, thereby enabling the generation of various types and scenarios of blurred images. This solves the problems in existing technologies that fail to meet the completeness requirements of testing and that the obtained images have a low frequency of occurrence in real-world environments and are difficult to reproduce.

[0070] This invention first collects real-world images of trains in operation, analyzes the train operation scene, selects unblurred images as original images, and selects typical blurred images as reference images. Then, from the perspective of image style transfer, it constructs and trains a GAN-based image generation model. Taking the original and reference images as input, it transforms the normal, unblurred images of train operation into images with blur interference. Next, a structural similarity analysis algorithm is used to filter the generated images, removing those that have lost their practical meaning due to overly drastic image transformations, resulting in the final test cases. Using the test cases generated by this invention as input to the model, a train visual localization model based on deep learning technology is tested. This effectively exposes potential problems and hidden dangers in the model, providing guidance and a basis for model developers to improve the model. This invention designs a method for artificially generating test images based on the idea of ​​image-to-image translation. Taking the case of motion blur in images captured due to high-speed train movement as an example, it designs a GAN-based image generation network and obtains the image generation model through iterative training. In train visual positioning testing, an unblurred image is used as the original image, and a specified blurred scene is used as the reference image. By inputting these two images into the model, an image with the same scene as the original image and the same blur type as the reference image can be output as a test case. This solves the problem of difficulty and inefficiency in directly obtaining images of interfering scenes from the natural real environment.

[0071] The full names and specific meanings of some of the English abbreviations used in this invention are as follows:

[0072]

[0073]

[0074] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0075] Example 1:

[0076] like Figure 1As shown, this invention provides a method for generating test cases for train visual positioning. Currently, utilizing computer vision to achieve train positioning is a technological development direction for rail transit. This method uses high-speed cameras and other equipment to collect images of the surrounding environment in real time during train operation. Then, it uses a visual positioning model (generally based on YOLO target detection models, CNN convolutional neural network models, etc.) to perform target recognition or feature matching. After recognizing the image information to obtain the relative or absolute position information of the train, it performs comprehensive processing and calculation to obtain the train's current precise position (the visual positioning model is the object of this patent's testing, but not the inventive point of this patent).

[0077] The visual positioning model needs to accurately identify image information under various complex environmental conditions. The quality of the model directly affects the accuracy and safety of train positioning results, so it needs to be thoroughly tested.

[0078] When a train is traveling at high speed, there is relative motion between the camera and the subject being photographed, and the onboard camera equipment also vibrates, resulting in varying degrees of blurring in the captured images. In such scenarios, the train's visual positioning model is prone to misidentification of images captured by the image acquisition equipment.

[0079] This embodiment designs a method for artificially generating blurred test images based on the concept of image-to-image translation. First, a GAN-based image generation network is designed and trained iteratively to obtain the image generation model. In train visual positioning testing, a blur-free image captured from a real scene is used as the original image, and a specified blurred scene is used as the reference image. These two images are input into the model, which outputs an image with the same content as the original image and the same blur type as the reference image, serving as the test case.

[0080] The train visual positioning test case generation method provided in this embodiment specifically includes:

[0081] S1. Obtain images of the real environment surrounding the train.

[0082] S2. Classify the real environment images according to the blur type to obtain several blur training images of different blur types.

[0083] This embodiment constructs a real-environment image library. Using a high-speed camera mounted on the train's cab (or other image acquisition methods), images of the surrounding real environment during train operation are captured and classified according to different blur types (blur angle, blur intensity) to construct the real-environment image library. Various methods can be used to classify the blur types of the captured images. This embodiment uses the cepstral method to calculate and classify the blur types of the images, with the following steps:

[0084] The acquired images of the surrounding real environment are converted to grayscale, and their two-dimensional Fourier transforms are calculated.

[0085] Take the logarithm of the Fourier transform, calculate its square, and then perform an inverse Fourier transform to obtain its cepstral spectrum.

[0086] The cepstral plot is dynamically compressed and cyclically shifted to center its low-frequency components.

[0087] The Canny operator is used to perform edge detection and binarization on the compressed and centered spectral image to obtain a binarized spectral image. The compressed and centered spectral image is then inverted to obtain the dark channel image.

[0088] Calculate the Radon transform of the binarized spectrum from 1° to 180°, find the maximum value in the matrix after the Radon transform, and the corresponding column number ±90° is the desired blur angle.

[0089] Binarize the dark channel image to obtain the dark channel skeleton map, calculate the distance d between the two skeletons at the center of the image, and let the image height be H, then the blur intensity = (2*H) / d.

[0090] After obtaining the blur angle and blur intensity of the image, n threshold ranges are set, and images with blur type values ​​within the same range are classified into one category, ultimately resulting in n categories of images with different blur types.

[0091] After classification, all unblurred images in the image library can be used as original images in subsequent steps, while other images with motion blur can be used as reference images. This image library also serves as training samples for the blurred image generation network in subsequent steps.

[0092] S3. Using an unblurred training image, a blurred training image of any blur type within the same scene, and a preset blur type as input, and a reconstructed blurred image and its corresponding blur type as output, train a GAN-based image generation network to obtain an image generation model. The scene of the reconstructed blurred image is the same as the scene of the unblurred training image, and the blur type of the reconstructed blurred image is the same as the blur type of the blurred training image or the preset blur type. Here, "within the same scene" means that the blurred training image and the unblurred training image are in the same scene.

[0093] In this embodiment, a GAN-based image generation network is first designed, and then trained to obtain an image generation model. The specific steps for designing the GAN-based image generation network include:

[0094] First, we provide basic definitions as the principle for subsequent network construction. An image T is defined as being represented by a binary tuple (C, B), where C is the original content space of the image, and B is the blur type of the image. Different images can share the original content space (tunnel environment, railway tracks, signal lights, kilometer markers, etc.) but have different blur types. Combining the same content space with different blur types generates diverse blurred images, thereby improving the completeness of test cases, such as... Figure 2 As shown.

[0095] Based on the above definitions, a GAN-based image generation network is constructed to convert original images into blurred images. This network mainly consists of four modules: encoder, deconstructor, reconstructor, and discriminator. The logical relationships between the modules in the image generation network are as follows: Figure 3 As shown.

[0096] The specific structure and functions of each module are described below:

[0097] ① Encoder

[0098] Input: Random noise and the specified image blur type.

[0099] Output: The blur type code corresponding to the specified image blur type.

[0100] The encoder is composed of a six-layer MLP fully connected network with multiple output branches. It effectively learns style representations for all fuzzy types by randomly sampling latent vectors, producing different fuzzy type codes.

[0101] ② Deconstructor

[0102] Input: Original image or reference image. In this embodiment, when training the model, the original image is an unblurred training image, and the reference image is a blurred training image; when generating images using the trained image generation model, the original image is a real unblurred image, and the reference image is a reference blurred image.

[0103] Output: The blur type encoding and image content encoding of the image.

[0104] A deconstructor is built using four downsampling layers and a convolutional neural network with n output branches, where n represents the number of fuzzy types. First, downsampling is used to reduce the dimensionality of the image while preserving effective information. Then, convolutional layers extract typical fuzzy features and content features of the image. Finally, a fully connected layer is connected to obtain the fuzzy type encoding and image content encoding. In this embodiment, the image content encoding format is a multidimensional tensor (array) corresponding to the basic content of the image (tunnel environment, railway tracks, signal lights, and kilometer markers, etc.), which can be understood as a mapping. The fuzzy type encoding follows the same principle.

[0105] ③ Reconstructor

[0106] Input: Image content encoding and fuzzy type encoding.

[0107] Output: A reconstructed image with fuzzy type encoding corresponding to the fuzzy type and content encoding corresponding to the image content.

[0108] A four-layer MLP network is used to extract fuzzy type coding features, and four residual layers are used to extract image content coding features. The AdaIN algorithm is used in the normalization stage to fuse the fuzzy type coding and the fuzzy type coding. Finally, four upsampling layers are connected to form a reconstructor to reconstruct a new image with the same size as the original image.

[0109] ④ Discriminator

[0110] Input: The reconstructed image generated by the reconstructor.

[0111] Output: Whether the image is a real image and its corresponding blur type.

[0112] A discriminator is constructed using two convolutional layers and six residual layers. The output is a multi-branch structure, with each branch corresponding to a fuzzy type. Binary classification is used to determine whether an image belongs to that fuzzy type. The specific framework structure of the image generation network is as follows: Figure 4 As shown.

[0113] Then, images of different blur types are selected from the aforementioned real-world image library to construct a model training set. A corresponding loss function is designed to constrain and guide the parameter update direction. The neural network model is trained using gradient descent to obtain the image generation model. During training, the images must be in the same scene. The model uses a training set consisting of an original image set and n image sets with different blur types. During each iteration of model training, one original image and one blurred image (selected sequentially from the n different blur type image sets) are read in and used as input.

[0114] Specifically, in this embodiment, the unblurred training image, a blurred training image of any blur type in the same scene, and a preset blur type are used as inputs, and the reconstructed blurred image and its corresponding blur type are used as outputs to train a GAN-based image generation network to obtain an image generation model, specifically including:

[0115] Step 1: Input the unblurred training image T and the blurred training image R of any blur type in the same scene into the GAN-based image generation network; the GAN-based image generation network includes: deconstructor, encoder, reconstructor, discriminator and optimizer.

[0116] Step 2: Use the destructor to obtain the content code Tc and fuzzy type code Tb of the unfuzzy training image T, and the content code Rc and fuzzy type code Rb of the fuzzy training image R.

[0117] Step 3: Set the preset fuzzy type I. In this embodiment, I is a specific fuzzy type value, which is selected sequentially from the range of fuzzy types for the subsequent reconstruction training process.

[0118] Step 4: Use the encoder to map random noise into a fuzzy type code Ib that conforms to the preset fuzzy type I.

[0119] Step 5: Using the reconstructor, perform self-reconstruction and cross-reconstruction on the content encoding Tc and fuzzy type encoding Tb of the unfuzzy training image T, the content encoding Rc and fuzzy type encoding Rb of the fuzzy training image R, and the fuzzy type encoding Ib of the preset fuzzy type I to obtain the reconstruction result.

[0120] In this embodiment, the content encoding Tc and fuzzy type encoding Tb of the unfuzzy training image T are input into the reconstructor to perform self-reconstruction to obtain the unfuzzy self-reconstructed image RebT.

[0121] The content encoding Rc and fuzzy type encoding Rb of the fuzzy training image R are input into the reconstructor to perform self-reconstruction and obtain the fuzzy self-reconstructed image RebR.

[0122] The content encoding Tc of the unambiguous training image T and the fuzzy type encoding Rb of the fuzzy training image R are input into the reconstructor for cross-reconstruction to obtain the first cross-reconstructed image CrossT1.

[0123] The content encoding Tc of the unambiguous training image T and the fuzzy type encoding Ib of the preset fuzzy type I are input into the reconstructor for cross-reconstruction to obtain the second cross-reconstructed image CrossT2.

[0124] Step 6: Input the reconstruction result, the unambiguous training image T, and the fuzzy training image R into the discriminator to obtain the discrimination result.

[0125] Step 7: Calculate the loss functions based on the discrimination results and perform backpropagation to obtain the gradient of the image generation network parameters.

[0126] The process of calculating each loss function in this embodiment specifically includes:

[0127] Calculate the reconstruction loss Loss(Reb) = 0.5 * (L1Loss(T, RebT) + L1Loss(R, RebR)); where L1Loss() is the basic loss function, RebT represents the unblurred self-reconstructed image, and RebR represents the blurred self-reconstructed image.

[0128] The discrimination loss Loss(Dis) is calculated as follows: Loss(Dis) = 0.25 * (L1Loss(Dis(T), Dis(RebT)) + L1Loss(Dis(R), Dis(RebR)) + L1Loss(Dis(R), Dis(CrossT1)) + L1Loss(I, Dis(CrossT2))); where Dis(T) is the discrimination result of the unfuzzy training image T, Dis(R) is the discrimination result of the fuzzy training image R, Dis(RebT) is the discrimination result of the unfuzzy self-reconstructed image, Dis(RebR) is the discrimination result of the fuzzy self-reconstructed image, Dis(CrossT1) is the discrimination result of the first cross-reconstructed image, and Dis(CrossT2) is the discrimination result of the second cross-reconstructed image.

[0129] Step 8: Use the optimizer to optimize the parameters of the image generation network according to the gradient, and iterate to obtain the image generation model.

[0130] As an optional implementation, in this embodiment, during model training, the deconstructor is responsible for deconstructing the image to obtain the image content code and fuzzy type code, while the encoder is responsible for mapping random noise into fuzzy type code. After obtaining the image content code and fuzzy type code from the above two sources, they are input into the reconstructor to reconstruct a new image. The discriminator is responsible for judging the image generated by the reconstructor, determining whether it is a real image or an image generated by the reconstructor, and giving the fuzzy type category corresponding to the image.

[0131] The specific steps for each training iteration are as follows:

[0132] D1. Deconstruct the unambiguous training images and fuzzy training images to obtain the content encoding and fuzzy encoding of these images.

[0133] D2. Reconstruct the image by combining content encoding and fuzzy encoding.

[0134] D3. Input the unblurred training image, the blurred training image, and the reconstructed image into the discriminator to obtain the blur type of each image;

[0135] D4. Using the unblurred training image, the blurred training image, and the reconstructed image, as well as the content encoding and fuzzy encoding of the unblurred training image and the blurred training image, and the fuzziness type of each image as input to the loss function, calculate the loss value for this iteration.

[0136] D5. Perform backpropagation based on the loss value to update the parameters (i.e., the connection weights and biases of all neural networks) of the deconstructor, encoder, reconstructor, and discriminator, thus completing this iteration.

[0137] The termination condition for iteration is: the number of iterations reaches M steps (which is the maximum number of iterations preset before training), or the loss value no longer decreases after N consecutive iterations (N is the preset value before training) (i.e., it reaches a local optimum).

[0138] The specific implementation method and necessary explanation of the above iterative process are as follows:

[0139] For iteration D1:

[0140] The training image R is an image with different blur types. The blur type refers to the combination of blur intensity and blur angle. Different combinations result in different blur types.

[0141] Content encoding is obtained by inputting an unfuzzy training image T and a fuzzy training image R into the deconstructor. The content encodings obtained from these two types of images are denoted as Tc and Rc, respectively.

[0142] Fuzzy type encoding is obtained in two ways:

[0143] ① Input T and R into the deconstructor to obtain the fuzzy type codes of the two types of images, denoted as Tb and Rb respectively; ② Preset the specified fuzzy type (denoted as I), and the encoder maps random noise to fuzzy type code Ib that conforms to I according to I.

[0144] For iteration D2: self-reconstruction and cross-reconstruction are performed on the obtained image content encoding and fuzzy type encoding. The specific steps are as follows:

[0145] a) Input Tc and Tb into the reconstructor to perform self-reconstruction and obtain the self-reconstructed image RebT of the original image.

[0146] b) Input Rc and Rb into the reconstructor to perform self-reconstruction and obtain the self-reconstructed image RebR of the reference image.

[0147] c) Input Tc and Rb into the reconstructor to perform cross-reconstruction to obtain the cross-reconstructed image CrossT1.

[0148] d) Input Tc and Ib into the reconstructor to perform cross-reconstruction to obtain the cross-reconstructed image CrossT2.

[0149] For iteration D3: Input T, R, RebT, RebR, CrossT1, and CrossT2 into the discriminator to obtain Dis(T), Dis(R), Dis(RebT), Dis(RebR), Dis(CrossT1), and Dis(CrossT2).

[0150] For iteration D4: Calculate the loss function for each term, where L1Loss() is the basic loss function, which calculates the mean absolute error between each element in the input x and the target y. The specific steps and formulas are as follows:

[0151] a) Reconstruction loss Loss(Reb) = 0.5 * (L1Loss(T, RebT) + L1Loss(R, RebR)); The goal is to restore the original image to its original state as much as possible after passing through the deconstructor and reconstructor.

[0152] b) The discrimination loss Loss(Dis) = 0.25*(L1Loss(Dis(T), Dis(RebT)) + L1Loss(Dis(R), Dis(RebR)) + L1Loss(Dis(R), Dis(CrossT1)) + L1Loss(I, Dis(CrossT2))) is intended to make the generated fake image as similar as possible to the original real image.

[0153] For iteration D5: calculate the error of each loss function and backpropagate it to update the parameters of each deconstructor, encoder, reconstructor, and discriminator; through multiple iterations, finally determine the optimal parameters of each module to achieve dynamic equilibrium and obtain the trained image generation model.

[0154] The general principle of deep learning model training is as follows (taking PyTorch framework as an example):

[0155] First, a loss function, criterion, is defined. Then, in each iteration, the error of the loss function is calculated to obtain the loss value, loss. Next, backpropagation of the error is performed using loss.backward (this function automatically calculates the gradient of each parameter using PyTorch's internal mechanism). After obtaining the gradient of each parameter through backpropagation of loss, an optimizer (an optimization algorithm; in PyTorch, torch.optim is a package that implements various optimization algorithms and can be called directly) is defined. The parameters that need to be updated (the connection weights and biases of all neural networks in the aforementioned four modules) are passed to the optimizer. The optimizer calculates the updated parameter values ​​using the optimization algorithm, thus completing one round of training iteration.

[0156] During model training, a maximum number of iterations is typically set manually, and training stops when this number is reached. However, this method requires manual tuning based on experience (setting different training steps, optimizing algorithms, loss functions, etc.) through multiple training iterations, and then determining which training result to use as the final model parameters. Alternatively, a maximum number of iterations can be manually defined, and an early stopping parameter k can be set. After each training iteration, the total loss value is evaluated. If the loss value does not decrease after k consecutive iterations, the model is considered to have converged, and training ends even if the maximum number of iterations has not been reached (the value of k also needs to be determined manually based on experience through multiple training experiments to find the most suitable value, therefore a universally applicable value cannot be given). This embodiment uses the second method.

[0157] S4. Input the real unblurred image and the target reference data into the image generation model to generate a target reconstructed blurred image and the corresponding blur type; the target reference data is a reference blurred image or a specified blur type; the reference blurred image is a blurred image with the same scene as the real unblurred image.

[0158] Input the real unblurred image and the reference blurred image from the real environment image library above into the image generation model. The model retains the content of the real unblurred image, absorbs the style of the reference blurred image, and generates a target reconstructed blurred image with the same blur type as the reference blurred image. Alternatively, you can not specify the reference blurred image, but only specify the blur type and input the real unblurred image into the image generation model, which will also generate a target reconstructed blurred image that conforms to the specified blur type.

[0159] Specifically, there are two situations:

[0160] In the first case, when the input is a real unblurred image and a reference blurred image, the reference blurred image is deconstructed by the deconstructor of the image generation model to obtain the first reference blurred type code.

[0161] The image generation model deconstructs the real, unblurred image to obtain the real image content encoding.

[0162] The image generation model's reconstructor fuses the first reference blur type encoding and the real image content encoding to reconstruct a target reconstructed blurry image that has the same scene as the real unblurred image and the same blur type as the reference blurry image.

[0163] The blur type of the target reconstructed blurred image is obtained through the discriminator of the image generation model;

[0164] In the second case, when the input is a real unblurred image and a specified blur type, the encoder of the image generation model obtains a second reference blur type code based on the specified blur type (by mapping a random vector to the specified blur type to obtain the corresponding blur type code).

[0165] The image generation model deconstructs the real, unblurred image to obtain the real image content encoding.

[0166] By fusing the second reference blur type encoding and the real image content encoding through the reconstructor of the image generation model, a target reconstructed blur image with the same scene as the real unblurred image and the blur type being the specified blur type is obtained.

[0167] The blur type of the target reconstructed blurred image is obtained by the discriminator of the image generation model.

[0168] S5. Calculate the structural similarity between the target reconstructed blurred image and the real unblurred image;

[0169] The formula for calculating structural similarity is:

[0170]

[0171] Where, μ x μ y σ is the average pixel value of the generated target reconstructed blurred image x and the real unblurred image y (the average pixel value of all pixels in the image), x σ y σ is the standard deviation (the standard deviation between the image pixel value matrices) between the generated target reconstructed blurred image x and the real unblurred image y. xy W1 and W2 are constants set to prevent system instability when the denominator tends to 0, representing the covariance between the generated target reconstructed blurred image x and the real unblurred image y.

[0172] S6. Delete the target reconstructed blurry image whose structural similarity is lower than the set threshold to obtain test cases.

[0173] According to the test requirements, a filtering threshold α is set (in this embodiment, any integer between (0, 10) is selected). If the structural similarity between the generated target reconstructed blurred image x and the real unblurred image y is lower than the filtering threshold α, it is considered that the structure of the target reconstructed blurred image x has a significant change and distortion compared with the real unblurred image y, and it is removed; all images with similarity higher than the threshold are retained.

[0174] Then, the test cases are input into the visual positioning model of the train under test; if the visual positioning model of the train can correctly identify the image information of the test cases and correctly achieve train positioning, the test passes (the tested object is qualified); otherwise, the test fails (the test fails because the tested object has a defect and does not meet the requirements, and this defect has been discovered by the test).

[0175] In this embodiment, after obtaining the test cases, the test cases are combined and selected based on the expected output to determine the final test cases. The specific numerical values ​​of the fuzziness type (fuzziness angle, fuzziness intensity) of the test cases are obtained, and it is determined whether they fall within a given threshold range. If so, the expected output is assigned as {true, image information (e.g., the content of kilometer markers in the image)}; otherwise, the expected output is assigned as {empty}. If the test objective is to test the accuracy of the model, all candidate test cases with expected outputs of true are selected as the final test cases. If the test objective is to test the false recognition rate of the model, some candidate test cases with expected outputs of empty can be added as the final test cases.

[0176] The test was conducted using the final test cases described above. The final test cases were input into the train visual positioning model under test, and the model's output was collected. If the test case expected the output to be {true, image information}, and the model correctly identified the image information (e.g., visual labels, key point features, etc.) and correctly achieved train positioning, the test passed. If the model failed to correctly identify the image information, resulting in incorrect train positioning or inability to position the train, the test failed. If the test case expected the output to be {empty}, and the model provided an empty result, the test passed. If the model provided a result (which must be an incorrect result), the test failed. Based on the test results, the safety and reliability of the train visual positioning model under test can be further improved, and the applicable scope of the train visual positioning model can also be clarified.

[0177] The train visual positioning test case generation method provided in this embodiment has the following detailed flowchart: Figure 5 The generated test cases are highly complete and can effectively expose potential errors in the visual positioning model of the tested train when faced with varying degrees of fuzziness interference, identifying hidden dangers before accidents occur. After the model is trained, the same original image can be converted to different fuzziness types by inputting reference images of different fuzzy scenarios, enhancing data diversity and making it easier for the model to make positioning errors, thus effectively exposing potential problems in the model.

[0178] This embodiment boasts high test case generation efficiency. Motion blurring in captured images due to high-speed train movement is a typical scenario in train operation, easily leading to train visual positioning errors. This embodiment can quickly generate test cases with such interference. Compared to manual methods that require setting up, searching, collecting, and filtering in a real environment, this method can generate test images for specified blurred scenes, thus improving efficiency.

[0179] This embodiment generates test cases at a low cost, requiring only a small number of samples to generate a large number of test cases. For the visual positioning task of subway trains, after training the initial model, a large number of images can be quickly generated as test cases from a small number of original seed images by setting different parameters, demonstrating strong reusability and data augmentation capabilities. Manual methods, on the other hand, require building real trains, tracks, tunnels, signal lights, etc., as the test environment, which is more costly. Furthermore, this embodiment also allows for manually constructing rules, modifying image pixel values ​​according to the characteristics of different blurred scenes to generate images that meet the requirements as test cases.

[0180] Example 2:

[0181] like Figure 6 As shown, this embodiment provides a train visual positioning test case generation system, which includes:

[0182] Image acquisition unit M1 is used to acquire images of the real environment around the train.

[0183] The fuzzy classification unit M2 is used to classify the real environment image according to the fuzzy type to obtain fuzzy training images of several fuzzy types.

[0184] The model training unit M3 is used to train a GAN-based image generation network by taking the unblurred training image, a blurred training image of any blur type in the same scene, and a preset blur type as input, and reconstructing the blurred image and the corresponding blur type as output, to obtain an image generation model; the scene of the reconstructed blurred image is the same as the scene of the unblurred training image, and the blur type of the reconstructed blurred image is the same as the blur type of the blurred training image or the preset blur type.

[0185] The image generation unit M4 is used to input the real unblurred image and the target reference data into the image generation model to generate a target reconstructed blurred image and the corresponding blur type; the target reference data is a reference blurred image or a specified blur type; the reference blurred image is a blurred image with the same scene as the real unblurred image.

[0186] The similarity calculation unit M5 is used to calculate the structural similarity between the target reconstructed blurred image and the real unblurred image.

[0187] The image filtering unit M6 is used to delete the target reconstructed blurry image with a structural similarity lower than a set threshold to obtain test cases.

[0188] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.

[0189] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for generating test cases for train visual positioning, characterized in that, The method comprises: acquiring a real environment image around a train; classifying the real environment image according to a blur type to obtain blur training images of several blur types; training a GAN-based image generation network by taking a non-blur training image, a blur training image of any blur type under the same scene and a preset blur type as input and taking a reconstructed blur image and a corresponding blur type as output to obtain an image generation model; the scene of the reconstructed blur image is the same as that of the non-blur training image, and the blur type of the reconstructed blur image is the same as that of the blur training image or the same as the preset blur type; inputting a real non-blur image and target reference data into the image generation model to generate a target reconstructed blur image and a corresponding blur type; the target reference data is a reference blur image or a specified blur type; the reference blur image is a blur image with the same scene as the real non-blur image; calculating a structural similarity between the target reconstructed blur image and the real non-blur image; deleting the target reconstructed blur image with a structural similarity lower than a set threshold to obtain a test case.

2. The train visual localization test case generation method of claim 1, wherein, The blur type comprises a blur angle and a blur intensity.

3. The method of claim 1, wherein, The training of the GAN-based image generation network by taking the non-blur training image, the blur training image of any blur type under the same scene and the preset blur type as input and taking the reconstructed blur image and the corresponding blur type as output to obtain the image generation model specifically comprises: inputting the non-blur training image T and the blur training image R of any blur type under the same scene into the GAN-based image generation network; the GAN-based image generation network comprises a deconstructor, an encoder, a reconstructor, a discriminator and an optimizer; obtaining content encoding Tc and blur type encoding Tb of the non-blur training image T and content encoding Rc and blur type encoding Rb of the blur training image R by using the deconstructor; setting a preset blur type I; mapping random noise into blur type encoding Ib conforming to the preset blur type I by using the encoder; performing self-reconstruction and cross-reconstruction on the content encoding Tc and the blur type encoding Tb of the non-blur training image T, the content encoding Rc and the blur type encoding Rb of the blur training image R and the blur type encoding Ib of the preset blur type I by using the reconstructor to obtain a reconstruction result; inputting the reconstruction result, the non-blur training image T and the blur training image R into the discriminator to obtain a discrimination result; calculating loss functions according to the discrimination result and performing back propagation to obtain a gradient of image generation network parameters; optimizing the image generation network parameters according to the gradient by using the optimizer to iteratively obtain an image generation model.

4. The method of claim 3, wherein, The self-reconstruction and cross-reconstruction on the content encoding Tc and the blur type encoding Tb of the non-blur training image T, the content encoding Rc and the blur type encoding Rb of the blur training image R and the blur type encoding Ib of the preset blur type I by using the reconstructor to obtain the reconstruction result specifically comprises: Input the content encoding Tc and the blur type encoding Tb of the non-blur training image T into the reconstructor for self-reconstruction to obtain a non-blur self-reconstruction image RebT; Input the content encoding Rc and the blur type encoding Rb of the blur training image R into the reconstructor for self-reconstruction to obtain a blur self-reconstruction image RebR; Input the content encoding Tc of the non-blur training image T and the blur type encoding Rb of the blur training image R into the reconstructor for cross-reconstruction to obtain a first cross-reconstruction image CrossT1; Input the content encoding Tc of the non-blur training image T and the blur type encoding Ib of the preset blur type I into the reconstructor for cross-reconstruction to obtain a second cross-reconstruction image CrossT2.

5. The method of claim 3, wherein, The calculation of each loss function according to the discrimination result specifically includes: calculating a reconstruction loss Loss(Reb) = 0.5*(L1Loss(T, RebT) + L1Loss(R, RebR)); wherein L1Loss() is a basic loss function, RebT represents a non-blur self-reconstruction image, and RebR represents a blur self-reconstruction image; calculating a discrimination loss Loss(Dis) = 0.25*(L1Loss(Dis(T), Dis(RebT)) + L1Loss(Dis(R), Dis(RebR)) + L1Loss(Dis(R), Dis(CrossT1)) + L1Loss(I, Dis(CrossT2))); wherein Dis(T) is the discrimination result of the non-blur training image T, Dis(R) is the discrimination result of the blur training image R, Dis(RebT) is the discrimination result of the non-blur self-reconstruction image, Dis(RebR) is the discrimination result of the blur self-reconstruction image, Dis(CrossT1) is the discrimination result of the first cross-reconstruction image, and Dis(CrossT2) is the discrimination result of the second cross-reconstruction image.

6. The method of claim 1, wherein, The input of the real non-blur image and the target reference data into the image generation model generates a target reconstruction blur image and a corresponding blur type, and specifically includes: when the input is a real non-blur image and a reference blur image, a first reference blur type encoding is obtained by deconstructing the reference blur image through the deconstructor of the image generation model; a real image content encoding is obtained by deconstructing the real non-blur image through the deconstructor of the image generation model; a target reconstruction blur image with the same scene as the real non-blur image and the same blur type as the reference blur image is reconstructed by fusing the first reference blur type encoding and the real image content encoding through the reconstructor of the image generation model; the blur type of the target reconstruction blur image is obtained through the discriminator of the image generation model; when the input is a real non-blur image and a specified blur type, a second reference blur type encoding is obtained according to the specified blur type; when the input is a real non-blur image and a specified blur type, a second reference blur type encoding is obtained according to the specified blur type; deconstructing the real un-blurred image by a deconstructor of the image generation model to obtain real image content encoding; fusing the second reference blur type encoding and the real image content encoding by a reconstructor of the image generation model to obtain a target reconstructed blurred image with the same scene as the real un-blurred image and the blur type being the specified blur type; obtaining the blur type of the target reconstructed blurred image by a discriminator of the image generation model.

7. The method of claim 1, wherein, The calculation formula of the structural similarity is: wherein μ x , μ y is the pixel mean of the generated target reconstructed blurred image x and the real unblurred image y, σ x , σ y is the standard deviation of the generated target reconstructed blurred image x and the real unblurred image y, and W1, W2 are constants set to avoid system instability when the denominator tends to 0.

8. The method of claim 1, wherein, After the target reconstructed blurred image with the structural similarity lower than the set threshold is deleted to obtain the test case, the method further includes: inputting the test case into the train visual positioning model to be tested; if the train visual positioning model can correctly identify the image information of the test case and correctly implement train positioning, the test is passed; otherwise, the test is failed.

9. The method of claim 1, wherein, The real environment image is classified according to the blur type to obtain blurred training images of several blur types, and the method specifically includes: calculating the blur type of the real environment image by using a cepstrum method; classifying the real environment image into blurred training images of several blur types according to the blur type.

10. A train visual positioning test case generation system, characterized by, The system includes: an image acquisition unit configured to acquire a real environment image around a train; a blur classification unit configured to classify the real environment image according to a blur type to obtain blurred training images of several blur types; a model training unit configured to train a GAN-based image generation network by taking an un-blurred training image, a blurred training image of any blur type under the same scene, and a preset blur type as input and taking a reconstructed blurred image and a corresponding blur type as output to obtain an image generation model; the scene of the reconstructed blurred image is the same as that of the un-blurred training image, and the blur type of the reconstructed blurred image is the same as that of the blurred training image or the same as the preset blur type; an image generation unit configured to input a real un-blurred image and target reference data into the image generation model to generate a target reconstructed blurred image and a corresponding blur type; the target reference data is a reference blurred image or a specified blur type; the reference blurred image is a blurred image with the same scene as the real un-blurred image; a similarity calculation unit configured to calculate a structural similarity between the target reconstructed blurred image and the real un-blurred image; an image screening unit configured to delete the target reconstructed blurred image with the structural similarity lower than a set threshold to obtain a test case.

Citation Information

Patent Citations

  • GAN-based face retrieval method

    CN109857879A

  • Fuzzy image synthesis method based on degradation imaging mechanism and generative adversarial mechanism

    CN110070517A