Data enhancement method and system based on digital twin and image conversion

Through digital twin technology and GAN network, high-precision, self-labeled virtual traffic pictures are generated, which solves the problem of insufficient extreme environment vehicle data sets in the existing technology, improves vehicle identification accuracy, and supports intelligent applications in smart cities.

CN114049422BActive Publication Date: 2024-10-18SHANGHAI JIAOTONG UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111332745.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-11
Publication Date
2024-10-18
Estimated Expiration
2041-11-11

AI Technical Summary

Technical Problem

Existing technology is difficult to generate sufficient, accurate, and rich extreme environment vehicle data sets in the field of image conversion, which limits the training and application of vehicle recognition neural networks, especially under different weather and lighting conditions.

Method used

A data enhancement method based on digital twins and image conversion is used to obtain video data through road test cameras, perform target recognition and three-dimensional reconstruction, use particle systems and shaders to build weather systems, randomly replace models and colors, and combine GAN networks to generate content codes and styles. code to realize picture style conversion and generate high-precision, self-labeled virtual traffic pictures.

Benefits of technology

It achieves self-labeling, high-precision, and high-degree-of-freedom traffic image generation, provides high-quality data set enhancement solutions, improves vehicle identification accuracy in extreme environments, and supports intelligent analysis and supervision applications in smart cities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114049422B_ABST
    Figure CN114049422B_ABST
Patent Text Reader

Abstract

The present invention provides a data enhancement method and system based on digital twin and image conversion, including: step S1: acquiring video data by shooting with a road test camera, identifying the 2D coordinates, vehicle model and color data of the vehicle in the video through a target recognition algorithm, and then acquiring the coordinates of the vehicle in the virtual world through a mapping function and performing three-dimensional reconstruction; step S2: obtaining the screen coordinates of the bounding box according to the coordinates of the vehicle in the virtual world and the coordinates of the camera; step S3: using a weather system constructed by a particle system and a shader, and randomly replacing the vehicle model and color to generate a virtual picture set; step S4: generating a content code c and a style code s from the virtual data set through a GAN network, and converting the picture into another style by combining different style codes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision and image conversion, and specifically, to a data enhancement method and system based on digital twin and image conversion, and more specifically, to an algorithm for converting virtual traffic scene images generated by a digital twin system into real-style images to enhance a data set. Background Art

[0002] The present invention uses digital twin transportation as the basic data source. Through digital twin technology, a virtual scene corresponding to the real scene can be generated to reproduce the vehicle in three dimensions. By changing the vehicle model, color, weather and other attributes, the generated virtual picture can almost cover all vehicles in all extreme environments and all different subcategories in the real scene. Then, through the image conversion method, the virtual scene picture is converted into a real photo style picture, so as to obtain sufficient extreme environment vehicle data for training.

[0003] At present, the information wave represented by new technologies such as cloud computing, big data, artificial intelligence, virtual reality, and driverless driving is sweeping the world, and also affecting urban planning, construction, and development. The virtual image of the city constructed in the bit space is superimposed on the physical space of the city, which will greatly change the appearance of the city, reshape the urban infrastructure, and form a new form of urban development that combines virtuality and reality and interacts with twins; with more ubiquitous and inclusive perception, faster networks, and smarter computing, a new type of smarter city will be created. As a vital part of urban management, intelligent digitalization is the development direction of future urban transportation systems.

[0004] Digital Twin is a mapping relationship between physical space and virtual space that integrates the real and the virtual and intelligently controlled. It records, simulates, and predicts the operation trajectory of the object throughout its life cycle in the physical world and digital virtual space to achieve the optimal configuration of information resources and material resources within the system. Digital Twin Transportation is a widespread application of digital twin technology at the transportation level. By constructing a complex system that corresponds one-to-one, maps to each other, and interacts collaboratively with the physical world of urban transportation and the network virtual space, a matching and corresponding twin transportation system is recreated in the cyberspace, realizing the digitization and virtualization of all elements of urban transportation, the real-time and visualization of the status, and the coordination and intelligence of management and decision-making, forming a new transportation development pattern in which the physical world in the physical dimension and the virtual world in the information dimension coexist and integrate the real and the virtual.

[0005] In recent years, with the introduction of deep autoencoders, variational autoencoders and generative adversarial networks (GAN), image generation and image-to-image domain conversion have been widely studied. This is because compared with traditional generative models, generative models based on deep neural networks are end-to-end learning methods, which do not require explicit expressions of generated distributions and eliminate the complex mathematical reasoning in traditional generative models.

[0006] In 2006, Hinton et al. used unsupervised greedy layer-by-layer training algorithm and BP algorithm to train the hidden layer and the entire neural network respectively, effectively improving the problem of training parameters falling into local optimal solutions. In 2014, Goodfellow et al. proposed a GAN based on the BP algorithm of deep neural network, which includes a generator G and a discriminator D for "maximum-minimum" game, avoiding many difficult probability calculations in maximum likelihood estimation and related algorithms, and using adversarial methods to gradually bring the generated data probability model closer to the real data probability distribution. As a result, the research on image translation or image conversion using GAN began to develop rapidly. The cornerstone is the cGAN proposed by Mirza et al., which adds conditional restrictions to the input of GAN, that is, conditional information is introduced in the input of both the generator G and the discriminator D. In this way, the completely unsupervised learning of the original GAN ​​becomes conditional supervised learning, solving the problems that the original GAN ​​depends entirely on the random noise of the input when generating data and the generated samples are uncontrollable.

[0007] The most typical cGAN-based image translation task is the pix2pix generative adversarial network model proposed by Isola et al. Given an input image, each output pixel is considered conditionally independent of all other pixels. The model takes noise as input, one type of photo as a condition, and outputs another type of photo. It also uses a structured loss function to make the generated image more realistic and clear. However, pix2pix requires a large amount of paired data during training, and these data are usually difficult to obtain. For example, to convert a daytime picture into a nighttime picture, it is necessary to use daytime and nighttime pictures of the same place as a pair of training data to train the model, and each pair of training data should keep all the contents unchanged as much as possible except for the attributes to be converted, which greatly limits its application areas.

[0008] In the field of inter-domain image conversion, paired training data is difficult to obtain, so Zhu et al. proposed CycleGAN, which can achieve relatively good results in the conversion of two unpaired inter-domain images, also known as unsupervised image conversion. CycleGAN takes the source domain image as input and the target domain image as a condition, and outputs the converted image. Its main contribution is the application of two pairs of generators G and discriminators D in one model, and the introduction of the concept of cycle consistency, so that images of different styles can be converted very naturally. But the disadvantage is that unsupervised methods cannot generate polymorphic images. In order to solve the above problem, Huang et al. proposed MUNIT in 2018, which divides the image information into two parts: content and style. Domains 1 and 2 that need to be converted to each other share content information. When generating images, the same content and different styles are combined to encode and output to generate polymorphic images.

[0009] Most of the above examples are based on converting real pictures from day to night. There are deficiencies such as no labeled information, uneven distribution of vehicles, and low degrees of freedom, which make it impossible to generate sufficient, accurate, and rich data sets for the recognition neural network to learn. A data enhancement method based on digital twins and image conversion that realizes self-labeling, high precision, high complexity, and high degrees of freedom is a very meaningful and challenging task.

[0010] Patent document CN104715479A (application number: 201510100413.1) discloses a scene reproduction detection method based on enhanced virtuality, which includes the following steps: generation of a three-dimensional virtual scene model; establishment of a three-dimensional virtual scene model database; calibration of the internal parameter matrix of a camera installed on a robotic arm; collection and storage of real scene image frame data and robotic arm position data; automatic loading of real scene image frame data and image processing; estimation of the world coordinate value of a feature point in the real scene from its pixel coordinates; registration of real scene feature points with corresponding feature points in the three-dimensional virtual scene model; and realization of an enhanced virtual display effect combining virtuality and reality. Summary of the invention

[0011] In view of the defects in the prior art, the object of the present invention is to provide a data enhancement method and system based on digital twins and image conversion.

[0012] A data enhancement method based on digital twin and image conversion provided by the present invention includes:

[0013] Step S1: Obtain video data through a road test camera, identify the 2D coordinates, vehicle model and color data of the vehicle in the video through a target recognition algorithm, and then obtain the coordinates of the vehicle in the virtual world through a mapping function and perform three-dimensional reconstruction;

[0014] Step S2: Calculate the screen coordinates of the bounding box according to the coordinates of the vehicle in the virtual world and the coordinates of the camera;

[0015] Step S3: Using the weather system constructed by the particle system and shader, and randomly replacing the vehicle model and color to generate a virtual picture set;

[0016] Step S4: Generate content code c and style code s through the trained GAN network, and realize image style conversion by combining different style codes;

[0017] The virtual data set includes a virtual picture set and screen coordinates of a bounding box;

[0018] The screen coordinates of the bounding box are the coordinates of the bounding box of each vehicle model in the image coordinate system and the three-dimensional bounding box of the vehicle.

[0019] Preferably, step S1 adopts: based on a fixed camera viewing angle and road height, a conversion function F(Xreal, Yreal) = (Xvirtual, Yvirtual, 0) is obtained for each camera, wherein Xreal, Yreal represent the position of the vehicle identified from each frame of the video, Xvirtual, Yvirtual represent the virtual world X, Y coordinates of the vehicle in the corresponding urban scene, and the Z coordinate defaults to 0.

[0020] Preferably, the step S2 adopts: obtaining the three-dimensional coordinates of the eight vertices of the bounding box in the vehicle model space through the three-dimensional bounding box assigned to each vehicle model, converting the coordinates of the vertices from the model space coordinates to the screen space coordinates through MVP matrix conversion, and then sorting the x and y coordinate values ​​of the eight vertices according to the x-axis and y-axis respectively to obtain the x coordinates. min , x max ,y min ,y max , thus obtaining the bounding box coordinates (x, y, w, h) of the vehicle that needs to be annotated in the dataset in the image coordinate system; where (x, y) is the center coordinate of the bounding box, (w, h) is the width and height of the bounding box, and x is the height of the bounding box. min Indicates the minimum x-axis coordinate among the eight vertices; x max Indicates the maximum x-axis coordinate among the eight vertices; y min Indicates the minimum y-axis coordinate among the eight vertices; y max Indicates the maximum y-axis coordinate among the eight vertices.

[0021] Preferably, the step S3 adopts: by combining different weather conditions, modifying the vehicle types and colors on the vehicle track to generate a virtual picture set covering all vehicle types, all colors and all weather conditions.

[0022] Preferably, the step S4 adopts: training the GAN network using the training set and the validation set until the loss function converges to obtain a trained GAN network;

[0023] The loss function includes a reconstructed L1 loss function and a GAN loss function;

[0024] The reconstructed L1 loss function adopts:

[0025]

[0026] in, Represents the difference loss between the first style image after reconstruction and the original image; represents expectation; x1 represents the first style of picture; p(x1) represents the probability distribution of the first style of pictures; G1 represents the reconstruction function of the first style of pictures; Indicates the expectation of the first type of picture content code; the superscript c indicates the content code; represents the expectation of the first picture style code, and the superscript s represents the style code; represents the difference loss between the content code of the image reconstructed by the first content code and the second style code and the original first content; c1 represents the content code of the first image; p(c1) represents the probability distribution of the first picture content code; s2 The style code of the second picture; q(s2) represents the probability distribution of the second picture style code; Represents the expectation of the content code of the second type of picture after generation; G2 represents the second type of picture constructor; Indicates the difference loss between the second style code and the first content code after the image obtains the style code and the original second style code; Represents the expectation of the style code of the second image after generation;

[0027] The GAN loss function adopts:

[0028]

[0029] in, represents the adversarial loss between the second type of image and the generator; D is the discriminator, which is used to determine whether the image belongs to a certain domain, if it does, it takes 1, if it does not, it takes 0; D2 represents the judgment of whether the image belongs to the second type of image; G is the generator function, which generates images by receiving content codes and style codes, and G2 represents the generation of images of the second style; x2 represents images of the second style; p(x2) Represents the probability distribution of the second type of picture.

[0030] Preferably, the GAN network includes an encoder and a decoder;

[0031] The encoder includes a content encoder and a style encoder;

[0032] The content encoder includes a downsampling and residual network;

[0033] The style encoder is composed of downsampling and global pooling to map the original data to the hidden feature space, and then connected to the fully connected layer to extract the global segmentation;

[0034] The decoder first extracts adaptive instance normalization parameters from the style code by a multi-layer perceptron, aligns the mean and variance of the content image features to the mean and variance of the style image through affine transformation, and then regenerates the image through upsampling.

[0035] A data enhancement system based on digital twin and image conversion provided by the present invention includes:

[0036] Module M1: Obtain video data through road test cameras, use the target recognition algorithm to identify the 2D coordinates, model and color data of the vehicle in the video, and then use the mapping function to obtain the coordinates of the vehicle in the virtual world and perform 3D reconstruction;

[0037] Module M2: Calculate the screen coordinates of the bounding box based on the coordinates of the vehicle in the virtual world and the coordinates of the camera;

[0038] Module M3: A weather system built using a particle system and shader, with random replacement of vehicle models and colors, to generate a virtual picture set;

[0039] Module M4: Generate content code c and style code s through the trained GAN network, and realize image style conversion by combining different style codes;

[0040] The virtual data set includes a virtual picture set and screen coordinates of a bounding box;

[0041] The screen coordinates of the bounding box are the coordinates of the bounding box of each vehicle model in the image coordinate system and the three-dimensional bounding box of the vehicle.

[0042] Preferably, the module M1 adopts: based on a fixed camera viewing angle and road height, a conversion function F(Xreal, Yreal) = (Xvirtual, Yvirtual, 0) is obtained for each camera, wherein Xreal, Yreal represent the position of the vehicle identified from each frame of the video, Xvirtual, Yvirtual represent the virtual world X, Y coordinates of the vehicle in the corresponding urban scene, and the Z coordinate defaults to 0.

[0043] Preferably, the module M2 adopts: through the 3D bounding box assigned to each vehicle model, the 3D coordinates of the eight vertices of the bounding box in the vehicle model space are obtained, and the coordinates of the vertices are converted from the coordinates of the model space to the coordinates of the screen space through MVP matrix conversion, and then the x and y coordinate values ​​of the eight vertices are sorted according to the x-axis and y-axis respectively to obtain the x coordinates. min , x max ,y min ,y max , thus obtaining the bounding box coordinates (x, y, w, h) of the vehicle that needs to be annotated in the dataset in the image coordinate system; where (x, y) is the center coordinate of the bounding box, (w, h) is the width and height of the bounding box, and x is the height of the bounding box. min Indicates the minimum x-axis coordinate among the eight vertices; x max Indicates the maximum x-axis coordinate among the eight vertices; y min Indicates the minimum y-axis coordinate among the eight vertices; y max Indicates the maximum y-axis coordinate among the eight vertices;

[0044] The module M3 adopts: by combining different weather conditions, modifying the vehicle models and colors on the vehicle track to generate a virtual picture set covering all vehicle models, all colors and all weather conditions.

[0045] Preferably, the module M4 adopts: training the GAN network using the training set and the validation set until the loss function converges to obtain a trained GAN network;

[0046] The loss function includes a reconstructed L1 loss function and a GAN loss function;

[0047] The reconstructed L1 loss function adopts:

[0048]

[0049] in, Represents the difference loss between the first style image after reconstruction and the original image; represents expectation; x1 represents the first style of picture; p(x1) represents the probability distribution of the first style of pictures; G1 represents the reconstruction function of the first style of pictures; Indicates the expectation of the first type of picture content code; the superscript c indicates the content code; represents the expectation of the first picture style code, and the superscript s represents the style code; represents the difference loss between the content code of the image reconstructed by the first content code and the second style code and the original first content; c1 represents the content code of the first image; p(c1) represents the probability distribution of the first picture content code; s2 The style code of the second picture; q(s2)represents the probability distribution of the second picture style code; Represents the expectation of the content code of the second type of picture after generation; G2 represents the second type of picture constructor; Indicates the difference loss between the second style code and the first content code after the image obtains the style code and the original second style code; Represents the expectation of the style code of the second image after generation;

[0050] The GAN loss function adopts:

[0051]

[0052] in, represents the adversarial loss between the second type of image and the generator; D is the discriminator, which is used to determine whether the image belongs to a certain domain, if it does, it takes 1, if it does not, it takes 0; D2 represents the judgment of whether the image belongs to the second type of image; G is the generator function, which generates images by receiving content codes and style codes, and G2 represents the generation of images of the second style; x2 represents images of the second style; p(x2) Represents the probability distribution of the second type of picture;

[0053] The GAN network includes an encoder and a decoder;

[0054] The encoder includes a content encoder and a style encoder;

[0055] The content encoder includes a downsampling and residual network;

[0056] The style encoder is composed of downsampling and global pooling to map the original data to the hidden feature space, and then connected to the fully connected layer to extract the global segmentation;

[0057] The decoder first extracts adaptive instance normalization parameters from the style code by a multi-layer perceptron, aligns the mean and variance of the content image features to the mean and variance of the style image through affine transformation, and then regenerates the image through upsampling.

[0058] Compared with the prior art, the present invention has the following beneficial effects:

[0059] 1. The present invention realizes the generation of traffic images in special environments with self-annotation, high precision, high complexity and high degree of freedom, and provides a high-quality solution for enhancing the traffic vehicle identification data set in smart cities. Through the technology of virtual data generation and image conversion, it realizes enriching the data set in extreme environments and improving the accuracy of vehicle identification in such environments, becoming the cornerstone of building smart cities and ensuring the high-quality operation of upper-layer applications such as intelligent analysis, intelligent supervision and intelligent scheduling;

[0060] 2. The algorithm of the present invention can be applied to generate traffic pictures under different weather and lighting conditions. It has high generation efficiency and can control the distribution of the generated data types to generate personalized data sets according to needs. These data sets can assist in retraining the vehicle recognition network and improve the recognition rate of vehicles in extreme environments. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0062] Figure 1 Flowchart of data enhancement method based on digital twin and image conversion.

[0063] Figure 2 Schematic diagram of virtual vehicle self-annotation.

[0064] Figure 3 Schematic diagram of the image translation model. DETAILED DESCRIPTION

[0065] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.

[0066] Aiming at the low recognition rate of vehicle recognition in special environments such as night and rainy days, insufficient data sets and insufficient image conversion methods to solve this problem, a data enhancement method based on digital twins and image conversion is designed. This method aims to achieve self-annotation, high-precision, high-complexity, and high-degree-of-freedom traffic picture generation in special environments, provide a high-quality solution for traffic vehicle recognition data set enhancement in smart cities, build the cornerstone of smart cities, and ensure the high-quality operation of upper-level applications such as intelligent analysis, intelligent supervision, and intelligent scheduling.

[0067] Example 1

[0068] According to a data enhancement method based on digital twin and image conversion provided by the present invention, Figure 1 As shown, including:

[0069] Step S1: Obtain high-definition video data through road test camera shooting, identify the 2D coordinates, vehicle model and color data of the vehicle in the video through the target recognition algorithm, and obtain a conversion function F(Xreal, Yreal) = (Xvirtual, Yvirtual, 0) for each camera based on the fixed camera viewing angle and road height, where Xreal and Yreal represent the position of the vehicle identified from each frame of the video. For a 1080P video stream, the range of Xreal is [0, 1920], the range of Yreal is [0, 1080], and Xvirtual and Yvirtual represent the virtual world X and Y coordinates of the vehicle in the corresponding urban scene, and the Z coordinate defaults to 0; then obtain the coordinates of the vehicle in the virtual world through the mapping function and perform three-dimensional reconstruction;

[0070] Step S2: Calculate the screen coordinates of the bounding box based on the coordinates of the vehicle in the virtual world and the coordinates of the camera; each vehicle model can be assigned a three-dimensional bounding box in advance, so that we can obtain the three-dimensional coordinates of the eight vertices of the bounding box in the model space, that is, the world coordinates of the eight vertices are calculated in combination with the world coordinates of the vehicle center point; then, through the MVP matrix transformation, the coordinates of the vertices are converted from the coordinates of the model space to the coordinates of the screen space, and then the x, y coordinate values ​​of the eight vertex coordinates are sorted according to the x-axis and y-axis respectively to obtain 4 values ​​xmin, xmax, ymin, ymax, so as to obtain the bounding box coordinates (x, y, w, h) of the vehicle that needs to be labeled in the data set in the image coordinate system, where (x, y) are the center coordinates of the bounding box, (w, h) are the width and height of the bounding box, xmin represents the minimum x-axis coordinate value among the eight vertices; xmax represents the maximum x-axis coordinate value among the eight vertices; ymin represents the minimum y-axis coordinate value among the eight vertices; ymax represents the maximum y-axis coordinate value among the eight vertices. Figure 2 shown.

[0071] Step S3: Use the weather system constructed by the particle system and shader, and randomly replace the vehicle model and color to generate a virtual picture set; the virtual picture set has 13 types of vehicle models (van, hatchback, SUV, taxi, bus, van, minivan, large box truck, TruckBoxMed, TruckUtil, flatbed truck, pickup truck, police car). There are 11 vehicle colors (red, orange, yellow, green, blue, light brown, brown, white, silver, gray, black). By combining different weathers, modifying the vehicle model and color on the vehicle trajectory, virtual data covering all models, all colors and all weathers can be generated. By combining different weathers, modifying the vehicle model and color on the vehicle trajectory, a virtual picture set covering all models, all colors and all weathers is generated.

[0072] Step S4: Generate content code c and style code s through the trained GAN network, and realize image style conversion by combining different style codes;

[0073] The virtual data set includes a virtual picture set and screen coordinates of a bounding box;

[0074] The screen coordinates of the bounding box are the coordinates of the bounding box of each vehicle model in the image coordinate system and the three-dimensional bounding box of the vehicle.

[0075] Specifically, step S4 adopts: using the training set and the validation set to train the GAN network until the loss function converges to obtain the trained GAN network; specifically, the training uses 12496 real style pictures and 37760 generated virtual pictures as the training set and uses 2650 real style pictures and 5428 virtual pictures as the validation set for training.

[0076] The loss function includes a reconstructed L1 loss function and a GAN loss function;

[0077] The reconstructed L1 loss function guarantees two points. The first point is that when the style code and the content code are not changed, the difference between the image after parsing and reconstructing and the original image should be as small as possible. The second point is that the new content code and style code generated by encoding after the image is reconstructed without transformation should be as similar as possible to the previous content code and style code.

[0078] The GAN loss function is mainly used to determine whether the generated image after image conversion conforms to some characteristics of the new image domain and whether it is realistic enough to not be identified as a generated image by the discriminator.

[0079] The reconstructed L1 loss function adopts:

[0080]

[0081] in, Represents the difference loss between the first style image after reconstruction and the original image; represents expectation; x1 represents the first style of picture; p(x1) represents the probability distribution of the first style of pictures; G1 represents the reconstruction function of the first style of pictures; Indicates the expectation of the first type of picture content code; the superscript c indicates the content code; represents the expectation of the first picture style code, and the superscript s represents the style code; represents the difference loss between the content code of the image reconstructed by the first content code and the second style code and the original first content; c1 represents the content code of the first image; p(c1) represents the probability distribution of the first picture content code;s2 The style code of the second picture; q(s2) represents the probability distribution of the second picture style code; Represents the expectation of the content code of the second type of picture after generation; G2 represents the second type of picture constructor; Indicates the difference loss between the second style code and the first content code after the image obtains the style code and the original second style code; Represents the expectation of the style code of the second image after generation;

[0082] Formula (1) mainly calculates the difference between the image after encoding and reconstruction and the original image. That is to say, the loss function ensures the stability of encoding and reconstruction, so that the image can be restored to its original state as much as possible after encoding and reconstruction.

[0083] Formula (2) calculates the difference between the new content code obtained by encoding the image reconstructed by the style code s2 and the content code c1 and the original content code c1;

[0084] Formula (3) calculates the difference between the new style code obtained by encoding the image reconstructed by the style code s2 and the content code c1 and the original style code s2. Both are to ensure that the encoding result of the reconstructed image is the same as the original content code and style code.

[0085] The GAN loss function adopts:

[0086]

[0087] in, represents the adversarial loss between the second type of image and the generator; D is the discriminator, which is used to determine whether the image belongs to a certain domain, if it does, it takes 1, if it does not, it takes 0; D2 represents the judgment of whether the image belongs to the second type of image; G is the generator function, which generates images by receiving content codes and style codes, and G2 represents the generation of images of the second style; x2 represents images of the second style; p(x2) Represents the probability distribution of the second type of picture;

[0088] The GAN loss function is mainly used for training two parts, namely the discriminator D and the generator G, with different goals. It hopes that the discriminator loss function is as large as possible and the generator loss function is as small as possible, and then optimizes the two separately. The GAN loss function is mainly obtained by adding two parts. When optimizing the discriminator, the first half is used to distinguish the generated image, so the value of D2 is expected to be as 0 as possible. Therefore, (1-D2) is used to make the first half an increasing function, and the second half distinguishes x2, and the expected value is 1, which is an increasing function. When optimizing the generator, only the first half is related to it. When the generator is more powerful, the value of D2 approaches 1, so that the entire formula decreases to meet the requirements.

[0089] Specifically, the GAN network includes an encoder and a decoder, such as Figure 3 As shown;

[0090] The encoder includes a content encoder and a style encoder;

[0091] The content encoder includes downsampling and residual networks to ensure that the features extracted by the network are rich enough to avoid image information loss caused by convolution and pooling operations in the non-sampling layer when the network is too deep;

[0092] The style encoder is composed of downsampling and global pooling to map the original data to the hidden feature space, and then connected to the fully connected layer to extract the global segmentation;

[0093] The decoder first extracts adaptive instance normalization parameters (Adaptive Instance Normalization, AdaIN) from the style code by a multi-layer perceptron, aligns the mean and variance of the content image features to the mean and variance of the style image through affine transformation; and then regenerates the image through upsampling.

[0094] The present invention can generate a large number of required data sets, such as labeled training sets on rainy days or at night, for use in training the recognition neural network, thereby improving the recognition rate of the recognition network.

[0095] According to a data enhancement method based on digital twin and image conversion provided by the present invention, Figure 1 As shown, including:

[0096] 3D reconstruction module: obtain high-definition video data through road test cameras, identify the 2D coordinates, vehicle model and color data of the vehicle in the video through the target recognition algorithm, and obtain a conversion function F(Xreal,Yreal)=(Xvirtual,Yvirtual,0) for each camera based on the fixed camera viewing angle and road height, where Xreal and Yreal represent the position of the vehicle identified from each frame of the video. For 1080P video stream, the range of Xreal is [0,1920], the range of Yreal is [0,1080], Xvirtual and Yvirtual represent the virtual world X and Y coordinates of the vehicle in the corresponding urban scene, and the Z coordinate defaults to 0; then obtain the coordinates of the vehicle in the virtual world through the mapping function and perform 3D reconstruction;

[0097] Vehicle self-labeling module: The screen coordinates of the bounding box are calculated based on the coordinates of the vehicle in the virtual world and the coordinates of the camera; each vehicle model can be assigned a 3D bounding box in advance, so that we can obtain the three-dimensional coordinates of the eight vertices of the bounding box in the model space, that is, the world coordinates of the eight vertices are calculated in combination with the world coordinates of the vehicle center point; then the coordinates of the vertices are converted from the coordinates of the model space to the coordinates of the screen space through the MVP matrix transformation, and then the x and y coordinate values ​​of the eight vertex coordinates are sorted according to the x-axis and y-axis to obtain 4 values ​​xmin, xmax, ymin, ymax, so as to obtain the bounding box coordinates (x, y, w, h) of the vehicle that needs to be labeled in the data set in the image coordinate system, where (x, y) are the center coordinates of the bounding box, (w, h) are the width and height of the bounding box, xmin represents the minimum x-axis coordinate value of the eight vertices; xmax represents the maximum x-axis coordinate value of the eight vertices; ymin represents the minimum y-axis coordinate value of the eight vertices; ymax represents the maximum y-axis coordinate value of the eight vertices. Figure 2 shown.

[0098] Virtual traffic image generation module: The weather system constructed by particle system and shader is used to randomly replace the vehicle model and color to generate a virtual picture set; there are 13 types of vehicle models in the virtual picture set (van, hatchback, Suv, taxi, bus, van, minivan, large box truck, TruckBoxMed, TruckUtil, flatbed truck, pickup truck, police car). There are 11 vehicle colors (red, orange, yellow, green, blue, light brown, brown, white, silver, gray, black). By combining different weathers, modifying the vehicle model and color on the vehicle track, virtual data covering all models, colors and weather can be generated. By combining different weathers, modifying the vehicle model and color on the vehicle track, a virtual picture set covering all models, colors and weather can be generated.

[0099] Image conversion module: Generate content code c and style code s through the trained GAN network, and realize image style conversion by combining different style codes;

[0100] The virtual data set includes a virtual picture set and screen coordinates of a bounding box;

[0101] The screen coordinates of the bounding box are the coordinates of the bounding box of each vehicle model in the image coordinate system and the three-dimensional bounding box of the vehicle.

[0102] Specifically, the image conversion module adopts: using the training set and the validation set to train the GAN network until the loss function converges to obtain the trained GAN network; specifically, the training uses 12496 real style pictures and 37760 generated virtual pictures as the training set and uses 2650 real style pictures and 5428 virtual pictures as the validation set for training.

[0103] The loss function includes a reconstructed L1 loss function and a GAN loss function;

[0104] The reconstructed L1 loss function guarantees two points. The first point is that when the style code and the content code are not changed, the difference between the image after parsing and reconstructing and the original image should be as small as possible. The second point is that the new content code and style code generated by encoding after the image is reconstructed without transformation should be as similar as possible to the previous content code and style code.

[0105] The GAN loss function is mainly used to determine whether the generated image after image conversion conforms to some characteristics of the new image domain and whether it is realistic enough to not be identified as a generated image by the discriminator.

[0106] The reconstructed L1 loss function adopts:

[0107]

[0108] in, Represents the difference loss between the first style image after reconstruction and the original image; represents expectation; x1 represents the first style of picture; p(x1) represents the probability distribution of the first style of pictures; G1 represents the reconstruction function of the first style of pictures; Indicates the expectation of the first type of picture content code; the superscript c indicates the content code; represents the expectation of the first picture style code, and the superscript s represents the style code; represents the difference loss between the content code of the image reconstructed by the first content code and the second style code and the original first content; c1 represents the content code of the first image; p(c1) represents the probability distribution of the first picture content code; s2 The style code of the second picture; q(s2) represents the probability distribution of the second picture style code; Represents the expectation of the content code of the second type of picture after generation; G2 represents the second type of picture constructor; Indicates the difference loss between the second style code and the first content code after the image obtains the style code and the original second style code; Represents the expectation of the style code of the second image after generation;

[0109] Formula (1) mainly calculates the difference between the image after encoding and reconstruction and the original image. That is to say, the loss function ensures the stability of encoding and reconstruction, so that the image can be restored to its original state as much as possible after encoding and reconstruction.

[0110] Formula (2) calculates the difference between the new content code obtained by encoding the image reconstructed by the style code s2 and the content code c1 and the original content code c1;

[0111] Formula (3) calculates the difference between the new style code obtained by encoding the image reconstructed by the style code s2 and the content code c1 and the original style code s2. Both are to ensure that the encoding result of the reconstructed image is the same as the original content code and style code.

[0112] The GAN loss function adopts:

[0113]

[0114] in, represents the adversarial loss between the second type of image and the generator; D is the discriminator, which is used to determine whether the image belongs to a certain domain, if it does, it takes 1, if it does not, it takes 0; D2 represents the judgment of whether the image belongs to the second type of image; G is the generator function, which generates images by receiving content codes and style codes, and G2 represents the generation of images of the second style; x2 represents images of the second style; p(x2) Represents the probability distribution of the second type of picture;

[0115] The GAN loss function is mainly used for training two parts, namely the discriminator D and the generator G, with different goals. It hopes that the discriminator loss function is as large as possible and the generator loss function is as small as possible, and then optimizes the two separately. The GAN loss function is mainly obtained by adding two parts. When optimizing the discriminator, the first half is used to distinguish the generated image, so the value of D2 is expected to be as 0 as possible. Therefore, (1-D2) is used to make the first half an increasing function, and the second half distinguishes x2, and the expected value is 1, which is an increasing function. When optimizing the generator, only the first half is related to it. When the generator is more powerful, the value of D2 approaches 1, so that the entire formula decreases to meet the requirements.

[0116] Specifically, the GAN network includes an encoder and a decoder, such as Figure 3 As shown;

[0117] The encoder includes a content encoder and a style encoder;

[0118] The content encoder includes downsampling and residual networks to ensure that the features extracted by the network are rich enough to avoid image information loss caused by convolution and pooling operations in the non-sampling layer when the network is too deep;

[0119] The style encoder is composed of downsampling and global pooling to map the original data to the hidden feature space, and then connected to the fully connected layer to extract the global segmentation;

[0120] The decoder first extracts adaptive instance normalization parameters (Adaptive Instance Normalization, AdaIN) from the style code by a multi-layer perceptron, aligns the mean and variance of the content image features to the mean and variance of the style image through affine transformation; and then regenerates the image through upsampling.

[0121] The present invention can generate a large number of required data sets, such as labeled training sets on rainy days or at night, for use in training the recognition neural network, thereby improving the recognition rate of the recognition network.

[0122] Those skilled in the art know that, in addition to implementing the system, device and its various modules provided by the present invention in a purely computer-readable program code, it is entirely possible to implement the same program in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded microcontrollers by logically programming the method steps. Therefore, the system, device and its various modules provided by the present invention can be considered as a hardware component, and the modules included therein for implementing various programs can also be considered as structures within the hardware component; the modules for implementing various functions can also be considered as both software programs for implementing the method and structures within the hardware component.

[0123] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.

Claims

1. A data enhancement method based on digital twins and image conversion, characterized in that: include: Step S1: Obtain video data through a road test camera, identify the 2D coordinates, vehicle model and color data of the vehicle in the video through a target recognition algorithm, and then obtain the coordinates of the vehicle in the virtual world through a mapping function and perform three-dimensional reconstruction; Step S2: Calculate the screen coordinates of the bounding box according to the coordinates of the vehicle in the virtual world and the coordinates of the camera; Step S3: Using the weather system constructed by the particle system and shader, by combining different weather conditions, modifying the vehicle model and color on the vehicle track to generate a virtual picture set covering all vehicle models, all colors and all weather conditions; Step S4: Generate content code c and style code s through the trained GAN network, and realize image style conversion by combining different style codes; The step S4 adopts: using the training set and the validation set to train the GAN network until the loss function converges, thereby obtaining a trained GAN network; The loss function includes a reconstructed L1 loss function and a GAN loss function; The reconstructed L1 loss function adopts: in, Represents the difference loss between the first style image after reconstruction and the original image; represents expectation; x1 represents the first style of picture; p(x1) represents the probability distribution of the first style of pictures; G1 represents the reconstruction function of the first style of pictures; Indicates the expectation of the first type of picture content code; the superscript c indicates the content code; E1 s represents the expectation of the first picture style code, and the superscript s represents the style code; represents the difference loss between the content code of the image reconstructed by the first content code and the second style code and the original first content; c1 represents the content code of the first image; p(c1) represents the probability distribution of the first picture content code; s2 The style code of the second picture; q(s2) represents the probability distribution of the second picture style code; Represents the expectation of the content code of the second type of picture after generation; G2 represents the second type of picture constructor; Indicates the difference loss between the second style code and the first content code after the image obtains the style code and the original second style code; Represents the expectation of the style code of the second image after generation; The GAN loss function adopts: in, represents the adversarial loss between the second type of image and the generator; D is the discriminator, which is used to determine whether the image belongs to a certain domain, if it does, it takes 1, if it does not, it takes 0; D2 represents the judgment of whether the image belongs to the second type of image; G is the generator function, which generates images by receiving content codes and style codes, and G2 represents the generation of images of the second style; x2 represents images of the second style; p(x2) Represents the probability distribution of the second type of picture; The virtual data set includes a virtual picture set and screen coordinates of a bounding box; The screen coordinates of the bounding box are the coordinates of the bounding box of each vehicle model in the image coordinate system and the three-dimensional bounding box of the vehicle.

2. The data enhancement method based on digital twin and image conversion according to claim 1 is characterized in that: The step S1 adopts: based on a fixed camera viewing angle and road height, a conversion function F(Xreal, Yreal) = (Xvirtual, Yvirtual, 0) is obtained for each camera, wherein Xreal, Yreal represent the position of the vehicle identified from each frame of the video, Xvirtual, Yvirtual represent the virtual world X, Y coordinates of the vehicle in the corresponding urban scene, and the Z coordinate defaults to 0.

3. The data enhancement method based on digital twin and image conversion according to claim 1 is characterized in that: The step S2 adopts the following method: using the 3D bounding box assigned to each vehicle model, obtaining the 3D coordinates of the eight vertices of the bounding box in the vehicle model space, converting the coordinates of the vertices from the model space coordinates to the screen space coordinates through MVP matrix conversion, and then sorting the x and y coordinate values ​​of the eight vertices according to the x-axis and y-axis respectively to obtain the x coordinates. min , x max ,y min ,y max , thus obtaining the bounding box coordinates (x, y, w, h) of the vehicle that needs to be annotated in the dataset in the image coordinate system; where (x, y) is the center coordinate of the bounding box, (w, h) is the width and height of the bounding box, and x is the height of the bounding box. min Indicates the minimum x-axis coordinate among the eight vertices; x max Indicates the maximum x-axis coordinate among the eight vertices; y miin Indicates the minimum y-axis coordinate among the eight vertices; y max Indicates the maximum y-axis coordinate among the eight vertices.

4. The data enhancement method based on digital twin and image conversion according to claim 1 is characterized in that: The GAN network includes an encoder and a decoder; The encoder includes a content encoder and a style encoder; The content encoder includes a downsampling and residual network; The style encoder is composed of downsampling and global pooling to map the original data to the hidden feature space, and then connected to the fully connected layer to extract the global segmentation; The decoder first extracts adaptive instance normalization parameters from the style code by a multi-layer perceptron, aligns the mean and variance of the content image features to the mean and variance of the style image through affine transformation, and then regenerates the image through upsampling.

5. A data enhancement system based on digital twins and image conversion, characterized in that: include: Module M1: Obtain video data through road test cameras, use the target recognition algorithm to identify the 2D coordinates, model and color data of the vehicle in the video, and then use the mapping function to obtain the coordinates of the vehicle in the virtual world and perform 3D reconstruction; Module M2: Calculate the screen coordinates of the bounding box based on the coordinates of the vehicle in the virtual world and the coordinates of the camera; Module M3: A weather system built using a particle system and shader, which modifies the vehicle models and colors on the vehicle track by combining different weather conditions to generate a virtual picture set covering all vehicle models, all colors, and all weather conditions; Module M4: Generate content code c and style code s through the trained GAN network, and realize image style conversion by combining different style codes; The module M4 adopts: using the training set and the validation set to train the GAN network until the loss function converges, thereby obtaining a trained GAN network; The loss function includes a reconstructed L1 loss function and a GAN loss function; The reconstructed L1 loss function adopts: in, Represents the difference loss between the first style image after reconstruction and the original image; represents expectation; x1 represents the first style of picture; p(x1) represents the probability distribution of the first style of pictures; G1 represents the reconstruction function of the first style of pictures; Indicates the expectation of the first type of picture content code; the superscript c indicates the content code; represents the expectation of the first picture style code, and the superscript s represents the style code; represents the difference loss between the content code of the image reconstructed by the first content code and the second style code and the original first content; c1 represents the content code of the first image; p(c1) represents the probability distribution of the first picture content code; s2 The style code of the second picture; q(s2) represents the probability distribution of the second picture style code; Represents the expectation of the content code of the second type of picture after generation; G2 represents the second type of picture constructor; E2 represents the difference loss between the second style code and the first content code after the image is reconstructed and the original second style code is obtained; s Represents the expectation of the style code of the second image after generation; The GAN loss function adopts: in, represents the adversarial loss between the second type of image and the generator; D is the discriminator, which is used to determine whether the image belongs to a certain domain, if it does, it takes 1, if it does not, it takes 0; D2 represents the judgment of whether the image belongs to the second type of image; G is the generator function, which generates images by receiving content codes and style codes, and G2 represents the generation of images of the second style; x2 represents images of the second style; p(x2) Represents the probability distribution of the second type of picture; The virtual data set includes a virtual picture set and screen coordinates of a bounding box; The screen coordinates of the bounding box are the coordinates of the bounding box of each vehicle model in the image coordinate system and the three-dimensional bounding box of the vehicle.

6. The data enhancement system based on digital twin and image conversion according to claim 5, characterized in that: The module M1 adopts: based on a fixed camera viewing angle and road height, a conversion function F(Xreal, Yreal) = (Xvirtual, Yvirtual, 0) is obtained for each camera, wherein Xreal, Yreal represent the position of the vehicle identified from each frame of the video, Xvirtual, Yvirtual represent the virtual world X, Y coordinates of the vehicle in the corresponding urban scene, and the Z coordinate defaults to 0.

7. The data enhancement system based on digital twin and image conversion according to claim 5, characterized in that: The module M2 adopts: through the 3D bounding box assigned to each vehicle model, the 3D coordinates of the eight vertices of the bounding box in the vehicle model space are obtained, and the coordinates of the vertices are converted from the coordinates of the model space to the coordinates of the screen space through the MVP matrix conversion, and then the x and y coordinate values ​​of the eight vertices are sorted according to the x axis and y axis respectively to obtain the x coordinates. min , x max ,y min ,y max , thus obtaining the bounding box coordinates (x, y, w, h) of the vehicle that needs to be annotated in the dataset in the image coordinate system; where (x, y) is the center coordinate of the bounding box, (w, h) is the width and height of the bounding box, and x is the height of the bounding box. min Indicates the minimum x-axis coordinate among the eight vertices; x max Indicates the maximum x-axis coordinate among the eight vertices; y miin Indicates the minimum y-axis coordinate among the eight vertices; y max Indicates the maximum y-axis coordinate among the eight vertices.

8. The data enhancement system based on digital twin and image conversion according to claim 5, characterized in that: The GAN network includes an encoder and a decoder; The encoder includes a content encoder and a style encoder; The content encoder includes a downsampling and residual network; The style encoder is composed of downsampling and global pooling to map the original data to the hidden feature space, and then connected to the fully connected layer to extract the global segmentation; The decoder first extracts adaptive instance normalization parameters from the style code by a multi-layer perceptron, aligns the mean and variance of the content image features to the mean and variance of the style image through affine transformation, and then regenerates the image through upsampling.

Citation Information

Patent Citations

  • Scene reproduction detection method based on augmented virtuality

    CN104715479A

  • Underwater image composition method of multi-style generative adversarial network and application thereof

    CN108961198A

  • Video-animation style migration method based on deep adversarial network

    CN112164130A