Training method and device of image processing model and image processing method and device
Through the training of image processing models, multi-level feature extraction and loss function adjustment are used to solve the problem of image quality degradation in outdoor environments, improve the clarity and contrast of rain-removed images, and achieve better image restoration effects.
Patent Information
- Application Number
- CN202310267263.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-14
- Publication Date
- 2024-09-20
AI Technical Summary
Images collected in outdoor environments are easily affected by natural weather conditions, resulting in a decrease in image quality, especially a decrease in contrast caused by rain coverage and water mist, which affects the clarity and visual satisfaction of the image, thereby affecting advanced visual tasks such as image detection and segmentation.
The training method of the image processing model is used to obtain rainy images, use multi-level feature extraction layers to extract feature maps, and calculate the loss function based on the rain-removed images and supervised rain-free images at different resolutions, and adjust the model until the end of the training to Improve the rain removal effect of images.
The clarity and contrast of the rain-removed image are improved, the image structure information is retained, more details are restored, and the image quality is improved.
Smart Images

Figure CN118674656A
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a training method and device for an image processing model, and an image processing method and device. Background Art
[0002] When collecting images in outdoor environments, they are often affected by natural weather conditions, such as rain, snow, fog, etc., which affects the image quality. In rain, the rain streaks contained in the image will first cause part of the image content to be covered by rain, and the water mist formed by rain in heavy rain scenes will also cause the image contrast to decrease and lack of transparency. Such image quality degradation not only affects people's visual satisfaction, but also affects other image-based advanced visual tasks (such as image detection, image segmentation, etc.).
[0003] Therefore, how to remove rain from images, improve the clarity and contrast of derained images, and improve image quality has become one of the important research directions. Summary of the invention
[0004] The present application aims to solve at least one of the technical problems in the related art to a certain extent.
[0005] The first embodiment of the present application proposes a training method for an image processing model, comprising:
[0006] Obtain sample rainy images, and train an image processing model based on the sample rainy images;
[0007] The N-level feature extraction layers in the image processing model perform feature extraction on the sample rainy image to obtain feature maps of each level, and based on the feature maps of each level, obtain rain-removed images of the sample rainy image at different resolutions, where N is an integer greater than 2;
[0008] For each resolution, according to the derained image at the resolution and the supervised rain-free image at the resolution, obtain the loss function corresponding to the resolution;
[0009] Based on the loss function of each resolution, the image processing model is adjusted, and the next sample rainy image is used to train the adjusted image processing model until the training is completed to obtain the target image processing model.
[0010] The embodiments of the present application can improve the accuracy of the image processing model, thereby improving the clarity and contrast of the derained image, improving the quality of the image, constraining the image at multiple scales, thereby restoring more image details, and better preserving the image structure information.
[0011] The second aspect of the present application provides a training device for an image processing model, including:
[0012] A first acquisition module is used to acquire a sample rainy image and train an image processing model based on the sample rainy image;
[0013] The second acquisition module is used to extract features of the sample rainy image by using N-level feature extraction layers in the image processing model to obtain feature maps of each level, and obtain rain-removed images of the sample rainy image at different resolutions based on the feature maps of each level, where N is an integer greater than 2;
[0014] The third acquisition module is used to acquire, for each resolution, a loss function corresponding to the resolution according to the derained image at the resolution and the supervised rain-free image at the resolution;
[0015] The adjustment module is used to adjust the image processing model based on the loss function of each resolution, and continue to use the next sample rainy image to train the adjusted image processing model until the training is completed to obtain the target image processing model.
[0016] The third aspect of the present application provides an image processing method, including:
[0017] Obtain the target rainy image to be processed;
[0018] The target rainy image is input into the trained target image processing model, and the target image processing model outputs the target rain-free image;
[0019] Among them, the target image processing model is a model trained using the training method of the above-mentioned image processing model.
[0020] The embodiments of the present application can improve the clarity and contrast of the derained image, improve the image quality, and better preserve the image structure information of the target derained image.
[0021] A fourth aspect of the present application provides an image processing device, including:
[0022] An acquisition module, used for acquiring a target rainy image to be processed;
[0023] The processing module is used to input the target rainy image into the trained target image processing model, and the target image processing model outputs the target rain-free image; wherein the target image processing model is a model trained by the training device using the above-mentioned image processing model.
[0024] A fifth aspect of the present application provides an electronic device, including:
[0025] at least one processor; and
[0026] a memory communicatively connected to at least one processor; wherein,
[0027] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor so that the at least one processor can execute the training method of the image processing model provided in the embodiment of the first aspect of the present application or execute the image processing method provided in the embodiment of the third aspect of the present application.
[0028] The sixth aspect embodiment of the present application proposes a computer-readable storage medium on which computer instructions are stored, wherein the computer instructions are used to enable a computer to execute the training method of the image processing model provided in the first aspect embodiment of the present application or to execute the image processing method provided in the third aspect embodiment of the present application.
[0029] The seventh aspect embodiment of the present application proposes a computer program product, including a computer program, which, when executed by a processor, implements the training method of the image processing model provided in the first aspect embodiment of the present application or implements the image processing method provided in the third aspect embodiment of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 is a flowchart of a method for training an image processing model according to an embodiment of the present application;
[0031] Figure 2 is a schematic diagram of a training method for an image processing model according to an embodiment of the present application;
[0032] Figure 3 is a schematic diagram of a gradient operator according to an embodiment of the present application;
[0033] Figure 4 is a flowchart of a method for training an image processing model according to an embodiment of the present application;
[0034] Figure 5 is a schematic diagram of a training method for an image processing model according to an embodiment of the present application;
[0035] Figure 6 is a schematic diagram of a training method for an image processing model according to an embodiment of the present application;
[0036] Figure 7 is a schematic diagram of an image processing method according to an embodiment of the present application;
[0037] Figure 8 It is a structural block diagram of a training device for an image processing model according to an embodiment of the present application;
[0038] Fig. 9 is a structural block diagram of an image processing device according to an embodiment of the present application;
[0039] Fig.10 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0040] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0041] The following describes the image processing model training method, device and image processing method and device of the embodiments of the present application in conjunction with the accompanying drawings.
[0042] Figure 1 is a flowchart of a method for training an image processing model according to an embodiment of the present application. Figure 1 As shown, the method comprises the following steps:
[0043] S101, obtaining a sample rainy image, and training an image processing model based on the sample rainy image.
[0044] In an embodiment of the present application, a sample image set is obtained, wherein the sample image set includes multiple sample rainy images and a supervised rain-free image of any sample rainy image, and then an image processing model is trained based on the sample rainy images and the supervised rain-free image of the sample rainy images.
[0045] In some implementations, in order to improve the accuracy of model training, the algorithm is used to remove rain lines in rainy images to improve the objective quality of the images. Preset sample rainy images can be used, for example, sample rainy images and supervised rain-free images are obtained from a known data set (Rain100H) for training and testing. The data set contains multiple sample rainy images and their corresponding supervised rain-free images (GT). Since the sample rainy images in the data set are obtained by synthetic superposition, the images are aligned and the image quality is good.
[0046] In some implementations, the image processing model may be a convolutional neural network. Optionally, the image processing model in the embodiments of the present application may be a multi-level output neural network simplified from a convolutional neural network (U-Net network).
[0047] S102, extracting features of the sample rainy image by N-level feature extraction layers in the image processing model to obtain feature maps of each level, and obtaining derained images of the sample rainy image at different resolutions based on the feature maps of each level.
[0048] Wherein, N is an integer greater than 2.
[0049] It should be noted that in an embodiment of the present application, the sample rainy image can be randomly sampled, for example, a red, green, and blue (RGB) image with a resolution of 256*256 is randomly sampled, and then the N-level feature extraction layer in the image processing model performs feature extraction on the RGB image to obtain feature maps of each level, and based on the feature maps of each level, derained images of the sample rainy image at different resolutions are obtained.
[0050] In some implementations, the image processing model is a convolutional neural network with three-level outputs. The image processing model performs three-level feature extraction on the sample rainy image to obtain feature maps of each level. After the first-level feature extraction is performed on the sample rainy image, a candidate feature map of the sample rainy image at the original resolution (X1 resolution) is obtained. Further, after the second-level feature extraction is performed on the feature map at the X1 resolution, a candidate feature map of the sample rainy image at the X2 resolution is obtained. Further, after the third-level feature extraction is performed on the feature map at the X2 resolution, a candidate feature map of the sample rainy image at the X3 resolution is obtained. Then, a de-rained image at the X3 resolution is obtained according to the candidate feature map at the X3 resolution. Then, a de-rained image at the X2 resolution is obtained according to the candidate feature map at the X3 resolution and the candidate feature map at the X2 resolution. Then, a de-rained image at the X1 resolution is obtained according to the candidate feature map at the X1 resolution, the candidate feature map at the X3 resolution and the candidate feature map at the X2 resolution. In particular, the X1 resolution is the original resolution, the X2 resolution is 1 / 2 of the original resolution, and the X3 resolution is 1 / 4 of the original resolution.
[0051] It should be noted that the multi-level feature extraction layers have different convolution kernels, so based on the feature maps of each level, the derained images obtained have different sizes, that is, the derained images of the sample rainy images at different resolutions are obtained.
[0052] S103, for each resolution, according to the derained image at the resolution and the supervised rain-free image at the resolution, obtaining a loss function corresponding to the resolution.
[0053] In some implementations, the sample rainy image is an image collected in a rainy environment, and the supervised rain-free image of the sample rainy image is a standard image of a rain-free environment of the same scene. Optionally, in an embodiment of the present application, the supervised rain-free image includes multiple resolutions, such as X1 resolution, X2 resolution, and X3 resolution. Thus, based on the derained image and the supervised rain-free image at each resolution, the loss function corresponding to the resolution can be obtained, thereby further performing multi-level supervision.
[0054] The image gradient represents the speed at which the grayscale value of the image changes. In the embodiment of the present application, Figure 2As shown, a gradient map 220 can be obtained according to the change rate of each pixel value in the sample rainy image 210 in the horizontal and vertical directions. For the supervised rain-free image 230 of the sample rainy image 210, a gradient map 240 can be obtained according to the change rate of each pixel value in the supervised rain-free image 230 in the horizontal and vertical directions. By comparing the gradient map 220 and the gradient map 240, it can be seen that the rain line can be clearly shown in the gradient map. In some implementations, since the rain line can be clearly shown in the gradient map, the loss function corresponding to the resolution can be obtained based on the image gradient. In the embodiment of the present application, the mean absolute error between the pixel value in the rain-removed image at the original resolution of the sample rainy image and the pixel value in the supervised rain-free image at the original resolution is obtained. Based on the Soble gradient operator, the horizontal gradient and the vertical gradient between the pixel value in the rain-removed image at the original resolution and the pixel value in the supervised rain-free image at the original resolution are obtained. According to the mean absolute error, the horizontal gradient and the vertical gradient, the loss function at the original resolution is determined.
[0055] Alternatively, the Soble gradient operator can be used as follows Figure 3 The operator shown, where dx represents the gradient operator in the horizontal direction and dy represents the gradient operator in the vertical direction.
[0056] In some implementations, for the residual resolution other than the original resolution, the mean absolute error between the pixel values of the derained image at the residual resolution and the pixel values in the supervised rain-free image at the residual resolution is obtained, and the loss function at the residual resolution is determined according to the mean absolute error. That is, on the derained image of the residual resolution (low resolution lower than the original resolution) other than the original resolution, only the mean absolute error is used to determine the loss function, and on the derained image of the original resolution, the loss function is determined according to the mean absolute error, the gradient in the horizontal direction, and the gradient in the vertical direction.
[0057] It should be noted that the mean absolute error is the average of the absolute values of the deviations of all individual pixel values from the arithmetic mean. The mean absolute error can avoid the problem of errors offsetting each other, and thus can accurately reflect the size of the actual prediction error.
[0058] S104, adjusting the image processing model based on the loss function of each resolution, and continuing to use the next sample rainy image to train the adjusted image processing model until the training is completed to obtain the target image processing model.
[0059] In the embodiment of the present application, the image processing model is a convolutional neural network with three-level output as an example for explanation. The loss function in the training stage can adopt the following formula:
[0060]
[0061] Among them, L represents the loss function, F i represents the derained image at the i-th resolution of the image processing model, GT i Represents the supervised rain-free image corresponding to the derained image at the i-th resolution.
[0062] In some implementations, the training may be terminated to obtain the target image processing model after reaching a preset number of training iterations. In some implementations, the training may be terminated to obtain the target image processing model after the loss function converges to a preset loss threshold.
[0063] In the embodiment of the present application, the image processing model performs multi-level feature extraction on the sample rainy image to obtain feature maps of each level, and based on the feature maps of each level, obtains the rain-free image of the sample rainy image at different resolutions; for each resolution, according to the rain-free image at the resolution and the supervised rain-free image at the resolution, obtains the loss function corresponding to the resolution; based on the loss function of each resolution, adjusts the image processing model, and continues to use the next sample rainy image to train the adjusted image processing model until the training is completed to obtain the target image processing model. The embodiment of the present application can improve the accuracy of the image processing model, thereby improving the clarity and contrast of the rain-free image, improving the quality of the image, constraining the image at multiple scales, thereby restoring more image details, and better retaining the image structure information.
[0064] Figure 4 is a flowchart of a method for training an image processing model according to an embodiment of the present application. Figure 4 As shown, the method comprises the following steps:
[0065] S401, for the i-th level feature extraction layer, perform maximum pooling and the first convolution processing on the candidate feature map i-1 of the i-1-th level feature extraction layer input into the i-th level feature extraction layer, obtain the candidate feature map i of the i-th level feature extraction layer, and input the candidate feature map i into the i+1-th level feature extraction layer for overall feature extraction to obtain the i+1-th level feature map.
[0066] It should be noted that i is a positive integer greater than or equal to 1 and less than N.
[0067] It should be noted that the size of the convolution kernel used in each feature extraction layer for convolution processing is different, and the input of the first-level feature extraction layer is the sample rainy image.
[0068] That is to say, the sample rainy image is input into the first-level feature extraction layer of the image processing model for the first convolution process to obtain the candidate features Figure 1 , the second-level feature extraction layer extracts candidate features Figure 1 Perform maximum pooling and the first convolution to obtain candidate features Figure 2 , the third-level feature extraction layer extracts candidate features Figure 2 Perform maximum pooling and the first convolution to obtain candidate features Figure 3 , and so on, until the N-th level feature extraction layer performs maximum pooling and the first convolution on the candidate feature map N-1 to obtain the candidate feature map N, where for the N-th level feature extraction layer, the candidate feature map N is also the N-th level feature map.
[0069] That is to say, the process of obtaining the Nth level feature map includes: obtaining the candidate feature map N-1 of the N-1th level feature extraction layer; inputting the candidate feature map N-1 into the Nth level feature extraction layer for maximum pooling and the first convolution processing to obtain the Nth level feature map.
[0070] S402, performing deconvolution on the i+1th level feature map to obtain a deconvolution feature map i.
[0071] Deconvolution, also called transposed convolution, is an operation that realizes the mapping of an image from a small resolution to a large resolution. In the embodiment of the present application, the i+1th level feature map is deconvolved to obtain a deconvolved feature map i, wherein the deconvolved feature map i has the same resolution as the candidate feature map i, so as to perform the next step of fusion calculation to obtain the ith level feature map.
[0072] S403, fusing the deconvolution feature map i with the candidate feature map i and performing a second convolution process to obtain an i-th level feature map.
[0073] Furthermore, the N-1th level feature extraction layer deconvolves the N-th level feature map to obtain the deconvolved feature map N, and then the N-1th level feature extraction layer fuses the deconvolved feature map N with the candidate feature map N and performs a second convolution process to obtain the N-1th level feature map, and so on, until the first level feature map is obtained.
[0074] S404, performing a third convolution process on the i-th level feature map to obtain a rain-free image of the sample rainy image at the i-th resolution.
[0075] Among them, since the convolution kernels of each level of feature extraction layer are different during the convolution processing, the resolution of the obtained derained image is different. Therefore, after the third convolution processing is performed on the i-th level feature map, the derained image of the sample rainy image at the i-th resolution can be obtained.
[0076] Figure 5 is a schematic diagram of a training method for an image processing model according to an embodiment of the present application, such as Figure 5 As shown in the figure, the sample rainy image is input into the first-level feature extraction layer of the image processing model for the first convolution process to obtain the candidate features. Figure 1, when the value of i is greater than 1, the i-th level feature extraction layer performs maximum pooling and the first convolution processing on the candidate feature map i-1 to obtain the candidate feature map i of the i-th level feature extraction layer, and inputs the candidate feature map i into the i+1-th level feature extraction layer for overall feature extraction to obtain the i+1-th level feature map. Deconvolution is performed on the i+1-th level feature map to obtain the deconvolution feature map i, the deconvolution feature map i is fused with the candidate feature map i and the second convolution processing is performed to obtain the i-th level feature map, the i-th level feature map is subjected to the third convolution processing to obtain the rain-free image of the sample rainy image at the i-th resolution. Among them, the N-th level feature map is obtained by the N-th level feature extraction layer performing maximum pooling and the first convolution processing on the candidate feature map N-1.
[0077] Figure 6 is a schematic diagram of a training method for an image processing model according to an embodiment of the present application, such as Figure 6 As shown in the figure, assuming that the input sample rain image dimension is H*W*3, the image processing model includes three layers of feature extraction layers as an example. The sample rain image is input into the first-level feature extraction layer of the image processing model for the first convolution processing (3*3 convolution 1), and connected to the nonlinear activation layer ReLU (all convolutions except convolution 4, convolution 6, and convolution 8 are connected to the nonlinear activation layer, which will not be repeated later). At this time, the candidate feature with the dimension of H*W*C is obtained. Figure 1 , the second-level feature extraction layer extracts candidate features Figure 1 Perform maximum pooling and the first convolution (3*3 convolution 2) to obtain candidate features with dimensions of H / 2*W / 2*2C Figure 2 , the third-level feature extraction layer extracts candidate features Figure 2 Perform the maximum pooling and the first convolution (3*3 convolution 3) to obtain the third-level feature map of H / 4*W / 4*4C. Then perform a deconvolution process (deconvolution 1) on the third-level feature map with a convolution kernel size of 4*4 and a step size of 2 to obtain the deconvolution feature of H / 2*W / 2*4C. Figure 2 , for the deconvolution features Figure 2 and candidate features Figure 2 Perform fusion (cascade) to obtain the fusion feature of H / 2*W / 2*6C Figure 2 At the same time, the third-level feature extraction layer performs the first convolution processing (3*3 convolution 4) on the third-level feature map to obtain a three-channel output image with a resolution of H / 4*W / 4*3, that is, the third derained image. The second-level feature extraction layer performs the first convolution processing (3*3 convolution 4) on the third-level feature map to obtain a three-channel output image with a resolution of H / 4*W / 4*3, that is, the third derained image. Figure 2The second convolution process (1*1 convolution 5) is performed to obtain the second-level feature map of H / 2*W / 2*2C after dimensionality reduction. The second-level feature extraction layer performs the third convolution process (convolution 6) on the second-level feature map to obtain a three-channel output image of H / 2*W / 2*3 (i.e., the second derained image). The second-level feature map is deconvolved (deconvolution 2) to obtain the deconvolution feature. Figure 1 , deconvolution features Figure 1 With candidate features Figure 1 Perform fusion (cascade) to obtain fusion features Figure 1 , the first level feature extraction layer is used to fusion feature Figure 1 A second convolution process (1*1 convolution 7) is performed to obtain a first-level feature map. The first-level feature extraction layer performs a third convolution process (convolution 8) on the first-level feature map to obtain an output first derained image of H*W*3.
[0078] Among them, H, W, and C are positive integers, representing the image dimensions of the sample rainy images, and all convolution steps are 1. The resolution of the first derained image is the original resolution, the resolution of the second derained image is 1 / 2 of the original resolution, and the resolution of the third derained image is 1 / 4 of the original resolution.
[0079] In the embodiment of the present application, since the differences between image gradients are compared, better results can be achieved in removing rain lines from rainy images. A multi-level supervised training method is adopted to constrain the image at multiple scales, which can restore more image details and better preserve the image structure information. The present application uses a fully convolutional neural network, which can process image inputs of any size and has high algorithm robustness.
[0080] Figure 7 is a flowchart of an image processing method according to an embodiment of the present application. Figure 7 As shown, the method comprises the following steps:
[0081] S701, obtaining a target rainy image to be processed.
[0082] Optionally, image acquisition may be performed in a rainy environment to obtain a target rainy image to be processed.
[0083] S702, input the target rainy image into the trained target image processing model, and the target image processing model outputs the target rain-free image.
[0084] The target image processing model is a model trained by using the training method of the image processing model as described above, and the resolution of the target derained image is the same as the resolution of the target rainy image.
[0085] The embodiments of the present application can improve the clarity and contrast of the derained image, improve the image quality, and better preserve the image structure information of the target derained image.
[0086] like Figure 8 As shown, based on the same application concept, the embodiment of the present application further provides a training device 800 for an image processing model, including:
[0087] A first acquisition module 810 is used to acquire a sample rainy image and train an image processing model based on the sample rainy image;
[0088] The second acquisition module 820 is used to perform feature extraction on the sample rainy image by using N-level feature extraction layers in the image processing model to obtain feature maps of each level, and obtain rain-removed images of the sample rainy image at different resolutions based on the feature maps of each level, where N is an integer greater than 2;
[0089] The third acquisition module 830 is used to acquire, for each resolution, a loss function corresponding to the resolution according to the derained image at the resolution and the supervised rain-free image at the resolution;
[0090] The adjustment module 840 is used to adjust the image processing model based on the loss function of each resolution, and continue to use the next sample rainy image to train the adjusted image processing model until the training is completed to obtain the target image processing model.
[0091] In some implementations, the second acquisition module 820 is further configured to:
[0092] For the i-th level feature extraction layer, perform maximum pooling and the first convolution process on the candidate feature map i-1 of the i-1th level feature extraction layer input into the i-th level feature extraction layer to obtain the candidate feature map i of the i-th level feature extraction layer, and input the candidate feature map i into the i+1th level feature extraction layer for overall feature extraction to obtain the i+1th level feature map, where i is a positive integer greater than or equal to 1 and less than N;
[0093] Deconvolve the i+1th level feature map to obtain the deconvoluted feature map i;
[0094] The deconvolution feature map i is fused with the candidate feature map i and a second convolution process is performed to obtain the i-th level feature map;
[0095] Among them, the size of the convolution kernel used in each feature extraction layer for convolution processing is different.
[0096] In some implementations, the process of obtaining the Nth level feature map includes:
[0097] Obtain candidate feature map N-1 of the N-1th level feature extraction layer;
[0098] The candidate feature map N-1 is input into the Nth level feature extraction layer for maximum pooling and the first convolution process to obtain the Nth level feature map.
[0099] In some implementations, the input of the first-level feature extraction layer is a sample rainy image.
[0100] In some implementations, the second acquisition module 820 is further configured to:
[0101] The third convolution process is performed on the i-th level feature map to obtain the derained image of the sample rainy image at the i-th resolution, wherein the derained images at different resolutions have different numbers of channels.
[0102] In some implementations, the third acquisition module 830 is further configured to:
[0103] Get the mean absolute error between the pixel values in the derained image at the original resolution of the sample rainy image and the pixel values in the supervised rain-free image at the original resolution;
[0104] Based on the Soble gradient operator, the horizontal gradient and vertical gradient between the pixel values in the derained image at the original resolution and the pixel values in the supervised rain-free image at the original resolution are obtained;
[0105] The loss function at the original resolution is determined based on the mean absolute error, the horizontal gradient, and the vertical gradient.
[0106] In some implementations, the third acquisition module 830 is further configured to:
[0107] For the remaining resolution except the original resolution, the mean absolute error between the pixel values in the derained image at the remaining resolution and the pixel values in the supervised rain-free image at the remaining resolution is obtained, and the loss function at the remaining resolution is determined according to the mean absolute error.
[0108] The embodiments of the present application can improve the accuracy of the image processing model, thereby improving the clarity and contrast of the derained image, improving the quality of the image, constraining the image at multiple scales, thereby restoring more image details, and better preserving the image structure information.
[0109] like Fig. 9 As shown, based on the same application concept, the embodiment of the present application further provides an image processing device 900, including:
[0110] An acquisition module 910 is used to acquire a target rainy image to be processed;
[0111] The processing module 920 is used to input the target rainy image into the trained target image processing model, and the target image processing model outputs the target rain-free image; wherein the target image processing model is a model trained by the training device 700 such as the above-mentioned image processing model.
[0112] In some implementations, the resolution of the target derained image is the same as the resolution of the target rainy image.
[0113] The embodiments of the present application can improve the clarity and contrast of the derained image, improve the image quality, and better preserve the image structure information of the target derained image.
[0114] Based on the same application concept, an embodiment of the present application also provides an electronic device.
[0115] Fig.10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.10 As shown, the electronic device 1000 includes a memory 1010, a processor 1020, and a computer program product stored in the memory 1010 and executable on the processor 1020. When the processor executes the computer program, the aforementioned image processing model training method or image processing method is implemented.
[0116] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0117] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0118] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0119] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0120] Based on the same application concept, an embodiment of the present application also provides a computer-readable storage medium on which computer instructions are stored, wherein the computer instructions are used to enable a computer to execute the training method of the image processing model or the image processing method in the above-mentioned embodiment.
[0121] Based on the same application concept, an embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, is a training method for the image processing model or an image processing method in the above embodiment.
[0122] It should be noted that in the claims, any reference signs placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The present application may be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names.
[0123] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0124] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0125] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A training method for an image processing model, characterized in that: include: Acquire a sample rainy image, and train an image processing model based on the sample rainy image; Performing feature extraction on the sample rainy image by N-level feature extraction layers in the image processing model to obtain feature maps of each level, and obtaining rain-removed images of the sample rainy image at different resolutions based on the feature maps of each level, where N is an integer greater than 2; For each resolution, according to the derained image at the resolution and the supervised rain-free image at the resolution, obtain the loss function corresponding to the resolution; Based on the loss function of each resolution, the image processing model is adjusted, and the adjusted image processing model is continuously trained using the next sample rainy image until the training is completed to obtain the target image processing model.
2. The method according to claim 1, characterized in that The method further comprises: For the i-th level feature extraction layer, the candidate feature map i-1 of the i-1th level feature extraction layer input into the i-th level feature extraction layer is subjected to maximum pooling and the first convolution process to obtain the candidate feature map i of the i-th level feature extraction layer, and the candidate feature map i is input into the i+1th level feature extraction layer for overall feature extraction to obtain the i+1th level feature map, where i is a positive integer greater than or equal to 1 and less than N; Performing deconvolution on the i+1th level feature map to obtain a deconvolution feature map i; The deconvolution feature map i is merged with the candidate feature map i and a second convolution process is performed to obtain an i-th level feature map; Among them, the size of the convolution kernel used in each feature extraction layer for convolution processing is different.
3. The method according to claim 2, characterized in that The process of obtaining the Nth level feature map includes: Obtain candidate feature map N-1 of the N-1th level feature extraction layer; The candidate feature map N-1 is input into the Nth level feature extraction layer for maximum pooling and the first convolution process to obtain the Nth level feature map.
4. The method according to claim 2, characterized in that: The input of the first-level feature extraction layer is the sample rainy image.
5. The method according to claim 2, characterized in that: The step of obtaining the rain-removed images of the sample rainy images at different resolutions based on the feature maps at each level includes: A third convolution process is performed on the i-th level feature map to obtain a derained image of the sample rainy image at the i-th resolution, wherein the derained images at different resolutions have different numbers of channels.
6. The method according to claim 5, characterized in that For each resolution, according to the derained image at the resolution and the supervised rain-free image at the resolution, obtaining the loss function corresponding to the resolution includes: Obtaining the mean absolute error between the pixel values in the derained image at the original resolution of the sample rainy image and the pixel values in the supervised rain-free image at the original resolution; Based on the Soble gradient operator, obtaining the horizontal gradient and the vertical gradient between the pixel value in the derained image at the original resolution and the pixel value in the supervised rain-free image at the original resolution; A loss function at the original resolution is determined according to the mean absolute error, the gradient in the horizontal direction, and the gradient in the vertical direction.
7. The method according to any one of claims 1 to 6, characterized in that For each resolution, according to the derained image at the resolution and the supervised rain-free image at the resolution, obtaining the loss function corresponding to the resolution includes: For a residual resolution other than the original resolution, the mean absolute error between pixel values in the derained image at the residual resolution and pixel values in the supervised rain-free image at the residual resolution is obtained, and the loss function at the residual resolution is determined according to the mean absolute error.
8. An image processing method, characterized in that: include: Obtain the target rainy image to be processed; Inputting the target rain-bearing image into a trained target image processing model, and the target image processing model outputs a target rain-free image; The target image processing model is a model trained by the training method described in any one of claims 1 to 8.
9. The method according to claim 8, characterized in that The resolution of the target de-rained image is the same as the resolution of the target rainy image.
10. A training device for an image processing model, characterized in that: include: A first acquisition module, used for acquiring a sample rainy image and training an image processing model based on the sample rainy image; A second acquisition module is used to perform feature extraction on the sample rainy image by using N-level feature extraction layers in the image processing model to obtain feature maps of each level, and obtain rain-removed images of the sample rainy image at different resolutions based on the feature maps of each level, where N is an integer greater than 2; The third acquisition module is used to acquire, for each resolution, a loss function corresponding to the resolution according to the derained image at the resolution and the supervised rain-free image at the resolution; An adjustment module is used to adjust the image processing model based on the loss function of each resolution, and continue to use the next sample rainy image to train the adjusted image processing model until the training is completed to obtain a target image processing model.
11. An image processing device, characterized in that: include: An acquisition module, used for acquiring a target rainy image to be processed; A processing module is used to input the target rainy image into a trained target image processing model, and the target image processing model outputs a target derained image; wherein the target image processing model is a model trained using the training device as described in claim 10.
12. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method of any one of claims 1-7 or the method of any one of claims 8-9.
13. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to make the computer execute the method according to any one of claims 1-7 or execute the method according to any one of claims 8-9.
14. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 7 or implements the method according to any one of claims 8 to 9.
