Image processing method and device
By extracting features from multiple channels of the input image and upsampling the bilateral grid data, it solves the problem of large amount of calculation for image dehazing in the existing technology, achieves a lightweight and efficient image dehazing effect, and improves user experience. experience.
Patent Information
- Application Number
- CN202110293366.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-18
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2041-03-18
AI Technical Summary
Existing technology is difficult to achieve lightweight and efficient image defogging. The end-to-end network requires a large amount of calculation and cannot process high-resolution images in real time.
By extracting features from multiple channels of the input image and upsampling the bilateral grid data, the image is dehazed and enhanced, reducing the amount of calculation and improving the user experience.
It achieves a lightweight image defogging effect, reduces the amount of calculation, can process images in real time, improves image clarity and contrast, and enhances user experience.
Smart Images

Figure CN113284055B
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and in particular to a method and device for image processing. Background Art
[0002] Dehazing methods have gone through three stages of development: the mainstream methods in the early days were traditional methods, which modeled and estimated light propagation, but the artificially designed models and prior knowledge of images could not be accurately applied to complex and different types of real images. After convolutional neural networks were applied to a large number of visual tasks and achieved significant breakthroughs in results, learning-based methods became mainstream, replacing some modules in traditional methods with learnable network layers. The most recent methods discarded artificially designed modules such as light estimation and used end-to-end networks to solve the dehazing task, that is, the entire process of image transformation was learned by the network, and the algorithm was completely data-driven. However, end-to-end networks require a lot of computing power and cannot process images in real time. Therefore, how to achieve lightweight and better image enhancement effects has become an urgent problem to be solved. Summary of the invention
[0003] The present application provides an image processing method and device, which extracts features from multiple channels in an input image respectively to guide upsampling of bilateral grid data, so that better image enhancement effects, such as dehazing, can be achieved in each channel of the image, and lightweight image dehazing can be achieved to improve user experience.
[0004] In view of this, in a first aspect, the present application provides a method for image processing, comprising: obtaining an input image, the input image including information of multiple channels; extracting features from the information of multiple channels of the input image respectively to obtain multiple guide maps, the multiple guide maps corresponding to the multiple channels one-to-one, that is, each channel has a corresponding guide map; obtaining bilateral grid data corresponding to the input image, the bilateral grid data including data formed by information of a brightness dimension arranged in a spatial dimension, the information of the brightness dimension being obtained based on features extracted from the input image, the resolution of the bilateral grid data being lower than the resolution of the input image, and the spatial dimension being a preset space or a space determined based on the input image; upsampling the bilateral grid data using each guide map in the multiple guide maps as a guiding condition respectively to obtain multiple feature maps, wherein each guide map can be used to guide the selection of information corresponding to a corresponding channel from the brightness dimension in the bilateral grid data for upsampling; fusing the multiple feature maps to obtain an output image.
[0005] Therefore, in the implementation manner of the present application, features can be extracted from the dimension of each channel of the input image as a guide map, and the bilateral grid data of the input image can be upsampled, thereby smoothing the noise in the input image, improving the clarity of the image, and avoiding information loss in each channel, further improving the clarity of the image. In addition, the present application achieves image enhancement by upsampling low-resolution bilateral grid data. Since the resolution of the bilateral grid data is low, the amount of computation consumed is also less, thereby achieving lightweight image enhancement. For example, when it is necessary to defog an image, features can be extracted from each channel of the image by the method provided in the embodiment of the present application, so that the final output image can retain more detailed information of each channel in the input image, achieve a lightweight defogging effect, and improve the user experience.
[0006] In a possible implementation, the aforementioned upsampling of the bilateral grid data using each of the multiple guide maps as a guiding condition may include: using the first guiding map as a guiding condition to upsample the bilateral grid data to obtain upsampled features, the first guiding map being any one of the multiple guide maps; fusing the upsampled features and the input image to obtain a first feature map, the first feature map being included in the multiple feature maps.
[0007] In the implementation manner of the present application, the bilateral grid data can be upsampled using a guidance map as a guidance condition, so that when upsampling is performed, the features of each channel in the input image can be referred to, and under the guidance of the features of each channel, a better upsampling effect can be achieved, so that the features obtained by upsampling can more accurately describe the details in the input image, and smooth the noise in the input image to achieve a denoising effect.
[0008] In a possible implementation, the above-mentioned fusion of the upsampled features and the input image to obtain the first feature map may include: compressing the upsampled features to obtain compressed features, the number of channels of the compressed features being less than the number of channels of the upsampled features; performing an element-wise product on the compressed features and the input image, that is, multiplying the value of each pixel in the compressed features by the value of the corresponding pixel in the input image to obtain the first feature map.
[0009] In the implementation manner of the present application, the upsampled features can be compressed to obtain compressed features with fewer channels, thereby reducing the amount of calculation when subsequently fusing the input image and features, helping to achieve lightweight image enhancement, so as to facilitate application in various devices and improve generalization capabilities.
[0010] In a possible implementation, the above-mentioned acquisition of bilateral grid data corresponding to the input image to obtain the output image may include: downsampling the input image to obtain a downsampled image; extracting features from the downsampled image to obtain downsampled features, and then obtaining the bilateral grid data based on the downsampled features.
[0011] Therefore, in the implementation manner of the present application, the input image can be downsampled to obtain a low-resolution image, and features can be extracted from the low-resolution image, so that when the bilateral grid data is subsequently upsampled, the upsampling can be performed under the guidance of the guide map, thereby achieving the effect of smoothing noise.
[0012] In a possible implementation, the above-mentioned fusing of multiple feature maps to obtain a stitched image includes: stitching multiple feature maps to obtain a stitched image; performing feature extraction on the stitched image at least once to obtain at least one first feature; and fusing the at least one first feature and the input image to obtain an output image.
[0013] Therefore, in the implementation manner of the present application, channel dimension stitching can be achieved by stitching to obtain output images of multiple channels.
[0014] In a possible implementation, the above-mentioned stitching of multiple feature maps may include: stitching the multiple feature maps and the input image to obtain a stitched image.
[0015] In the implementation manner of the present application, when stitching the feature map, the input image can be integrated, so that the detail information of the stitched image can be supplemented by the information included in the input image, thereby avoiding the loss of information in the input image and improving the clarity of the image.
[0016] In a second aspect, the present application provides a neural network training method, including: obtaining a training set, the training set including multiple image samples and a true image corresponding to each image sample, each image sample including information of multiple channels; using the training set to perform at least one iterative training on the neural network to obtain a trained neural network; wherein, in any iterative training process, the neural network extracts features from the information of multiple channels of the input image respectively to obtain multiple guidance maps, the multiple guidance maps correspond to the multiple channels one-to-one, that is, each channel corresponds to a guidance map, obtains bilateral grid data corresponding to the input image, uses each guidance map in the multiple guidance maps as a guidance condition, upsamples the bilateral grid data to obtain multiple feature maps, fuses the multiple feature maps to obtain an output image, updates the neural network according to the output image and the true image corresponding to the input image, and obtains the neural network after the current update, the bilateral grid data includes data formed by information of a brightness dimension arranged in a preset space, the information of the brightness dimension is obtained according to the features extracted from the input image, and the resolution of the bilateral grid data is lower than the resolution of the input image.
[0017] Therefore, in the method provided by the present application, when training the neural network, features can be extracted from the dimension of each channel of the input image as a guide map, and the bilateral grid data of the input image can be upsampled, thereby smoothing the noise in the input image, improving the clarity of the image, and avoiding information loss in each channel, further improving the clarity of the image output by the neural network. In addition, the present application achieves image enhancement by upsampling low-resolution bilateral grid data. Since the resolution of the bilateral grid data is low, the amount of computation consumed is also less, thereby achieving lightweight image enhancement. For example, when it is necessary to defog an image, a neural network trained by the method provided in an embodiment of the present application can be used to extract features from each channel of the image, so that the final output image can retain more detailed information of each channel in the input image, and achieve a defogging effect, thereby improving the user experience.
[0018] In a possible implementation, the aforementioned upsampling of the bilateral grid data using each of the multiple guide maps as a guiding condition may include: using the first guiding map as a guiding condition to upsample the bilateral grid data to obtain upsampled features, the first guiding map being any one of the multiple guide maps; fusing the upsampled features and the input image to obtain a first feature map, the first feature map being included in the multiple feature maps.
[0019] In the implementation manner of the present application, the bilateral grid data can be upsampled using a guidance map as a guidance condition, so that when upsampling is performed, the features of each channel in the input image can be referred to, and under the guidance of the features of each channel, a better upsampling effect can be achieved, so that the features obtained by upsampling can more accurately describe the details in the input image, and smooth the noise in the input image to achieve a denoising effect.
[0020] In a possible implementation, the above-mentioned fusion of the upsampled features and the input image may include: compressing the upsampled features to obtain compressed features, the number of channels of the compressed features is less than the number of channels of the upsampled features; and performing item-by-item multiplication of the compressed features and the input image to obtain a first feature map.
[0021] In the implementation manner of the present application, the upsampled features can be compressed to obtain compressed features with fewer channels, thereby reducing the amount of calculation when subsequently fusing the input image and features, helping to achieve lightweight image enhancement, so as to facilitate application in various devices and improve generalization capabilities.
[0022] In a possible implementation, the above-mentioned acquisition of bilateral grid data corresponding to the input image may include: downsampling the input image to obtain a downsampled image; extracting features from the downsampled image to obtain downsampled features, and the bilateral grid data includes the downsampled features.
[0023] Therefore, in the implementation manner of the present application, the input image can be downsampled to obtain a low-resolution image, and features can be extracted from the low-resolution image, so that when the bilateral grid data is subsequently upsampled, the upsampling can be performed under the guidance of the guide map, thereby achieving the effect of smoothing noise.
[0024] In a possible implementation, the above-mentioned fusion of multiple feature maps includes: splicing multiple feature maps to obtain a spliced image; performing feature extraction on the spliced image at least once to obtain at least one first feature; and fusing the at least one first feature and the input image to obtain an output image.
[0025] Therefore, in the implementation manner of the present application, channel dimension stitching can be achieved by stitching to obtain output images of multiple channels.
[0026] In a possible implementation, the above-mentioned stitching of multiple feature maps may include: stitching the multiple feature maps and the input image to obtain a stitched image.
[0027] In the implementation manner of the present application, when stitching the feature map, the input image can be integrated, so that the detail information of the stitched image can be supplemented by the information included in the input image, thereby avoiding the loss of information in the input image and improving the clarity of the image.
[0028] In a third aspect, the present application provides a neural network that may include: a bilateral grid generation network, a guidance map generation network, a feature reconstruction network, and an image reconstruction network, etc.
[0029] Among them, the bilateral grid generation network can be used to: downsample the full-resolution input image to obtain a low-resolution image, and then generate bilateral grid data based on the downsampled image, and the bilateral grid data includes information related to spatial dimension and brightness to form at least three-dimensional data.
[0030] The guide map generation network is used to extract features based on each channel of the full-resolution input image to obtain a guide map corresponding to each channel, that is, each channel corresponds to a guide map.
[0031] The feature reconstruction network is used to upsample the bilateral grid for each channel under the guidance of the corresponding guidance map to obtain the feature map corresponding to each channel.
[0032] The image reconstruction network is used to fuse the feature maps corresponding to each channel, and fuse the fused features with the input image to obtain the output image.
[0033] In addition, it should be understood that the neural network can be used to execute the method steps of the aforementioned first aspect or any optional implementation manner of the first aspect.
[0034] In a fourth aspect, an embodiment of the present application provides an image processing device, which has the function of implementing the image processing method of the first aspect. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.
[0035] In a fifth aspect, an embodiment of the present application provides a training device, which has the function of implementing the neural network training method of the second aspect. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.
[0036] In a sixth aspect, an embodiment of the present application provides an image processing device, comprising: a processor and a memory, wherein the processor and the memory are interconnected via a line, and the processor calls a program code in the memory to execute the processing-related functions in the method for image processing shown in any one of the first aspects above. Optionally, the image processing device may be a chip.
[0037] In a seventh aspect, an embodiment of the present application provides a training device, comprising: a processor and a memory, wherein the processor and the memory are interconnected via a line, and the processor calls a program code in the memory to execute the processing-related functions in the neural network training method shown in any one of the third aspects above. Optionally, the training device can be a chip.
[0038] In the eighth aspect, an embodiment of the present application provides an image processing device, which may also be referred to as a digital processing chip or chip. The chip includes a processing unit and a communication interface. The processing unit obtains program instructions through the communication interface, and the program instructions are executed by the processing unit. The processing unit is used to perform functions related to processing in the above-mentioned first aspect or any optional embodiment of the first aspect.
[0039] In the ninth aspect, an embodiment of the present application provides a training device, which can also be called a digital processing chip or chip. The chip includes a processing unit and a communication interface. The processing unit obtains program instructions through the communication interface, and the program instructions are executed by the processing unit. The processing unit is used to perform functions related to processing as described in the second aspect or any optional embodiment of the second aspect.
[0040] In the tenth aspect, an embodiment of the present application provides a computer-readable storage medium, including instructions, which, when executed on a computer, enables the computer to execute a method in any optional implementation of the first aspect or the second aspect above.
[0041] In the eleventh aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute a method in any optional implementation of the first aspect or the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 A schematic diagram of an artificial intelligence main framework for this application;
[0043] Figure 2 A schematic diagram of a convolutional neural network structure provided in an embodiment of the present application;
[0044] Figure 3 A schematic diagram of a system architecture provided for an embodiment of the present application;
[0045] Figure 4 Another schematic diagram of a system architecture provided for an embodiment of the present application;
[0046] Figure 5 A schematic diagram of an application scenario provided for an embodiment of the present application;
[0047] Figure 6 A schematic diagram of another application scenario provided for an embodiment of the present application;
[0048] Figure 7 A flowchart of an image processing method provided in an embodiment of the present application;
[0049] Figure 8 A flowchart of another image processing method provided in an embodiment of the present application;
[0050] Fig. 9 A schematic diagram of a process for generating bilateral grid data provided in an embodiment of the present application;
[0051] Fig.10 A schematic diagram of a process for generating a guide map provided in an embodiment of the present application;
[0052] Fig.11 A schematic diagram of another process for generating a guide map provided in an embodiment of the present application;
[0053] Fig.12 A schematic diagram of a process of feature reconstruction of one of the channels provided in an embodiment of the present application;
[0054] Fig.13A schematic diagram of another process of feature reconstruction of one of the channels provided in an embodiment of the present application;
[0055] Fig.14 A schematic diagram of an image reconstruction process provided in an embodiment of the present application;
[0056] Fig.15 A schematic diagram of the structure of a neural network provided in an embodiment of the present application;
[0057] Fig.16 A flowchart of a neural network training method provided in this application;
[0058] Fig.17 A schematic diagram of an image enhancement effect provided in this application;
[0059] Fig.18A A schematic diagram of an image enhancement effect provided in this application;
[0060] Fig.18B Another schematic diagram of image enhancement effect provided by this application;
[0061] Fig.18C Another schematic diagram of image enhancement effect provided by this application;
[0062] Fig.19 A schematic diagram of the structure of an image processing device provided by the present application;
[0063] Fig. 20 A schematic diagram of the structure of a neural network training provided in this application;
[0064] Fig.21 A schematic diagram of the structure of another image processing device provided by the present application;
[0065] Fig. 22 A schematic diagram of another neural network training structure provided for this application;
[0066] Fig.23 A schematic diagram of the structure of a chip provided in this application. DETAILED DESCRIPTION
[0067] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0068] First, the overall workflow of the artificial intelligence system is described. Figure 1 , Figure 1The figure shows a structural diagram of the main framework of artificial intelligence. The following is an explanation of the above artificial intelligence theme framework from the two dimensions of "intelligent information chain" (horizontal axis) and "IT value chain" (vertical axis). Among them, the "intelligent information chain" reflects a series of processes from data acquisition to processing. For example, it can be a general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, intelligent execution and output. In this process, the data has undergone a condensation process of "data-information-knowledge-wisdom". The "IT value chain" reflects the value that artificial intelligence brings to the information technology industry from the underlying infrastructure of human intelligence, information (providing and processing technology implementation) to the industrial ecology process of the system.
[0069] (1) Infrastructure
[0070] Infrastructure provides computing power support for artificial intelligence systems, enables communication with the outside world, and supports it through the basic platform. It communicates with the outside world through sensors; computing power is provided by smart chips, such as central processing units (CPU), neural-network processing units (NPU), graphics processing units (GPU), application specific integrated circuits (ASIC) or field programmable gate arrays (FPGA) and other hardware acceleration chips; the basic platform includes distributed computing frameworks and networks and other related platform guarantees and support, which can include cloud storage and computing, interconnected networks, etc. For example, sensors communicate with the outside world to obtain data, and these data are provided to the smart chips in the distributed computing system provided by the basic platform for calculation.
[0071] (2) Data
[0072] The data on the upper layer of the infrastructure is used to represent the data sources in the field of artificial intelligence. The data involves graphics, images, voice, text, and IoT data of traditional devices, including business data of existing systems and perception data such as force, displacement, liquid level, temperature, and humidity.
[0073] (3) Data processing
[0074] Data processing usually includes data training, machine learning, deep learning, search, reasoning, decision-making and other methods.
[0075] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.
[0076] Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formalized information to perform machine thinking and solve problems based on reasoning control strategies. Typical functions are search and matching.
[0077] Decision-making refers to the process of making decisions after intelligent information is reasoned, usually providing functions such as classification, sorting, and prediction.
[0078] (4) General ability
[0079] After the data has undergone the data processing mentioned above, some general capabilities can be further formed based on the results of the data processing, such as an algorithm or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
[0080] (5) Smart products and industry applications
[0081] Smart products and industry applications refer to the products and applications of artificial intelligence systems in various fields. They are the encapsulation of the overall artificial intelligence solution, which productizes intelligent information decision-making and realizes practical applications. Its application areas mainly include: smart terminals, smart transportation, smart medical care, autonomous driving, safe cities, etc.
[0082] The embodiments of the present application involve a large number of neural network-related applications. In order to better understand the solutions of the embodiments of the present application, the relevant terms and concepts of the neural network that may be involved in the embodiments of the present application are first introduced below.
[0083] (1) Neural Network
[0084] A neural network may be composed of neural units. A neural unit may refer to an operation unit with xs and intercept 1 as input. The output of the operation unit may be as shown in formula (1-1):
[0085]
[0086] Where s=1, 2, ...n, n is a natural number greater than 1, Ws is the weight of xs, and b is the bias of the neural unit. f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into the output signal. The output signal of the activation function can be used as the input of the next convolution layer, and the activation function can be a sigmoid function. A neural network is a network formed by connecting multiple single neural units mentioned above, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the characteristics of the local receptive field. The local receptive field can be an area composed of several neural units.
[0087] (2) Deep Neural Networks
[0088] A deep neural network (DNN), also known as a multi-layer neural network, can be understood as a neural network with multiple intermediate layers. According to the position of different layers, the neural network inside the DNN can be divided into three categories: input layer, intermediate layer, and output layer. Generally speaking, the first layer is the input layer, the last layer is the output layer, and the layers in between are all intermediate layers, or hidden layers. The layers are fully connected, that is, any neuron in the i-th layer must be connected to any neuron in the i+1-th layer.
[0089] Although DNN looks complicated, each layer can be expressed as a linear relationship expression: in, is the input vector, is the output vector, is the offset vector or bias parameter, w is the weight matrix (also called coefficient), and α() is the activation function. Each layer is just an input vector After such a simple operation, the output vector Since DNN has many layers, the coefficient W and the offset vector The number of these parameters is also relatively large. The definitions of these parameters in DNN are as follows: Taking the coefficient w as an example: Assume that in a three-layer DNN, the linear coefficient from the 4th neuron in the second layer to the 2nd neuron in the third layer is defined as The superscript 3 represents the layer number of the coefficient W, while the subscripts correspond to the third layer index 2 of the output and the second layer index 4 of the input.
[0090] In summary, the coefficients from the kth neuron in the L-1th layer to the jth neuron in the Lth layer are defined as
[0091] It should be noted that the input layer does not have a W parameter. In a deep neural network, more intermediate layers allow the network to better characterize complex situations in the real world. Theoretically, the more parameters a model has, the higher its complexity and the greater its "capacity", which means it can complete more complex learning tasks. Training a deep neural network is the process of learning the weight matrix, and its ultimate goal is to obtain the weight matrix of all layers of the trained deep neural network (a weight matrix formed by many layers of vectors W).
[0092] (3) Convolutional Neural Network
[0093] Convolutional neural network (CNN) is a deep neural network with a convolutional structure. Convolutional neural network contains a feature extractor consisting of a convolution layer and a subsampling layer, which can be regarded as a filter. Convolutional layer refers to the neuron layer in the convolutional neural network that performs convolution processing on the input signal. In the convolutional layer of the convolutional neural network, a neuron can only be connected to some neurons in the adjacent layers. A convolutional layer usually contains several feature planes, each of which can be composed of some rectangularly arranged neural units. The neural units in the same feature plane share weights, and the shared weights here are convolution kernels. Shared weights can be understood as the way to extract image information is independent of position. The convolution kernel can be initialized in the form of a matrix of random size, and the convolution kernel can obtain reasonable weights through learning during the training process of the convolutional neural network. In addition, the direct benefit of shared weights is to reduce the connection between the layers of the convolutional neural network, while reducing the risk of overfitting.
[0094] The network for extracting features mentioned below in this application may include one or more convolutional layers. Exemplarily, the network for extracting features may be implemented using CNN.
[0095] (4) Loss Function
[0096] In the process of training a deep neural network, because we hope that the output of the deep neural network is as close as possible to the value we really want to predict, we can compare the predicted value of the current network with the target value we really want, and then update the weight vector of each layer of the neural network according to the difference between the two (of course, there is usually an initialization process before the first update, that is, pre-configuring parameters for each layer in the deep neural network). For example, if the predicted value of the network is high, adjust the weight vector to make it predict a lower value, and continue to adjust until the deep neural network can predict the target value we really want or a value very close to the target value we really want. Therefore, it is necessary to pre-define "how to compare the difference between the predicted value and the target value", which is the loss function or objective function, which are important equations used to measure the difference between the predicted value and the target value. Among them, taking the loss function as an example, the higher the output value (loss) of the loss function, the greater the difference, so the training of the deep neural network becomes a process of minimizing this loss as much as possible. The loss function can usually include loss functions such as squared error, cross entropy, logarithm, exponential, etc. For example, the squared error can be used as a loss function, defined as The specific loss function can be selected according to the actual application scenario.
[0097] (5) Back propagation algorithm
[0098] Neural networks can use the error back propagation (BP) algorithm to correct the size of the parameters in the initial neural network model during the training process, so that the reconstruction error loss of the neural network model becomes smaller and smaller. Specifically, the forward transmission of the input signal to the output will generate error loss, and the parameters in the initial neural network model are updated by back propagating the error loss information, so that the error loss converges. The back propagation algorithm is a back propagation movement dominated by error loss, which aims to obtain the optimal parameters of the neural network model, such as the weight matrix.
[0099] (6) Receptive Field
[0100] A term used in the field of deep neural networks in the field of computer vision to indicate the size of the receptive range of neurons at different positions within the neural network to the original image. The larger the value of the neuron's receptive field, the larger the range of the original image it can access, which also means that the neuron may contain more global and higher-level semantic features; the smaller the value, the more local and detailed the features it contains. The value of the receptive field can be roughly used to determine the level of abstraction of each layer.
[0101] (7) Image (image quality) enhancement
[0102] It refers to the technology of processing the brightness, color, contrast, saturation, dynamic range, etc. of an image to meet certain specific indicators, or it is called image quality enhancement, which is equivalent to improving the quality of the image and making the image clearer.
[0103] (8) Defogging
[0104] Refers to a type of image enhancement that makes a blurred image clearer. For example, an image may be taken in a foggy environment, and the image may not be clear at this time. The method provided in this application can be used to perform defogging to improve the clarity or contrast of the image and make the image clearer.
[0105] (9) RGB image
[0106] RGB images are images with at least three channels, namely red, green and blue. These three colors make up all the colors that can be perceived by vision and are one of the most widely used color systems. For example, a frame of RGB image is an M*N*3 color pixel array, where M*N is the size of the image, and each color pixel is a three-value group, and these three values correspond to the red, green and blue components respectively.
[0107] Generally, CNN is a commonly used neural network. For example, the network used for feature extraction mentioned below in this application may be CNN or other networks including convolutional layers. For ease of understanding, the structure of the convolutional neural network is introduced as an example below.
[0108] Combine the following Figure 2 The structure of CNN is introduced in detail as an example. As mentioned in the basic concept introduction above, convolutional neural network is a deep neural network with convolution structure, which is a deep learning architecture. Deep learning architecture refers to multiple levels of learning at different abstract levels through machine learning algorithms. As a deep learning architecture, CNN is a feed-forward artificial neural network, in which each neuron can respond to the image input into it.
[0109] like Figure 2 As shown, the convolutional neural network (CNN) 200 may include an input layer 210, a convolution layer / pooling layer 220 (wherein the pooling layer is optional), and a fully connected layer 230. In the following embodiments of the present application, for ease of understanding, each layer is referred to as a stage. The relevant contents of these layers are described in detail below.
[0110] Convolutional layer / pooling layer 220:
[0111] like Figure 2 The convolution layer / pooling layer 220 shown may include layers 221-226, for example: in one implementation, layer 221 is a convolution layer, layer 222 is a pooling layer, layer 223 is a convolution layer, layer 224 is a pooling layer, layer 225 is a convolution layer, and layer 226 is a pooling layer; in another implementation, layers 221 and 222 are convolution layers, layer 223 is a pooling layer, layer 224 and 225 are convolution layers, and layer 226 is a pooling layer. That is, the output of a convolution layer can be used as the input of a subsequent pooling layer, or as the input of another convolution layer to continue the convolution operation.
[0112] The following will take the convolution layer 221 as an example to introduce the internal working principle of a convolution layer.
[0113] The convolution layer 221 may include a plurality of convolution operators, which are also called kernels. The convolution operator is equivalent to a filter that extracts specific information from the input image matrix in image processing. The convolution operator can be essentially a weight matrix, which is usually predefined. In the process of performing convolution operations on the image, the weight matrix is usually processed one pixel after another (or two pixels after two pixels... depending on the value of the step length stride) in the horizontal direction on the input image, thereby completing the work of extracting specific features from the image. The size of the weight matrix should be related to the size of the image. It should be noted that the depth dimension of the weight matrix is the same as the depth dimension of the input image. In the process of performing convolution operations, the weight matrix will extend to the entire depth of the input image. Therefore, convolution with a single weight matrix will produce a convolution output with a single depth dimension, but in most cases, a single weight matrix is not used, but multiple weight matrices of the same size (row × column), that is, multiple isotype matrices, are applied. The output of each weight matrix is stacked to form the depth dimension of the convolution image, and the dimension here can be understood as being determined by the "multiple" mentioned above. Different weight matrices can be used to extract different features in the image, for example, one weight matrix is used to extract image edge information, another weight matrix is used to extract specific colors of the image, and another weight matrix is used to blur unwanted noise in the image, etc. The multiple weight matrices have the same size (rows × columns), and the feature maps extracted by the multiple weight matrices of the same size are also the same size. The extracted feature maps of the same size are then merged to form the output of the convolution operation.
[0114] The weight values in these weight matrices need to be obtained through a lot of training in practical applications. The weight matrices formed by the weight values obtained through training can be used to extract information from the input image, so that the convolutional neural network 200 can make correct predictions.
[0115] When the convolutional neural network 200 has multiple convolutional layers, the initial convolutional layer (for example, 221) often extracts more general features, which can also be called low-level features. As the depth of the convolutional neural network 200 increases, the features extracted by the later convolutional layers (for example, 226) become more and more complex, such as high-level semantic features. Features with higher semantics are more suitable for the problem to be solved.
[0116] In the following embodiments of the present application, the feature extraction process mentioned may be a process of extracting features through convolution. For example, the convolution layer may include a separation convolution with a convolution kernel size of 3×3 (sep_conv_3x3), a separation convolution with a convolution kernel size of 5×5 (sep_conv_5x5), a dilated convolution with a convolution kernel size of 3×3 and a dilation rate of 2 (dil_conv_3x3), a dilated convolution with a convolution kernel size of 5×5 and a dilation rate of 2 (dil_conv_5x5), and the like.
[0117] Pooling layer:
[0118] Since it is often necessary to reduce the number of training parameters, it is often necessary to periodically introduce a pooling layer after the convolution layer. The pooling layer can also be called a downsampling layer, which can be used to downsample the image. Figure 2 Each layer 221-226 illustrated in 220 may be a convolution layer followed by a pooling layer, or may be multiple convolution layers followed by one or more pooling layers. In the image processing process, the purpose of the pooling layer is to reduce the spatial size of the image. The pooling layer may include an average pooling operator and / or a maximum pooling operator for sampling the input image to obtain an image of smaller size. The average pooling operator may calculate the pixel values in the image within a specific range to generate an average value as the result of average pooling. The maximum pooling operator may take the pixel with the largest value in the range within a specific range as the result of maximum pooling. In addition, just as the size of the weight matrix used in the convolution layer should be related to the image size, the operator in the pooling layer should also be related to the image size. The size of the image output after processing by the pooling layer may be smaller than the size of the image input to the pooling layer, and each pixel in the image output by the pooling layer represents the average value or maximum value of the corresponding sub-region of the image input to the pooling layer.
[0119] Fully connected layer 230:
[0120] After being processed by the convolution layer / pooling layer 220, the convolution neural network 200 is not sufficient to output the required output information. As mentioned above, the convolution layer / pooling layer 220 only extracts features and reduces the parameters brought by the input image. However, in order to generate the final output information (the required class information or other related information), the convolution neural network 200 needs to use the fully connected layer 230 to generate one or a group of outputs of the required number of classes. Therefore, the fully connected layer 230 may include multiple hidden layers (such as Figure 2 As shown in 231, 232 to 23n), the parameters contained in the multi-layer hidden layer can be pre-trained according to relevant training data of a specific task type. For example, the task type may include image enhancement, image recognition, image classification, image super-resolution reconstruction, etc.
[0121] After the multiple hidden layers in the fully connected layer 230, that is, the last layer of the entire convolutional neural network 200 is the output layer 240, which has a loss function similar to the classification cross entropy, specifically used to calculate the prediction error. Once the forward propagation of the entire convolutional neural network 200 (such as Figure 2 The propagation from 210 to 240 is forward propagation), and the reverse propagation (such as Figure 2 The propagation from 240 to 210 is called back propagation) and then starts to update the weight values and biases of the aforementioned layers to reduce the loss of the convolutional neural network 200 and the error between the result output by the convolutional neural network 200 through the output layer and the ideal result.
[0122] It should be noted that if Figure 2 The convolutional neural network 200 shown is only an example of a convolutional neural network. In specific applications, the convolutional neural network can also exist in the form of other network models. Figure 2 A portion of the network structure shown in , for example, the convolutional neural network used in the embodiment of the present application may only include an input layer 210, a convolution layer / pooling layer 220 and an output layer 240.
[0123] In this application, you can use Figure 2 The convolutional neural network 200 shown in FIG. 1 processes the image to be processed to obtain an enhanced image. Figure 2 As shown, after the image to be processed is processed by the input layer 210, the convolution layer / pooling layer 220 and the fully connected layer, the output is enhanced to be a clearer image containing more texture information.
[0124] The method for image processing provided in the embodiment of the present application can be executed on a server or on a terminal device, or the neural network mentioned below in the present application can be deployed on a server or on a terminal, which can be adjusted according to the actual application scenario. The terminal device can be a mobile phone with image processing function, a tablet personal computer (TPC), a media player, a smart TV, a laptop computer (LC), a personal digital assistant (PDA), a personal computer (PC), a camera, a video camera, a smart watch, a wearable device (WD) or an autonomous driving vehicle, etc., which is not limited in the embodiment of the present application.
[0125] like Figure 3 As shown, the embodiment of the present application provides a system architecture 100. Figure 3 In some optional implementations, for image enhancement, the sample pairs included in the training data may include images with lower image quality and clear images. For example, a sample pair may include an image taken on a foggy day and a clear image (or a true value image) that has been heavily processed.
[0126] After the training data is collected, the data collection device 160 stores the training data in the database 130, and the training device 120 obtains the target model / rule 101 through training based on the training data maintained in the database 130. Optionally, the training set mentioned in the following embodiments of the present application can be obtained from the database 130 or through user input data.
[0127] Among them, the target model / rule 101 can be a neural network after training in the embodiment of the present application.
[0128] The following describes how the training device 120 obtains the target model / rule 101 based on the training data. The training device 120 processes the input original image and compares the output image with the original image until the difference between the image output by the training device 120 and the original image is less than a certain threshold, thereby completing the training of the target model / rule 101.
[0129] The above-mentioned target model / rule 101 can be used to implement the neural network trained by the method for image processing in the embodiment of the present application, that is, the data to be processed (such as an image) is input into the target model / rule 101 after relevant preprocessing, and the processing result can be obtained. The target model / rule 101 in the embodiment of the present application can specifically be the first neural network mentioned below in the present application, and the first neural network can be a neural network of the aforementioned CNN, DNN or RNN type. It should be noted that in actual applications, the training data maintained in the database 130 does not necessarily all come from the collection of the data acquisition device 160, and may also be received from other devices. It should also be noted that the training device 120 does not necessarily train the target model / rule 101 completely based on the training data maintained by the database 130, and it is also possible to obtain training data from the cloud or other places for model training. The above description should not be used as a limitation on the embodiment of the present application.
[0130] The target model / rule 101 trained by the training device 120 can be applied to different systems or devices, such as Figure 3 The execution device 110 shown in the figure may also be called a computing device. The execution device 110 may be a terminal, such as a mobile phone terminal, a tablet computer, a laptop computer, an augmented reality (AR) / virtual reality (VR), a vehicle terminal, etc., or a server or a cloud device, etc. Figure 5 In the embodiment, the execution device 110 is configured with an input / output (I / O) interface 112 for data interaction with an external device. A user may input data to the I / O interface 112 through a client device 140. The input data may include: data to be processed input by the client device in the embodiment of the application.
[0131] Preprocessing module 113 and preprocessing module 114 are used to perform preprocessing according to input data (such as data to be processed) received by I / O interface 112. In an embodiment of the present application, preprocessing module 113 and preprocessing module 114 may not be provided (or only one of the preprocessing modules may be provided), and computing module 111 may be used directly to process the input data.
[0132] When the execution device 110 preprocesses the input data, or when the computing module 111 of the execution device 110 performs calculations and other related processing, the execution device 110 can call the data, code, etc. in the data storage system 150 for corresponding processing, and can also store the data, instructions, etc. obtained from the corresponding processing into the data storage system 150.
[0133] Finally, the I / O interface 112 returns the processing result to the client device 140 for providing it to the user. For example, if the first neural network is used for image classification and the processing result is a classification result, the I / O interface 112 returns the classification result obtained above to the client device 140 for providing it to the user.
[0134] It should be noted that the training device 120 can generate corresponding target models / rules 101 based on different training data for different goals or different tasks, and the corresponding target models / rules 101 can be used to achieve the above goals or complete the above tasks, thereby providing the user with the desired results. In some scenarios, the execution device 110 and the training device 120 can be the same device, or located in the same computing device. For ease of understanding, this application will introduce the execution device and the training device separately, without limitation.
[0135] exist Figure 3 In the case shown, the user can manually give input data, and the manual giving can be operated through the interface provided by the I / O interface 112. In another case, the client device 140 can automatically send input data to the I / O interface 112. If the client device 140 is required to automatically send input data and needs to obtain the user's authorization, the user can set the corresponding authority in the client device 140. The user can view the results output by the execution device 110 on the client device 140, and the specific presentation form can be a specific method such as display, sound, action, etc. The client device 140 can also be used as a data acquisition terminal to collect the input data input to the I / O interface 112 as shown in the figure and the predicted label output from the I / O interface 112 as new sample data, and store it in the database 130. Of course, it is also possible not to collect through the client device 140, but the I / O interface 112 directly stores the input data input to the I / O interface 112 as shown in the figure and the predicted label output from the I / O interface 112 as new sample data in the database 130.
[0136] It should be noted that Figure 3 This is only a schematic diagram of a system architecture provided by an embodiment of the present application. The positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. For example, in Figure 3 In the embodiment, the data storage system 150 is an external memory relative to the execution device 110. In other cases, the data storage system 150 may also be placed in the execution device 110.
[0137] like Figure 3As shown, the target model / rule 101 is obtained by training according to the training device 120. The target model / rule 101 in the embodiment of the present application can be a neural network in the present application. Specifically, the neural network provided in the embodiment of the present application can be CNN, deep convolutional neural networks (DCNN), recurrent neural networks (RNN), etc.
[0138] See attached Figure 4 , the embodiment of the present application also provides a system architecture 400. The execution device 110 is implemented by one or more servers (such as a server cluster), and optionally cooperates with other computing devices, such as data storage, routers, load balancers, etc.; the execution device 110 can be arranged on a physical site, or distributed on multiple physical sites. The execution device 110 can use the data in the data storage system 150, or call the program code in the data storage system 150 to implement the following of the present application Figure 7-Figure 16 Corresponding steps for image processing methods or neural network training methods.
[0139] Users can operate their respective user devices (e.g., local device 401 and local device 402) to interact with execution device 110. Each local device can represent any computing device, such as a personal computer, a computer workstation, a smart phone, a tablet computer, a smart camera, a smart car or other type of cellular phone, a media consumption device, a wearable device, a set-top box, a game console, etc.
[0140] The local device of each user can interact with the execution device 110 through a communication network of any communication mechanism / communication standard, and the communication network can be a wide area network, a local area network, a point-to-point connection, or any combination thereof. Specifically, the communication network may include a wireless network, a wired network, or a combination of a wireless network and a wired network. The wireless network includes, but is not limited to: a fifth generation mobile communication technology (5th-Generation, 5G) system, a long term evolution (long termevolution, LTE) system, a global system for mobile communication (global system for mobile communication, GSM) or a code division multiple access (code division multiple access, CDMA) network, a wideband code division multiple access (wideband code division multiple access, WCDMA) network, wireless fidelity (wireless fidelity, WiFi), Bluetooth (bluetooth), Zigbee protocol (Zigbee), radio frequency identification technology (radio frequency identification, RFID), long range (Lora) wireless communication, near field communication (near field communication, NFC) in any one or more combinations. The wired network may include a fiber optic communication network or a network composed of coaxial cables, etc.
[0141] In another implementation, one or more aspects of the execution device 110 may be implemented by each local device, for example, the local device 401 may provide local data or feedback calculation results to the execution device 110. The local device may also be referred to as a computing device.
[0142] It should be noted that all functions of the execution device 110 may also be implemented by the local device. For example, the local device 401 implements the functions of the execution device 110 and provides services to the user, or provides services to the user of the local device 402, such as providing image optimization services.
[0143] Usually, in some foggy scenes or scenes with weak light intensity, the captured images may be blurred or have low contrast, resulting in unclear images. For example, taking defogging as an example, the early mainstream methods were traditional methods, which modeled and estimated light propagation, but the artificially designed models and image prior knowledge cannot be accurately applied to complex and different types of real images. After convolutional neural networks were applied to a large number of visual tasks and achieved major breakthroughs in results, learning-based methods became the mainstream, replacing some modules in traditional methods with learnable network layers. The existing methods discard artificially designed modules such as light estimation and use end-to-end networks to solve the defogging task, that is, the entire process of image transformation is learned by the network, and the algorithm is completely data-driven. The current end-to-end network that achieves SOTA (State-of-the-art) effects has a large demand for computing, and it takes a lot of time to process high-resolution images, and some high-resolution images cannot be processed in real time.
[0144] Some commonly used dehazing methods can, for example, use U-Net as the backbone network of the network, borrow a method from the field of denoising to gradually enhance the dehazing effect; and propose a feature fusion module to fuse features of different scales together to overcome the shortcomings of the original U-Net, which loses spatial information and lacks non-adjacent level connections. However, this method has a high computational complexity, takes a long time to process images, and cannot achieve real-time processing.
[0145] For another example, a low-resolution image can be processed to obtain the conversion coefficients stored in the bilateral grid, and the features of the full-resolution image can be extracted to obtain a guide map. Under the guidance of the guide map, the bilateral grid coefficients are upsampled to obtain a pixel transformation matrix, and each pixel of the input image is transformed using the pixel transformation matrix to obtain the final output. When obtaining the guide map, the features of the image need to be compressed, which may result in information loss, and the method of upsampling the bilateral grid coefficients is inefficient and time-consuming to implement.
[0146] Therefore, the present application provides an image processing method, which realizes efficient image enhancement through a lightweight architecture, and even realizes real-time image processing, thereby improving the efficiency of image enhancement.
[0147] First, some scenarios of application of this application are introduced exemplarily.
[0148] For example, Figure 5As shown, low-quality video data collected by various monitoring devices can be collected and stored in a memory, such as smart city, outdoor scene monitoring, indoor monitoring, in-car monitoring, pet monitoring, outdoor shooting or outdoor monitoring, etc. When playing the video data, the image processing method provided by the present application can be used to enhance the video data, such as defogging or improving the contrast, so as to obtain higher-definition video data and improve the user's viewing experience.
[0149] For another example, the image processing method provided in this application can be applied to live video broadcasting scenarios, such as Figure 6 As shown, the server can send a video stream to the client used by the user. After the client receives the data stream sent by the server, the image processing method provided by the present application can be used to perform image enhancement processing on the data stream, thereby obtaining higher-definition video data and improving the user's viewing experience.
[0150] For another example, in an autonomous driving scenario, the camera installed on the smart car can capture images around the vehicle, and based on the images, a driving path can be planned for the vehicle or driving decisions can be made. Through the image processing method provided by this application, the image captured by the camera can be enhanced to obtain a clearer image, especially in foggy scenes, to achieve a defogging effect, thereby improving the driving safety of the vehicle and improving the user experience.
[0151] For example, a user can use a terminal to take photos in a foggy environment. The captured image may not be clear due to the fog. The image processing method provided in the present application can be used to defog the captured image, thereby improving the image clarity and improving the user experience.
[0152] For example, in some scenes with large differences in ambient light, the images captured by the user may be unclear due to low contrast. In this case, the image processing method provided in the present application can be used to process the captured images to improve the contrast of the images, making the images clearer and improving the user experience.
[0153] The following is a detailed introduction to the image processing method provided by this application in combination with the aforementioned scenarios and system architecture.
[0154] Furthermore, the image processing method provided in the present application can be implemented through a neural network. For example, the neural network can be deployed on a user's terminal, and the terminal can run the neural network to implement the steps of the image processing method provided in the present application.
[0155] First, see Figure 7 , a flow chart of an image processing method provided in the present application is as follows.
[0156] 701. Obtain an input image.
[0157] The input image may be an image captured by the terminal or a received image, and the input image has multiple channels.
[0158] The input image may be obtained by user input, for example, see Figure 3 , the user can send input data to the execution device 110 through the client device 140, and the input data can carry the input image.
[0159] Alternatively, if the image processing method provided in the present application is executed by a terminal, the input image may also be an image captured by the terminal. For example, the input image may be an image captured by the terminal in a foggy scene, and defogging processing is required to improve the clarity of the image.
[0160] 702. Extract features from information of multiple channels of the input image respectively to obtain multiple guide maps.
[0161] Wherein, the input image has multiple channels, and the present application can extract features from the dimension of each channel respectively, and obtain a feature map of each channel dimension, that is, a guide map, and each channel can correspond to a feature map, that is, multiple guide maps are obtained. The multiple guide maps can be used to guide the upsampling of the bilateral grid data later, which is equivalent to playing the role of guiding upsampling.
[0162] For example, the input image may include information of three channels, and features may be extracted from the information of each channel respectively to obtain features corresponding to each channel and a guidance map corresponding to each channel.
[0163] 703. Obtain bilateral grid data corresponding to the input image.
[0164] The bilateral grid data may include data formed by information of the spatial dimension and information of the brightness dimension, in other words, the bilateral grid data includes data formed by information of the brightness dimension arranged in a preset space. It can be understood that the bilateral grid data may include data of at least three dimensions.
[0165] Specifically, the spatial dimension may be pre-set or determined according to the size of the input image, and the spatial dimension includes at least two dimensions, that is, the spatial dimension may include a two-dimensional space or a three-dimensional space, etc.
[0166] For example, the spatial dimension corresponds to the size of the input image, and each position in the spatial dimension corresponds to one or more pixels in the input image. Accordingly, after extracting the feature from the input image, the feature can be processed, and the information obtained after the processing is related to the brightness of the input image. The feature is assigned to the spatial dimension to obtain bilateral grid data.
[0167] In one possible implementation, the input image is downsampled to obtain a downsampled image; features are extracted from the downsampled image to obtain downsampled features, and the bilateral grid data may include the downsampled features. There may be multiple downsampling methods, such as bilinear interpolation or bicubic interpolation.
[0168] It can be understood that the input image is first downsampled to reduce the resolution of the image, which can reduce the subsequent computational complexity and help achieve lightweight image enhancement; then features are extracted from the downsampled image and average pooled to obtain information related to the brightness of the input image, namely the downsampled features. The downsampled features are mapped to the spatial dimension to obtain bilateral grid data.
[0169] The spatial dimension in the bilateral grid data may be a pre-set dimension or a dimension determined according to the size of the input image. For example, a size may be pre-set, which is equivalent to the size of the spatial dimension of the bilateral grid data, and the pixels in the downsampled image may have a corresponding relationship with the size. For example, the size may be 100*100, and the resolution of the downsampled image is 200*200, then every 4 pixels in the downsampled image may correspond to a pixel in the size. After extracting the downsampled features from the downsampled image, the downsampled features are assigned to the corresponding pixels in the size according to the corresponding relationship between the pixels in the downsampled image and the size, and the bilateral grid data can be obtained.
[0170] It should be noted that the present application does not limit the execution order of step 702 and step 703. Step 702 may be executed first, or step 703 may be executed first, or both may be executed simultaneously. The specific execution order may be adjusted according to the actual application scenario.
[0171] 704. Using each of the multiple guide maps as a guide condition, up-sample the bilateral grid data to obtain multiple feature maps.
[0172] After obtaining multiple guide maps, the bilateral grid data can be upsampled for each channel under the guidance of the guide maps corresponding to each channel to obtain multiple feature maps corresponding to the multiple channels. Each guide map can be used to guide the selection of information related to the corresponding channel from the information of the brightness dimension in the bilateral grid data during upsampling to obtain a feature map corresponding to each channel.
[0173] Among them, the upsampling method can adopt various interpolation algorithms, such as bilinear interpolation, bicubic interpolation or trilinear interpolation, so as to obtain a feature map with a higher resolution than the bilateral grid data.
[0174] Optionally, taking the processing of one of the multiple guide maps (referred to as the first guide map) as an example, the first guide map is used as a guiding condition, the bilateral grid data is upsampled to obtain upsampled features, and then the upsampled features and the input image are fused to obtain a first feature map, i.e., one of the multiple feature maps. The fusion method may include, but is not limited to: multiplication, concatenation, or weighted fusion.
[0175] For example, the information of the brightness dimension in the bilateral grid data can be used as a coefficient and upsampled by interpolation, wherein each point in the spatial dimension of the bilateral grid data may correspond to multiple coefficient values. When upsampling, under the guidance of the guide map, one or more of the multiple coefficients corresponding to each point or each several points are selected for interpolation to obtain an upsampled feature of the same size as the guide map. The specific guidance method of the guide map may include: the value corresponding to each pixel point in the guide map can be understood as a brightness level, each point in the guide map has a corresponding relationship with the point in the spatial dimension of the bilateral grid data, and the coefficient matching the brightness level can be selected from the multiple coefficients corresponding to each point or each several points in the bilateral grid data according to the brightness level of each point in the guide map to perform interpolation to obtain an upsampled feature.
[0176] Therefore, in an embodiment of the present application, the bilateral grid data can be upsampled using a guidance map as a guide to obtain upsampled features with higher resolution, and the present application guides the upsampling of the bilateral grid data through a guidance map for each channel, and a feature map can be obtained for each channel, so that the final output image can perform better and clearer in each channel.
[0177] Optionally, the method of fusing the upsampled features and the input image may include: compressing the upsampled features to obtain compressed features. The compressed features and the input image are then fused to achieve feature reconstruction and obtain one of the corresponding feature maps. Specific fusion methods may include term-by-term product or weighted fusion. The compression is to reduce the number of channels of the upsampled features so that the number of channels of the compressed features is less than the number of channels of the upsampled features, thereby reducing the amount of data. Among them, the specific method of compression can be compressed by convolution, which is equivalent to further feature extraction from the upsampled features. Compression can be performed by adjusting the number of convolution kernels to obtain compressed features with smaller data volume.
[0178] Therefore, in the implementation manner of the present application, the upsampled features can be compressed, and the compressed features and the input image can be fused. Feature reconstruction is achieved by fusing the compressed features and the input image to obtain features in each channel that can more accurately characterize the instances in the input image.
[0179] 705. Fuse multiple feature maps to obtain an output image.
[0180] After obtaining multiple feature maps, the multiple feature maps can be fused, which is equivalent to restoring each channel to obtain a multi-channel output image. The number of channels of the output image is usually the same as the number of channels of the input image.
[0181] Therefore, in the implementation manner of the present application, features can be extracted from the dimensions of multiple channels of the input image to obtain multiple guide maps, and under the guidance of the multiple guide maps, the low-resolution bilateral grid data can be upsampled to obtain multiple feature maps, and the multiple feature maps and the output image can be fused, which is equivalent to smoothing the noise in the input image by upsampling the low-resolution bilateral grid data, improving the clarity of the input image, achieving the defogging effect of the input image or improving the contrast of the input image, and obtaining a clearer output image. In addition, the present application achieves image enhancement by upsampling the low-resolution bilateral grid data. Since the resolution of the bilateral grid data is low, the amount of computation consumed is also less, thereby achieving lightweight image enhancement.
[0182] Optionally, the specific process of fusing multiple feature maps may include: splicing multiple feature maps to obtain a spliced image, and then performing at least one feature extraction on the spliced image. When there are multiple feature extractions, it may be an iterative extraction, that is, extracting the current feature from the feature extracted last time to obtain at least one first feature, and fusing the at least one feature with the input image to obtain an output image. Therefore, in the embodiment of the present application, multiple feature maps can be fused by splicing, because the feature map is obtained by upsampling the bilateral grid data under the guidance of the guide map of each channel. In this step, by splicing multiple feature maps, the channels of the spliced image can be restored, so that the spliced image has multiple channels, which are fused with the input image to obtain an output image of multiple channels. This is equivalent to enhancing the input image from the dimensions of each channel to obtain an enhanced output image, thereby improving the clarity of the image and improving the user experience.
[0183] Optionally, when stitching multiple feature maps, the multiple feature maps and the input image may be stitched together to obtain a stitched image. Thus, the details of the multiple feature maps may be supplemented by the details included in the input image, such as low-frequency information such as color or brightness, so that the details of the stitched image are richer, and the over-smoothing caused by the aforementioned steps is avoided, thereby improving the clarity of the output image.
[0184] The above has introduced in detail the process of the image processing method provided by the present application. For ease of understanding, the process of the image processing method provided by the present application is introduced in more detail below using a specific application scenario as an example.
[0185] See also Figure 8, a flowchart of another image processing method provided in this application.
[0186] For ease of understanding, the image processing method of the present application is divided into multiple steps for introduction, such as Figure 8 The bilateral grid generation 801, guide map generation 802, feature reconstruction 803 and image reconstruction 804 shown in FIG.
[0187] In which, the bilateral grid generation 801 can downsample the full-resolution input image I to obtain a low-resolution image Then based on the downsampled image Generate bilateral grid data g, which includes information related to spatial dimension and brightness to form at least three-dimensional data.
[0188] Guide map generation 802: Extract features based on each channel of the full-resolution input image I to obtain a guide map corresponding to each channel, such as Figure 8 The guide graphs G1 / G2 / G3 shown in FIG.
[0189] Feature reconstruction 803: For each channel, under the guidance of the corresponding guide map, upsample the bilateral grid to obtain the feature map F1 / F2 / G3 corresponding to each channel.
[0190] Image reconstruction 804: Fusing the feature maps corresponding to each channel, and fusing the fused features with the input image to obtain an output image O. Optionally, when fusing the feature maps, the input image may also be fused to fuse the details (such as low-frequency features such as color or brightness) included in the input image with the features of each channel to obtain a fused image with richer details.
[0191] In the implementation manner of the present application, feature reconstruction can be performed based on bilateral grid data under the guidance of the guidance map of each channel, so as to reconstruct more accurate and clear features for each channel of the input image, and further fuse them with the input image, so as to smooth the noise in the input image, make the input image clearer, and achieve the effect of dehazing or improving contrast.
[0192] Furthermore, each step is described in more detail below.
[0193] 1. Bilateral Mesh Generation
[0194] Among them, the full-resolution input image I is downsampled to obtain a low-resolution image That is, downsampling the image. There are many ways to downsample, such as bilinear interpolation, trilinear interpolation, or bicubic interpolation. Then, from the low-resolution image The bilateral grid data can be obtained by extracting features from the image to obtain downsampled features, and allocating the downsampled features to the corresponding space. The space can be pre-set or obtained according to the size of the input image, such as reducing the size of the input image to obtain a two-dimensional space.
[0195] For example, to generate bilateral grid data, see Fig. 9 , and get a low-resolution image Afterwards, the low-resolution image As the input of multi-layer convolution, the extracted features can be used to represent low-resolution images The brightness of the image is then pooled by average pooling to obtain downsampled features. A two-dimensional space can be pre-set, which is the same as the input image or low-resolution image. The pixels of the input image have a mapping relationship, such as one or more pixels in the input image correspond to a point in the two-dimensional space. Then the downsampled features are mapped to each pixel in the two-dimensional space to obtain bilateral grid data. That is, the grid data includes at least three-dimensional data, including the two-dimensional space, and information related to the brightness of the input image, etc. The information related to the brightness of the input image can be represented by the downsampled features.
[0196] 2. Guided graph generation
[0197] The input image I may include information of multiple channels, such as an RGB image including information of three channels. Information may be extracted from each channel of the input image I to obtain a feature map corresponding to each channel, and the feature map corresponding to each channel may be used as a guide map to guide subsequent upsampling of the bilateral grid data.
[0198] For example, the method of generating the guide map can be referred to Fig.10 , the input image I has three channels, such as Fig.10 Channel 1, channel 2 and channel 3 shown in , such as RGB channel can be divided into three channels: R, G, and B. Then, feature extraction is performed on each channel to obtain the feature map corresponding to each channel, such as Fig.10 The feature maps G1, G2 and G3 shown in .
[0199] For example, Fig.11 As shown, feature extraction can be achieved through multi-layer convolution, such as Fig.11 As shown in , one or more convolutional layers and one or more parametric rectified linear unit (PReLU) layers can be used as a feature extraction network, each channel of the input image is used as the input of the feature extraction network, and the feature map of each channel, i.e., feature maps G1, G2, and G3, is output.
[0200] Therefore, in the implementation manner of the present application, feature extraction is performed on each channel respectively to obtain multiple guide maps, which can extract more details in the input image and reduce detail loss.
[0201] 3. Feature Reconstruction
[0202] For example, the feature reconstruction of one channel can be performed as follows: Fig.12 As shown, after obtaining the guide map and the bilateral grid data, under the guidance of the guide map, the bilateral grid data is upsampled, and the upsampling method includes but is not limited to bilinear interpolation, bicubic interpolation or trilinear interpolation to obtain the upsampled feature U, and then the upsampled feature U is feature compressed to obtain the compressed feature C, and then the feature reconstruction is performed based on the input image I and the compressed feature C, such as performing item-by-item product of the input image I and the compressed feature C to obtain the feature map F corresponding to the current channel. For example, the resolution of the input image I can be 100*100, and the resolution of the compressed feature C can also be 100*100. The pixels of the input image I and the pixels of the compressed feature C correspond one to one. The value of each pixel in the input image I can be multiplied by the value of the corresponding pixel in the compressed feature C to obtain the feature map F. Of course, in addition to item-by-item product, feature reconstruction can also be achieved by weighted fusion or splicing. This application exemplarily takes multiplication as an example for illustrative introduction, and is not limited thereto. The specific feature reconstruction method can be adjusted according to the actual application scenario.
[0203] For example, Fig.13 As shown in the figure, the feature maps G1, G2 and G3 are used as guide maps to guide the upsampling of the bilateral grid g to obtain the upsampled feature U, and then the number of channels of the upsampled feature U is reduced by convolution to obtain the compressed feature C. Then the compressed feature C is multiplied by the input image I to obtain the feature map F.
[0204] Therefore, in the implementation manner of the present application, feature reconstruction can be performed by multiplying the compressed features and the input image, which is beneficial to the training convergence of the model and has a small amount of calculation, which is conducive to achieving lightweight image enhancement.
[0205] 4. Image Reconstruction
[0206] In which, taking the input image having three channels as an example, after the feature reconstruction is performed as described above, feature maps F1, F2 and F3 can be obtained, and the feature maps F1, F2 and F3 can be spliced together to obtain a spliced image. Then, at least one feature is extracted from the spliced image by at least one iteration, and the at least one feature is spliced together and fused with the input image to obtain the final output image.
[0207] For example, the image reconstruction method can be as follows: Fig.14 As shown, first, the feature maps F1, F2 and F3 are spliced together to obtain a spliced image C1. Optionally, when splicing the feature maps F1, F2 and F3, the input image can also be spliced in at the same time to make the information included in the spliced image richer and avoid loss of details. Perform at least one iterative feature extraction on C1, and record the features obtained by each feature extraction. Each feature extraction can be achieved by a basic unit (block) formed by one or more convolution stacks, and each block can output a feature map. Splice at least one extracted feature to obtain a spliced feature C2, and then fuse the spliced feature C2 through a block to obtain a fused feature M. Fuse the fused feature M with the input image to obtain a full-resolution enhanced output image O. The method of fusing the feature M and the input image can be weighted fusion or item-by-item product, which can be adjusted according to the actual application scenario.
[0208] Therefore, in the embodiment of the present application, the feature map of each channel can be spliced to restore each channel of the image. When splicing, the input image can be spliced to supplement the details in the feature map, so that the spliced image has richer details. Moreover, by fusing the feature M and the input image by multiplication, the input image can be defogged to obtain an enhanced image.
[0209] The above-mentioned process of the image processing method provided by the present application is described in detail. The following is a supplementary description of the neural network for executing the image processing method provided by the present application and the training method of the neural network. The neural network can be used to execute the above-mentioned Figure 7-14 The corresponding method steps.
[0210] For example, see Fig.15 , a schematic diagram of the structure of a neural network provided in this application.
[0211] With the aforementioned Figure 8 Correspondingly, it can be divided into multiple modules, such as Fig.15 The bilateral mesh generation network, guided map generation network, feature reconstruction network and image reconstruction network shown in .
[0212] Among them, the bilateral mesh generation network can be used to downsample the full-resolution input image I to obtain a low-resolution image Then based on the downsampled image Generate bilateral grid data, which includes spatial dimension and brightness-related information to form at least three-dimensional data.
[0213] The guide map generation network is used to extract features based on each channel of the full-resolution input image I to obtain the guide map corresponding to each channel, such as Figure 8 The guide graphs G1 / G2 / G3 shown in FIG.
[0214] The feature reconstruction network is used to upsample the bilateral grid for each channel under the guidance of the corresponding guidance map to obtain the feature map F1 / F2 / G3 corresponding to each channel.
[0215] The image reconstruction network is used to fuse the feature maps corresponding to each channel, and fuse the fused features with the input image to obtain an output image O. Optionally, when fusing the feature maps, the input image may also be fused to fuse the details included in the input image with the features of each channel to obtain a fused image with richer details.
[0216] Based on the structure of the neural network, the training method of the neural network is introduced below.
[0217] See also Fig.16 , a flowchart of a neural network training method provided in this application is as follows.
[0218] 1601. Obtain a training set.
[0219] The training set includes multiple image samples and a label corresponding to each image sample, and each image sample includes information of multiple channels.
[0220] Specifically, there are many ways to obtain the training set. For example, if the present application is Figure 2 If the training set is executed by the training device 120 shown in the figure, the training set can be information extracted from the database 130, or data sent by the client device 140.
[0221] For example, the training set may include multiple sample pairs, each of which has an image sample and a corresponding true value image (i.e., label), and the clarity of the true value image is higher than that of the image sample. For example, after a clear multi-channel image is captured, the image is used as the true value image, and the true value image is blurred, such as by adding fog or reducing contrast, to obtain an image sample, which is used as a sample pair with the true value image.
[0222] 1602. Perform at least one iterative training on the neural network using the training set to obtain a trained neural network.
[0223] The image samples in the training set can be used as the input of the neural network to train the neural network at least once to obtain a trained neural network. The trained neural network can be used for image enhancement, such as implementing the aforementioned Figure 7-14The steps of the corresponding method.
[0224] The training process is illustrated below by taking one iteration process as an example, as shown in steps 16021 to 16026.
[0225] 16021. Extract features from information of multiple channels of the input image respectively to obtain multiple guidance maps.
[0226] In an iterative training process, one or more image samples in the training set may be used as input to the neural network. This application exemplarily introduces an input image as an example.
[0227] 16022. Get the bilateral grid data corresponding to the input image.
[0228] 16023. Use each of the multiple guide maps as a guiding condition to upsample the bilateral grid data to obtain multiple feature maps.
[0229] 16024. Fuse multiple feature maps to obtain an output image.
[0230] Among them, steps 16021 to 16023 are similar to the processes of the aforementioned steps 701 to 705 and will not be repeated here.
[0231] 16025. Update the neural network according to the output image and the corresponding true value image to obtain the neural network after the current update.
[0232] Among them, there are many loss functions that can be used, such as mean square error, cross entropy, logarithm, exponential loss functions, etc. It is equivalent to using a function to calculate the offset between the output image and the true value image.
[0233] After calculating the loss value, the gradient of the parameters of the neural network can be calculated based on the loss value. The gradient can be used to represent the derivative when updating the parameters of the neural network, so that the parameters of the neural network can be updated according to the gradient to obtain the updated neural network.
[0234] 16026. Determine whether the convergence condition is met. If so, execute step 1603; if not, execute step 16021.
[0235] After obtaining the updated neural network, it can be determined whether the convergence condition is met. If the convergence condition is met, the updated neural network can be output, that is, the training of the neural network is completed. If the convergence condition is not met, the neural network can continue to be trained, that is, step 16021 is repeated until the convergence condition is met.
[0236] Among them, the convergence condition may include one or more of the following: the number of training times for the neural network reaches a preset number, or the output accuracy of the neural network is higher than a preset accuracy value, or the average accuracy of the neural network is higher than a preset average value, or the training time of the neural network exceeds a preset time, etc.
[0237] In the implementation manner of the present application, when fusing the upsampled image and the input image, the upsampled image can be compressed to obtain compressed features, and then the compressed features and the input image are multiplied item by item. By means of the product, the information in the input image can be quickly fed back to the feature map, thereby accelerating the convergence speed of the neural network and efficiently obtaining a trained neural network.
[0238] 1603. Output the updated neural network.
[0239] Among them, after the convergence conditions are met, the trained neural network can be output. The neural network can be deployed in a terminal or server, such as in a mobile phone, camera, smart car or monitoring equipment, etc., such as in scenarios such as mobile phone photography, camera photography, automatic driving or smart cities, to enhance the collected images and improve the image clarity. In particular, in scenarios with high requirements for real-time performance and computing overhead, image enhancement can be achieved through the lightweight model provided in this application.
[0240] Therefore, through the method provided in the present application, a converged neural network can be efficiently obtained and applied in various lightweight scenarios, especially in some weak computing devices. It can be deployed on the computing nodes of related devices to enhance the images degraded by fog to obtain clear results with normal colors, or to improve the contrast of the image to achieve image enhancement effects.
[0241] To further facilitate understanding of the image enhancement effect of the method provided in the present application, the image enhancement effect achieved by the method provided in the present application is introduced below in combination with some commonly used methods.
[0242] First of all, some commonly used image enhancement methods can include: a fast single image haze removal algorithm using color attenuationprior (CAP), non-local image dehazing (NLD), single image haze removal using dark channel prior (DCP), efficient image dehazing with boundary constraint and contextual regularization (BCCR), an end-to-end system for single image haze removal (DehazeNet), all-in-one dehazing network (AOD), single image dehazing via multiscale convolutional neural networks (MSCNN), robust haze removal based on patch map for single image dehazing (Robust haze removal based on patch map for single image dehazing). The image dehazing method based on the multi-scale network of the attention mechanism (PMS), the image dehazing method based on the multi-scale network of the attention mechanism (Griddehaze), the image dehazing method based on the domain adaptation (DA), and the multi-scale boosted dehazing network with dense feature fusion (MSBDN). For example, the running time and peak signal-to-noise ratio (PSNR) achieved by the above-mentioned image enhancement method and the image processing method provided in the present application can be as follows: Fig.17As shown, it is obvious that the image processing method provided by the present application can obtain images with higher PSNR on the basis of lower running time, can realize lightweight images with better dehazing effect, and can realize the ability to process 4K images in real time.
[0243] In more detail, the following Table 1 compares the output results of the above-mentioned commonly used dehazing methods and the image processing method provided by this application on the O-HAZE dataset, where the comparison is made using PSNR and structural similarity index measure (SSIM).
[0244]
[0245] Table 1
[0246] Obviously, the image processing method provided by the present application can consume less computational effort and obtain an image with better dehazing effect on the basis of achieving high PSNR and high SSIM.
[0247] More intuitively, the image enhancement effects of the present application and some common methods can be compared as follows: Fig.18A , Fig.18B and Fig.18C As shown, it is obvious that the image dehazing effect achieved by the image processing method provided by the present application is better, and the PSNR and SSIM achieved are also better, which greatly improves the clarity of the image and improves the user experience.
[0248] The above has introduced in detail the process and neural network of the method provided by the present application. The structure of the device provided by the present application for executing the above method steps is introduced below.
[0249] See also Fig.19 , a schematic diagram of the structure of an image processing device provided in the present application.
[0250] The image processing device may include:
[0251] The transceiver module 1901 is used to obtain an input image, where the input image includes information of multiple channels;
[0252] A feature extraction module 1902 is used to extract features from information of multiple channels of the input image to obtain multiple guide maps;
[0253] The bilateral generation module 1903 is used to obtain bilateral grid data corresponding to the input image, where the bilateral grid data includes data formed by information of a brightness dimension arranged in a spatial dimension, where the information of the brightness dimension is obtained according to features extracted from the input image, where the resolution of the bilateral grid data is lower than the resolution of the input image, and where the spatial dimension is a preset space or a space determined according to the input image;
[0254] A guiding module 1904 is used to upsample the bilateral grid data using each of the multiple guiding maps as a guiding condition to obtain multiple feature maps;
[0255] The fusion module 1905 is used to fuse multiple feature maps to obtain an output image.
[0256] In one possible implementation, the guiding module 1904 can be specifically used to: use the first guiding map as a guiding condition to upsample the bilateral grid data to obtain upsampled features, where the first guiding map is any one of multiple guiding maps; fuse the upsampled features and the input image to obtain a first feature map, where the first feature map is included in multiple feature maps.
[0257] In a possible implementation, the guiding module 1904 can be specifically used to: compress the upsampled features to obtain compressed features, where the number of channels of the compressed features is less than the number of channels of the upsampled features; and perform item-by-item product of the compressed features and the input image to obtain a first feature map.
[0258] In a possible implementation, the bilateral generation module 1902 may be specifically used to: downsample the input image to obtain a downsampled image; extract features from the downsampled image to obtain downsampled features, and the bilateral grid data includes the downsampled features.
[0259] In a possible implementation, the fusion module 1905 can be specifically used to: stitch multiple feature maps to obtain a stitched image; perform at least one feature extraction on the stitched image to obtain at least one first feature; and fuse the at least one first feature with the input image to obtain an output image.
[0260] In a possible implementation, the fusion module 1905 may be specifically used to splice multiple feature maps and an input image to obtain a spliced image.
[0261] See also Fig. 20 , a structural schematic diagram of a neural network training provided in this application is described as follows.
[0262] The training device may include:
[0263] An acquisition module 2001 is used to acquire a training set, wherein the training set includes a plurality of image samples and a true value image corresponding to each image sample, and each image sample includes information of a plurality of channels;
[0264] A training module 2002 is used to perform at least one iterative training on the neural network using the training set to obtain a trained neural network;
[0265] In which, during any iterative training process, the neural network extracts features from the information of multiple channels of the input image to obtain multiple guidance maps, obtains bilateral grid data corresponding to the input image, takes each of the multiple guidance maps as a guidance condition, upsamples the bilateral grid data to obtain multiple feature maps, fuses the multiple feature maps to obtain an output image, updates the neural network according to the output image and the true image corresponding to the input image, and obtains the neural network after the current update. The bilateral grid data includes data formed by information of brightness dimension arranged in a preset space, the information of brightness dimension is obtained according to the features extracted from the input image, and the resolution of the bilateral grid data is lower than the resolution of the input image.
[0266] In one possible implementation, the training module 2002 can be specifically used to: use the first guiding map as a guiding condition to upsample the bilateral grid data to obtain upsampled features, where the first guiding map is any one of multiple guiding maps; fuse the upsampled features and the input image to obtain a first feature map, where the first feature map is included in multiple feature maps.
[0267] In a possible implementation, the training module 2002 can be specifically used to: compress the upsampled features to obtain compressed features, where the number of channels of the compressed features is less than the number of channels of the upsampled features; and perform item-by-item product of the compressed features and the input image to obtain a first feature map.
[0268] In a possible implementation, the training module 2002 may be specifically used to: downsample the input image to obtain a downsampled image; extract features from the downsampled image to obtain downsampled features, and the bilateral grid data includes the downsampled features.
[0269] In a possible implementation, the training module 2002 may be specifically used to: stitch multiple feature maps to obtain a stitched image; perform at least one feature extraction on the stitched image to obtain at least one first feature; and fuse the at least one first feature with the input image to obtain an output image.
[0270] In a possible implementation, the training module 2002 may be specifically used to splice multiple feature maps and an input image to obtain a spliced image.
[0271] See also Fig.21 , a structural schematic diagram of another image processing device provided by the present application is described as follows.
[0272] The training device may include a processor 2101 and a memory 2102. The processor 2101 and the memory 2102 are interconnected via a line. The memory 2102 stores program instructions and data.
[0273] The memory 2102 stores the aforementioned Figure 7-Figure 14 The program instructions and data corresponding to the steps in .
[0274] Processor 2101 is used to execute the above Figure 7-Figure 14 The method steps are performed by the image processing device shown in any one of the embodiments.
[0275] Optionally, the image processing apparatus may further include a transceiver 2103 for receiving or sending data.
[0276] The present application also provides a computer-readable storage medium in which a program is stored. When the program is run on a computer, the computer executes the above-mentioned Figure 7-Figure 14 The illustrated embodiments describe steps in a method.
[0277] Optionally, the aforementioned Fig.21 The image processing device shown in is a chip.
[0278] See also Fig. 22 , a structural schematic diagram of another training device provided in the present application is described as follows.
[0279] The training device may include a processor 2201 and a memory 2202. The processor 2201 and the memory 2202 are interconnected via a line. The memory 2202 stores program instructions and data.
[0280] The memory 2202 stores the aforementioned Figure 15-16 The program instructions and data corresponding to the steps in .
[0281] Processor 2201 is used to execute the above Figure 15-16 The method steps are performed by the training device shown in any embodiment.
[0282] Optionally, the training device may further include a transceiver 2203 for receiving or sending data.
[0283] The present application also provides a computer-readable storage medium in which a program is stored. When the program is run on a computer, the computer executes the above-mentioned Figure 15-16 The illustrated embodiments describe steps in a method.
[0284] Optionally, the aforementioned Fig. 22 The training device shown in is a chip.
[0285] The present application also provides an image processing device, which can also be called a digital processing chip or chip. The chip includes a processing unit and a communication interface. The processing unit obtains program instructions through the communication interface. The program instructions are executed by the processing unit. The processing unit is used to execute the aforementioned Figure 7-Figure 14 The method steps shown in any one of the embodiments.
[0286] The embodiment of the present application also provides a training device, which can also be called a digital processing chip or chip. The chip includes a processing unit and a communication interface. The processing unit obtains program instructions through the communication interface. The program instructions are executed by the processing unit. The processing unit is used to execute the aforementioned Figure 15-16 The steps of the method shown in any embodiment.
[0287] The embodiment of the present application also provides a digital processing chip. The digital processing chip integrates a circuit and one or more interfaces for implementing the functions of the above-mentioned processor 2101, processor 2201, or processor 2101, processor 2201. When a memory is integrated in the digital processing chip, the digital processing chip can complete the method steps of any one or more of the above-mentioned embodiments. When the digital processing chip does not integrate a memory, it can be connected to an external memory through a communication interface. The digital processing chip implements the method steps in the above-mentioned embodiment according to the program code stored in the external memory.
[0288] The present application also provides a computer program product which, when executed on a computer, enables the computer to execute the above Figure 7-Figure 14 Any embodiment or Figure 15-16 The steps in the method described in any embodiment.
[0289] The image processing device or training device provided in the embodiment of the present application may be a chip, and the chip includes: a processing unit and a communication unit, the processing unit may be, for example, a processor, and the communication unit may be, for example, an input / output interface, a pin or a circuit. The processing unit may execute the computer execution instructions stored in the storage unit to enable the chip in the server to execute the above Figure 7-Figure 14 The deep learning training method for a computing device described in the illustrated embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit may also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0290] Specifically, the aforementioned processing unit or processor may be a central processing unit (CPU), a neural-network processing unit (NPU), a graphics processing unit (GPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC) or a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0291] For example, see Fig.23 , Fig.23 A schematic diagram of the structure of a chip provided in an embodiment of the present application, the chip can be expressed as a neural network processor NPU 230, NPU 230 is mounted on the host CPU (Host CPU) as a coprocessor, and the host CPU assigns tasks. The core part of the NPU is the operation circuit 2303, which is controlled by the controller 2304 to extract matrix data from the memory and perform multiplication operations.
[0292] In some implementations, the operation circuit 2303 includes multiple processing units (process engines, PEs) inside. In some implementations, the operation circuit 2303 is a two-dimensional systolic array. The operation circuit 2303 can also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the operation circuit 2303 is a general-purpose matrix processor.
[0293] For example, assume there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit takes the corresponding data of matrix B from the weight memory 2302 and caches it on each PE in the operation circuit. The operation circuit takes the matrix A data from the input memory 2301 and performs matrix operation with matrix B, and the partial result or final result of the matrix is stored in the accumulator 2308.
[0294] The unified memory 2306 is used to store input data and output data. The weight data is directly transferred to the weight memory 2302 through the direct memory access controller (DMAC) 2305. The input data is also transferred to the unified memory 2306 through the DMAC.
[0295] The bus interface unit (BIU) 2310 is used for the interaction between the AXI bus and the DMAC and instruction fetch buffer (IFB) 2309 .
[0296] The bus interface unit 2310 (BIU) is used for the instruction fetch memory 2309 to obtain instructions from the external memory, and is also used for the storage unit access controller 2305 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
[0297] DMAC is mainly used to transfer input data in the external memory DDR to the unified memory 2306 or to transfer weight data to the weight memory 2302 or to transfer input data to the input memory 2301.
[0298] The vector calculation unit 2307 includes multiple operation processing units, and further processes the output of the operation circuit when necessary, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional / fully connected layer network calculations in neural networks, such as batch normalization, pixel-level summation, upsampling of feature planes, etc.
[0299] In some implementations, the vector calculation unit 2307 can store the processed output vector to the unified memory 2306. For example, the vector calculation unit 2307 can apply a linear function and / or a nonlinear function to the output of the operation circuit 2303, such as linear interpolation of the feature plane extracted by the convolution layer, and then, for example, a vector of accumulated values to generate an activation value. In some implementations, the vector calculation unit 2307 generates a normalized value, a pixel-level summed value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 2303, for example, for use in a subsequent layer in a neural network.
[0300] An instruction fetch buffer 2309 connected to the controller 2304 is used to store instructions used by the controller 2304;
[0301] Unified memory 2306, input memory 2301, weight memory 2302 and instruction fetch memory 2309 are all On-Chip memories. External memories are private to the NPU hardware architecture.
[0302] Among them, the operations of each layer in the recurrent neural network can be performed by the operation circuit 2303 or the vector calculation unit 2307.
[0303] The processor mentioned in any of the above can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more processors for controlling the above Figure 7-Figure 14 Any embodiment or Figure 15-16 An integrated circuit is implemented by a program of the method of any one of the embodiments.
[0304] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.
[0305] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0306] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0307] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive (SSD)), etc.
[0308] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0309] Finally, it should be noted that the above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for image processing, characterized in that: include: Acquire an input image, wherein the input image includes information of multiple channels; Extracting features from information of multiple channels of the input image respectively to obtain multiple guide maps, wherein the multiple guide maps correspond to the multiple channels one by one; Acquire bilateral grid data corresponding to the input image, the bilateral grid data including data formed by information of a brightness dimension arranged in a spatial dimension, the information of the brightness dimension being obtained according to features extracted from the input image, a resolution of the bilateral grid data being lower than a resolution of the input image, and the spatial dimension being a preset space or a space determined according to the input image; Using each of the multiple guide maps as a guide condition, upsampling the bilateral grid data to obtain multiple feature maps; The multiple feature maps are fused to obtain an output image.
2. The method according to claim 1, characterized in that The upsampling of the bilateral grid data by taking each of the plurality of guide maps as a guide condition comprises: Upsampling the bilateral grid data using a first guiding map as a guiding condition to obtain an upsampled feature, wherein the first guiding map is any one of the multiple guiding maps; The upsampled features and the input image are fused to obtain a first feature map, where the first feature map is included in the multiple feature maps.
3. The method according to claim 2, characterized in that The fusing the upsampled features and the input image to obtain a first feature map includes: Compressing the upsampled features to obtain compressed features, wherein the number of channels of the compressed features is less than the number of channels of the upsampled features; An element-wise product is performed on the compressed feature and the input image to obtain the first feature map.
4. The method according to any one of claims 1 to 3, characterized in that The obtaining of bilateral grid data corresponding to the input image comprises: Downsampling the input image to obtain a downsampled image; Extract features from the downsampled image to obtain downsampled features; The bilateral grid data is determined according to the down-sampling feature.
5. The method according to any one of claims 1 to 4, characterized in that The fusing the multiple feature maps to obtain the output image includes: Splicing the multiple feature maps to obtain a spliced image; Performing at least one feature extraction on the stitched image to obtain at least one first feature; The at least one first feature and the input image are fused to obtain the output image.
6. The method according to claim 5, characterized in that The step of splicing the plurality of feature maps to obtain a spliced image includes: The multiple feature maps and the input image are spliced to obtain the spliced image.
7. A neural network training method, characterized in that: include: Acquire a training set, wherein the training set includes a plurality of image samples and a true value image corresponding to each image sample, wherein each image sample includes information of a plurality of channels; Perform at least one iterative training on the neural network using the training set to obtain a trained neural network; In which, during any iterative training process, the neural network extracts features from the information of multiple channels of the input image respectively to obtain multiple guidance maps, the multiple guidance maps correspond to the multiple channels one by one, and the bilateral grid data corresponding to the input image is obtained, each of the multiple guidance maps is used as a guidance condition, the bilateral grid data is upsampled to obtain multiple feature maps, the multiple feature maps are fused to obtain an output image, and the neural network is updated according to the output image and the true value image corresponding to the input image to obtain the neural network after the current update, the bilateral grid data includes data formed by information of brightness dimension arranged in a preset space, the information of brightness dimension is obtained according to the features extracted from the input image, and the resolution of the bilateral grid data is lower than the resolution of the input image.
8. The method according to claim 7, characterized in that The upsampling of the bilateral grid data by taking each of the plurality of guide maps as a guide condition comprises: Upsampling the bilateral grid data using a first guiding map as a guiding condition to obtain an upsampled feature, wherein the first guiding map is any one of the multiple guiding maps; The upsampled features and the input image are fused to obtain a first feature map, where the first feature map is included in the multiple feature maps.
9. An image processing device, characterized in that: include: A transceiver module, used to obtain an input image, wherein the input image includes information of multiple channels; A feature extraction module, used to extract features from information of multiple channels of the input image respectively to obtain multiple guide maps, wherein the multiple guide maps correspond to the multiple channels one by one; a bilateral generation module, configured to obtain bilateral grid data corresponding to the input image, the bilateral grid data comprising data formed by information of a brightness dimension arranged in a spatial dimension, the information of the brightness dimension being obtained according to features extracted from the input image, the resolution of the bilateral grid data being lower than the resolution of the input image, and the spatial dimension being a preset space or a space determined according to the input image; A guiding module, configured to upsample the bilateral grid data using each of the plurality of guiding maps as a guiding condition to obtain a plurality of feature maps; The fusion module is used to fuse the multiple feature maps to obtain an output image.
10. The device according to claim 9, characterized in that The guiding module is specifically used for: Upsampling the bilateral grid data using a first guiding map as a guiding condition to obtain an upsampled feature, wherein the first guiding map is any one of the multiple guiding maps; The upsampled features and the input image are fused to obtain a first feature map, where the first feature map is included in the multiple feature maps.
11. The device according to claim 10, characterized in that The guiding module is specifically used for: Compressing the upsampled features to obtain compressed features, wherein the number of channels of the compressed features is less than the number of channels of the upsampled features; The compressed features and the input image are multiplied term by term to obtain the first feature map.
12. The device according to any one of claims 9 to 11, characterized in that The bilateral generation module is specifically used for: Downsampling the input image to obtain a downsampled image; Extract features from the downsampled image to obtain downsampled features; The bilateral grid data is determined according to the down-sampling feature.
13. The device according to any one of claims 9 to 12, characterized in that The fusion module is specifically used for: Splicing the multiple feature maps to obtain a spliced image; Performing at least one feature extraction on the stitched image to obtain at least one first feature; The at least one first feature and the input image are fused to obtain the output image.
14. The device according to claim 13, characterized in that The fusion module is specifically used to splice the multiple feature maps and the input image to obtain the spliced image.
15. A training device, characterized in that: include: An acquisition module, used to acquire a training set, wherein the training set includes a plurality of image samples and a true value image corresponding to each image sample, wherein each image sample includes information of a plurality of channels; A training module, used to perform at least one iterative training on the neural network using the training set to obtain a trained neural network; In which, during any iterative training process, the neural network extracts features from the information of multiple channels of the input image respectively to obtain multiple guidance maps, the multiple guidance maps correspond to the multiple channels one by one, and the bilateral grid data corresponding to the input image is obtained, each of the multiple guidance maps is used as a guidance condition, the bilateral grid data is upsampled to obtain multiple feature maps, the multiple feature maps are fused to obtain an output image, and the neural network is updated according to the output image and the true value image corresponding to the input image to obtain the neural network after the current update, the bilateral grid data includes data formed by information of brightness dimension arranged in a preset space, the information of brightness dimension is obtained according to the features extracted from the input image, and the resolution of the bilateral grid data is lower than the resolution of the input image.
16. The device according to claim 15, characterized in that The training module is specifically used for: Upsampling the bilateral grid data using a first guiding map as a guiding condition to obtain an upsampled feature, wherein the first guiding map is any one of the multiple guiding maps; The upsampled features and the input image are fused to obtain a first feature map, where the first feature map is included in the multiple feature maps.
17. An image processing device, characterized in that: The method comprises a processor, wherein the processor is coupled to a memory, wherein the memory stores a program, and when the program instructions stored in the memory are executed by the processor, the method according to any one of claims 1 to 6 is implemented.
18. A training device, characterized in that: The method comprises a processor, the processor is coupled to a memory, the memory stores a program, and when the program instructions stored in the memory are executed by the processor, the method according to claim 7 or 8 is implemented.
19. A computer-readable storage medium comprising a program, which, when executed by a processing unit, performs the method according to any one of claims 1 to 8.
20. A computer program product, characterized in that The computer program product comprises software code for executing the method according to any one of claims 1 to 8.
