Image processing method, training method, device, equipment and computer-readable storage medium
The pure rain layer and rain removal background layer are generated through the attention mechanism network, and the parameters are updated using adversarial and cyclic consistent loss values, which solves the problem of distinguishing rain lines and background edges in the existing technology, and achieves efficient image rain removal and improves generation The authenticity of the image.
Patent Information
- Application Number
- CN202010447845.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2020-05-15
- Filing Date
- 2020-05-25
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2040-05-25
AI Technical Summary
Existing image rain removal methods are difficult to effectively distinguish when the rain lines overlap with the background edge, resulting in increased algorithm complexity and poor rain removal effect.
The attention mechanism network is used to generate pure rain layers and rain removal background layers, and the adversarial loss value and cyclic consistent loss value are back propagated and updated, reducing dependence on external information and realizing image rain removal.
Improve the efficiency of image rain removal and the authenticity of generated images, reduce the dependence on paired image set databases, and simplify the rain removal process.
Smart Images

Figure CN111754419B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an image processing method and apparatus, a training method and apparatus, equipment and a computer-readable storage medium. Background Art
[0002] With the rapid development of computer vision, outdoor vision systems have been widely used. However, outdoor vision systems are easily affected by factors such as weather. Rain is one of the factors that affect outdoor vision systems. Removing the influence of rain such as raindrops or rain lines has important practical significance.
[0003] Existing image deraining methods generally include methods based on dictionary learning and filtering methods using filters such as guided filtering.
[0004] The dictionary learning-based method believes that rain lines and background edges belong to different structures and should be represented by different dictionaries to distinguish whether the edge belongs to the rain line for rain removal. However, in real life, the characteristics of rain lines and certain background edges will overlap, which requires the continuous introduction of new features in the subsequent dictionary separation step to increase the discrimination of the dictionary to improve accuracy, but at the same time it will increase the complexity of the algorithm. Traditional filters, even existing edge-preserving filters, cannot achieve rain removal well. Summary of the invention
[0005] In order to solve the problems existing in the prior art, at least one embodiment of the present invention provides an image processing method and apparatus, a training method and apparatus, a device and a computer-readable storage medium to solve the various problems mentioned in the above background technology section.
[0006] In a first aspect, an embodiment of the present invention proposes an image processing method, comprising: obtaining an image to be processed, wherein the image to be processed is an original rainy image; a first generator generates a pure rain layer according to the original rainy image, wherein the pure rain layer indicates the raindrop positions of the original rainy image; and a second generator generates a background layer without rain according to the pure rain layer and the original rainy image.
[0007] In some embodiments, the rain in the original rainy image includes raindrops or rain lines.
[0008] In some embodiments, the method further includes: pre-training the first generator and the second generator, wherein the pre-training of the first generator and the second generator includes: a first discriminator obtains the background layer without rain generated by the second generator to obtain a corresponding first adversarial loss value GAN_Loss_B; synthesizes the background layer without rain generated by the second generator and the pure rain layer generated by the first generator to obtain a synthesized rainy image; a second discriminator obtains the synthesized rainy image to obtain a corresponding second adversarial loss value GAN_Loss_A; determines a third adversarial loss value according to the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A, and updates the parameters of the first generator and the second generator through back propagation according to the third loss adversarial value.
[0009] In some embodiments, the third adversarial loss value is obtained according to the weighted average of the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A.
[0010] In some embodiments, the pre-training of the first generator and the second generator also includes: comparing the synthesized rainy image and the original rainy image to obtain a cycle-consistent loss value; and updating the parameters of the first generator and the second generator through back propagation according to the cycle-consistent loss value.
[0011] In some embodiments, the first discriminator is a no-raindrop discriminator, and the method further comprises training the no-raindrop discriminator, wherein the training of the no-raindrop discriminator comprises: taking a real no-raindrop picture and a generated no-raindrop picture as input, wherein there is no corresponding relationship between the real no-raindrop picture and the generated no-raindrop picture, or there is a corresponding relationship between the real no-raindrop picture and the generated no-raindrop picture; obtaining the discrimination error of the no-raindrop discriminator for the real no-raindrop picture and the generated no-raindrop picture during the training process; and updating the no-raindrop discriminator parameters through back propagation according to the discrimination error.
[0012] In some embodiments, the second discriminator is a raindrop discriminator, and the method further includes training the raindrop discriminator, wherein the training of the raindrop discriminator includes: taking a real picture with raindrops and a generated picture with raindrops as input, wherein there is no corresponding relationship between the real picture with raindrops and the generated picture with raindrops, or there is a corresponding relationship between the real picture with raindrops and the generated picture with raindrops; obtaining the discrimination error of the raindrop discriminator for the real picture with raindrops and the generated picture with raindrops during the training process; and updating the raindrop discriminator parameters through back propagation according to the discrimination error.
[0013] In some embodiments, when there is a corresponding relationship between the real picture with raindrops and the generated picture with raindrops, the real picture with raindrops is the original rainy image, and the generated picture with raindrops is the corresponding synthesized rainy image.
[0014] The second invention, an embodiment of the present invention provides an image processing device, including: an acquisition module, used to acquire an image to be processed, wherein the image to be processed is an original rainy image; a first generator, used to generate a pure rain layer according to the original rainy image, wherein the pure rain layer indicates the raindrop positions of the original rainy image; a second generator, used to generate a background layer without rain according to the pure rain layer and the original rainy image.
[0015] In some embodiments, the device further includes a first training module for pre-training the first generator and the second generator, and the first training module includes: a first discriminator for obtaining the background layer without rain generated by the second generator to obtain the corresponding first adversarial loss value GAN_Loss_B; a synthesizer for synthesizing the background layer without rain generated by the second generator and the pure rain layer generated by the first generator to obtain a synthesized rainy image; a second discriminator for obtaining the synthesized rainy image to obtain the corresponding second adversarial loss value GAN_Loss_A; a first parameter adjustment module for determining a third adversarial loss value according to the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A, and updating the parameters of the first generator and the second generator through back propagation according to the third loss adversarial value.
[0016] In some embodiments, the device further includes a second training module for pre-training the first generator and the second generator, and the second training module includes: a comparator for comparing the synthesized rainy image and the original rainy image to obtain a cycle-consistent loss value; and a second parameter adjustment module for updating the parameters of the first generator and the second generator through back propagation according to the cycle-consistent loss value.
[0017] In some embodiments, the first discriminator is a rainless discriminator, and the device further includes a third training module for training the rainless discriminator, the third training module including: a first input unit, used to take a real rainless picture and a generated rainless picture as input, wherein there is no corresponding relationship between the real rainless picture and the generated rainless picture, or there is a corresponding relationship between the real rainless picture and the generated rainless picture; a first error acquisition unit, used to acquire the discrimination error of the rainless discriminator for the real rainless picture and the generated rainless picture during the training process; a first parameter adjustment unit, used to update the rainless discriminator parameters through back propagation according to the discrimination error.
[0018] In some embodiments, the second discriminator is a raindrop discriminator, and the device further includes a fourth training module for training the raindrop discriminator, the fourth training module including: a second input unit, used to take a real picture with raindrops and a generated picture with raindrops as input, wherein there is no corresponding relationship between the real picture with raindrops and the generated picture with raindrops, or there is a corresponding relationship between the real picture with raindrops and the generated picture with raindrops; a second error acquisition unit, used to acquire the discrimination error of the raindrop discriminator for the real picture with raindrops and the generated picture with raindrops during the training process; a second parameter adjustment unit, used to update the parameters of the raindrop discriminator through back propagation according to the discrimination error.
[0019] In a third aspect, an embodiment of the present application also provides a training method, including: obtaining an original rainy image; a first generator generates a pure rain layer based on the original rainy image, and the pure rain layer indicates the raindrop position of the original rainy image; a second generator generates a background layer without rain based on the pure rain layer and the original rainy image; a first discriminator obtains the background layer without rain generated by the second generator, and obtains a corresponding first adversarial loss value GAN_Loss_B; synthesizes the background layer without rain generated by the second generator and the pure rain layer generated by the first generator to obtain a synthesized rainy image; a second discriminator obtains the synthesized rainy image to obtain a corresponding second adversarial loss value GAN_Loss_A; determines a third adversarial loss value based on the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A, and updates the parameters of the first generator and the second generator through back propagation based on the third loss adversarial value.
[0020] In some embodiments, the method further includes: comparing the synthesized rainy image with the original rainy image to obtain a cycle-consistent loss value; and updating the parameters of the first generator and the second generator through back propagation according to the cycle-consistent loss value.
[0021] In a fourth aspect, an embodiment of the present application also provides a training device, further comprising: an input layer for obtaining an original rainy image; a first generator for generating a pure rain layer according to the original rainy image, wherein the pure rain layer indicates the raindrop position of the original rainy image; a second generator for generating a background layer without rain according to the pure rain layer and the original rainy image; a first discriminator for obtaining the background layer without rain generated by the second generator, and obtaining a corresponding first adversarial loss value GAN_Loss_B; a synthesizer for synthesizing the background layer without rain generated by the second generator and the pure rain layer generated by the first generator to obtain a synthesized rainy image; a second discriminator for obtaining the synthesized rainy image and obtaining a corresponding second adversarial loss value GAN_Loss_A; a first parameter adjustment module for determining a third adversarial loss value according to the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A, and updating the parameters of the first generator and the second generator through back propagation according to the third loss adversarial value.
[0022] In some embodiments, the device also includes a comparator and a second parameter adjustment module, wherein the comparator is used to compare the synthesized rainy image with the original rainy image to obtain a cycle-consistent loss value; the second parameter adjustment module is also used to update the parameters of the first generator and the second generator through back propagation according to the cycle-consistent loss value.
[0023] In a fifth aspect, an embodiment of the present invention further provides a computer device, comprising: at least one processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; a memory coupled to the at least one processor, wherein the memory stores executable instructions, wherein the executable instructions, when executed by the at least one processor, implement the method in the first aspect or the third aspect mentioned above.
[0024] In a sixth aspect, an embodiment of the present invention further provides a chip for executing the method in the first aspect. Specifically, the chip includes: a processor for calling and running a computer program from a memory, so that a device equipped with the chip is used to execute the method in the first or third aspect.
[0025] In a seventh aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described in the first aspect or the third aspect is implemented.
[0026] In an eighth aspect, an embodiment of the present invention further provides a computer program product, comprising computer program instructions, which enable a computer to execute the method in the first aspect or the third aspect.
[0027] It can be seen that the image processing method and device of the embodiment of the present invention adopts the attention mechanism network to obtain the raindrop layer according to the original rainy image, and then obtains the derained background image according to the pixel difference between the raindrop layer and the original rainy image. It is not necessary to use the corresponding rainy and rainless comparison images as training data sets to achieve image deraining, which reduces the dependence on external information, reduces the cost and improves the efficiency of image deraining. In addition, the embodiment of the present application also improves the authenticity of the generated image through pre-training. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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 paying creative labor.
[0029] Figure 1 is a flowchart of a specific embodiment of the image processing method of the present invention;
[0030] Figure 2 is a structural block diagram of a specific embodiment of an image processing device of the present invention;
[0031] Figure 3 is a flow chart of a specific embodiment of the training method of the present invention;
[0032] Figure 4 is a structural block diagram of a specific embodiment of the training device of the present invention;
[0033] Figure 5 This is a basic structural block diagram of the computer device in this embodiment. Specific implementation plan
[0034] The present application is described in detail below in conjunction with the drawings and specific embodiments, so that the purpose, features and advantages of the present application are more clearly understood. It should be understood that the aspects described below in conjunction with the drawings and specific embodiments are only exemplary and should not be construed as limiting the scope of protection of the present application in any way. Unless the context clearly indicates otherwise, the singular forms "one" and "the" include plural referents. As used in the present application, the terms "first" and "second" are used interchangeably to distinguish one or a class of components from another or another class, respectively, and are not intended to represent the position or importance of independent components.
[0035] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0036] The term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0037] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0038] Rain, such as raindrops and rain lines, will hinder the visibility of the background scene and reduce the quality of the image. Moreover, the impact of rain on the image quality is different from that of stains, because rain is transparent and will produce refraction and reflection. Therefore, the different shapes of raindrops or rain lines formed by rain will have different effects. The problem of removing raindrops or rain lines is more difficult to solve than other problems that affect the image quality, such as stains. It can be summarized into the following two points: First, the area blocked by raindrops is not fixed. Second, most of the information of the background scene in the blocked area is completely lost.
[0039] The inventors found in the research process that the existing image deraining methods all adopt a supervised approach, that is, they all need to be trained by comparing raindrop images with corresponding raindrop-free images. Usually, many pairs of training samples are obtained, where each pair of training samples is a rainy image and a rainless image of the same scene. Such paired image set data is difficult to collect in practice, which also hinders the development of technology to a certain extent.
[0040] The prior art also uses an artificial rain layer to create such an image set. For example, first obtain a picture, block the glass on the picture, and then sprinkle water drops on the glass to form an image with rain drops. Alternatively, the prior art also takes a picture without rain, and then puts the glass with water drops in front of the camera to take the same scene, thereby making the picture wet. Alternatively, the prior art also uses other methods to artificially synthesize rainy images, but this method of artificially synthesizing rainy images is that the data set about the rain layer is not real and natural, and secondly, the method must also construct a paired image training database, and the cost of constructing a database that meets the requirements is very high. For this reason, the inventor of the present application has proposed an embodiment of the present application after long-term research and development and experiments, which does not require support from a paired picture set database.
[0041] The first aspect of the present application provides an image processing method. Figure 1 is a flowchart of a specific embodiment of the image processing method of the present invention, as shown in Figure 1 As shown, the image processing method of the present application comprises:
[0042] Step 110, obtaining an image to be processed, wherein the image to be processed is an original rainy image. The image obtained may be a single image or a frame image in a video. The original rainy image indicated here may be a real rainy image, that is, a non-synthesized rainy image, such as a rainy photo taken in a natural scene, or a frame image in a rainy video. The rain in the original rainy image includes raindrops or rain lines. It can be understood that when the rain falls faster, raindrops will form visual rain lines, or rain lines will be formed on the picture based on the length of the exposure time. Therefore, rain lines can be understood as a collection of raindrops that are relatively close to each other.
[0043] Step 120, the first generator generates a pure rain layer according to the original rainy image, and the pure rain layer indicates the raindrop position of the original rainy image. The first generator generates a raindrop layer according to the original rainy image. A self-attention mechanism can be used to form a feature map. For example, a LSTM (Long-Short Term Memory) network can be used to obtain a raindrop layer. Alternatively, several variant networks of LSTM can be used, such as GRU (Gated Recurrent Unit), or other network structures using a self-attention mechanism in the future.
[0044] Step 130, the second generator generates a background layer without rain according to the pure rain layer and the original rainy image. The original rainy image and the pure rain layer generated by the first generator are subtracted to generate a background layer without rain, and a background image without rain is obtained for the original rainy image.
[0045] This application adopts an attention mechanism network to obtain a raindrop layer based on the original rainy image, and then obtains a derained background image based on the pixel difference between the raindrop layer and the original rainy image. Image deraining can be achieved without using corresponding rainy and non-rainy comparison images as training data sets, reducing dependence on external information, and improving the efficiency of image deraining while reducing costs.
[0046] In one embodiment, the image deraining method of the present application further includes: pre-training the first generator and the second generator, wherein the pre-training the first generator and the second generator includes:
[0047] The first discriminator obtains the background layer without rain generated by the second generator, and obtains the corresponding first adversarial loss value GAN_Loss_B. In this training method, a discriminator is added after the generator. For example, the first discriminator is connected after the second generator. The first discriminator can judge whether the background layer without rain generated by the second generator is a real picture without rain. The working principle of the interaction between the first discriminator and the second generator is similar to the GAN (Generative Adversarial Networks) network in the prior art. The first discriminator can improve the authenticity of the background picture generated by the second generator. Specifically, the first discriminator can be a rainless discriminator, and the adversarial loss value (adversarial loss), GAN_Loss_B, is obtained through the rainless picture discriminator.
[0048] The background layer without rain generated by the second generator and the pure rain layer generated by the first generator are synthesized to obtain a synthesized rainy image. Assume that the physical model of the original real rainy image I is Image(I), which includes a background layer and a rain layer. The synthesizer adds the pure rain layer generated by the first generator and the background layer without rain generated by the second generator to obtain a synthesized rainy image I_rec.
[0049] The second discriminator obtains the synthesized rainy image and obtains the corresponding second adversarial loss value GAN_Loss_A; the second discriminator may be a raindrop discriminator, and the raindrop picture discriminator obtains the adversarial loss value GAN_Loss_A (adversarial loss).
[0050] A third adversarial loss value is determined according to the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A, and the parameters of the first generator and the second generator are updated by back propagation according to the third loss adversarial value. Specifically, the third adversarial loss value is obtained by taking the weighted average of the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A. For example, the final adversarial loss value is GAN_Loss = (GAN_Loss_A + GAN_Loss_B) / 2, and this loss value updates the parameters of the second generator network and the first generator network, such as the LSTM network, by back propagation.
[0051] In another embodiment, pre-training the first generator and the second generator further comprises:
[0052] Compare the synthesized rainy image with the original rainy image to obtain a cycle consistency loss value; add the raindrop layer generated by the first generator and the background layer generated by the second generator to obtain a synthesized raindrop image I_rec, and compare the synthesized raindrop image I_rec with the input real raindrop image I to obtain a cycle consistency loss value (cycle consistency loss)
[0053] The parameters of the first generator and the second generator are updated by back propagation according to the cycle-consistent loss value. This cycle-consistent loss is used to ensure that the background of the generated rain-free image is consistent with the background of the original rain image I.
[0054] The embodiment of the present application improves the authenticity of the generated pure rain map and synthetic rain map by training the first generator and the second generator.
[0055] Furthermore, in another embodiment, the method further includes training the first discriminator, that is, the no-raindrop discriminator, in advance, wherein the training of the no-raindrop discriminator includes:
[0056] A real rainless picture and a generated rainless picture are used as input, wherein there is no corresponding relationship between the real rainless picture and the generated rainless picture, or there is a corresponding relationship between the real rainless picture and the generated rainless picture; it can be understood that in this embodiment, the training of the rainless discriminator does not require a corresponding relationship between rainy pictures and rainless pictures. The discrimination error of the rainless discriminator for the real rainless picture and the generated rainless picture during the training process is obtained; and the parameters of the rainless discriminator are updated through back propagation according to the discrimination error.
[0057] Furthermore, in another embodiment, the method further includes training the second discriminator in advance, that is, training the raindrop discriminator in advance, wherein the training of the raindrop discriminator includes:
[0058] A real picture with raindrops and a generated picture with raindrops are used as input, wherein there is no corresponding relationship between the real picture with raindrops and the generated picture with raindrops, or there is a corresponding relationship between the real picture with raindrops and the generated picture with raindrops. When there is a corresponding relationship between the real picture with raindrops and the generated picture with raindrops, the real picture with raindrops is the original picture with raindrops, and the generated picture with raindrops is the corresponding synthesized picture with raindrops.
[0059] Obtain the discrimination error of the raindrop discriminator for the real picture with raindrops and the generated picture with raindrops during the training process; and update the parameters of the raindrop discriminator through back propagation according to the discrimination error.
[0060] In this embodiment, pre-training the two discriminators can further improve the authenticity of the pictures generated by the generator without the need for a corresponding image set.
[0061] A second aspect of the present application provides an image processing device, Figure 2 FIG. 1 is a structural block diagram of a specific embodiment of the image processing device of the present invention. Figure 2 As shown, the image processing device of the present application includes an acquisition module 201, a first generator 202 and a second generator 203, wherein:
[0062] An acquisition module 201 is used to acquire an image to be processed, where the image to be processed is an original rainy image;
[0063] A first generator 202, configured to generate a pure rain layer according to the original image with rain, wherein the pure rain layer indicates the raindrop positions of the original image with rain;
[0064] The second generator 203 is used to generate a background layer without rain according to the pure rain layer and the original image with rain.
[0065] The operations performed by each specific module in this device can be found in Figure 1 The corresponding steps achieve the same beneficial effects. In this embodiment, a raindrop layer is obtained through the original rainy image, and then a derained background image is obtained according to the pixel difference between the raindrop layer and the original rainy image. Image deraining can be achieved without using corresponding rainy and rainless comparison images as training data sets, thereby reducing dependence on external information, and improving the efficiency of image deraining while reducing costs.
[0066] In another embodiment, the image processing apparatus of the present application further includes a first training module for pre-training the first generator and the second generator, wherein the first training module includes:
[0067] A first discriminator is used to obtain the background layer without rain generated by the second generator to obtain the corresponding first adversarial loss value GAN_Loss_B; a synthesizer is used to synthesize the background layer without rain generated by the second generator and the pure rain layer generated by the first generator to obtain a synthesized rainy image; a second discriminator is used to obtain the synthesized rainy image to obtain the corresponding second adversarial loss value GAN_Loss_A; a first parameter adjustment module is used to determine a third adversarial loss value according to the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A, and update the parameters of the first generator and the second generator through back propagation according to the third loss adversarial value.
[0068] In another embodiment, the image processing device of the present application also includes a second training module for pre-training the first generator and the second generator, and the second training module includes: a comparator for comparing the synthesized rainy image and the original rainy image to obtain a cycle-consistent loss value; a second parameter adjustment module for updating the parameters of the first generator and the second generator through back propagation according to the cycle-consistent loss value.
[0069] The embodiment of the present application improves the authenticity of the generated pure rain map and synthetic rain map by training the first generator and the second generator.
[0070] In another embodiment, the first discriminator in the image processing device of the present application is a rainless discriminator, and the device further includes a third training module for training the rainless discriminator, wherein the third training module includes:
[0071] A first input unit is used to take a real rainless picture and a generated rainless picture as input, wherein there is no corresponding relationship between the real rainless picture and the generated rainless picture, or there is a corresponding relationship between the real rainless picture and the generated rainless picture; a first error acquisition unit is used to obtain the discrimination error of the rainless discriminator for the real rainless picture and the generated rainless picture during training; and a first parameter adjustment unit is used to update the parameters of the rainless discriminator through back propagation according to the discrimination error.
[0072] In another embodiment, the second discriminator in the image processing device of the present application is a raindrop discriminator, and the device further includes a fourth training module for training the raindrop discriminator, and the fourth training module includes:
[0073] a second input unit, used to take a real picture with raindrops and a generated picture with raindrops as input, wherein there is no corresponding relationship between the real picture with raindrops and the generated picture with raindrops, or there is a corresponding relationship between the real picture with raindrops and the generated picture with raindrops; a second error acquisition unit, used to acquire the discrimination error of the raindrop discriminator for the real picture with raindrops and the generated picture with raindrops during the training process; and a second parameter adjustment unit, used to update the parameters of the raindrop discriminator through back propagation according to the discrimination error.
[0074] In this embodiment, pre-training the two discriminators can further improve the authenticity of the pictures generated by the generator without the need for a corresponding image set.
[0075] The third aspect of the present application provides a training method. Figure 3 is a flow chart of a specific embodiment of the training method of the present invention, as shown in Figure 3 As shown, the training method of the present application comprises:
[0076] Step 310, obtaining an original rainy image;
[0077] Step 320, the first generator generates a pure rain layer according to the original image with rain, and the pure rain layer indicates the raindrop positions of the original image with rain;
[0078] Step 330, a second generator generates a background layer without rain according to the pure rain layer and the original rainy image;
[0079] Step 340, the first discriminator obtains the background layer without rain generated by the second generator, and obtains the corresponding first adversarial loss value GAN_Loss_B;
[0080] Step 350, synthesizing the background layer without rain generated by the second generator and the pure rain layer generated by the first generator to obtain a synthesized rainy image;
[0081] Step 360, the second discriminator obtains the synthesized rainy image and obtains the corresponding second adversarial loss value GAN_Loss_A;
[0082] Step 370: determine a third adversarial loss value according to the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A, and update the parameters of the first generator and the second generator through back propagation according to the third loss adversarial value.
[0083] Furthermore, the training method may also include: comparing the synthesized rainy image with the original rainy image to obtain a cycle-consistent loss value; and updating the parameters of the first generator and the second generator through back propagation according to the cycle-consistent loss value.
[0084] Through the above training method, the authenticity and clarity of the generator generating a rain-removed background image based on the original rainy image can be further improved without the need for a corresponding image set.
[0085] A fourth aspect of the present application provides a training device, Figure 4 FIG. 1 is a structural block diagram of a specific embodiment of the training device of the present invention, as shown in FIG. Figure 4 As shown, the training device of the present application includes an input layer 401, a first generator 402, a second generator 403, a first discriminator 404, a synthesizer 405, a second discriminator 406 and a parameter adjustment module, wherein:
[0086] An input layer 401 is used to obtain an original rainy image; a first generator 402 is used to generate a pure rain layer according to the original rainy image, and the pure rain layer indicates the raindrop position of the original rainy image; a second generator 403 is used to generate a background layer without rain according to the pure rain layer and the original rainy image; a first discriminator 404 is used to obtain the background layer without rain generated by the second generator, and obtain a corresponding first adversarial loss value GAN_Loss_B; a synthesizer 405 is used to synthesize the background layer without rain generated by the second generator and the pure rain layer generated by the first generator to obtain a synthesized rainy image; a second discriminator 406 is used to obtain the synthesized rainy image and obtain a corresponding second adversarial loss value GAN_Loss_A; a first parameter adjustment module is used to determine a third adversarial loss value according to the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A, and update the parameters of the first generator and the second generator through back propagation according to the third loss adversarial value.
[0087] In another embodiment, the training device also includes a comparator and a second parameter adjustment module, wherein the comparator is used to compare the synthesized rainy image with the original rainy image to obtain a cycle-consistent loss value; the second parameter adjustment module is also used to update the parameters of the first generator and the second generator through back propagation according to the cycle-consistent loss value.
[0088] The training device of the present application can further improve the authenticity and clarity of the rain-removed background image generated by the generator based on the original rainy image without the need for a corresponding image set by training the generator and the discriminator.
[0089] In a fifth aspect, the present application embodiment further provides a computer device, which may be a neural network server. For details, please refer to Figure 5 , Figure 5 This is a basic structural block diagram of the computer device in this embodiment.
[0090] The computer device 5 includes a memory 51, a processor 52, and a network interface 53 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 5 with components 51-53, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device 5 here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0091] The computer device 5 may be a computing device such as a desktop computer, a notebook, a palm computer, a cloud server, etc. The computer device 5 may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0092] The memory 51 includes at least one type of readable storage medium, and the memory can store executable instructions of a controller, a microcontroller, a microprocessor, or other data processing chip, and includes at least one type of readable storage medium. The readable storage medium includes a non-volatile memory or a volatile memory, such as a flash memory, a hard disk, a multimedia card, a card-type memory (such as an SD or DX memory, etc.), a random access memory (random access memory, RAM), a read-only memory (read-only memory, ROM), an erasable programmable read-only memory (erasable programmable read-only memory, EPROM), an electrically erasable programmable read-only memory (electrically erasable programmable read-only memory, EEPROM), a programmable read-only memory (programmable read-only memory, PROM), a magnetic memory, a disk, an optical disk, etc., and the RAM may include a static RAM or a dynamic RAM. In some embodiments, the memory 51 may be an internal storage unit of the computer device 5, such as a hard disk or a memory of the computer device 5. In other embodiments, the memory 51 may also be an external storage device of the computer device 5, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the computer device 5. Of course, the memory 51 may also include both the internal storage unit of the computer device 5 and its external storage device. In this embodiment, the memory 51 is generally used to store the operating system and various application software installed on the computer device 5, such as program codes for performing image processing, etc. In addition, the memory 51 may also be used to temporarily store various data that have been output or are to be output.
[0093] In the embodiment of the present application, the processor 52 may be a central processing unit (CPU) or a graphic processing unit (GPU). The processor 52 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, such as a single-chip microcomputer, etc.
[0094] The processor 52 is generally used to control the overall operation of the computer device 5. In this embodiment, the memory 51 is used to store program codes or instructions, the program codes include computer operation instructions, and the processor 52 is used to execute the program codes or instructions stored in the memory 51 or process data, such as executing program codes for image processing.
[0095] The bus described in this article can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus system can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0096] In a sixth aspect, an embodiment of the present invention further provides a chip for executing the method in the first aspect. Specifically, the chip includes: a processor for calling and running a computer program from a memory, so that a device equipped with the chip is used to execute the above image processing method.
[0097] In addition, in a seventh aspect, an embodiment of the present invention further provides a computer-readable storage medium, which may be a computer-readable signal medium or a computer-readable medium. A processor in a computer reads a computer-readable program code stored in the computer-readable medium, so that the processor can execute the program code in the process. Figure 1The functional actions specified in each step or combination of steps in the corresponding image processing method; generate a device that implements the functional actions specified in each block or combination of blocks in the block diagram.
[0098] Computer-readable media include but are not limited to electronic, magnetic, optical, electromagnetic, infrared memory or semiconductor systems, devices or apparatuses, or any suitable combination of the foregoing, wherein the memory is used to store program codes or instructions, the program codes include computer operating instructions, and the processor is used to execute the program codes or instructions stored in the memory.
[0099] The definitions of the memory and the processor can refer to the description of the aforementioned computer device embodiment, which will not be repeated here. The computer readable storage medium stores a computer program, and when the computer program is executed by the processor, the method described in any one of the first aspects above is implemented.
[0100] In an eighth aspect, an embodiment of the present invention further provides a computer program product, including computer program instructions, which enable a computer to execute the method in the first aspect.
[0101] It will be appreciated by those skilled in the art that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0102] In the embodiments of the present application, the disclosed systems, devices and methods can be implemented in other ways. For example, the division of units is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system. In addition, the coupling between the various units can be direct coupling or indirect coupling. In addition, the various functional units in the embodiments of the present application can be integrated into a processing unit, or can be separate physical existences, etc.
[0103] It should be understood that in the various embodiments of the present application, the size of the serial number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0104] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a machine-readable storage medium. Therefore, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a machine-readable storage medium, which can include several instructions to enable an electronic device to perform all or part of the technical solution described in the embodiments of the present application. The above-mentioned storage medium may include various media that can store program codes, such as ROM, RAM, removable disk, hard disk, magnetic disk or optical disk.
[0105] The above contents are only specific implementation methods of the present application, and the protection scope of the present application is not limited thereto. Those skilled in the art may make changes or substitutions within the technical scope disclosed in the present application, and these changes or substitutions shall be within the protection scope of the present application.
Claims
1. An image processing method, characterized in that: include: Acquire an image to be processed, where the image to be processed is an original rainy image; A first generator generates a pure rain layer according to the original rainy image, wherein the pure rain layer indicates the raindrop positions of the original rainy image; The second generator generates a background layer without rain according to the pure rain layer and the original rainy image; The method further includes: pre-training the first generator and the second generator, wherein the pre-training the first generator and the second generator includes: The first discriminator obtains the background layer without rain generated by the second generator, and obtains the corresponding first adversarial loss value GAN_Loss_B; Combining the background layer without rain generated by the second generator and the pure rain layer generated by the first generator to obtain a composite rainy image; The second discriminator obtains the synthesized rainy image and obtains the corresponding second adversarial loss value GAN_Loss_A; Determine a third adversarial loss value according to the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A, and update the parameters of the first generator and the second generator through back propagation according to the third adversarial loss value; Comparing the synthesized rainy image with the original rainy image to obtain a cycle-consistent loss value; Updating parameters of the first generator and the second generator by back propagation according to the cycle-consistent loss value; The first generator uses a self-attention mechanism network to form the pure rain layer, and the second generator subtracts the original rainy image and the pure rain layer pixels to generate the background layer.
2. The method according to claim 1, characterized in that The third adversarial loss value is obtained according to the weighted average of the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A.
3. An image processing device, characterized in that: include: An acquisition module, used for acquiring an image to be processed, wherein the image to be processed is an original rainy image; A first generator, configured to generate a pure rain layer according to the original image with rain, wherein the pure rain layer indicates the raindrop positions of the original image with rain; A second generator, used for generating a background layer without rain according to the pure rain layer and the original rainy image; A first training module is used to pre-train the first generator and the second generator, and the first training module includes: a first discriminator, used to obtain the background layer without rain generated by the second generator, and obtain the corresponding first adversarial loss value GAN_Loss_B; a synthesizer, used to synthesize the background layer without rain generated by the second generator and the pure rain layer generated by the first generator, and obtain a synthesized rainy image; a second discriminator, used to obtain the synthesized rainy image, and obtain the corresponding second adversarial loss value GAN_Loss_A; a first parameter adjustment module, used to determine a third adversarial loss value according to the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A, update the parameters of the first generator and the second generator through back propagation according to the third adversarial loss value, compare the synthesized rainy image with the original rainy image, obtain a cycle-consistent loss value, and update the parameters of the first generator and the second generator through back propagation according to the cycle-consistent loss value; The first generator uses a self-attention mechanism network to form the pure rain layer, and the second generator subtracts the original rainy image and the pure rain layer pixels to generate the background layer.
4. A training method, characterized in that: include: Get the original rainy image; A first generator generates a pure rain layer according to the original rainy image, wherein the pure rain layer indicates the raindrop positions of the original rainy image; The second generator generates a background layer without rain according to the pure rain layer and the original rainy image; The first discriminator obtains the background layer without rain generated by the second generator, and obtains the corresponding first adversarial loss value GAN_Loss_B; Combining the background layer without rain generated by the second generator and the pure rain layer generated by the first generator to obtain a composite rainy image; The second discriminator obtains the synthesized rainy image and obtains the corresponding second adversarial loss value GAN_Loss_A; Determine a third adversarial loss value according to the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A, and update the parameters of the first generator and the second generator through back propagation according to the third adversarial loss value; Comparing the synthesized rainy image with the original rainy image, obtaining a cycle-consistent loss value, and updating parameters of the first generator and the second generator through back propagation according to the cycle-consistent loss value; The first generator uses a self-attention mechanism network to form the pure rain layer, and the second generator subtracts the original rainy image and the pure rain layer pixels to generate the background layer.
5. A training device, characterized in that: Also includes: Input layer, used to obtain the original rainy image; A first generator, configured to generate a pure rain layer according to the original image with rain, wherein the pure rain layer indicates the raindrop positions of the original image with rain; A second generator, used for generating a background layer without rain according to the pure rain layer and the original rainy image; A first discriminator is used to obtain the background layer without rain generated by the second generator, and obtain a corresponding first adversarial loss value GAN_Loss_B; A synthesizer, used for synthesizing the background layer without rain generated by the second generator and the pure rain layer generated by the first generator to obtain a synthesized rainy image; A second discriminator is used to obtain the synthesized rainy image and obtain a corresponding second adversarial loss value GAN_Loss_A; A first parameter adjustment module, configured to determine a third adversarial loss value according to the first adversarial loss value GAN_Loss_B and the second adversarial loss value GAN_Loss_A, update parameters of the first generator and the second generator through back propagation according to the third adversarial loss value, compare the synthesized rainy image with the original rainy image, obtain a cycle-consistent loss value, and update parameters of the first generator and the second generator through back propagation according to the cycle-consistent loss value; The first generator uses a self-attention mechanism network to form the pure rain layer, and the second generator subtracts the original rainy image and the pure rain layer pixels to generate the background layer.
6. A computer device comprising: At least one processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; A memory coupled to the at least one processor, the memory storing executable instructions, wherein the executable instructions, when executed by the at least one processor, enable the method according to any one of claims 1 to 2 or claim 4 to be implemented.
7. A chip, characterized in that: include: A processor, configured to call and run a computer program from a memory, so that a device equipped with the chip executes: the method according to any one of claims 1 to 2 or claim 4.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 2 or claim 4 are implemented.
