Car window color stripe removing method and device and computer program product
By obtaining prior information in car window images and using an unsupervised generative adversarial network to train a car window color streak removal model, the problem of reduced image quality caused by color streak removal in car window images in the existing technology is solved, and efficient color streaks are achieved removal and image quality preservation.
Patent Information
- Application Number
- CN202410857477.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-29
AI Technical Summary
Existing methods cannot effectively reduce or eliminate color fringes in car window images, and the process of removing color fringes may lead to a reduction in image quality, and collecting paired images is time-consuming and laborious, affecting the generalization ability of the model.
By obtaining the prior information of the car window image and using an unsupervised method to train the car window tint removal model, a generative adversarial network is used to remove the car window tint while retaining the image quality. The pre-training method is used to provide rich information for the unsupervised generative adversarial network. The prior information of the car window image.
It can effectively reduce or eliminate color streaks in car window images, ensure image quality, reduce the difficulty and cost of sample collection, and improve the model's generalization ability in different scenarios.
Smart Images

Figure CN118864320A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, device and computer program product for removing vehicle window color streaks. Background Art
[0002] Road monitoring system is an important device for safe driving on roads, and can be used for in-car scene analysis and face recognition, etc. However, for the sake of heat insulation or anti-glare, a layer of film is attached to the car window glass, which causes the window imaging process to be affected by the refraction and interference of additional light, resulting in the appearance of color stripes (referred to as color stripes), which seriously affects the visual quality of the image and subsequent analysis.
[0003] The traditional method to solve the problem of color streaks on car windows is to install a polarizer at a specific angle in front of the image sensor or lens to improve the color streak condition, but the effect is minimal. With the development of artificial intelligence technology, the current method is to reduce the color streaks on car window images by collecting paired images of vehicles in the same scene to train the model, but these methods may cause image quality degradation while removing the color streaks. More importantly, collecting paired images is time-consuming and labor-intensive, which affects the model's generalization ability for different scenes. Summary of the invention
[0004] The present invention provides a method, device and computer program product for removing color streaks from vehicle windows, so as to solve the problem that the existing methods cannot effectively reduce or eliminate the color streaks in vehicle window images or eliminate the color streaks in vehicle window images at the cost of sacrificing image quality. The method utilizes prior information of vehicle window images and a vehicle window color streak removal model trained in an unsupervised manner to effectively reduce or eliminate the color streaks in vehicle window images and ensure image quality.
[0005] In a first aspect, an embodiment of the present invention provides a method for training a vehicle window color streak removal model, comprising:
[0006] Acquire a first vehicle window image sample and a second vehicle window image sample; the second vehicle window image sample comprises: a second vehicle window image sample with color patterns and a second vehicle window image sample without color patterns;
[0007] Train an initial image generation model according to the first vehicle window image sample and the image generation description text to obtain a vehicle window image generation model;
[0008] Inputting the second vehicle window image sample with color patterns and the description text for generating the image without color patterns into the vehicle window image generation model to obtain a predicted vehicle window image without color patterns;
[0009] Inputting the second color streak-free vehicle window image sample and the predicted color streak-free vehicle window image into a discriminator, calculating a first loss function value according to a discrimination result of the discriminator, and adjusting parameters of the discriminator according to the first loss function value;
[0010] A second loss function value is calculated according to the discrimination result of the discriminator, and the model parameters of the vehicle window image generation model are adjusted according to the second loss function value to obtain a target vehicle window color pattern removal model.
[0011] In a second aspect, an embodiment of the present invention provides a method for removing colored streaks on a vehicle window, comprising:
[0012] Obtain the vehicle window image to be processed;
[0013] Inputting the to-be-processed vehicle window image into a target vehicle window color streak removal model obtained by training using a vehicle window color streak removal model training method;
[0014] The target window color pattern removal model is used to remove color patterns from the window image to be processed, and a window image without color patterns is obtained.
[0015] In a third aspect, an embodiment of the present invention provides an electronic device, the electronic device comprising:
[0016] at least one processor; and
[0017] a memory communicatively connected to the at least one processor; wherein,
[0018] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the training method for the vehicle window color streak removal model described in any embodiment of the present invention, or the vehicle window color streak removal method described in any embodiment.
[0019] In a fourth aspect, an embodiment of the present invention provides a computer program product including a computer program, which, when executed by a processor, implements the training method for a vehicle window color streak removal model described in any embodiment of the present invention, or the vehicle window color streak removal method described in any embodiment.
[0020] The technical solution of the embodiment of the present invention is to obtain a first vehicle window image sample and a second vehicle window image sample; the second vehicle window image sample includes: a second vehicle window image sample with color patterns and a second vehicle window image sample without color patterns; train an initial image generation model according to the first vehicle window image sample and image generation description text to obtain a vehicle window image generation model; input the second vehicle window image sample with color patterns and the image generation description text without color patterns into the vehicle window image generation model to obtain a predicted vehicle window image without color patterns; input the second vehicle window image sample without color patterns and the predicted vehicle window image without color patterns into a discriminator, calculate a first loss function value according to a discrimination result of the discriminator, and adjust the parameters of the discriminator according to the first loss function value; calculate a second loss function value according to the discrimination result of the discriminator, and adjust the model parameters of the vehicle window image generation model according to the second loss function value to obtain a target vehicle window color pattern removal model. A pre-training method is used to provide the unsupervised generative adversarial network with rich prior information of the car window image, thereby improving the color pattern removal effect of the car window color pattern removal model. This solves the problem that the existing method of eliminating color patterns in car window images sacrifices image quality. The method has the technical effect of effectively reducing or eliminating color patterns in car window images while ensuring image quality.
[0021] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0023] Figure 1 A flowchart of a method for training a vehicle window color streak removal model provided in Embodiment 1 of the present invention;
[0024] Figure 2A A flowchart of another method for training a vehicle window color streak removal model provided in the second embodiment of the present invention;
[0025] Figure 2B Schematic diagram of the network structure of the model for generating the initial image;
[0026] Figure 3A A flowchart of another method for training a vehicle window color streak removal model provided in Embodiment 3 of the present invention;
[0027] Figure 3B Schematic diagram of the formation principle of the first positive and negative sample pairs;
[0028] Figure 4 A flowchart of a method for removing colored streaks from a vehicle window provided in Embodiment 4 of the present invention;
[0029] Figure 5 A schematic diagram of the structure of a training device for a vehicle window color streak removal model provided in Embodiment 5 of the present invention;
[0030] Figure 6 A schematic diagram of a vehicle window color streak removal device provided in Embodiment 6 of the present invention
[0031] Figure 7 A schematic diagram of the structure of an electronic device provided in Embodiment 7 of the present invention. DETAILED DESCRIPTION
[0032] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0033] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0034] Embodiment 1
[0035] Figure 1 This is a flowchart of a method for training a window color pattern removal model provided in the first embodiment of the present invention. This embodiment can be applied to the case where a target window color pattern removal model is obtained through training to remove color patterns from window images. The method can be executed by a training device for a window color pattern removal model. The training device for a window color pattern removal model can be implemented in the form of hardware and / or software. The training device for a window color pattern removal model can be configured in an electronic device. Figure 1 As shown, the method specifically comprises the following steps:
[0036] S110, obtaining a first vehicle window image sample and a second vehicle window image sample; the second vehicle window image sample includes: a second vehicle window image sample with color patterns and a second vehicle window image sample without color patterns.
[0037] Among them, the first vehicle window image sample can be understood as a vehicle window image sample used for pre-training. The first vehicle window image sample includes: a first vehicle window image sample without color patterns, and can also include a first vehicle window image sample with color patterns. The second vehicle window image sample can be understood as a vehicle window image sample used to further train the vehicle window image generation model, and the second vehicle window image sample includes: a second vehicle window image sample with color patterns and a second vehicle window image sample without color patterns. The first vehicle window image sample without color patterns and the second vehicle window image sample without color patterns essentially refer to vehicle window images without color patterns.
[0038] It should be noted that in the traditional supervised training method, fully paired car window image samples with color patterns and car window image samples without color patterns are required as control samples, which requires collecting car window image samples with color patterns and car window image samples without color patterns based on the same car window under the same lighting environment and at the same angle, which undoubtedly increases the difficulty and cost of sample acquisition; if the acquisition of samples does not meet the requirements, it will inevitably affect the color pattern removal effect of the target car window color pattern removal model. In this embodiment, unlike the traditional supervised training method, the second car window image sample with color patterns and the second car window image sample without color patterns can be images collected under different environments, at different times, or based on different car windows. Therefore, the sample acquisition method is relatively easy, reducing the sample acquisition cost, and reducing the negative impact of the imperfection of the samples on the color pattern removal effect of the target car window color pattern removal model.
[0039] The embodiment of the present invention does not limit the method of obtaining the first vehicle window image sample and the second vehicle window image sample. For example, the vehicle image may be captured by using an image acquisition device such as a road monitoring device, and the vehicle window image in the vehicle image may be obtained by using a vehicle window detection or segmentation algorithm. The vehicle window image is divided into a vehicle window image without color grain and a vehicle window image with color grain. In this embodiment, in order to ensure that the image sample does not have color grain, a high-quality vehicle window image without glass may be used as a vehicle window image sample without color grain. In other words, the first vehicle window image sample and the second vehicle window image sample may be understood as a real vehicle window image.
[0040] Generally, image sensors perform imaging based on the optical imaging physical model, which is constructed based on the linear photosensitive characteristics of the sensor. The image acquired by the image sensor is a nonlinear sRGB image processed by ISP. Furthermore, in an optional embodiment, the initial window image is subjected to inverse ISP processing to convert the nonlinear initial window image into a linear window image sample. The inverse ISP processing is specifically as follows:
[0041] I linear =ISP -1 (I sRGB );
[0042] Among them, I sRGB is the initial window image of sRGB type; I linear is a linear car window image sample, ISP -1 () is the inverse ISP processing. In actual application, the inverse ISP processing parameters can be determined according to the ISP processing parameters of the image sensor that collects the window image. The inverse ISP processing is intended to offset the nonlinear changes caused by the ISP processing of the image sensor.
[0043] S120: Train an initial image generation model according to the first vehicle window image sample and the image generation description text to obtain a vehicle window image generation model.
[0044] The initial image generation model can be understood as an untrained image generation model, which is used to generate a corresponding image according to input information. The car window image generation model refers to an image generation model obtained by training the initial image generation model. In this embodiment, the car window image generation model is further used as an initial basic model to train a target car window color pattern removal model. Therefore, the car window image generation model can be considered as a pre-trained model of the target car window color pattern removal model.
[0045] The input information of the initial image generation model includes: a first vehicle window image sample and an image generation description text. The image generation description text can be understood as text information used to describe whether the generated image is an image with color grain or an image without color grain, and is used to guide the initial image generation model to generate a corresponding reconstructed image. The image generation description text can be "a vehicle window image with color grain" or "a vehicle window image without color grain".
[0046] Specifically, a first vehicle window image sample and an image generation description text are input into an initial image generation model to obtain a first reconstructed image; a loss function value between the first reconstructed image and the first vehicle window image sample is calculated, and model parameters in the initial image generation model are adjusted according to the loss function value until a text-guided vehicle window image generation model is finally obtained.
[0047] In an optional embodiment, the step of training an initial image generation model based on the first vehicle window image sample and the image generation description text to obtain the vehicle window image generation model includes: training an initial image generation model based on the first vehicle window image sample without color grain and the image generation description text without color grain to obtain the vehicle window image generation model containing vehicle window prior information.
[0048] The window prior information can be understood as the window information without color patterns.
[0049] In this embodiment, the first color pattern-free window image sample and the description text for generating the color pattern-free image are input into the initial image generation model, and the model parameters of the initial image generation model are trained so that the window image generation model can include window prior information, and can provide the prior information of the window image after color pattern removal for the training of the target window color pattern removal model, so as to ensure that the quality of the window image is not reduced while removing the color pattern, and improve the color pattern removal effect.
[0050] In another optional embodiment, the step of training an initial image generation model based on the first vehicle window image sample and image generation description text to obtain the vehicle window image generation model includes: training the initial image generation model based on a first vehicle window image sample without color patterns and image generation description text without color patterns, and a first vehicle window image sample with color patterns and image generation description text with color patterns, to obtain a vehicle window image generation model containing vehicle window prior information and color pattern prior information.
[0051] The color pattern prior information may be understood as the prior information of the color pattern contained in the color pattern window image.
[0052] In this embodiment, the first sample of the vehicle window image without color patterns and the description text of the image generation without color patterns are input into the initial image generation model, and the model parameters of the initial image generation model are trained so that the vehicle window image generation model can include the vehicle window prior information; and the first sample of the vehicle window image with color patterns and the description text of the image generation with color patterns are input into the initial image generation model, and the model parameters of the initial image generation model are trained so that the vehicle window image generation model can include the color pattern prior information, thereby obtaining a vehicle window image generation model including the vehicle window prior information and the color pattern prior information, which can provide the prior information of the vehicle window image after the color pattern is removed and the prior information of the color pattern to be removed for the training of the target vehicle window color pattern removal model, thereby further improving the accuracy of the color pattern removal and enhancing the color pattern removal effect.
[0053] S130, inputting the second vehicle window image sample with color patterns and the description text for generating the image without color patterns into a vehicle window image generation model to obtain a predicted vehicle window image without color patterns.
[0054] The prediction of the color pattern-free window image can be understood as reconstructing the second color pattern-free window image sample through the window image generation model to predict the color pattern-free window image. The color pattern-free image generation description text is used to describe the text description information of generating the color pattern-free window image.
[0055] Specifically, the acquired second vehicle window image sample with color patterns and the description text for generating the image without color patterns are input into the vehicle window image generation model, and the second vehicle window image sample with color patterns is reconstructed through the vehicle window image generation model to obtain a predicted vehicle window image without color patterns.
[0056] The embodiment of the present invention obtains a vehicle window image generation model by training an initial image generation model with a first vehicle window image sample representing a real vehicle window image with colored patterns, so that the vehicle window image generation model contains a large amount of vehicle window image prior information; the vehicle window image prior information may include: vehicle window prior information without colored patterns, and may also include colored pattern prior information; and the vehicle window image generation model is used as the initial model of a target vehicle window color pattern removal model, providing rich vehicle window image prior information for the training of the target vehicle window color pattern removal model, thereby facilitating improving the effect of vehicle window color pattern removal without reducing the image quality of the vehicle window image.
[0057] S140, inputting the second color pattern-free window image sample and the predicted color pattern-free window image into a discriminator, calculating a first loss function value according to a discrimination result of the discriminator, and adjusting parameters of the discriminator according to the first loss function value.
[0058] The input of the discriminator is the predicted color pattern-free window image and the real color pattern-free window image; the output of the discriminator is usually a probability value between 0 and 1, indicating the probability that the input sample is a real sample. The discriminator is used to accurately distinguish between real samples and predicted samples to identify forged samples generated by the generator, so that the initial window color pattern removal model can output the predicted color pattern-free window image with the same distribution as the real color pattern-free window image. The first loss function value is used to measure the degree of distinction between the predicted color pattern-free window image forged by the window image generation model and the real second color pattern-free window image sample by the discriminator.
[0059] Specifically, the predicted color pattern-free window image output by the initial window color pattern removal model and the second color pattern-free window image sample used to represent the actual color pattern-free window image are input into the discriminator, the second color pattern-free window image sample and the predicted color pattern-free window image are discriminated by the discriminant function in the discriminator, and the first loss function value is calculated according to the discrimination result of the second color pattern-free window image sample and the predicted color pattern-free window image, and the parameters of the discriminator are adjusted according to the first loss function value.
[0060] Exemplarily, the first loss function value may be a value calculated based on a cross entropy loss function, and the calculation formula is specifically as follows: L D =logD(I out )+log(1-D(I gt )); where L D is the first loss function value, I out To predict the window image without color pattern, I gt is the second sample of the car window image without color pattern; D() is the discriminator function. This formula indicates that the discriminator hopes to increase the score of the true sample as much as possible and reduce the score of the false sample.
[0061] S150, calculating a second loss function value according to the discrimination result of the discriminator, and adjusting the model parameters of the vehicle window image generation model according to the second loss function value to obtain a target vehicle window color pattern removal model.
[0062] The second loss function value is used to measure the discriminator's discriminant result on the predicted window image without color grain. This embodiment does not limit the type of the second loss function, for example, it can be an adversarial loss function and a cross entropy loss function. The target window color grain removal model can be understood as a well-trained window image generation model, which is used to remove window color grains from window images with color grains.
[0063] Specifically, the second loss function value is calculated according to the discrimination result of the discriminator on the predicted color pattern-free window image, and the parameters of the window image generation model are continuously adjusted based on the second loss function value through back propagation and optimization algorithm (such as gradient descent), so that the predicted color pattern-free window image generated by the window image generation model gradually approaches the distribution of the real second color pattern-free window image sample.
[0064] In this embodiment, the goal of the car window image generation model as a generator is to allow the generated samples to be identified as real samples by the discriminator, while the goal of the discriminator is to distinguish the real samples from the generated samples as accurately as possible. By alternately training the generator and the discriminator and continuously iterating and optimizing, the effect of generating realistic car window images without color streaks can be achieved.
[0065] The technical solution of the embodiment of the present invention is to obtain a first vehicle window image sample and a second vehicle window image sample; the second vehicle window image sample includes: a second vehicle window image sample with color patterns and a second vehicle window image sample without color patterns; train an initial image generation model according to the first vehicle window image sample and image generation description text to obtain a vehicle window image generation model; input the second vehicle window image sample with color patterns and the description text of the image generation without color patterns into the vehicle window image generation model to obtain a predicted vehicle window image without color patterns; input the second vehicle window image sample without color patterns and the predicted vehicle window image without color patterns into a discriminator, calculate a first loss function value according to the discrimination result of the discriminator, and adjust the parameters of the discriminator according to the first loss function value; calculate a second loss function value according to the discrimination result of the discriminator, and adjust the model parameters of the vehicle window image generation model according to the second loss function value to obtain a target vehicle window color pattern removal model. The pre-training method is used to provide rich prior information of the vehicle window image for the unsupervised generative adversarial network, effectively reducing or eliminating the color patterns of the vehicle window image while ensuring the image quality. Moreover, compared with the training method of the supervised color pattern removal model, there is no need to collect paired images of vehicles in the same scene, which reduces the difficulty of sample collection.
[0066] Embodiment 2
[0067] Figure 2AA flowchart of a training method for a vehicle window color streak removal model provided in the second embodiment of the present invention, this embodiment further defines the network structure of the initial image generation model on the basis of the above embodiment. Specifically, the initial image generation model includes: an image encoding module, a text encoding module, an image reconstruction module and an image decoding module; the initial image generation model is trained according to the first vehicle window image sample and the image generation description text, and the step of obtaining the vehicle window image generation model includes: inputting the first vehicle window image sample and the image generation description text into the initial image generation model; performing image encoding on the first vehicle window image sample by the image encoding module to obtain a first encoding feature image, and performing text encoding on the image generation description text by the text encoding module to obtain description text encoding features; inputting the first encoding feature image and the description text encoding features into the image reconstruction module to obtain a first reconstructed feature image output by the image reconstruction module; inputting the first reconstructed feature image into the image decoding module to obtain a first reconstructed image output by the image decoding module; calculating a third loss function value according to the first reconstructed image and the first vehicle window image sample, and adjusting the network loss in the initial image generation model according to the third loss function value to obtain the vehicle window image generation model.
[0068] like Figure 2A As shown, the method includes:
[0069] S210, obtaining a first vehicle window image sample and a second vehicle window image sample; the second vehicle window image sample includes: a second vehicle window image sample with color patterns and a second vehicle window image sample without color patterns.
[0070] S220, inputting the first vehicle window image sample and the image generation description text into an initial image generation model; the initial image generation model includes: an image encoding module, a text encoding module, an image reconstruction module and an image decoding module.
[0071] Specifically, Figure 2B This is a schematic diagram of the network structure of the initial image generation model. Figure 2B As shown, the initial image generation model includes: an image encoding module 21, a text encoding module 22, an image reconstruction module 23 and an image decoding module 24. The image encoding module 21 is used to encode the input image. The text encoding module 22 is used to encode the input text description information. The image reconstruction module 23 is used to use the prior knowledge of the degradation process to restore the original appearance of the degraded image, and can reconstruct the degraded image into an original ideal image that is close to or completely free of degradation. The image decoding module 24 is used to decode the reconstructed feature image. Optionally, the image reconstruction module can be a generative adversarial model, a variable differential autoencoder, a flow model or a diffusion model.
[0072] S230, performing image encoding on the first vehicle window image sample through an image encoding module to obtain a first encoding feature image, and performing text encoding on the image-generated description text through a text encoding module to obtain a description text encoding feature.
[0073] The first coding feature image is a coding feature image output by the image coding module, which can be understood as the image coding result of the first window image sample. The description text coding feature is a coding feature data output by the text coding module, which can be understood as the text coding result of the image-generated description text.
[0074] Specifically, the first vehicle window image sample is input into the image encoding module of the initial image generation model, and the image generation description text is input into the text encoding module of the initial image generation model. The first vehicle window image sample is image encoded by the image encoding module to obtain a first encoding feature image corresponding to the first vehicle window image sample; the image generation description text is text encoded by the text encoding module to obtain a description text encoding feature corresponding to the image generation description text.
[0075] S240: Input the first coding feature image and the description text coding feature into an image reconstruction module to obtain a first reconstructed feature image output by the image reconstruction module.
[0076] The first reconstructed feature image is a feature image output by the image reconstruction module, and can be understood as a feature image obtained after the first encoded feature image is reconstructed.
[0077] Specifically, in the initial image generation model, the first coding feature image output by the image coding module and the descriptive text coding features output by the text coding module are input into the image reconstruction module. Under the guidance of the descriptive text coding features, the image reconstruction module performs feature image restoration on the first coding feature image to obtain a first reconstructed feature image.
[0078] In an optional embodiment, the step of inputting the first coding feature image and the description text coding feature into the image reconstruction module to obtain the first reconstructed feature image output by the image reconstruction module includes:
[0079] S241, inputting the first coding feature image and the description text coding feature into an image reconstruction module; the image reconstruction module adopts a diffusion model;
[0080] S242. Perform feature fusion on the first encoded feature image and the descriptive text encoded feature based on the cross attention mechanism through the diffusion model to obtain a first reconstructed feature image.
[0081] Preferably, the image reconstruction module adopts a diffusion module.
[0082] Specifically, the first encoded feature image and the descriptive text encoded features are input into the diffusion module. In the diffusion module, the first encoded feature image and the descriptive text encoded features are fused using a cross attention mechanism to obtain a first reconstructed feature image. The specific calculation formula is:
[0083] cross_attention(z image ,z text )=softmax(W q (z image )W k (z text ) T )W v (z text );
[0084] Among them, cross_attention is the cross attention mechanism, z image is the first encoding feature image, z text To describe the text encoding features, W q is the first convolution operation of the first encoded feature image, W k To describe the convolution operation of text encoding features, W v is the second convolution operation of the first encoded feature image; softmax is the normalized exponential function.
[0085] In this embodiment, a cross-attention fusion mechanism is used in the diffusion module to establish a connection between the image encoding module and the text encoding module, which promotes the exchange and integration of information, thereby improving the ability of the image generation model to process complex images.
[0086] S250 , inputting the first reconstructed feature image into an image decoding module to obtain a first reconstructed image output by the image decoding module.
[0087] The first reconstructed image is an image output by the image decoding module, which can be understood as a decoding result of the first reconstructed feature image, and is also an image obtained by reconstructing the first vehicle window image sample under the guidance of the text of the image generation description text.
[0088] In this embodiment, the first reconstructed feature image output by the image reconstruction module is input to the image decoding module, and the first reconstructed image is obtained by decoding the first reconstructed feature image by the image decoding module.
[0089] S260, calculating a third loss function value according to the first reconstructed image and the first vehicle window image sample, and adjusting the model parameters in the initial image generation model according to the third loss function value to obtain a vehicle window image generation model.
[0090] The third loss function value is used to measure the difference between the first vehicle window image sample before and after reconstruction and the first reconstructed image.
[0091] Specifically, the third loss function value is calculated according to the first reconstructed image and the first vehicle window image sample output by the initial image generation model, and the model parameters of the image encoding module, text encoding module, image reconstruction module and image decoding module in the initial image generation model are adjusted according to the third loss function value to obtain the vehicle window image generation model.
[0092] S270: Input the second vehicle window image sample with color patterns and the description text for generating the image without color patterns into a vehicle window image generation model to obtain a predicted vehicle window image without color patterns.
[0093] Specifically, the second vehicle window image sample with colored patterns and the vehicle window image without colored patterns generation description text are input into the vehicle window image generation model obtained by training, and the second vehicle window image sample with colored patterns is processed by the image encoding module, text encoding module, image reconstruction module and image decoding module in the vehicle window image generation model to obtain a predicted vehicle window image without colored patterns.
[0094] In an optional embodiment, the second vehicle window image sample with color patterns and the description text for generating an image without color patterns are input into a vehicle window image generation model, and the step of obtaining a predicted vehicle window image without color patterns includes: inputting the second vehicle window image sample with color patterns and the description text for generating an image without color patterns into the vehicle window image generation model; performing image encoding on the second vehicle window image sample with color patterns through the image encoding module to obtain a second coded feature image with color patterns, and performing text encoding on the description text for generating an image without color patterns through the text encoding module to obtain a coding feature of a description text without color patterns; inputting the second coded feature image with color patterns and the coding feature of the description text without color patterns into an image reconstruction module to obtain a predicted feature image without color patterns output by the image reconstruction module; and inputting the predicted feature image without color patterns into an image decoding module to obtain a predicted vehicle window image without color patterns output by the image decoding module.
[0095] The description text for generating a color grain-free image is used to indicate that the generated image is a window image without color grains. The second color grain-encoded feature image is a feature image obtained after encoding the second window image sample with color grains. The color grain-free description text encoding feature is feature data obtained after encoding the color grain-free image generation description text. The predicted color grain-free feature image is a predicted color grain-free feature image obtained by reconstructing the second color grain-encoded feature image under the guidance of the color grain-free image generation description text.
[0096] S280, inputting the second color pattern-free window image sample and the predicted color pattern-free window image into a discriminator, calculating a first loss function value according to a discrimination result of the discriminator, and adjusting parameters of the discriminator according to the first loss function value.
[0097] S290. Calculate the second loss function value according to the discrimination result of the discriminator, and adjust the model parameters of the vehicle window image generation model according to the second loss function value to obtain the target vehicle window color pattern removal model. The technical solution of the embodiment of the present invention is to obtain a first vehicle window image sample and a second vehicle window image sample; input the first vehicle window image sample and the image generation description text into the initial image generation model; the initial image generation model includes: an image encoding module, a text encoding module, an image reconstruction module and an image decoding module; perform image encoding on the first vehicle window image sample through the image encoding module to obtain a first encoding feature image, and perform text encoding on the image generation description text through the text encoding module to obtain the description text encoding feature; input the first encoding feature image and the description text encoding feature into the image reconstruction module to obtain the first reconstructed feature image output by the image reconstruction module; input the first reconstructed feature image into the image decoding module to obtain the first Reconstruct the image; calculate the third loss function value according to the first reconstructed image and the first car window image sample, and adjust the model parameters in the initial image generation model according to the third loss function value to obtain the car window image generation model; input the second car window image sample with color pattern and the description text generated by the image without color pattern into the car window image generation model to obtain the predicted car window image without color pattern; input the second car window image sample without color pattern and the predicted car window image without color pattern into the discriminator, calculate the first loss function value according to the discrimination result of the discriminator, and adjust the parameters of the discriminator according to the first loss function value; calculate the second loss function value according to the discrimination result of the discriminator, and adjust the model parameters of the car window image generation model according to the second loss function value to obtain the target car window color pattern removal model. The pre-training method is used to provide the unsupervised generative adversarial network with rich prior information of the car window image without color pattern and the car window image with color pattern, effectively reduce or eliminate the color pattern of the car window image while retaining the details of the car window image and not reducing the quality of the car window image, and improve the generalization ability of the target car window color pattern removal model for different complex car window images.
[0098] Embodiment 3
[0099] Figure 3AA flowchart of a method for training a vehicle window color streak removal model provided in the third embodiment of the present invention, this embodiment further defines the process of adjusting the model parameters of the vehicle window image generation model on the basis of the above embodiment. Specifically, the second loss function value is calculated according to the discrimination result of the discriminator, and the model parameters of the vehicle window image generation model are adjusted according to the second loss function value, and the steps of obtaining the target vehicle window color streak removal model include: calculating the second loss function value according to the discrimination result of the discriminator, freezing the parameters of the image reconstruction module and the text encoding module in the vehicle window image generation model, adjusting the parameters of the image encoding module and the image decoding module in the vehicle window image generation model according to the second loss function value, and obtaining the target vehicle window color streak removal model.
[0100] This embodiment further limits the calculation process of calculating the second loss function value according to the discrimination result of the discriminator.
[0101] In an optional embodiment, the second loss function value is calculated according to the discrimination result of the discriminator, including: calculating the first function value of the adversarial loss function according to the discrimination result of the discriminator on the predicted color pattern-free window image; and determining the first function value as the second loss function value.
[0102] In another optional embodiment, the second loss function value is calculated according to the discrimination result of the discriminator, including: calculating the first function value of the adversarial loss function according to the discrimination result of the discriminator on the predicted color pattern-free window image; determining a comparison sample set of the second color patterned window image sample and the predicted color pattern-free window image, and calculating the second function value of the comparison loss function based on the comparison sample set; calculating the third function value of the difference loss function according to the color pattern image contained in the second color patterned window image sample and the predicted color pattern-free window image; determining the weighted sum of the first function value and the target function value as the second loss function value; wherein the target function value includes: the second function value and / or the third function value.
[0103] Preferably, the weighted sum of the first function value, the second function value and the third function value is determined as the second loss function value. Next, the training of the vehicle window color streak removal model is further described in detail in combination with the preferred implementation of the second loss function value.
[0104] like Figure 3A As shown, the method includes:
[0105] S310, obtaining a first vehicle window image sample and a second vehicle window image sample; the second vehicle window image sample includes: a second vehicle window image sample with color patterns and a second vehicle window image sample without color patterns.
[0106] S320: Train an initial image generation model according to the first vehicle window image sample and the image generation description text to obtain a vehicle window image generation model.
[0107] S330: Input the second vehicle window image sample with color patterns and the description text for generating the image without color patterns into a vehicle window image generation model to obtain a predicted vehicle window image without color patterns.
[0108] In an optional embodiment, the second vehicle window image sample with color patterns and the description text for generating an image without color patterns are input into a vehicle window image generation model, and the step of obtaining a predicted vehicle window image without color patterns includes: inputting the second vehicle window image sample with color patterns and the description text for generating an image without color patterns into the vehicle window image generation model; performing image encoding on the second vehicle window image sample with color patterns through the image encoding module to obtain a second coded feature image with color patterns, and performing text encoding on the description text for generating an image without color patterns through the text encoding module to obtain a coding feature of a description text without color patterns; inputting the second coded feature image with color patterns and the coding feature of the description text without color patterns into an image reconstruction module to obtain a predicted feature image without color patterns output by the image reconstruction module; and inputting the predicted feature image without color patterns into an image decoding module to obtain a predicted vehicle window image without color patterns output by the image decoding module.
[0109] S340, inputting the second color pattern-free window image sample and the predicted color pattern-free window image into a discriminator, calculating a first loss function value according to a discrimination result of the discriminator, and adjusting parameters of the discriminator according to the first loss function value.
[0110] S350, calculating and generating a first function value of the adversarial loss function according to the discriminator's discriminant result on the predicted window image without color streaks.
[0111] The first function value is the value of the adversarial loss function. The adversarial loss function is used to measure the authenticity of the predicted color-pattern-free window image output by the discriminator to the window image generation model.
[0112] Specifically, the adversarial loss function can be L gan = -log(D(I out ));L gan is the first function value of the adversarial loss function, I out To predict the window image without color pattern, D(I out ) is the discriminator’s judgment result on the predicted window image without color patterns, which is usually a probability value between 0 and 1, indicating the probability that the predicted window image without color patterns is discriminated as a real window image.
[0113] S360: Determine a comparison sample set of the second vehicle window image sample with color patterns and the predicted vehicle window image without color patterns, and calculate a second function value of the comparison loss function based on the comparison sample set.
[0114] The second function value is the value of the comparison sample set of the second vehicle window image sample with color patterns and the predicted vehicle window image without color patterns on the comparison loss function.
[0115] Specifically, only using the first function value of the adversarial loss function as a constraint often causes the model to produce many artifacts that affect the image quality. Based on the physical principle of window color pattern generation, a color pattern physical model can be established, I = T + R; I is the window image with color patterns, T is the window image without color patterns, and R is the color pattern image. And based on the observation and analysis of the color pattern image I and the non-color pattern image T, the color pattern window image I and the non-color pattern window image T of the same window are both different and related in terms of image and feature image. A set of sample pairs {I, T} consisting of a window image with color patterns and a window image without color patterns, the data blocks (pixel blocks or feature blocks) of the window image without color patterns and the data blocks (pixel blocks or feature blocks) at the same position of the window image with color patterns should have similar background features, and have certain differences in background features relative to the data blocks at other positions on the window image with color patterns I. Therefore, the contrast sample set {I, T} consisting of positive and negative sample pairs is introduced to calculate the second function value of the contrast loss function to constrain the model parameters of the window image generation model.
[0116] In an optional embodiment, the step of determining a comparison sample set of the second vehicle window image sample with colored patterns and the predicted vehicle window image without colored patterns includes: obtaining a first positive sample pair consisting of a first pixel block in the predicted vehicle window image without colored patterns and a second pixel block in the second vehicle window image sample with colored patterns, and a first negative sample pair consisting of a first pixel block in the predicted vehicle window image without colored patterns and a third pixel block in the second vehicle window image sample with colored patterns; forming a first positive-negative sample pair based on the first positive sample pair and the first negative sample pair; and forming a comparison sample set based on each of the first positive and negative sample pairs.
[0117] Among them, the second pixel block is the pixel block corresponding to the pixel position of the first pixel block in the second sample of the image of the car window with color patterns, and the third pixel block is a pixel block selected from other pixel blocks in the second sample of the image of the car window with color patterns except the second pixel block. The first positive sample pair can be understood as a pixel block sample pair that is a positive contrast to each other; the first negative sample pair can be understood as a pixel block sample pair that is a reverse contrast to each other. The first positive and negative sample pair is a set of the first positive sample pair and the first negative sample pair corresponding to a first pixel block in the predicted image of the car window without color patterns. The comparison sample set is a set of the first positive and negative sample pairs corresponding to all the first pixel blocks in the predicted image of the car window without color patterns.
[0118] Specifically, Figure 3B Schematic diagram of the formation principle of the first positive and negative sample pairs. Figure 3BAs shown, for each first pixel block B1 in the predicted image of the vehicle window without color patterns and the second pixel block B2 at the same pixel position in the second sample of the vehicle window with color patterns, a pair of first positive sample pairs (B1, B2) are formed; for each first pixel block B1 in the predicted image of the vehicle window without color patterns and all or part of the third pixel blocks B3 at different pixel positions in the second sample of the vehicle window with color patterns, a pair of first negative sample pairs (B1, B3) are formed respectively ( Figure 3B The first pixel block B1 and all the third pixel blocks B constitute a negative sample pair). The first positive sample pair and the first negative sample pair corresponding to a first pixel block constitute a first positive-negative sample pair, and the set of first positive-negative sample pairs corresponding to all first pixel blocks in the predicted color pattern-free window image is determined as a comparison sample set.
[0119] Furthermore, for the predicted color pattern-free window image with a pixel size of A×A, since each pixel block has A×A-1 negative samples, the predicted color pattern-free window image has a total of A×A×(A×A-1) negative samples and A×A positive samples, and the amount of sample data is very large. In order to ensure the diversity of the image and maintain the image details while improving the efficiency of model training, for each pixel block of the predicted color pattern-free window image, a certain number of first negative samples are randomly selected from the (A×A-1) negative control pixel blocks of the second color pattern window image sample, so that multi-level image details are guaranteed in the formed comparison sample set, and there will not be too much calculation. The number of randomly selected first negative samples can be set according to actual needs or customized based on the requirements for hardware resources.
[0120] In another optional embodiment, the step of determining a comparison sample set of the second color pattern vehicle window image sample and the predicted color pattern-free vehicle window image includes: obtaining a second positive sample pair consisting of a first feature block in a predicted color pattern-free feature image corresponding to the predicted color pattern-free vehicle window image and a second feature block in a second color pattern coded feature image corresponding to the second color pattern vehicle window image sample, and a second negative sample pair consisting of a first feature block in a predicted color pattern-free feature image corresponding to the predicted color pattern-free vehicle window image and a third feature block in a second color pattern coded feature image corresponding to the second color pattern vehicle window image sample.
[0121] Among them, the first feature block is the feature block corresponding to the position of the first feature block in the predicted feature image without color patterns, and the third feature block is a feature block selected from other feature blocks in the second feature image with color patterns except the second feature block; the second positive and negative sample pairs are formed according to the second positive sample pair and the second negative sample pair; and the comparison sample set is formed according to each second positive and negative sample pair.
[0122] Similarly, in this embodiment, the predicted color-line-free feature image corresponding to the predicted color-line-free window image can be used instead of the predicted color-line-free window image to generate a comparison sample set. The process of forming a comparison sample set based on the predicted color-line-free feature image is basically the same as the process of forming a comparison sample set based on the predicted color-line-free window image, which will not be described in detail in this embodiment.
[0123] In another optional embodiment, a first positive sample pair consisting of a first pixel block in the predicted vehicle window image without color patterns and a second pixel block in the second vehicle window image sample with color patterns, and a first negative sample pair consisting of a first pixel block in the predicted vehicle window image without color patterns and a third pixel block in the second vehicle window image sample with color patterns are obtained; wherein the second pixel block is a pixel block corresponding to the pixel position of the first pixel block in the second vehicle window image sample with color patterns, and the third pixel block is a pixel block selected from other pixel blocks in the second vehicle window image sample with color patterns except the second pixel block; a first positive-negative sample pair is formed based on the first positive sample pair and the first negative sample pair; the first feature block and the third pixel block in the predicted feature image without color patterns corresponding to the predicted vehicle window image without color patterns are obtained. A second positive sample pair is formed by a second feature block in a second coded feature image with colored patterns corresponding to two samples of the image of the window with colored patterns, and a second negative sample pair is formed by a first feature block in a predicted feature image without colored patterns corresponding to the predicted feature image of the window with colored patterns and a third feature block in a second coded feature image with colored patterns corresponding to the second sample of the image of the window with colored patterns; wherein the first feature block is a feature block corresponding to the position of the first feature block in the predicted feature image without colored patterns, and the third feature block is a feature block selected from other feature blocks in the second coded feature image with colored patterns except the second feature block; a second positive and negative sample pair is formed according to the second positive sample pair and the second negative sample pair; a comparison sample set is formed according to each of the first positive and negative sample pairs and each of the second positive and negative sample pairs.
[0124] Specifically, the predicted color pattern-free window image and the predicted color pattern-free feature image contain different levels of information. In order to further improve the color pattern removal effect of the model, the set of the first positive sample pairs corresponding to all the first pixel blocks in the predicted color pattern-free window image and the set of the second positive sample pairs corresponding to all the first feature blocks in the predicted color pattern-free feature image corresponding to the predicted color pattern-free window image are determined as a comparison sample set.
[0125] In another optional embodiment, the calculation formula for calculating the second function value of the contrast loss function based on the contrast sample set is:
[0126]
[0127] i∈[0,M-1],j∈[0,N-1];
[0128] Among them, L PNCE is the contrast loss function, p is the case of predicting the window image without color pattern, p + and p- comes from the second sample of the car window image with color patterns, or p is the predicted image without color patterns, p + and p- comes from the second color-coded feature image; p + and p constitute a positive sample pair, and p- and p constitute a negative sample pair; represents the positive sample of pi, represents the jth negative sample of pi; M is the number of positive sample pairs, N is the number of negative sample pairs; τ is a hyperparameter. A hyperparameter can be, for example, a temperature coefficient, which is used to adjust the degree of attention paid to difficult samples.
[0129] The physical meaning of the contrast loss function is to convert the similarity between positive and negative samples into the possibility of random events, that is, to judge the similarity between the real distribution and the estimated distribution of the samples by measuring the distance between the two. By minimizing the contrast loss function, the distance between the positive sample pairs is gradually reduced, and the distance between the negative sample pairs is gradually increased, so that the predicted color pattern-free window image is closer to the real window image.
[0130] By calculating the second function value of the contrast loss function of the contrast sample set, the difference between the predicted color-pattern-free window image and the actual color-pattern-free window image sample can be accurately compared, thereby improving the training accuracy of the window image generation model.
[0131] S370, calculating a third function value of the difference loss function according to the color pattern image included in the second color pattern vehicle window image sample and the predicted color pattern-free vehicle window image.
[0132] The third function value is the value of the difference loss function, which is used to measure the difference between the color pattern image contained in the second color pattern vehicle window image sample input by the vehicle window image generation model and the predicted color pattern-free vehicle window image output by the vehicle window image generation model.
[0133] In order to more effectively remove the color streak while maintaining the details of the original car window image, the color streak physical model is I = T + R; I is the car window image with color streak, T is the car window image without color streak, and R is the color streak image; and the input-output relationship of the car window image generation model is I out =Model(I in ), the process of removing color streaks is equivalent to removing the color streak from I = I in Decompose T=I out Component, so the color pattern image can be expressed as R = I in -I out. Since the color pattern-free window image T and the color pattern image R have two completely different feature expressions, it is expected that the color pattern image contained in the second color pattern window image sample input by the model and the predicted color pattern-free window image output by the model are as different as possible, that is, the difference between the color pattern image and the predicted color pattern-free window image is as large as possible, and the correlation is as small as possible, which means that the effect of removing the color pattern component is better. Therefore, a normalized correlation coefficient is introduced to constrain the difference between the predicted color pattern-free window image and the color pattern image.
[0134] In an optional embodiment, the step of calculating the third function value of the difference loss function based on the color pattern image contained in the second color pattern window image sample and the predicted color pattern-free window image includes: subtracting the second color pattern window image sample and the predicted color pattern-free window image to obtain the color pattern image; obtaining the color pattern feature image corresponding to the color pattern image and the predicted color pattern-free feature image corresponding to the predicted color pattern-free window image; and determining the normalized correlation coefficient between the color pattern feature image and the predicted color pattern-free feature image as the third function value of the difference loss function.
[0135] Exemplarily, the difference loss function is:
[0136] L PNCC (T,R)=L PNCC (I out ,I in -I out )=NCC(F(I out ),F(I in -I out ));
[0137] Among them, L PNCC (T, R) is the third function value of the difference loss function between the color pattern-free window image T and the color pattern image R; out To predict the window image without color pattern, I in is the second sample of the car window image with colored patterns; NCC is the normalized correlation coefficient, and F() is the feature extraction module. The feature extraction module can be, for example, a VGG network.
[0138] This embodiment proposes to use the difference between the color pattern image and the color pattern-free window image as one of the loss functions for model training, which enriches the dimensions for measuring model performance and further improves the accuracy and performance of the model.
[0139] S380. Determine a weighted sum of the first function value, the second function value, and the third function value as a second loss function value.
[0140] Specifically, a weighted sum is performed on the first function value, the second function value, and the third function value to obtain a second loss function value.
[0141] Exemplarily, the second loss function value is:
[0142] L=L gan +λL PNCE +βL PNCC ;
[0143] Among them, L is the second loss function value, λ is the second function value L PNCE The weight factor, γ is the value of the third function L PNCC The weight factor of .
[0144] This embodiment comprehensively considers the adversarial loss corresponding to the discrimination result, the contrast loss between the real window image sample with color pattern and the window image without color pattern predicted by the window image generation model, and the difference loss between the color pattern image and the predicted window image without color pattern. It can comprehensively estimate the error of the model and make the prediction result of the window image generation model closer to the real window image, thereby improving the accuracy and efficiency of the target window color pattern removal model in removing window color patterns.
[0145] S390, freezing the parameters of the image reconstruction module and the text encoding module in the vehicle window image generation model, adjusting the parameters of the image encoding module and the image decoding module in the vehicle window image generation model according to the second loss function value, and obtaining the target vehicle window color pattern removal model.
[0146] Specifically, the parameters of the image reconstruction module and the text encoding module in the vehicle window image generation model are frozen so that the parameters of the image reconstruction module and the text encoding module are not adjusted, and the parameters of the image encoding module and the image decoding module in the vehicle window image generation model are iteratively adjusted according to the second loss function value until the target vehicle window color pattern removal model is obtained.
[0147] The technical solution of the embodiment of the present invention comprises the following steps: obtaining a first vehicle window image sample and a second vehicle window image sample; the second vehicle window image sample comprises: a second vehicle window image sample with color patterns and a second vehicle window image sample without color patterns; training an initial image generation model according to the first vehicle window image sample and image generation description text to obtain a vehicle window image generation model; inputting the second vehicle window image sample with color patterns and the image generation description text without color patterns into the vehicle window image generation model to obtain a predicted vehicle window image without color patterns; inputting the second vehicle window image sample without color patterns and the predicted vehicle window image without color patterns into a discriminator, calculating a first loss function value according to the discrimination result of the discriminator, and adjusting the parameters of the discriminator according to the first loss function value; adjusting the parameters of the discriminator according to the predicted vehicle window image without color patterns by the discriminator; The first function value of the adversarial loss function is calculated based on the discrimination result of the image; a comparison sample set of the second car window image sample with color patterns and the predicted car window image without color patterns is determined, and the second function value of the comparison loss function is calculated based on the comparison sample set; the third function value of the difference loss function is calculated based on the color pattern image contained in the second car window image sample with color patterns and the predicted car window image without color patterns; the weighted sum of the first function value, the second function value and the third function value is determined as the second loss function value; the parameters of the image reconstruction module and the text encoding module in the car window image generation model are frozen, and the parameters of the image encoding module and the image decoding module in the car window image generation model are adjusted according to the second loss function value to obtain the target car window color pattern removal model. The pre-training method is used to provide the unsupervised generative adversarial network with rich prior information of the car window image without color patterns and the car window image with color patterns, and the loss function is optimized to effectively reduce or eliminate the color patterns of the car window image while retaining the details of the car window image and not reducing the quality of the car window image.
[0148] Embodiment 4
[0149] Figure 4 This is a flowchart of a method for removing color patterns from a car window provided in the fourth embodiment of the present invention. This embodiment is applicable to the case where a car window image with color patterns is subjected to color pattern removal. The method can be executed by a car window color pattern removal device. The car window color pattern removal device can be implemented in the form of hardware and / or software. The car window color pattern removal device can be configured in an electronic device. Figure 4 As shown, the method specifically comprises the following steps:
[0150] S410: Obtain a vehicle window image to be processed.
[0151] The vehicle window image to be processed is a vehicle window image with color patterns waiting to be removed.
[0152] Specifically, the collected image to be processed may be subjected to target detection or vehicle window detection to obtain the vehicle window image to be processed. In addition, the acquired vehicle window image may be subjected to inverse ISP processing according to actual needs.
[0153] S420, inputting the vehicle window image to be processed into a target vehicle window color pattern removal model obtained by training using a vehicle window color pattern removal model training method.
[0154] S430, removing color patterns from the window image to be processed by using the target window color pattern removal model to obtain a window image without color patterns.
[0155] The color-pattern-removed window image can be understood as the window image after the color patterns are removed.
[0156] Specifically, the target window color pattern removal model includes: an image encoding module, a text encoding module, an image reconstruction module and an image decoding module. The window image to be processed is input into the target window color pattern removal model; the window image to be processed is encoded by the image encoding module in the target window color pattern removal model to obtain an encoded window image; the image generation description text input into the text encoding module is set as the color pattern-free window image generation description text, and the output is the color pattern-free window description text encoding feature, the encoded window image and the color pattern-free window description text encoding feature are input into the image reconstruction module, and the color pattern-free window feature image output by the image reconstruction module is obtained; the color pattern-free window feature image is input into the image decoding module, and the color pattern-free window image output by the image decoding module is obtained.
[0157] It is understandable that, in the use scenario of color grain removal, the description text generated by the color grain-free window image input by the text encoding module can be input by the user or set as a default parameter.
[0158] In an optional embodiment, after the step of removing color patterns from the window image to be processed by using the target window color pattern removal model to obtain a color pattern removed window image, the step further includes: pyramid fusion of the color pattern removed window image and the window image to be processed to obtain a target window image.
[0159] Specifically, after obtaining the de-colorized window image after removing the color patterns from the window image to be processed, the de-colorized window image is fused into the window image to be processed using a pyramid fusion technique to ensure natural image transition and texture consistency.
[0160] The technical solution of the embodiment of the present invention is to obtain a vehicle window image to be processed; input the vehicle window image to be processed into a target vehicle window color pattern removal model trained by a vehicle window color pattern removal model training method; perform color pattern removal on the vehicle window image to be processed by the target vehicle window color pattern removal model to obtain a vehicle window image without color pattern, which can effectively reduce or eliminate the color patterns in the vehicle window image while retaining the details of the vehicle window image, thereby ensuring the quality of the vehicle window image.
[0161] Embodiment 5
[0162] Figure 5This is a schematic diagram of the structure of a training device for a vehicle window color streak removal model provided in Embodiment 5 of the present invention. Figure 5 As shown, the device includes: a sample acquisition module 510, an image generation model training module 520, an image prediction module 530, a discriminator training module 540 and a color pattern removal model training module 550; wherein,
[0163] The sample acquisition module 510 is used to acquire a first vehicle window image sample and a second vehicle window image sample; the second vehicle window image sample includes: a second vehicle window image sample with color patterns and a second vehicle window image sample without color patterns;
[0164] An image generation model training module 520 is used to train an initial image generation model according to the first vehicle window image sample and the image generation description text to obtain a vehicle window image generation model;
[0165] An image prediction module 530 is used to input the second vehicle window image sample with color streaks and the description text for generating a vehicle window image without color streaks into the vehicle window image generation model to obtain a predicted vehicle window image without color streaks;
[0166] A discriminator training module 540, configured to input the second color streak-free vehicle window image sample and the predicted color streak-free vehicle window image into a discriminator, calculate a first loss function value according to a discrimination result of the discriminator, and adjust parameters of the discriminator according to the first loss function value;
[0167] The color streak removal model training module 550 is used to calculate the second loss function value based on the discrimination result of the discriminator, and adjust the model parameters of the vehicle window image generation model according to the second loss function value to obtain the target vehicle window color streak removal model.
[0168] The technical solution of the embodiment of the present invention is to obtain a first vehicle window image sample and a second vehicle window image sample; the second vehicle window image sample includes: a second vehicle window image sample with color patterns and a second vehicle window image sample without color patterns; train an initial image generation model according to the first vehicle window image sample and image generation description text to obtain a vehicle window image generation model; input the second vehicle window image sample with color patterns and the image generation description text without color patterns into the vehicle window image generation model to obtain a predicted vehicle window image without color patterns; input the second vehicle window image sample without color patterns and the predicted vehicle window image without color patterns into a discriminator, calculate a first loss function value according to the discrimination result of the discriminator, and adjust the parameters of the discriminator according to the first loss function value; calculate a second loss function value according to the discrimination result of the discriminator, and adjust the model parameters of the vehicle window image generation model according to the second loss function value to obtain a target vehicle window color pattern removal model. The pre-training method is used to provide the unsupervised generative adversarial network with rich prior information of vehicle window images without color patterns and vehicle window images with color patterns, so as to effectively reduce or eliminate the color patterns of the vehicle window image while ensuring the image quality.
[0169] Optionally, the image generation model training module 520 is specifically used for:
[0170] The initial image generation model is trained according to the first color grain-free vehicle window image sample and the description text generated by the color grain-free image to obtain a vehicle window image generation model containing vehicle window prior information;
[0171] Alternatively, an initial image generation model is trained based on the first image sample of the vehicle window without color patterns and the description text generated from the image without color patterns, as well as the first image sample of the vehicle window with color patterns and the description text generated from the image with color patterns, to obtain a vehicle window image generation model containing vehicle window prior information and color pattern prior information.
[0172] Optionally, the image generation model training module 520 includes:
[0173] An input unit, used to input the first vehicle window image sample and the image generation description text into the initial image generation model; the initial image generation model includes: an image encoding module, a text encoding module, an image reconstruction module and an image decoding module;
[0174] an encoding unit, configured to perform image encoding on the first vehicle window image sample through the image encoding module to obtain a first encoding feature image, and to perform text encoding on the description text generated by the image through the text encoding module to obtain a description text encoding feature;
[0175] A reconstruction unit, used for inputting the first coding feature image and the description text coding feature into an image reconstruction module to obtain a first reconstructed feature image output by the image reconstruction module;
[0176] A decoding unit, used for inputting the first reconstructed feature image into an image decoding module to obtain a first reconstructed image output by the image decoding module;
[0177] The first parameter adjustment unit is used to calculate a third loss function value according to the first reconstructed image and the first vehicle window image sample, and adjust the model parameters in the initial image generation model according to the third loss function value to obtain a vehicle window image generation model.
[0178] Optional, reconstruction unit, specifically used for:
[0179] Inputting the first coding feature image and the description text coding feature into an image reconstruction module; the image reconstruction module adopts a diffusion model;
[0180] The diffusion model is used to perform feature fusion on the first encoded feature image and the descriptive text encoded features based on a cross attention mechanism to obtain a first reconstructed feature image.
[0181] Optionally, the color pattern removal model training module 550 includes:
[0182] A first calculation unit, used for calculating and generating a first function value of an adversarial loss function according to a discrimination result of the discriminator on the predicted color pattern-free vehicle window image;
[0183] A second calculation unit is used to determine a comparison sample set of the second vehicle window image sample with color patterns and the predicted vehicle window image without color patterns, and calculate a second function value of the comparison loss function based on the comparison sample set;
[0184] A third calculation unit, configured to calculate a third function value of a difference loss function according to the color pattern image included in the second color pattern vehicle window image sample and the predicted color pattern-free vehicle window image;
[0185] a determining unit, configured to determine the first function value as a second loss function value, or to determine a weighted sum of the first function value and an objective function value as a second loss function value; wherein the objective function value includes: the second function value and / or the third function value;
[0186] The second parameter adjustment unit is used to freeze the parameters of the image reconstruction module and the text encoding module in the vehicle window image generation model, and adjust the parameters of the image encoding module and the image decoding module in the vehicle window image generation model according to the second loss function value to obtain the target vehicle window color pattern removal model.
[0187] Optionally, the second computing unit is specifically configured to:
[0188] Obtain a first positive sample pair consisting of a first pixel block in the predicted vehicle window image without color patterns and a second pixel block in the second vehicle window image sample with color patterns, and a first negative sample pair consisting of a first pixel block in the predicted vehicle window image without color patterns and a third pixel block in the second vehicle window image sample with color patterns; wherein the second pixel block is a pixel block corresponding to a pixel position where the first pixel block is located in the second vehicle window image sample with color patterns, and the third pixel block is a pixel block selected from other pixel blocks in the second vehicle window image sample with color patterns except the second pixel block;
[0189] Constructing a first positive-negative sample pair according to the first positive sample pair and the first negative sample pair;
[0190] Obtain a second positive sample pair consisting of a first feature block in a predicted feature image without color patterns corresponding to the predicted vehicle window image without color patterns and a second feature block in a second coded feature image with color patterns corresponding to the second vehicle window image sample with color patterns, and a second negative sample pair consisting of a first feature block in a predicted feature image without color patterns corresponding to the predicted vehicle window image without color patterns and a third feature block in a second coded feature image with color patterns corresponding to the second vehicle window image sample with color patterns; wherein the first feature block is a feature block corresponding to the position of the first feature block in the predicted feature image without color patterns, and the third feature block is a feature block selected from other feature blocks in the second coded feature image with color patterns except the second feature block;
[0191] Constructing a second positive-negative sample pair according to the second positive sample pair and the second negative sample pair;
[0192] A comparison sample set is formed according to each of the first positive and negative sample pairs and / or each of the second positive and negative sample pairs.
[0193] Optionally, the third computing unit is specifically configured to:
[0194] Subtracting the second vehicle window image sample with color patterns from the predicted vehicle window image without color patterns to obtain a color pattern image;
[0195] Acquire a color pattern feature image corresponding to the color pattern image, and a predicted color pattern-free feature image corresponding to the predicted color pattern-free vehicle window image;
[0196] The normalized correlation coefficient between the color pattern feature image and the predicted non-color pattern feature image is determined as a third function value of the difference loss function.
[0197] The training device for the vehicle window color streak removal model provided in the embodiment of the present invention can execute the training method for the vehicle window color streak removal model provided in any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method.
[0198] Embodiment 6
[0199] Figure 6 This is a schematic diagram of the structure of a vehicle window color streak removal device provided in Embodiment 6 of the present invention. Figure 6 As shown, the device includes: an image acquisition module 610, an image input module 620, and a color pattern removal module 630, wherein:
[0200] An image acquisition module 610 is used to acquire a vehicle window image to be processed;
[0201] An image input module 620 is used to input the vehicle window image to be processed into a target vehicle window color streak removal model trained by a vehicle window color streak removal model training method;
[0202] The color pattern removal module 630 is used to remove color patterns from the vehicle window image to be processed by using the target vehicle window color pattern removal model to obtain a vehicle window image without color patterns.
[0203] The technical solution of the embodiment of the present invention is to obtain a vehicle window image to be processed; input the vehicle window image to be processed into a target vehicle window color pattern removal model trained by a vehicle window color pattern removal model training method; perform color pattern removal on the vehicle window image to be processed by the target vehicle window color pattern removal model to obtain a vehicle window image without color pattern, which can effectively reduce or eliminate the color patterns in the vehicle window image while retaining the details of the vehicle window image, thereby ensuring the quality of the vehicle window image.
[0204] The vehicle window color streak removal device provided in the embodiment of the present invention can execute the vehicle window color streak removal method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0205] Embodiment 7
[0206] Figure 7 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0207] like Figure 7 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0208] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0209] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 executes the various methods and processes described above, such as a training method for a vehicle window tint removal model or a vehicle window tint removal method.
[0210] In some embodiments, the training method of the window tint removal model or the window tint removal method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the training method of the window tint removal model or the window tint removal method described above may be executed. Alternatively, in other embodiments, the processor 11 may be configured to execute the training method of the window tint removal model or the window tint removal method in any other appropriate manner (e.g., by means of firmware).
[0211] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0212] In some embodiments, the training method of the window tint removal model or the window tint removal method can be implemented as a computer program, which is invisibly included in a computer program product. When the computer program is executed by a processor, the training method of the window tint removal model or the window tint removal method of the present invention is implemented. The computer program product can be understood as a software product that mainly implements its solution through a computer program. The computer program for implementing the method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flowchart and / or block diagram are implemented. The computer program can be executed entirely on the machine, partially on the machine, as an independent software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0213] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0214] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0215] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0216] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0217] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0218] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A training method for a car window color streak removal model, characterized in that: include: Acquire a first vehicle window image sample and a second vehicle window image sample; The second vehicle window image sample comprises: a second vehicle window image sample with color patterns and a second vehicle window image sample without color patterns; Train an initial image generation model according to the first vehicle window image sample and the image generation description text to obtain a vehicle window image generation model; Inputting the second vehicle window image sample with color patterns and the description text for generating the image without color patterns into the vehicle window image generation model to obtain a predicted vehicle window image without color patterns; Inputting the second color streak-free vehicle window image sample and the predicted color streak-free vehicle window image into a discriminator, calculating a first loss function value according to a discrimination result of the discriminator, and adjusting parameters of the discriminator according to the first loss function value; A second loss function value is calculated according to the discrimination result of the discriminator, and the model parameters of the vehicle window image generation model are adjusted according to the second loss function value to obtain a target vehicle window color pattern removal model.
2. The method according to claim 1, characterized in that The step of training an initial image generation model according to the first vehicle window image sample and the image generation description text to obtain a vehicle window image generation model comprises: The initial image generation model is trained according to the first color grain-free vehicle window image sample and the description text generated by the color grain-free image to obtain a vehicle window image generation model containing vehicle window prior information; Alternatively, an initial image generation model is trained based on the first image sample of the vehicle window without color patterns and the description text generated from the image without color patterns, as well as the first image sample of the vehicle window with color patterns and the description text generated from the image with color patterns, to obtain a vehicle window image generation model containing vehicle window prior information and color pattern prior information.
3. The method according to claim 1, characterized in that The step of training the initial image generation model according to the first vehicle window image sample and the image generation description text to obtain the vehicle window image generation model comprises: Inputting the first vehicle window image sample and the image generation description text into the initial image generation model; the initial image generation model comprises: an image encoding module, a text encoding module, an image reconstruction module and an image decoding module; Performing image encoding on the first vehicle window image sample by the image encoding module to obtain a first encoding feature image, and performing text encoding on the description text generated by the image by the text encoding module to obtain a description text encoding feature; Inputting the first coding feature image and the description text coding feature into an image reconstruction module to obtain a first reconstructed feature image output by the image reconstruction module; Inputting the first reconstructed feature image into an image decoding module to obtain a first reconstructed image output by the image decoding module; A third loss function value is calculated according to the first reconstructed image and the first vehicle window image sample, and model parameters in the initial image generation model are adjusted according to the third loss function value to obtain a vehicle window image generation model.
4. The method according to claim 3, characterized in that The step of inputting the first coding feature image and the description text coding feature into an image reconstruction module to obtain the first reconstructed feature image output by the image reconstruction module comprises: Inputting the first coding feature image and the description text coding feature into an image reconstruction module; the image reconstruction module adopts a diffusion model; The diffusion model is used to perform feature fusion on the first encoded feature image and the descriptive text encoded features based on a cross attention mechanism to obtain a first reconstructed feature image.
5. The method according to any one of claims 1 to 4, characterized in that: The step of calculating a second loss function value according to the discrimination result of the discriminator, and adjusting the model parameters of the vehicle window image generation model according to the second loss function value to obtain a target vehicle window color pattern removal model includes: Calculating and generating a first function value of an adversarial loss function according to a discrimination result of the discriminator on the predicted color pattern-free vehicle window image; Determine a comparison sample set of the second vehicle window image sample with color patterns and the predicted vehicle window image without color patterns, and calculate a second function value of the comparison loss function based on the comparison sample set; Calculating a third function value of the difference loss function according to the color pattern image included in the second color pattern vehicle window image sample and the predicted color pattern-free vehicle window image; Determine the first function value as a second loss function value, or determine a weighted sum of the first function value and an objective function value as a second loss function value; wherein the objective function value includes: the second function value and / or the third function value; Freeze the parameters of the image reconstruction module and the text encoding module in the vehicle window image generation model, adjust the parameters of the image encoding module and the image decoding module in the vehicle window image generation model according to the second loss function value, and obtain the target vehicle window color pattern removal model.
6. The method according to claim 5, characterized in that The step of determining the comparison sample set of the second vehicle window image sample with color patterns and the predicted vehicle window image without color patterns comprises: Obtain a first positive sample pair consisting of a first pixel block in the predicted vehicle window image without color patterns and a second pixel block in the second vehicle window image sample with color patterns, and a first negative sample pair consisting of a first pixel block in the predicted vehicle window image without color patterns and a third pixel block in the second vehicle window image sample with color patterns; wherein the second pixel block is a pixel block corresponding to a pixel position where the first pixel block is located in the second vehicle window image sample with color patterns, and the third pixel block is a pixel block selected from other pixel blocks in the second vehicle window image sample with color patterns except the second pixel block; Constructing a first positive-negative sample pair according to the first positive sample pair and the first negative sample pair; Obtain a second positive sample pair consisting of a first feature block in a predicted feature image without color patterns corresponding to the predicted vehicle window image without color patterns and a second feature block in a second coded feature image with color patterns corresponding to the second vehicle window image sample with color patterns, and a second negative sample pair consisting of a first feature block in a predicted feature image without color patterns corresponding to the predicted vehicle window image without color patterns and a third feature block in a second coded feature image with color patterns corresponding to the second vehicle window image sample with color patterns; wherein the first feature block is a feature block corresponding to the position of the first feature block in the predicted feature image without color patterns, and the third feature block is a feature block selected from other feature blocks in the second coded feature image with color patterns except the second feature block; Constructing a second positive-negative sample pair according to the second positive sample pair and the second negative sample pair; A comparison sample set is formed according to each of the first positive and negative sample pairs and / or each of the second positive and negative sample pairs.
7. The method according to claim 5, characterized in that The step of calculating the third function value of the difference loss function according to the color pattern image included in the second color pattern vehicle window image sample and the predicted color pattern-free vehicle window image comprises: Subtracting the second vehicle window image sample with color patterns from the predicted vehicle window image without color patterns to obtain a color pattern image; Acquire a color pattern feature image corresponding to the color pattern image, and a predicted color pattern-free feature image corresponding to the predicted color pattern-free vehicle window image; The normalized correlation coefficient between the color pattern feature image and the predicted non-color pattern feature image is determined as a third function value of the difference loss function.
8. A method for removing colored streaks from a vehicle window, characterized in that: include: Obtain the vehicle window image to be processed; Inputting the vehicle window image to be processed into a target vehicle window color streak removal model obtained by training the vehicle window color streak removal model training method according to any one of claims 1 to 7; The target vehicle window color pattern removal model is used to remove color patterns from the vehicle window image to be processed, so as to obtain a vehicle window image without color patterns.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the training method for the vehicle window color streak removal model described in any one of claims 1-7, or the vehicle window color streak removal method described in claim 8.
10. A computer program product, characterized in that The computer program product comprises a computer program, which, when executed by a processor, implements the method for training a vehicle window color streak removal model according to any one of claims 1 to 7, or the method for removing vehicle window color streak according to claim 8.
