Image processing model training method, device, image processing method and model

Through collaborative training of image processing models and optimization of loss functions, the problem of insufficient accuracy in edge areas in image segmentation is solved, and efficient and accurate image segmentation is achieved.

CN112258436BActive Publication Date: 2024-09-13HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011132152.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-21
Publication Date
2024-09-13
Estimated Expiration
2040-10-21

AI Technical Summary

Technical Problem

Existing technologies are insufficient in accuracy in image segmentation, especially in target edge areas, which results in increased recognition accuracy and computational complexity in subsequent tasks, and traditional methods are complex and slow.

Method used

An image processing model training method is used to generate feature maps through the first module. The second module and the third module are trained collaboratively. The reverse feature extraction layer and affinity map are used to transfer more contextual information, combining image-level and feature-level The loss function is trained to improve the accuracy of edge segmentation.

Benefits of technology

Without increasing the amount of calculation, it significantly improves the accuracy of image segmentation, especially the segmentation accuracy of edge areas, simplifies the model training process, and reduces development costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112258436B
    Figure CN112258436B
Patent Text Reader

Abstract

The present application provides a training method for an image processing model, the image processing model includes a first module, a second module and / or a third module, the method includes: inputting a first image and a second image into the first module to generate a first feature map; the first image includes a target object image; the second module generates a second feature map according to the first feature map, and generates a mask image according to the second feature map; the mask image corresponds to the target object image; the third module generates a third image according to the first feature map and the second feature map; the third image is a predicted composite image including the target object image and the second image; the image processing model is trained according to the loss function for generating the third image and the loss function for generating the mask image. A training device for the image processing model, an image processing method and model, a computing device and a storage medium are also provided accordingly. The present application can improve the segmentation accuracy of edges in image segmentation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of neural network technology, and in particular to a training method and device for an image processing model, an image processing method and model, a computing device and a storage medium. Background Art

[0002] Image segmentation is a basic and important research in the field of computer vision. Image segmentation is also the basis of video segmentation. By treating the video frame as a single image, the problem can be transformed into image segmentation. It requires the model to divide the image into several non-overlapping areas based on grayscale, color, spatial texture, geometric shape and other features, that is, to separate the target from the background. Image segmentation has a wide range of applications in image processing, video processing, computer vision, etc. For example, medical imaging, face recognition, fingerprint recognition, autonomous driving, etc., all require the target to be segmented first, and then the target is classified, recognized, etc.; for example, when the background replacement is applied to the target in the image or video (the target can be a human body, a building, the sky, a river, etc.), it is also based on the target to be segmented first, and then the target is merged with other backgrounds.

[0003] Compared with the traditional image segmentation method based on digital image processing, the image segmentation method based on deep neural network realizes semantic-based image segmentation, which greatly improves the performance of image segmentation. For example, the feature map (i.e., semantic features) of the image is extracted through the convolutional neural network, and then the pixel-level segmentation and category (such as foreground or background binary classification) of the image is used as the supervision signal to train the model end-to-end. Typical neural network models include FCN, U-net, Mask-RCNN, etc. FCN proposes a fully convolutional network and deconvolution layer. It replaces the fully connected network in the traditional convolutional network with a convolutional network, so that the network can accept pictures of any size, and use deconvolution to output a segmentation map of the same size as the original image from the feature map. U-net is a typical encoding module-decoding module structure. The semantic information of the entire image is extracted through the encoding module, and then the shallow high-resolution information is integrated for segmentation. Mask-RCNN solves both target detection and image segmentation tasks.

[0004] The accuracy of image segmentation, especially the accuracy of the target edge area, such as the accuracy of the edge area segmentation of the mask image generated based on semantic segmentation, is a key technology for image segmentation. The accuracy of image segmentation will also affect the effect of subsequent tasks. If the segmented image is inaccurate and there is too much edge noise, the recognition accuracy of this part of the image in subsequent tasks will be problematic, or it will cause problems such as low authenticity when fused with other background images, or it will cause more computational complexity in the subsequent analysis of the image. Therefore, how to improve the accuracy of image segmentation is a technical issue that is currently being continuously improved. Summary of the invention

[0005] In view of the above problems in the prior art, the present application provides a training method and apparatus for an image processing model, an image processing method and model, a computing device and a storage medium, which can improve the accuracy of image segmentation.

[0006] To achieve the above-mentioned object, the first aspect of the present application provides a training method for an image processing model, the image processing model comprising a first module, a second module and / or a third module, the method comprising:

[0007] Inputting a first image and a second image into a first module to generate a first feature map; the first image includes a target object image;

[0008] The second module generates a second feature map according to the first feature map, and generates a mask image according to the second feature map; the mask image corresponds to the target object image;

[0009] A third module generates a third image according to the first feature map and the second feature map; the third image is a predicted composite image including the target object image and the second image;

[0010] The image processing model is trained according to the loss function for generating the third image and the loss function for generating the mask image.

[0011] Among them, the first module can be an encoding module for generating a feature map from an image, and the second and third modules can be different decoding modules for restoring an image from a feature map. From the above, since the image processing model is trained according to the loss function for generating the third image and the loss function for generating the mask image, and the training is performed in a back-propagation manner, the second module will transfer the second feature map features related to the generated mask image to the third module for learning. During the training, the third module reversely corrects the second module, that is, the second module and the third module are trained collaboratively, thereby improving the image segmentation accuracy of the second module, and correspondingly, also improving the accuracy of the image merging of the third module.

[0012] As a possible implementation manner of the first aspect, the second module and the third module respectively include at least one inverse feature extraction layer; the inverse feature extraction layer is used to restore the high-resolution feature map from the low-resolution feature map;

[0013] Generating different second feature maps by different reverse feature extraction layers of the second module;

[0014] Passing at least one second feature map to at least one reverse feature extraction layer corresponding to the third module;

[0015] The third module generates the third image based on the first feature map and the second feature map, and the third module generates the third image based on the first feature map and the second feature map respectively received and fused into the original input feature map of the layer by at least one reverse feature extraction layer.

[0016] From the above, through the transmission of multiple second feature maps, the feature maps of different levels of the second module can be transmitted to the third module for learning. Since the transmitted feature parameters are large and at different levels, the third module will be more accurate when reversely correcting the second module during training, thereby further improving the image segmentation accuracy of the second module.

[0017] As a possible implementation manner of the first aspect, generating, by the third module, a third image according to the first feature map and the second feature map includes:

[0018] Generate a corresponding affinity map according to the second feature map; the affinity map is used to represent the relationship between at least one pixel in the second feature map and at least one other pixel;

[0019] The third image is generated by a third module according to the first feature map and the affinity map.

[0020] As described above, more contextual information in the second feature map is passed to the third module for learning through the affinity graph. Since the passed parameters incorporate more contextual information, the third module will be more accurate when reversely correcting the second module during training, thereby further improving the image segmentation accuracy of the second module.

[0021] As a possible implementation manner of the first aspect, the second module and the third module respectively include at least one inverse feature extraction layer;

[0022] Generating different second feature maps by different reverse feature extraction layers of the second module;

[0023] Generate at least one corresponding affinity map according to at least one second feature map, and pass it to at least one reverse feature extraction layer corresponding to the third module;

[0024] The third module generates the third image according to the first feature map and the affinity map, and the third module generates the third image according to the first feature map and the affinity map respectively received and fused to the original input feature map of the layer by at least one reverse feature extraction layer.

[0025] From the above, more contextual information in the second feature map is further passed to the third module for learning through more affinity maps. Since the passed parameters incorporate further contextual information, the third module will be more accurate when reversely correcting the second module during training, thereby further improving the image segmentation accuracy of the second module.

[0026] As a possible implementation manner of the first aspect, generating a corresponding affinity graph according to the second feature graph includes:

[0027] After multiplying the second feature map and the transpose of the second feature map, the affinity map corresponding to the second feature is obtained by an activation function operation.

[0028] The above implementation process becomes simple and the development cost is low.

[0029] As a possible implementation manner of the first aspect, the fusion into the original input feature map of the layer includes one of the following:

[0030] Multiply the original input feature map of the layer, and then sum the result with the original input feature map of the layer, and the result is used as the fused input feature map;

[0031] Multiply the original input feature map of the layer, and use the result as the fused input feature map;

[0032] The result is taken as the fused input feature map after being aligned and summed with the original input feature map of the layer.

[0033] The above method can flexibly realize the fusion of feature maps, and one of them can be selected according to needs.

[0034] As a possible implementation manner of the first aspect, the training of the image processing model according to the loss function for generating the third image and the loss function for generating the mask image includes: using the following loss function in the training:

[0035] LOSS = loss function for generating the mask image + loss function for generating the third image

[0036] =seg loss+(image level loss+feature level loss);

[0037] Seg loss refers to the image segmentation network loss function;

[0038] Image level loss is the loss function for predicting composite images and GT composite images;

[0039] Feature level loss is the loss function for predicting synthetic image features and GT synthetic image features;

[0040] The predicted composite image refers to the third image; the GT composite image refers to a composite image obtained by using a known GT mask including the first image and the second image; and the GT mask refers to an artificially annotated mask image.

[0041] As mentioned above, both the image-level loss function and the feature-level loss function are used. During the model training process, both the semantic features (overall) and the image-level details are taken into account, which is conducive to improving the image segmentation accuracy of the second module.

[0042] As a possible implementation manner of the first aspect, the training of the image processing model according to the loss function for generating the third image and the loss function for generating the mask image includes: using the following loss function in the training:

[0043] LOSS = loss function for generating the mask image + loss function for generating the third image

[0044] =seg loss+(image level loss+feature level loss)*(1+w);

[0045] Seg loss refers to the image segmentation network loss function;

[0046] Image level loss is the loss function for predicting composite images and GT composite images;

[0047] Feature level loss is the loss function for predicting synthetic image features and GT synthetic image features;

[0048] The predicted composite image refers to the third image; the GT composite image refers to a composite image obtained by using a known GT mask including the first image and the second image; the GT mask refers to a mask image that is manually annotated;

[0049] w is a two-dimensional image of the same size as the GT mask, with a pixel value range of 0 to 1. It is an image of the edge area of ​​the corresponding target object obtained by dilating and corroding the GT mask.

[0050] From the above, through the introduction of w, the penalty for edge areas is increased, so that during model training, more loss values ​​in the error areas can be back-transmitted to correct these errors and further improve the accuracy of image segmentation. Since w is related to the mask image, the accuracy of edge area segmentation is especially improved.

[0051] As a possible implementation of the first aspect, the first image and the second image are from a data pair in a training data set; the data set includes multiple data pairs, and the multiple data pairs are multiple data pairs consisting of the same first image and multiple different second images.

[0052] From the above, the same foreground is matched with different backgrounds for synthesis. The error area will strengthen the penalty of the error place on the different background synthesis images, so that when the model is trained, more loss values ​​in the error area can be back-transmitted, thereby correcting these errors and improving the accuracy of image segmentation.

[0053] A second aspect of the present application provides a training device for an image processing model, the image processing model comprising a first module, a second module and / or a third module, the device comprising:

[0054] A first feature map generating unit, configured to input a first image and a second image into a first module to generate a first feature map; the first image includes a target object image;

[0055] a mask image generating unit, configured to generate a second feature map according to the first feature map by a second module, and generate a mask image according to the second feature map; the mask image corresponds to the target object image;

[0056] A third image generating unit, configured to generate a third image by a third module according to the first feature map and the second feature map; the third image is a predicted composite image including the target object image and the second image;

[0057] A training unit is used to train the image processing model according to a loss function for generating the third image and a loss function for generating the mask image.

[0058] As a possible implementation manner of the second aspect, the second module and the third module respectively include at least one inverse feature extraction layer; the inverse feature extraction layer is used to restore the high-resolution feature map from the low-resolution feature map;

[0059] The mask image generation unit generates different second feature maps by different reverse feature extraction layers of the second module;

[0060] Also included is a feature map transfer module, used to transfer at least one second feature map to at least one reverse feature extraction layer corresponding to the third module;

[0061] The third image generating unit generates a third image by a third module according to the first feature map and the second feature map respectively received by at least one reverse feature extraction layer and fused into the original input feature map of the layer.

[0062] As a possible implementation of the second aspect, the method further includes an affinity module, which is used to generate a corresponding affinity map according to the second feature map; the affinity map is used to represent the relationship between at least one pixel in the second feature map and at least one other pixel;

[0063] The third image generating unit generates the third image by a third module according to the first feature map and the affinity map.

[0064] As a possible implementation manner of the second aspect, the second module and the third module respectively include at least one inverse feature extraction layer;

[0065] Generating different second feature maps by different reverse feature extraction layers of the second module;

[0066] The affinity module is at least one, and is used to generate at least one corresponding affinity graph according to at least one second feature graph;

[0067] Also included is an affinity map transfer module, used to transfer the at least one affinity map to at least one reverse feature extraction layer corresponding to the third module;

[0068] The third image generating unit generates the third image by a third module according to the first feature map and the affinity map respectively received and fused to the original input feature map of the layer by at least one reverse feature extraction layer.

[0069] As a possible implementation manner of the second aspect, the affinity module is specifically used to obtain the affinity map by multiplying the second feature map and the transpose of the second feature map and performing an activation function operation.

[0070] As a possible implementation manner of the second aspect, the fusion of the third module into the original input feature map of the layer includes one of the following:

[0071] Multiply the original input feature map of the layer, and then sum the result with the original input feature map of the layer, and the result is used as the fused input feature map;

[0072] Multiply the original input feature map of the layer, and use the result as the fused input feature map;

[0073] The result is taken as the fused input feature map after being summed with the original input feature map of the layer.

[0074] As a possible implementation manner of the second aspect, the training unit specifically uses the following loss function to train the image processing model:

[0075] LOSS = loss function for generating the mask image + loss function for generating the third image

[0076] =seg loss+(image level loss+feature level loss);

[0077] Seg loss refers to the image segmentation network loss function;

[0078] Image level loss is the loss function for predicting composite images and GT composite images;

[0079] Feature level loss is the loss function for predicting synthetic image features and GT synthetic image features;

[0080] The predicted composite image refers to the third image; the GT composite image refers to a composite image obtained by using a known GT mask including the first image and the second image; and the GT mask refers to an artificially annotated mask image.

[0081] As a possible implementation manner of the second aspect, the training unit specifically uses the following loss function to train the image processing model:

[0082] LOSS = loss function for generating the mask image + loss function for generating the third image

[0083] =seg loss+(image level loss+feature level loss)*(1+w);

[0084] Seg loss refers to the image segmentation network loss function;

[0085] Image level loss is the loss function for predicting composite images and GT composite images;

[0086] Feature level loss is the loss function for predicting synthetic image features and GT synthetic image features;

[0087] The predicted composite image refers to the third image; the GT composite image refers to a composite image obtained by using a known GT mask including the first image and the second image; the GT mask refers to a mask image that is manually annotated;

[0088] w is a two-dimensional image of the same size as the GT mask, with a pixel value range of 0 to 1. It is an image of the edge area of ​​the corresponding target object obtained by dilating and corroding the GT mask.

[0089] As a possible implementation of the second aspect, a training data set is also included, including multiple data pairs consisting of a same first image and multiple different second images, wherein the first image and the second image are from a data pair of the data set.

[0090] The third aspect of the present application provides an image processing method, comprising:

[0091] Inputting a first image into a first module to generate a first feature map; the first image includes a target object image;

[0092] The second module generates a second feature map according to the first feature map, and generates a mask image according to the second feature map; the mask image corresponds to the target object image;

[0093] The first module and the second module are trained by any possible implementation method of the training method of the image processing model provided in the first aspect of the present application.

[0094] From the above, through the image processing method, it is possible to achieve relatively accurate image segmentation, that is, to achieve the accuracy of mask image generation, especially the accuracy at the edges.

[0095] A fourth aspect of the present application provides an image processing model, including:

[0096] A first module is used to receive a first image and generate a first feature map; the first image includes a target object image;

[0097] A second module is used to generate a second feature map according to the first feature map, and to generate a mask image according to the second feature map; the mask image corresponds to the target object image;

[0098] The first module and the second module are trained by any possible implementation method of the training method of the image processing model provided in the first aspect of the present application.

[0099] A fifth aspect of the present application provides an image processing method, comprising:

[0100] Inputting a first image and a second image into a first module to generate a first feature map; the first image includes a target object image;

[0101] Generating a second feature map according to the first feature map by a second module;

[0102] Generate a third image according to the first feature map and the second feature map; the third image is a predicted composite image including the target object image and the second image;

[0103] The first module, the second module and the third module are trained by any possible implementation method of the training method of the image processing model provided in the first aspect of the present application.

[0104] From the above, through the image processing method, it is possible to achieve more accurate extraction of the target object image when two images are synthesized, so that the synthesized image is more accurate.

[0105] As a possible implementation manner of the fifth aspect, the second module also generates a mask image according to the second feature map; the mask image corresponds to the target object image.

[0106] From the above, through the image processing method, it is also possible to achieve relatively accurate image segmentation, that is, the accuracy of mask image generation, especially the accuracy at the edges.

[0107] As a possible implementation manner of the fifth aspect, generating the third image according to the first feature map and the second feature map includes:

[0108] Generate an affinity map according to the second feature map; the affinity map is used to represent the relationship between at least one pixel in the feature map and at least one other pixel;

[0109] A third module generates a third image according to the first feature map and the affinity map.

[0110] From the above, due to the image processing model using the affinity graph structure, it is possible to achieve more accurate extraction of the target object image when two images are synthesized, so that the synthesized image is more accurate.

[0111] A sixth aspect of the present application provides an image processing model, including:

[0112] A first module is configured to receive a first image and a second image and generate a first feature map; the first image includes a target object image;

[0113] A second module, configured to generate a second feature map according to the first feature map;

[0114] A third module is used to generate a third image according to the first feature map and the second feature map; the third image is a predicted composite image including the target object image and the second image;

[0115] The first module, the second module and the third module are trained by any possible implementation method of the training method of the image processing model provided in the first aspect of the present application.

[0116] As a possible implementation manner of the sixth aspect, the second module is further used to generate a mask image according to the second feature map; the mask image corresponds to the target object image.

[0117] As a possible implementation of the sixth aspect, the following also includes:

[0118] An affinity module, used to generate a corresponding affinity map according to the second feature map; the affinity map is used to represent the relationship between at least one pixel in the feature map and at least one other pixel;

[0119] The third module generates the third image according to the first feature map and the affinity map.

[0120] A seventh aspect of the present application provides a computing device, including:

[0121] A bus; a communication interface connected to the bus; at least one processor connected to the bus; and at least one memory connected to the bus and storing program instructions, which, when executed by the at least one processor, enable the at least one processor to execute any of the methods described in the above-mentioned aspects.

[0122] In an eighth aspect, the present application provides a computer-readable storage medium having program instructions stored thereon, wherein when the program instructions are executed by a computer, the computer executes any of the methods described in the above-mentioned aspects.

[0123] In addition, compared with the prior art 1 in the specific implementation method, the solution of the present application has a small amount of calculation and a fast speed, and can be deployed in a very small network module on the user terminal side. Since the second and third modules are trained collaboratively during the training process, and the third module can obtain the feature map related to the mask image provided by the second module, especially when more context information is provided, Figure 5A and Figure 5B It can be seen that the segmentation details of the model trained by this application are further improved, while at the same time being able to focus on the overall picture, resulting in better hollowing segmentation, more accurate edge segmentation during image segmentation, and more natural edge transition.

[0124] In addition, compared with the prior art 2 in the specific implementation method, the information source of the present application is different. Unlike the prior art 2, which uses the original image background and has low practicality, the present solution uses multiple sets of randomly generated virtual backgrounds. The training process is unlimited and a large number of training sample pairs can be generated. By establishing different contextual relationships (especially at the edges) to feedback and optimize the segmentation method, the segmentation branch can be enhanced to learn contextual information. Figure 5A and Figure 5B It can be seen that the model trained by this application improves the accuracy of edge area recognition.

[0125] In short, the present application improves the accuracy of segmentation of the foreground area, especially the edge area, thereby improving the effect of subsequent tasks. Moreover, after testing, the present application has fast computing speed and high real-time performance under the premise of providing segmentation accuracy, and basically does not increase the amount of computing, and can be implemented on the user terminal side.

[0126] These and other aspects of the invention will become apparent from the following description of the embodiment(s). BRIEF DESCRIPTION OF THE DRAWINGS

[0127] The following further illustrates the various features of the present invention and the relationship between the various features with reference to the accompanying drawings. The accompanying drawings are all exemplary, some features are not shown in actual proportion, and some drawings may omit the conventional features in the field involved in the present application and are not necessary for the present application, or additionally show the features that are not necessary for the present application. The combination of the various features shown in the accompanying drawings is not intended to limit the present application. In addition, throughout this specification, the same figure numerals refer to the same content. The specific description of the drawings is as follows:

[0128] Figure 1A This is a schematic diagram of the structure of the first embodiment of the image processing model of this application;

[0129] Figure 1B This is a schematic diagram of the principle of feature maps and feature map fusion in the first embodiment of the image processing model of this application;

[0130] Figure 2A This is a schematic diagram of the structure of the second embodiment of the image processing model of the present application;

[0131] Figure 2B A structural diagram of a specific implementation of the second embodiment of the image processing model of the present application;

[0132] Figure 2C A schematic diagram of the principle of generating affinity maps in this application;

[0133] Figure 2D Schematic diagram of the principle of fusion of feature map and affinity map in this application;

[0134] Figure 3 A flowchart of a first embodiment of a method for training an image processing model of the present application;

[0135] Figure 4A The first embodiment of the training device of the image processing model of the present application;

[0136] Figure 4B The second embodiment of the training device of the image processing model of the present application;

[0137] Figure 4C The third embodiment of the training device of the image processing model of the present application;

[0138] Figure 4D The fourth embodiment of the training device of the image processing model of the present application;

[0139] Figure 5A It is a comparative schematic diagram of the segmentation result graphs of each method;

[0140] Figure 5B It is a schematic diagram comparing a specific implementation of the second embodiment of the present application with a segmentation result diagram of the second prior art;

[0141] Figure 6 is a schematic diagram of a computing device of the present application;

[0142] Fig. 7A It is a flow chart of prior art one;

[0143] Figure 7B It is a flow chart of the second prior art. DETAILED DESCRIPTION

[0144] The words "first, second, third, etc." or module A, module B, module C and other similar terms in the specification and claims are only used to distinguish similar objects and do not represent a specific ordering of the objects. It is understandable that the specific order or sequence can be interchanged where permitted so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0145] In the following description, the numbers representing the steps, such as S110, S120, etc., do not necessarily mean that the steps must be executed in this manner. If permitted, the order of the previous and next steps can be interchanged, or they can be executed simultaneously.

[0146] The term "comprising" as used in the description and claims should not be interpreted as being limited to what is listed thereafter; it does not exclude other elements or steps. Therefore, it should be interpreted as specifying the presence of the features, integers, steps or components mentioned, but does not exclude the presence or addition of one or more other features, integers, steps or components and groups thereof. Therefore, the expression "a device comprising means A and B" should not be limited to a device consisting of components A and B only.

[0147] The reference to "one embodiment" or "an embodiment" in this specification means that a particular feature, structure or characteristic described in conjunction with the embodiment is included in at least one embodiment of the present invention. Therefore, the phrases "in one embodiment" or "in an embodiment" appearing in various places in this specification do not necessarily refer to the same embodiment, but may refer to the same embodiment.

[0148] Semantic Segmentation: Semantic segmentation is a classification at the pixel level. Pixels belonging to the same category are classified into one category. Therefore, semantic segmentation understands the image at the pixel level. The neural network that implements semantic segmentation usually includes two parts: the encoding module (Encoder) and the decoding module (Decoder). The encoder is used to extract input image features. For example, image feature extraction can be based on the convolutional neural network (CNN), or feature extraction networks such as the residual network (ResNet), ResNext network, dense convolution network (DenseNet), and feature pyramid network (FPN) can be used. The decoder is used to fuse the features of different resolutions proposed by the encoder and restore them to the original input size. This can be achieved through a convolution group.

[0149] Reverse feature extraction, relative to feature extraction, refers to restoring high-resolution feature maps from low-resolution feature maps. It is often used in the upsampling step in the decoding module and can be achieved through deconvolution (or transposed convolution).

[0150] Context Affinity Map (CAB), or Affinity Map for short, is used to represent the relationship response between each pixel and the other pixels in the feature map, that is, to represent the relationship between pixels (that is, the establishment of context information often mentioned in segmentation).

[0151] Reshape: It is used to rearrange a multidimensional matrix of a certain dimension to construct a new matrix with the same number of elements but different dimensions. The Reshape operation does not change the data of the original elements.

[0152] Convolution layer: used to perform convolution operation on the input image matrix to extract image features and output feature map.

[0153] Softmax: A type of activation function.

[0154] Pooling layer: used to downsample data, reduce the amount of data processing while retaining useful information.

[0155] Skip Connection: corresponds to a network containing an encoding module and a decoding module. This type of network typically includes a U-Net. Through Skip Connection, the feature map of the corresponding position of the encoding module can be fused on the channel during the upsampling process of each level or certain levels of the decoding module network. That is, during the decoding process, the decoding module cascades the feature matrix of the corresponding position of the encoding module with its feature matrix as the feature matrix to be used. By fusing the underlying features with the high-level features, the network can retain more high-resolution detail information contained in the high-level feature maps, thereby improving the accuracy of image segmentation.

[0156] Mask: Also known as a mask or a mask, it refers to the part that covers part of the image, usually represented by all-black pixels.

[0157] Backpropagation Pass: It is one of the common methods for training neural network models. Backpropagation is relative to feedforward pass. Feedforward propagation is the process in which each layer of the network performs calculations in turn based on the input samples and finally outputs the predicted value (Predit Label). Since there must be an error between the predicted value and the true value (label) (usually represented by the value of the loss function), backpropagation is used to pass the existing loss error information back to each layer, so that these layers can modify their model parameters, such as modifying the weights and bias b of the weight matrix W to reduce the loss error (Loss). The iterative training process of the neural network model based on the backpropagation algorithm, that is, through each forward and backward propagation, the weights and bias b of the weight matrix W of each layer are continuously updated, so that the loss function value continues to decrease and converge (that is, the error between the predicted value and the true value gradually decreases), until the training goal is reached, the model training ends, and the final weight matrices W and biases b are obtained. When the backpropagation algorithm training mode is adopted, the gradient descent method is usually used to update the weights.

[0158] Loss function: 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 keep adjusting 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 is an important equation for measuring 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 difference between the predicted value and the target value can be called the loss value of the neural network.

[0159] L1 norm loss function (L1_loss), also known as the minimum absolute deviation (LAD) and the minimum absolute error (LAE). It minimizes the sum of the absolute differences between the target value and the estimated value. The L1_Loss formula is as follows:

[0160]

[0161] The L2 norm loss function (L2_loss), also known as the least square error (LSE), minimizes the sum of the squares of the difference between the target value and the estimated value. The L1_Loss formula is as follows:

[0162]

[0163] The cross entropy loss function is used to measure the difference between two probability distributions, such as the target value and the estimated value. The smaller the cross entropy, the closer the two are. The cross entropy loss formula for N samples is as follows:

[0164]

[0165] Mean square error loss function (MSE loss), mean square error refers to the expected value of the square of the difference between the parameter estimate and the parameter value. MSE is a more convenient way to measure the "average error". MSE can evaluate the degree of change in data. The smaller the MSE value, the better the accuracy of the prediction model.

[0166] Dilation and Erosion, dilation is to expand and enlarge the bright white areas in the image by adding pixels to the perceived boundaries of objects in the image. Erosion is the opposite, removing pixels along the boundaries of objects and reducing the size of objects. Usually these two operations are performed in sequence to enhance important object features, such as those at the edges of the image.

[0167] The model training phase and the model inference phase refer to the phase of training the model (or algorithm) through existing sample data and the phase of executing the trained model (or algorithm) in the device to process data.

[0168] [Analysis of existing technology]

[0169] Prior art 1: Technical solution such as Fig. 7A As shown in the figure, the matting method is used to improve the edge segmentation accuracy. The processing process mainly includes: firstly obtaining the preliminary segmentation result; then obtaining the uncertain area by direct or indirect means; then inputting the RGB image or underlying features, the preliminary segmentation result and the uncertain area into the network to obtain the final mask result.

[0170] The defects of the prior art 1 are as follows: 1) if end-to-end matting is performed, since matting pays too much attention to details and parts, it is easy to cause hollowing out inside; 2) due to the existence of uncertain areas, it is more likely to cause edge jitter in the video, that is, the accuracy and stability of the edge area are low; 2) the process is complicated and therefore runs slowly.

[0171] Existing technology 2: Technical solution such as Figure 7B As shown in the figure, the real background input method is used to improve the edge segmentation accuracy, that is, the original background image without foreground is used to assist in improving the segmentation effect. The processing process mainly includes inputting RGB image, prior (background image without people in the original image), and inputting different encoders respectively, and then using the context switching module to fuse the semantic features obtained by the two encoders; then the fused semantic features are input to two decoders, one for foreground reconstruction and the other for generating masks; then the reconstructed foreground and background images are synthesized, that is, synthesized through αF+(1-α)B, where α represents opacity, F represents foreground color, and B represents background color; and finally a discriminator is used to judge the quality of the synthesized image.

[0172] The defects of the second prior art are: 1) It is necessary to collect the unmanned background image separately and align the background, which is of low practicality, especially for handheld and movable devices. The background may change due to hand-held or other people's movement in the background, so it is difficult to ensure that the required unmanned background image can be collected, which makes this method unusable, or it is necessary to scale and rotate the image of the manned / unmanned background image after collection before using this method, but it will increase the complexity of the implementation method; 2) The information redundancy extracted by the foreground branch and the segmentation branch is high; 3) The discriminator is used for training. Since the discriminator itself is not sensitive to the distinction of small differences, it will not be very sensitive to the accuracy of the edge area. 4) The context switching module uses a simple feature superposition and convolution structure, so the learning guidance is weak. 5) The overall network has extremely high algorithm complexity, which is not realistic to use on the user terminal side.

[0173] Based on the defects of the prior art, the present application provides an image segmentation method that can improve the accuracy of segmentation edges. The basic principle is to input the original RGB image and the virtual background pair. During model training, the third module of the synthetic image is derived through the second module that generates the mask image (or called the segmented image), and the predicted synthetic image is obtained. The third module assists in improving the segmentation accuracy of the second module; during reasoning, only the second module is retained, and the trained model is used to obtain the segmentation result, that is, the mask image. When the mask is generated, the segmentation edge accuracy of the present application is improved without substantially increasing the amount of calculation. In addition, through the component affinity module, more contextual relationships can be transmitted back to the second module during the training process, further improving the accuracy of the segmentation edges.

[0174] [Examples of image processing model application scenarios]

[0175] The image processing model of the present application can generate a mask image, based on which it can be used in the field of image segmentation, that is, to separate the target from the background. It can be applied to image processing, video processing, computer vision, etc., for example, in medical imaging, image recognition of lesions in magnetic resonance images, face recognition, fingerprint texture or fingerprint area from images, autonomous driving, pedestrians, buildings, obstacles, or traffic settings from front images or videos collected, all of which require first segmenting the target image, and then classifying and identifying the target; for example, it can also be applied to the background replacement of the target object (the target object can be a human body, a building, the sky, a river, etc.) on the image or video, which is also based on first segmenting the image containing the target object, and then fusing the segmented target object image with other background images. When the corresponding background replacement application is used, the background image can also use a virtual background (virtual background refers to a non-real image), such as a cartoon background, an automatically generated background, a dynamic background, etc.

[0176] On the other hand, the image processing model of the present application can also directly target two images, synthesize the target object identified in one image as the foreground and the other image as the background image, and can be directly applied to the fusion of the above-mentioned identified target object and the background image.

[0177] The following further illustrates some application scenarios of the image processing model of this application with some specific application examples:

[0178] Users use terminals and other devices to perform real-time video semantic segmentation of portraits, thereby realizing functions such as background blur or background replacement, live broadcast production, movie or animation production, etc. For example, a user turns on the video call function on the mobile phone. During the video call, the portrait in the picture is segmented in real time and the portrait is selected as the foreground. The user selects a virtual background to replace the original background with a virtual background. For example, the virtual background can be a virtual historical scene or a future scene, thereby realizing the effects of time and space changes and background crossing. Another example is the recognition and segmentation of the sky area in the background, and the replacement of the sky area in the original picture with a virtual sky. When the virtual sky is a designed dynamic magic sky, the magic sky effect can be achieved on the picture or video on the user terminal side.

[0179] [Image Processing Model First Embodiment]

[0180] Before introducing the training method of the image processing model of this application, the image processing model to be trained is first introduced.

[0181] like Figure 1A The first embodiment of the image processing model is shown, and reference is made to Figure 2B A specific implementation of the second embodiment of the image processing model shown in FIG. 1 is used to describe the first embodiment of the image processing model of the present invention. The image processing model includes:

[0182] The first module 110 is configured to receive a first image and a second image and generate a first feature map; the first image includes an image of a target object.

[0183] In some embodiments, the first module 110 can be implemented by an encoding module, which includes at least one feature extraction layer, each feature extraction layer is coupled in sequence, and each feature extraction layer extracts higher-level features from the feature map output by the previous layer, so that each feature extraction layer extracts low-level feature maps to high-level feature maps in sequence, wherein the low-level feature map corresponds to a feature map with high resolution, and the high-level feature map corresponds to a feature map with low resolution. This feature extraction process can also be called the downsampling process of the encoding module. Among them, the first module 110 can be implemented based on a convolutional neural network (CNN), a residual network (ResNet), a ResNext network, a dense convolutional network (DenseNet), a feature pyramid network (FPN), etc., or any combination of the above networks.

[0184] In this embodiment, the first module 110 can be implemented based on a CNN structure, and the first module 110 includes a plurality of convolutional layers coupled in sequence, and the downsampling process is completed through the plurality of convolutional layers. A pooling layer can also be set after each convolutional layer or a part of the convolutional layer to perform downsampling to reduce the amount of data. In this embodiment, the first feature map refers to the feature map obtained by the last sampling in the downsampling process.

[0185] The target object image included in the first image may be a human body, a building, the sky, a river, or an area distinguishable from surrounding pixels in the first image, etc. The second image may be any image, such as a photo, or an automatically randomly generated image, such as an automatically randomly generated virtual background image.

[0186] The second module 120 is used to generate a second feature map according to the first feature map; the second module 120 is also used to generate a mask image according to the second feature map; the mask image corresponds to the target object image in the first image.

[0187] In some embodiments, the second module 120 can be implemented by a decoding module, which includes at least one reverse feature extraction layer (reverse feature extraction refers to restoring a high-resolution feature map from a low-resolution feature map), each reverse feature extraction layer is coupled in sequence, and each reverse feature extraction layer generates a high-resolution feature map for the low-resolution feature map output by the previous layer, that is, restores the high-resolution feature map, so that a higher-resolution feature map can be restored from the low-resolution feature map in sequence, and the feature map restoration process can also be called the upsampling process of the decoding module. Among them, the second module 120 can be implemented based on a convolutional neural network (CNN), a residual network (ResNet), a ResNext network, a dense convolutional network (DenseNet), a feature pyramid network (FPN), etc., or any combination of the above networks.

[0188] In the present embodiment, the second module 120 is implemented based on the CNN structure, and the second module 120 includes multiple convolutional layers, and the upsampling process is implemented by the reverse convolution operation (or transposed convolution operation) of multiple convolutional layers. An up-pooling layer can also be set after each convolutional layer or part of the convolutional layer for upsampling to further fill the data volume to improve the resolution of the feature map. In the present embodiment, the second feature map is a feature map obtained by any sampling during the upsampling process performed by the second module 120. In other embodiments, there are different multiple second feature maps, which are feature maps obtained by sampling corresponding to different convolutional layers or upper pooling layers during the upsampling process performed by the second module 120.

[0189] The third module 130 is used to generate a third image according to the first feature map and the second feature map; the third image is a predicted composite image including the target object image and the second image.

[0190] In some embodiments, the third module 130 can be implemented by another decoding module, which includes at least one reverse feature extraction layer, each reverse feature extraction layer is coupled in sequence, and each reverse feature extraction layer generates a feature map with a higher resolution for the feature map output by the previous layer, that is, restores the higher resolution feature map, so that the higher resolution feature map can be restored from the low resolution feature map in sequence, and the feature restoration process can also be called the upsampling process of the decoding module. Among them, the third module 130 can be implemented based on a convolutional neural network (CNN), a residual network (ResNet), a ResNext network, a dense convolutional network (DenseNet), a feature pyramid network (FPN), etc., or any combination of the above networks.

[0191] In the present embodiment, the third module 130 is implemented based on the CNN structure, and the third module 130 includes multiple convolutional layers, and the upsampling process is implemented by the reverse convolution operation (or transposed convolution operation) of multiple convolutional layers. After each convolutional layer or part of the convolutional layer, an up-pooling layer can also be set to perform upsampling to further fill the data volume to improve the resolution of the feature map. In the present embodiment, the feature map output by any sampling in the upsampling process is fused with the second feature map as the input of the next sampling (or, when any sampling is performed in the upsampling process, the feature map output by the previous sampling is fused with the second feature map as the input of this sampling). In other embodiments, there are different multiple second feature maps, which will be fused to the feature maps of the original inputs of the corresponding different convolutional layers or upper pooling layers in the upsampling process of the third module 130.

[0192] like Figure 1B As shown, the fusion described in this embodiment can be implemented by multiplying the feature map output by the last sampling with the second feature map, and then performing element-wise summation with the feature map output by the last sampling, and the result is used as the input of this sampling. In order to implement the multiplication operation and element-wise summation operation, each feature map before and after the operation can be reshaped.

[0193] In some other embodiments, the fusion can also be implemented by: multiplying the feature map output by the previous sampling with the second feature map, and using the result as the input of this sampling; or, performing bitwise summation on the feature map output by the previous sampling and the second feature map, and using the result as the input of this sampling. In order to implement the multiplication operation and bitwise summation operation, each feature map can be reshaped before and after the operation.

[0194] In some other embodiments, there are other fusion methods, such as cascading the feature map output by the previous sampling with the second feature map as the input used this time.

[0195] In one implementation of this embodiment, the first module 110 and the third module 130 can be as follows: Figure 2BAs shown in the figure, a U-Net is constructed. The corresponding network layers of downsampling and upsampling, or some network layers, are provided with a skip connection structure (skip connect), so that the network layer in the upsampling process can receive the feature map of high-resolution detail information contained in the downsampling, and cascade it to the feature map of the original input of the network layer as its input. Usually, the cascade requires the same resolution of the two feature maps. If they are not the same, they can be adjusted by reshaping first. The skip connection structure improves the accuracy of image resolution restoration, thereby improving the accuracy of image segmentation.

[0196] When in the model training stage, the first image and the second image form an image pair and are input to the first module 110 as a training sample. When in the model inference stage, and for generating a mask image of the first image, only the first image may be input to the first module 110. In this case, the image processing model may not include the third module 130. When in the model inference stage, and for generating a composite image of the target object in the first image and the second image, or when simultaneously generating a mask image of the first image, the first image and the second image form an image pair and are input to the first module 110.

[0197] [Second embodiment of image processing model]

[0198] like Figure 2A The schematic diagram of the structure of the second embodiment of the image processing model is shown. Below, only the differences from the first embodiment of the image processing model are described. The second embodiment of the image processing model also includes a context affinity module (CAB), referred to as affinity module (Affinity block) 140, which is used to generate an affinity map according to the second feature map; the affinity map is used to represent the relationship between at least one pixel in the feature map and at least one other pixel. In some embodiments, the affinity module 140 is implemented by multiplying the second feature map and the transpose of the second feature map, and then generating the affinity map of the second feature map through an activation function operation.

[0199] The difference from the first embodiment of the corresponding image processing model also lies in the above-mentioned method of fusing the second feature map. In the third module 130 of this embodiment, the fusion of the second feature map is not direct fusion as in the first embodiment of the image processing model, but fusion of the affinity map generated by the second feature map. In this way, the second feature map is indirectly fused, and because the affinity map represents the relationship between at least one pixel in the feature map and at least one other pixel (i.e., the contextual relationship), it can represent the contextual relationship of the second feature map used to generate the mask image. Since the second feature map is related to the mask image, it can well represent the contextual relationship at the edge of the target object image, and continuously enhance the contextual information learned by the second module 120 during the training process, thereby improving the accuracy of edge area recognition.

[0200] In this embodiment, the principle of the affinity module 140, that is, the generation process of the affinity graph, is as follows: Figure 2C As shown, a process of obtaining an affinity graph S of a feature graph through a feature graph A of the second module 120 is described as an example, and the principle is as follows:

[0201] From the second module 120 feature map A, matrices B and C are obtained, both with dimensions of C*H*W. B and C are reshaped to C*N dimensions (N=H*W, representing the number of pixels); then the transpose of C is multiplied with B to obtain an N*N dimensional matrix, and a softmax activation function is performed on each point of the matrix to obtain sji. The affinity map S is described by the formula as follows:

[0202] Among them, sji measures the influence of the ith position on the jth position, that is, the relationship between the ith and jth positions of pixels (i.e., the contextual relationship), or the degree of association / correlation. The larger the relationship, the more similar they are.

[0203] In some other embodiments, the affinity map may be generated in other ways, such as generating a relationship matrix of each element through a neural network, or generating a matrix of the relationship of each element based on a structure as described in CPNet, or further combining the characteristics of different channels to generate an affinity map based on the pixel position.

[0204] In the third module 130, the process of fusing the feature map with the affinity map S is as follows: a feature map A' of the third module 130 is fused with the affinity map to obtain a fused feature map A" as an example. Figure 2D As shown, the description is as follows:

[0205] The matrix D is obtained from the feature map A' of the third module 130, and D is also reshaped to C*N dimensions (N=H*W, representing the number of pixels). Then D is multiplied by the affinity map S, and then reshaped to C*H*W dimensions. The element-wise summation is performed with the original feature map A' of the third module 130 to obtain the fused feature map A", which is described by the following formula:

[0206] A″∈R C×H×W : α represents the scaling factor, which is initialized to 0 and gradually learns to assign larger weights.

[0207] It can be seen from the above that the feature map A” of the third module 130 integrates the affinity map S related to all positions obtained by the second module 120 and the original feature map A’ of the third module 130. During forward training, the features of the affinity map S of the second module 120 are enhanced on the feature map of the third module 130, and the features of the third module 130 are integrated with the features of the affinity map S of the second module 120 to obtain the final synthetic image prediction result; the establishment of the synthetic image requires more learning of the pixel relationship between the foreground edge and the virtual background, so in the process of back propagation of the loss function of the third module 130, the affinity map S must be corrected in turn, that is, the contextual relationship of the second module 120 is corrected, especially at the edges, so as to optimize the model of the second module 120.

[0208] It should also be noted that Figure 2D The feature graph A of the second module and the feature graph A' of the third module shown in FIG. 1 are of the same size and channel. If the size and channel are different, they can be adjusted to be the same by reshaping.

[0209] In some other embodiments, the fusion may be implemented as follows: the third module 130 multiplies the feature map A' output from the previous sampling with the affinity map S, and uses the result as the input A" for this sampling; or, performs a positional summation on the feature map A' output from the previous sampling with the affinity map S, and uses the result as the input A" for this sampling. In order to implement the multiplication and positional summation operations, each feature map may be reshaped before and after the operation.

[0210] In some other embodiments, there are other fusion methods, such as concatenating the feature map A' output from the previous sampling with the affinity map S as the input A" used this time.

[0211] like Figure 2BAs shown, in the second embodiment of the image processing model, the first module and the third module constitute a structural diagram of an embodiment of a U-type network, wherein the first module 110 and the third module 130 constitute a U-type network (U-Net), and the corresponding network layers of downsampling and upsampling, or part of the network layers are also provided with a skip connection structure (Skip connect).

[0212] [First embodiment of the training method of the image processing model]

[0213] As described above, the image processing model provided by this application is introduced. Figure 3 The flowchart of the first embodiment of the training method of the image processing model of the present application is shown, and the first embodiment of the training method of the image processing model is introduced in detail. The training method includes the following steps:

[0214] S310, inputting a first image and a second image into a first module to generate a first feature map; the first image includes a target object image.

[0215] The target object image included in the first image may be a human body, a building, the sky, a river, or an area distinguishable from surrounding pixels in the first image, etc. The second image may be any image, such as a photo, or an automatically randomly generated image, such as an automatically randomly generated virtual background image.

[0216] When a virtual background image is used, since the virtual background image can be randomly generated without limit, a sufficient number of virtual background images can be generated to form a sufficient number of image pairs with the first image, thereby satisfying the training data set. When the first image and each virtual background form an image pair, that is, the same foreground matches different virtual backgrounds to form an image pair, the advantage is that the same foreground matches different virtual backgrounds for synthesis, and the error area will strengthen the penalty of the error area on the different background synthesis images, so that when the model is trained, more loss values ​​in the error area can be back-transmitted to correct these errors.

[0217] In this embodiment, when the virtual background image is generated, the image format and resolution can be generated according to the RGB image, that is, an image of the same RGB format with the same resolution is generated, which can reduce the preprocessing steps, such as eliminating the need for scaling or cropping to align the image size.

[0218] In some other embodiments, when the image format and resolution of the generated virtual background image are different from those of the RGB image, preprocessing such as image format conversion, image scaling or cropping is required.

[0219] In addition, even when the image sizes are aligned, the virtual background image and / or the original RGB image can be preprocessed, which includes the above-mentioned format conversion, scaling, and cropping, and may also include rotation, translation, denoising, brightness adjustment, grayscale adjustment, contrast adjustment, color temperature adjustment and other preprocessing.

[0220] S320. A second module generates a second feature map according to the first feature map, and generates a mask image according to the second feature map; the mask image corresponds to the target object image.

[0221] In this embodiment, the first feature map is used as the input of the second module, the second module performs the upsampling process, the second feature map is the feature map obtained by any sampling during the upsampling process performed by the second module, and the mask image is the output of the second module.

[0222] In other embodiments, there are multiple different second feature maps, which are feature maps obtained by sampling at different levels performed by different network layers during the upsampling process performed by the second module.

[0223] S330, generating a third image by a third module according to the first feature map and the second feature map; the third image is a predicted composite image including the target object image and the second image.

[0224] In some embodiments, the first feature map is used as the input of the third module, and the third module performs an upsampling process, and fuses the feature map output by any sampling in the upsampling process with the second feature map as the input of the next sampling. In other words, when performing any sampling in the upsampling process, the feature map output by the previous sampling is fused with the second feature map as the input of this sampling.

[0225] In other embodiments, there are multiple different second feature maps, which are respectively fused into the feature maps input when the third module performs upsampling at different levels of sampling.

[0226] In some other embodiments, for the above-mentioned method of fusing the second feature map, the above-mentioned direct fusion of the second feature map is not adopted, but the affinity map generated by the second feature map is fused, and the second feature map is indirectly fused in this way.

[0227] S340. Training the image processing model according to the loss function for generating the third image and the loss function for generating the mask image.

[0228] In some embodiments, back propagation can be used for training, so that the second module will pass the feature map of the pixels extracted by the second module, or the contextual relationship features between pixels to the third module for learning, and the third module reversely corrects the second module during training. When back propagation is used for training, a gradient descent method can be used for training.

[0229] In some embodiments, the final loss function (LOSS) includes the loss function of the second module and the loss function of the third module. The loss function of the third module includes the loss of the image level and the feature level, and increases the weight at the edge. The formula describing the loss function can be as follows:

[0230] LOSS = loss_second module + loss_third module

[0231] =seg loss+(image level loss+feature level loss)*(1+w)

[0232] The above loss_second module can be a commonly used image segmentation network loss function (seg loss), such as cross entropy loss, MSE loss, etc.

[0233] The above-mentioned loss_third module includes an image-level synthetic loss function (image level loss) and a feature-level synthetic loss function (feature level loss).

[0234] Here, image level loss is L1_loss or L2_loss of the predicted composite image (such as the third image described in this application) and the GT composite image.

[0235] Feature level loss is the L1_loss or L2_loss of the predicted synthetic image features and the GT synthetic image features. The predicted synthetic image features and the GT synthetic image features can be extracted by a pre-trained feature extractor;

[0236] The (1+w) in the formula means that the penalty for the edge area is increased in the loss_3 module, and the edge area of ​​the foreground is obtained by dilating and corroding the GT mask, which is denoted as w. w is a two-dimensional image of the same size as the GT mask, and its pixel value range is 0 to 1.

[0237] Among them, the above-mentioned GT mask refers to a manually labeled foreground mask, and its value range is 0 to 1; the GT composite image refers to a composite image obtained by a fusion algorithm using a known GT mask, a first image containing a foreground image (i.e., a target object image) and a second image as a background image, and it may be necessary to manually adjust the edge area.

[0238] In some other embodiments, the formula of the above final loss function (LOSS) does not include the (1+w) part, which can also be used for model training.

[0239] [First embodiment of the training device for image processing model]

[0240] like Figure 4A A first embodiment of a training device for an image processing model provided by the present application is disclosed. The first module, the second module and / or the third module of the image processing model, the training device comprises:

[0241] A first feature map generating unit 410 is used to input a first image and a second image into a first module to generate a first feature map; the first image includes a target object image;

[0242] A mask image generating unit 420, configured to generate a second feature map according to the first feature map by a second module, and generate a mask image according to the second feature map; the mask image corresponds to the target object image;

[0243] A third image generating unit 430 is configured to generate a third image according to the first feature map and the second feature map by a third module; the third image is a predicted composite image including the target object image and the second image;

[0244] The training unit 440 is used to train the image processing model according to the loss function for generating the third image and the loss function for generating the mask image.

[0245] [Second embodiment of the training device for image processing model]

[0246] like Figure 4B A second embodiment of a training device for an image processing model is disclosed. This embodiment is a variation of the first embodiment of the training device for an image processing model, wherein the second module and the third module each include at least one reverse feature extraction layer; the reverse feature extraction layer is used to restore a high-resolution feature map from a low-resolution feature map;

[0247] The mask image generating unit 420 generates different second feature maps by different reverse feature extraction layers of the second module;

[0248] Also included is a feature map transfer module 450, which is used to transfer at least one second feature map to at least one reverse feature extraction layer corresponding to the third module;

[0249] The third image generating unit 430 generates a third image by a third module according to the first feature map and the second feature map respectively received by the at least one reverse feature extraction layer and fused into the original input feature map of the layer.

[0250] [Third embodiment of the training device for image processing model]

[0251] like Figure 4C A third embodiment of a training device for an image processing model is disclosed. This embodiment is a variation of the first embodiment of the training device for an image processing model, and further includes an affinity module 460, which is used to generate a corresponding affinity map according to the second feature map; the affinity map is used to represent the relationship between at least one pixel in the second feature map and at least one other pixel;

[0252] The third image generating unit 430 generates the third image according to the first feature map and the affinity map by a third module.

[0253] [Fourth embodiment of the training device for image processing model]

[0254] like Figure 4D A fourth embodiment of a training device for an image processing model is disclosed. This embodiment is a variation of the third embodiment of the training device for an image processing model, wherein the second module and the third module each include at least one reverse feature extraction layer; different second feature maps are generated by different reverse feature extraction layers of the second module;

[0255] The affinity module 460 is at least one, and is used to generate at least one corresponding affinity graph according to at least one second feature graph;

[0256] Also included is an affinity map transfer module 470, for transferring the at least one affinity map to at least one reverse feature extraction layer corresponding to the third module;

[0257] The third image generating unit 430 generates a third image by a third module according to the first feature map and the affinity map respectively received and fused to the original input feature map of the layer by the at least one reverse feature extraction layer.

[0258] In some embodiments, the affinity module 460 is specifically used to obtain the affinity map by multiplying the second feature map and the transpose of the second feature map and performing an activation function operation.

[0259] In some embodiments, the fusion of the third module to the original input feature map of the layer includes: multiplying with the original input feature map of the layer, and summing the result with the original input feature map of the layer, and using the result as the fused input feature map; or, multiplying with the original input feature map of the layer, and using the result as the fused input feature map; or, summing with the original input feature map of the layer, and using the result as the fused input feature map.

[0260] [Beneficial effects of this application]

[0261] As shown in the following table, the test was conducted on the portrait segmentation dataset. The following table shows the benefits of the segmentation network (corresponding to the model composed of the first and second modules in this application), the segmentation network plus synthesis branch (corresponding to the model composed of the first, second, and third modules in this application), and the additional CAB (referring to the additional affinity module, corresponding to the model composed of the first, second, third modules and affinity module in this application). In the end, with the inference calculation amount basically unchanged, the overall mIOU increased by 1.1% and the edge details increased by 0.9%. The corresponding segmentation result diagrams of each method can be seen in Figure 5A shown.

[0262]

[0263]

[0264] More visualization effects such as Figure 5B The portrait segmentation visualization results shown in the figure show that the comparison results of various solutions show that the segmentation of many previously difficult details has been greatly improved, such as fingers, occluded arms with bracelets, highly reflective hair, hand-held objects, ears, etc.

[0265] A simple comparison is also made with the solution of the second prior art, that is, the method of using the original background image input without foreground. The comparison results are shown below. From the perspective of the reproduction effect, the image model trained by the method of the present application has great advantages in details such as edges and small hollows, and the calculation amount is small and does not require a real background image without people. From the actual measured background replacement effect, the edge transition is also relatively natural.

[0266]

[0267] Figure 6 15 is a schematic structural diagram of a computing device 1500 provided in an embodiment of the present application. The computing device 1500 includes: a processor 1510 , a memory 1520 , a communication interface 1530 , and a bus 1540 .

[0268] It should be understood that Figure 6 The communication interface 1530 in the computing device 1500 shown may be used to communicate with other devices.

[0269] The processor 1510 may be connected to a memory 1520. The memory 1520 may be used to store the program code and data. Therefore, the memory 1520 may be a storage unit inside the processor 1510, or an external storage unit independent of the processor 1510, or a component including a storage unit inside the processor 1510 and an external storage unit independent of the processor 1510.

[0270] Optionally, the computing device 1500 may further include a bus 1540. The memory 1520 and the communication interface 1530 may be connected to the processor 1510 via the bus 1540. The bus 1540 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus 1540 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 The fact that only one line is used in the diagram does not mean that there is only one bus or only one type of bus.

[0271] It should be understood that in the embodiment of the present application, the processor 1510 can adopt a central processing unit (CPU). The processor can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. Or the processor 1510 uses one or more integrated circuits to execute related programs to implement the technical solutions provided in the embodiments of the present application.

[0272] The memory 1520 may include a read-only memory and a random access memory, and provides instructions and data to the processor 1510. A portion of the processor 1510 may also include a nonvolatile random access memory. For example, the processor 1510 may also store information on the device type.

[0273] When the computing device 1500 is running, the processor 1510 executes the computer-executable instructions in the memory 1520 to perform the operating steps of the above method.

[0274] It should be understood that the computing device 1500 according to the embodiment of the present application can correspond to the corresponding subjects in the methods according to the embodiments of the present application, and the above-mentioned and other operations and / or functions of each module in the computing device 1500 are respectively for implementing the corresponding processes of each method of the present embodiment, which will not be repeated here for the sake of brevity.

[0275] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0276] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0277] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0278] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0279] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0280] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0281] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the program is used to execute a method for generating diversified questions, which includes at least one of the solutions described in the above embodiments.

[0282] The computer storage medium of the embodiment of the present application can adopt any combination of one or more computer-readable media. Computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive lists) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, computer-readable storage media can be any tangible medium containing or storing programs, which can be used by instruction execution systems, devices or devices or used in combination with them.

[0283] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0284] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0285] Computer program code for performing the operation of the present application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).

[0286] Note that the above are only preferred embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present application is described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may also include more other equivalent embodiments without departing from the concept of the present invention, all of which belong to the protection scope of the present invention.

Claims

1. A training method for an image processing model, characterized in that: The image processing model includes a first module, a second module and a third module, and the method includes: Inputting a first image and a second image into a first module to generate a first feature map; the first image includes a target object image; The second module generates a second feature map according to the first feature map, and generates a mask image according to the second feature map; the mask image corresponds to the target object image; A third module generates a third image according to the first feature map and the second feature map; the third image is a predicted composite image including the target object image and the second image; Training the image processing model according to the loss function for generating the third image and the loss function for generating the mask image; The generating of the third image by the third module according to the first feature map and the second feature map comprises: Generate a corresponding affinity map according to the second feature map; the affinity map is used to represent the relationship between at least one pixel in the second feature map and at least one other pixel; The third image is generated by a third module according to the first feature map and the affinity map.

2. The method according to claim 1, characterized in that The second module and the third module each include at least one reverse feature extraction layer; the reverse feature extraction layer is used to restore a high-resolution feature map from a low-resolution feature map; Generating different second feature maps by different reverse feature extraction layers of the second module; Passing at least one second feature map to at least one reverse feature extraction layer corresponding to the third module; The third module generates the third image based on the first feature map and the second feature map, and the third module generates the third image based on the first feature map and the second feature map respectively received and fused into the original input feature map of the layer by at least one reverse feature extraction layer.

3. The method according to claim 1, characterized in that The second module and the third module each include at least one inverse feature extraction layer; Generating different second feature maps by different reverse feature extraction layers of the second module; Generate at least one corresponding affinity map according to at least one second feature map, and pass it to at least one reverse feature extraction layer corresponding to the third module; The third module generates the third image according to the first feature map and the affinity map, and the third module generates the third image according to the first feature map and the affinity map respectively received and fused to the original input feature map of the layer by at least one reverse feature extraction layer.

4. The method according to claim 1 or 3, characterized in that: Generating a corresponding affinity graph according to the second feature graph includes: After multiplying the second feature map and the transpose of the second feature map, the affinity map corresponding to the second feature is obtained by an activation function operation.

5. The method according to claim 2 or 3, characterized in that: The fusion to the original input feature map of this layer includes one of the following: Multiply the original input feature map of the layer, and then sum the result with the original input feature map of the layer, and the result is used as the fused input feature map; Multiply the original input feature map of the layer, and use the result as the fused input feature map; The result is taken as the fused input feature map after being summed with the original input feature map of the layer.

6. The method according to any one of claims 1 to 5, characterized in that: In the training of the image processing model according to the loss function for generating the third image and the loss function for generating the mask image, the following loss function is used: LOSS = loss function for generating the mask image + loss function for generating the third image =seg loss + (image level loss + feature level loss); Seg loss refers to the image segmentation network loss function; Image level loss is the loss function for predicting composite images and GT composite images; Feature level loss is the loss function for predicting synthetic image features and GT synthetic image features; The predicted composite image refers to the third image; the GT composite image refers to a composite image obtained by using a known GT mask, the first image and the second image; and the GT mask refers to an artificially annotated mask image.

7. The method according to any one of claims 1 to 5, characterized in that: The training of the image processing model according to the loss function for generating the third image and the loss function for generating the mask image uses the following loss function: LOSS = loss function for generating the mask image + loss function for generating the third image ; Seg loss refers to the image segmentation network loss function; Image level loss is the loss function for predicting composite images and GT composite images; Feature level loss is the loss function for predicting synthetic image features and GT synthetic image features; The predicted composite image refers to the third image; the GT composite image refers to a composite image obtained by using a known GT mask, the first image and the second image; the GT mask refers to a mask image that is manually annotated; w is a two-dimensional image of the same size as the GT mask, with a pixel value range of 0 to 1. It is an image of the edge area of ​​the corresponding target object obtained by dilating and corroding the GT mask.

8. The method according to any one of claims 1 to 7, characterized in that: The first image and the second image are from a data pair of a training data set; the data set includes a plurality of data pairs, and the plurality of data pairs are a plurality of data pairs consisting of the same first image and a plurality of different second images.

9. A training device for an image processing model, characterized in that: The image processing model includes a first module, a second module and a third module, and the device includes: A first feature map generating unit, configured to input a first image and a second image into a first module to generate a first feature map; the first image includes a target object image; a mask image generating unit, configured to generate a second feature map according to the first feature map by a second module, and generate a mask image according to the second feature map; the mask image corresponds to the target object image; A third image generating unit, configured to generate a third image by a third module according to the first feature map and the second feature map; the third image is a predicted composite image including the target object image and the second image; A training unit, used for training the image processing model according to a loss function for generating the third image and a loss function for generating the mask image; An affinity module, used to generate a corresponding affinity map according to the second feature map; the affinity map is used to represent the relationship between at least one pixel in the second feature map and at least one other pixel; The third image generating unit generates the third image by a third module according to the first feature map and the affinity map.

10. The device according to claim 9, characterized in that The second module and the third module each include at least one reverse feature extraction layer; the reverse feature extraction layer is used to restore a high-resolution feature map from a low-resolution feature map; The mask image generation unit generates different second feature maps by different reverse feature extraction layers of the second module; Also included is a feature map transfer module, used to transfer at least one second feature map to at least one reverse feature extraction layer corresponding to the third module; The third image generating unit generates a third image by a third module according to the first feature map and the second feature map respectively received by at least one reverse feature extraction layer and fused into the original input feature map of the layer.

11. The device according to claim 9, characterized in that The second module and the third module each include at least one inverse feature extraction layer; Generating different second feature maps by different reverse feature extraction layers of the second module; The affinity module is at least one, and is used to generate at least one corresponding affinity graph according to at least one second feature graph; Also included is an affinity map transfer module, used to transfer the at least one affinity map to at least one reverse feature extraction layer corresponding to the third module; The third image generating unit generates the third image by a third module according to the first feature map and the affinity map respectively received and fused to the original input feature map of the layer by at least one reverse feature extraction layer.

12. The device according to claim 9 or 11, characterized in that The affinity module is specifically used to obtain the affinity map by multiplying the second feature map and the transpose of the second feature map, and then performing an activation function operation.

13. The device according to claim 10 or 11, characterized in that The fusion to the original input feature map of this layer includes one of the following: Multiply the original input feature map of the layer, and then sum the result with the original input feature map of the layer, and the result is used as the fused input feature map; Multiply the original input feature map of the layer, and use the result as the fused input feature map; The result is taken as the fused input feature map after being summed with the original input feature map of the layer.

14. The device according to any one of claims 9 to 13, characterized in that: The training unit specifically uses the following loss function to train the image processing model: LOSS = loss function for generating the mask image + loss function for generating the third image ; Seg loss refers to the image segmentation network loss function; Image level loss is the loss function for predicting composite images and GT composite images; Feature level loss is the loss function for predicting synthetic image features and GT synthetic image features; The predicted composite image refers to the third image; the GT composite image refers to a composite image obtained by using a known GT mask, the first image and the second image; and the GT mask refers to an artificially annotated mask image.

15. The device according to any one of claims 9 to 13, characterized in that: The training unit specifically uses the following loss function to train the image processing model: LOSS = loss function for generating the mask image + loss function for generating the third image ; Seg loss refers to the image segmentation network loss function; Image level loss is the loss function for predicting composite images and GT composite images; Feature level loss is the loss function for predicting synthetic image features and GT synthetic image features; The predicted composite image refers to the third image; the GT composite image refers to a composite image obtained by using a known GT mask, the first image and the second image; the GT mask refers to a mask image that is manually annotated; w is a two-dimensional image of the same size as the GT mask, with a pixel value range of 0 to 1. It is an image of the edge area of ​​the corresponding target object obtained by dilating and corroding the GT mask.

16. The device according to any one of claims 9 to 15, characterized in that It also includes a training data set, including a plurality of data pairs consisting of a same first image and a plurality of different second images, wherein the first image and the second image are from a data pair of the data set.

17. An image processing method, characterized in that: Inputting a first image into a first module to generate a first feature map; the first image includes a target object image; The second module generates a second feature map according to the first feature map, and generates a mask image according to the second feature map; the mask image corresponds to the target object image; The first module and the second module are trained by the method described in any one of claims 1 to 8.

18. An image processing model, characterized in that include: A first module is used to receive a first image and generate a first feature map; the first image includes a target object image; A second module is used to generate a second feature map according to the first feature map, and to generate a mask image according to the second feature map; the mask image corresponds to the target object image; The first module and the second module are trained by the method described in any one of claims 1 to 8.

19. An image processing method, characterized in that: Inputting a first image and a second image into a first module to generate a first feature map; the first image includes a target object image; Generating a second feature map according to the first feature map by a second module; Generate a third image according to the first feature map and the second feature map; the third image is a predicted composite image including the target object image and the second image; The first module, the second module and the third module are trained by the method according to any one of claims 1 to 8.

20. The method according to claim 19, characterized in that The second module also generates a mask image according to the second feature map; the mask image corresponds to the target object image.

21. The method according to claim 19 or 20, characterized in that Generating a third image according to the first feature map and the second feature map comprises: Generate an affinity map according to the second feature map; the affinity map is used to represent the relationship between at least one pixel in the feature map and at least one other pixel; A third module generates a third image according to the first feature map and the affinity map.

22. An image processing model, characterized in that include: A first module is used to receive a first image and a second image, and generate a first feature map; The first image includes a target object image; A second module, configured to generate a second feature map according to the first feature map; A third module is used to generate a third image according to the first feature map and the second feature map; the third image is a predicted composite image including the target object image and the second image; The first module, the second module and the third module are trained by the method according to any one of claims 1 to 8.

23. The model according to claim 22, characterized in that The second module is also used to generate a mask image according to the second feature map; the mask image corresponds to the target object image.

24. A model according to claim 22 or 23, characterized in that Also includes: An affinity module, used for generating a corresponding affinity graph according to the second feature graph; The affinity map is used to represent the relationship between at least one pixel in the feature map and at least one other pixel; The third module generates the third image according to the first feature map and the affinity map.

25. A computing device, characterized in that include: bus; A communication interface connected to the bus; at least one processor connected to the bus; as well as At least one memory connected to the bus and storing program instructions, wherein when the program instructions are executed by the at least one processor, the at least one processor executes the method of any one of claims 1 to 8, 17, 19 to 21.

26. A computer-readable storage medium having program instructions stored thereon, characterized in that: When the program instructions are executed by a computer, the computer performs the method according to any one of claims 1 to 8, 17, 19 to 21.