Image processing method and device

Predicting object masks and semantic segmentation images through the same image processing model, combined with Hadamard product operation, solves the problem of inaccurate parsing results caused by inaccurate detectors in the existing technology, and achieves rapid and accurate identification and label determination of target objects. .

CN114445632BActive Publication Date: 2024-09-10ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202210117352.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-08
Publication Date
2024-09-10
Estimated Expiration
2042-02-08

AI Technical Summary

Technical Problem

In the process of object recognition and partial replacement in the existing technology, the two-stage processing caused by the inaccuracy of the detector has a greater impact, resulting in inaccurate analysis results.

Method used

The same image processing model is used to predict the object mask image and semantic segmentation image of the target object, and the target object and its label are determined through Hadamard product operation to achieve rapid and accurate identification and analysis of the target object.

Benefits of technology

There is no need for two-stage processing, which avoids the problem of inaccurate analysis results caused by inaccurate detectors, and achieves rapid and accurate identification and label determination of target objects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114445632B
    Figure CN114445632B
Patent Text Reader

Abstract

The embodiments of this specification provide a method and device for image processing, wherein the method includes obtaining an image containing a target object; inputting the image into an image processing model to obtain an object mask image, a probability of the target object existing in the object mask image, and a semantic segmentation image containing an object label; determining the target object and the object label of the target object according to the object mask image, the probability of the target object existing in the object mask image, and the semantic segmentation image. Specifically, the method uses the same network to implement the two tasks of target object recognition and target object parsing, and quickly and accurately obtains the target object and the object label of the target object; there is no need to perform two-stage processing on the image, thereby avoiding the situation where the analysis result is inaccurate due to the influence of the detector in the two-stage processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present specification relate to the field of computer technology, and more particularly to a method for processing an image. Background Art

[0002] Currently, in many application scenarios, it is necessary to identify objects in images and then replace certain parts of the identified objects; for example, in e-commerce scenarios, it is necessary to identify human bodies in images and replace clothes or change hair color.

[0003] In the prior art, each human body in the image needs to be detected by a human body detector first, and then each part of each human body needs to be analyzed separately. However, this two-stage method is greatly affected by the detector. If the detector is inaccurate and the detected human body is incomplete (for example, the human body in the image overlaps), it will have a great impact on the next step of human body analysis, making the analysis result inaccurate. Summary of the invention

[0004] In view of this, an embodiment of this specification provides a method for processing an image. One or more embodiments of this specification also relate to an image processing apparatus, a computing device, a computer-readable storage medium, and a computer program to solve the technical defects existing in the prior art.

[0005] According to a first aspect of an embodiment of this specification, a method for processing an image is provided, including:

[0006] Get the image containing the target object;

[0007] Inputting the image into an image processing model to obtain an object mask image, a probability of a target object existing in the object mask image, and a semantic segmentation image including an object label;

[0008] The target object and the object label of the target object are determined according to the object mask image, the probability that the target object exists in the object mask image, and the semantic segmentation image.

[0009] According to a second aspect of an embodiment of this specification, there is provided a picture processing device, including:

[0010] A picture acquisition module, configured to acquire a picture containing a target object;

[0011] A model processing module is configured to input the image into an image processing model to obtain an object mask image, a probability that a target object exists in the object mask image, and a semantic segmentation image containing an object label;

[0012] The label determination module is configured to determine the target object and the object label of the target object according to the object mask image, the probability that the target object exists in the object mask image, and the semantic segmentation image.

[0013] According to a third aspect of an embodiment of this specification, a computing device is provided, including:

[0014] Memory and processor;

[0015] The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the above-mentioned image processing method are implemented.

[0016] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the steps of the above-mentioned image processing method are implemented.

[0017] According to a fifth aspect of the embodiments of this specification, a computer program is provided, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned image processing method.

[0018] An embodiment of the present specification implements an image processing method and device, wherein the image processing method includes obtaining an image containing a target object; inputting the image into an image processing model to obtain an object mask image, a probability of the target object existing in the object mask image, and a semantic segmentation image containing an object label; and determining the target object and the object label of the target object based on the object mask image, the probability of the target object existing in the object mask image, and the semantic segmentation image.

[0019] Specifically, the image processing method uses an image processing model to simultaneously predict the object mask image of each target object in the image and the semantic segmentation map of the entire image, that is, the same network is used to achieve the two tasks of target object recognition and target object parsing, and the target object and the object label of the target object are obtained quickly and accurately; there is no need to perform two-stage processing on the image, thus avoiding the situation where the analysis result is inaccurate due to the influence of the detector in the two-stage processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 This is a schematic diagram of a specific application scenario of an image processing method provided by an embodiment of this specification;

[0021] Figure 2 is a flow chart of a picture processing method provided by an embodiment of this specification;

[0022] Figure 3 It is a schematic diagram of a processing process of a picture processing method provided by an embodiment of this specification;

[0023] Figure 4 is a structural schematic diagram of a picture processing device provided by an embodiment of this specification;

[0024] Figure 5 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION

[0025] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.

[0026] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0027] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0028] First, the terms involved in one or more embodiments of this specification are explained.

[0029] Encoder: Encoder.

[0030] Decoder: decoder.

[0031] Patch Embedding: Image block mapping operation, through which the original image can be mapped from a two-dimensional image to a one-dimensional vector.

[0032] Transformer: A deep learning network structure based on the Encoder-Decoder structure model.

[0033] Swin Transformer model: is a Transformer that incorporates the CNN (convolutional neural network) sliding window concept. Limiting attention to a window can, on the one hand, introduce the locality of CNN convolution operations, and on the other hand, save computational effort.

[0034] stage: stage.

[0035] Patch Expand: Image block enlargement operation. Through this operation, the image can be enlarged.

[0036] Concat: concatenation operation refers to concatenating the outputs of the four stages along the channel dimension.

[0037] blocks: network modules, the structure is the same as that inside the stage.

[0038] semantic segmentation head: semantic segmentation head, used to output semantic segmentation result branch.

[0039] Instance segmentation head: Instance segmentation head, used to output instance segmentation result branch.

[0040] Drop "no person": The instance segmentation head outputs N masks, each of which represents the mask of a person. A threshold is set. If the average value of the mask is lower than the threshold, it means that the mask is not a human body.

[0041] Hadamard product: Hadamard product, which is the multiplication of corresponding positions in two matrices.

[0042] Ground truth: real sample.

[0043] inference: reasoning.

[0044] Human semantic parsing: It is a subtask of image semantic segmentation, which aims to perform pixel-level fine-grained segmentation of human images (for example, dividing body parts and clothing).

[0045] Instance level: Ordinary human body semantic parsing cannot distinguish the parts of different people and can only parse all the parts together; while instance-level human body parsing can parse each person separately.

[0046] In this specification, a method for processing an image is provided. This specification also relates to an image processing apparatus, a computing device, a computer-readable storage medium, and a computer program, which are described in detail one by one in the following embodiments.

[0047] In specific implementation, the image processing method can be applied to human body analysis scenes, and can also be applied to animal or other object analysis scenes, and this specification embodiment does not make any limitation on this. For ease of understanding, this specification embodiment takes the application of the image processing method to human body analysis scenes as an example for detailed description.

[0048] See also Figure 1 , Figure 1 A schematic diagram of a specific application scenario of an image processing method provided according to an embodiment of the present specification is shown.

[0049] Figure 1 The image processing method includes a picture to be processed 102 and a picture processing model including an encoder 104 and a decoder 106, wherein the picture to be processed 102 includes multiple target objects. The specific application scenarios of the picture processing method are different, and the target objects are also different. For example, if the picture processing method is applied to a human body analysis scene, the target object can be understood as a person; if the picture processing method is applied to an animal or vehicle analysis scene, the target object can be understood as an animal or a vehicle. The picture processing model can be understood as a pre-trained Swin Transformer model.

[0050] A specific description is given by taking the case where the image 102 to be processed includes multiple persons as an example.

[0051] The image 102 to be processed including multiple persons is input into the Swin Transformer model, and feature extraction is performed in the encoder 104 (Encoder) and the decoder 106 (Decoder) of the Swin Transformer model. Then, the extracted features are respectively input into the semantic segmentation head 108 (semantic segmentation head) and the instance segmentation head 110 (instance segmentation head) of the Swin Transformer model.

[0052] The semantic segmentation head outputs a semantic segmentation image of the image to be processed 102 , and the semantic segmentation image includes semantic analysis of each person's body parts, that is, each person's knees, hair, clothes, etc. are analyzed.

[0053] The instance segmentation head outputs a human body mask image of each person in the image 102 to be processed, and the probability that each human body mask image contains a human body.

[0054] The human body mask images with probabilities less than a preset probability threshold are filtered out, and the remaining human body mask images are used as target human body mask images and Hadamard product operations 112 are performed with the semantic segmentation images to obtain the parsed image 114 of each person in each target human body mask image, that is, the labels of each person's human body parts. The preset probability threshold can be set according to actual applications, and this specification does not impose any limitation on this.

[0055] In practical applications, the instance segmentation head outputs the mask (human mask image) of the image 102 to be processed, where each mask is a single-channel image (matrix) of H (height) x W (width), and the pixel range in the matrix is ​​generally between 0 and 1. The larger the value, the greater the probability that the pixel belongs to the human body. Because the output is the mask of N people, but not all pictures have so many people. For example, N = 12, but there are only 4 people in this picture. Ideally, only 4 of the 12 masks are valid, and the remaining 8 should all be invalid masks, or the values ​​of the remaining 8 masks are all low. Then you can set a preset probability threshold, such as 0.5 to filter out those invalid masks. In specific implementation, you can take the mean of the matrix as the value of the entire mask to compare with the preset probability threshold.

[0056] The image processing method provided in the embodiments of this specification uses the same network to implement the two tasks of human body recognition and human body analysis, and quickly and accurately obtains labels of human bodies and human body parts; there is no need to perform two-stage processing on the image, thus avoiding the situation where the analysis results are inaccurate due to the influence of the detector in the two-stage processing.

[0057] See also Figure 2 , Figure 2 A flowchart of a picture processing method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0058] Step 202: Acquire a picture containing a target object.

[0059] The specific application scenarios of the image processing method are different, and the target objects are also different. For example, when the image processing method is applied to a human body analysis scenario, the target object can be understood as a human, and when the image processing method is applied to an animal analysis scenario, the target object can be understood as an animal, etc. That is, the target object can be understood as any object to be processed, such as a person, an object, or an animal, etc.

[0060] The image containing the target object can be understood as an image of any size and format containing multiple target objects, such as a GIF image containing multiple human bodies.

[0061] Step 204: Input the image into an image processing model to obtain an object mask image, a probability of the target object existing in the object mask image, and a semantic segmentation image containing an object label.

[0062] Specifically, the image is input into the image processing model to obtain at least one object mask image, the probability of the target object existing in each object mask image, and a semantic segmentation image containing an object label; wherein the object label can be determined according to the target object, for example, if the target object is a human body, then the object label can be a person's knees, hair, clothes, eyes, etc.

[0063] In the specific implementation, it is necessary to pre-train an image processing model so that the object mask image, the probability of the target object existing in the object mask image, and the semantic segmentation image containing the object label can be obtained based on the pre-trained image processing model. The specific implementation method is as follows:

[0064] The training steps of the image processing model are as follows:

[0065] Acquire a sample image containing a target object and a sample label of the sample image, wherein the sample label is the target object contained in the sample image and an object attribute of the target object;

[0066] Segment the sample image according to a preset processing method to obtain a plurality of image block feature vectors of preset sizes;

[0067] Inputting the image block feature vector into the encoder and decoder of the image processing model for feature processing to obtain the target image feature of the sample image;

[0068] Inputting the target image features into the instance segmentation network and the semantic segmentation network of the image processing model respectively to obtain an object mask sample image and a semantic segmentation sample image;

[0069] The image processing model is obtained by training according to the object mask sample image, the semantic segmentation sample image and the sample labels of the sample image.

[0070] The specific explanation of the target object can be found in the above embodiments and will not be repeated here.

[0071] In practical applications, a plurality of sample images containing target objects are first obtained, and each sample image contains multiple target objects, as well as a sample label of each sample image, that is, the target objects contained in each sample image.

[0072] Then, the sample image is segmented according to a preset processing method to obtain a plurality of image block feature vectors of preset sizes. Specifically, the sample image is segmented according to a preset processing method to obtain a plurality of image block feature vectors of preset sizes, including:

[0073] The sample image is segmented according to the image block mapping operation, and the sample image is segmented into a plurality of image block feature vectors of preset sizes.

[0074] Among them, the image block mapping operation can be understood as Patch Embedding; the preset size can be set according to the actual application. If the patch is cut too large, it will affect the accuracy; the larger the patch size, the lower the model calculation amount, but the accuracy will also be lower; the smaller the patch, the higher the accuracy, but the calculation amount will also be larger; therefore, the preset size needs to be determined based on the comprehensive accuracy and calculation amount. This manual does not impose any restrictions on this, for example, setting the preset size to 4*4, etc.

[0075] Specifically, the sample image is segmented according to the image block mapping operation, and the sample image is segmented into a plurality of image block feature vectors of preset sizes. It can be understood that: the sample image is subjected to Patch Embedding, so that the original two-dimensional sample image can be converted into a series of one-dimensional Patch Embeddings.

[0076] In the embodiments of the present specification, a sample image is segmented by an image block mapping operation, and an image processing model is trained by using a plurality of one-dimensional image block feature vectors after segmentation, so that a better training result can be obtained.

[0077] After the sample image is segmented, the feature vector of each image block obtained after segmentation is input into the encoder and decoder of the image processing model for feature processing to obtain the target image features of the sample image. The specific implementation method is as follows:

[0078] The step of inputting the image block feature vector into an encoder and a decoder of a picture processing model for feature processing to obtain target image features of the sample picture includes:

[0079] Inputting the image block feature vector into an encoder of an image processing model for feature extraction to obtain initial image features of the sample image;

[0080] The initial image features are input into the decoder of the image processing model for feature processing to obtain the target image features of the sample image.

[0081] Specifically, the feature vector of each image block is input into the encoder of the image processing model for feature extraction to obtain the initial image features of the sample image; the initial image features are then input into the decoder of the image processing model for feature processing to obtain the target image features of the sample image.

[0082] In specific implementation, the encoder of the image processing model includes n feature processing stages, and n is a positive integer, such as 4; then each image block feature vector will be processed by the 4 feature processing stages of the encoder of the image processing model, and finally the initial image features of the sample image are determined according to the processing results. The specific implementation method is as follows:

[0083] The encoder includes n feature processing stages, where n is a positive integer;

[0084] Accordingly, the step of inputting the image block feature vector into an encoder of a picture processing model for feature extraction to obtain initial image features of the sample picture includes:

[0085] Inputting the image block feature vector into the i-th feature processing stage of the encoder of the picture processing model, wherein the initial value of i is 1;

[0086] In the i-th feature processing stage, the image block feature vector is reduced according to a preset size to obtain a reduced image block feature vector;

[0087] Determine whether i is less than n;

[0088] If not, then i is incremented by 1, and the i-th feature processing stage of inputting the reduced image block feature vector into the encoder of the picture processing model is continued;

[0089] The image block feature vectors of each feature processing stage are processed to obtain the initial image features of the sample image.

[0090] In practical applications, a detailed description is given by taking n as 4 as an example.

[0091] Specifically, an image block feature vector is input into the first feature processing stage of the encoder of the picture processing model, and the image block feature vector is reduced according to a preset size in the first feature processing stage to obtain a reduced image block feature vector; the reduced image block feature vector is then input into the second feature processing stage of the encoder of the picture processing model, and the image block feature vector is reduced according to a preset size in the second feature processing stage to obtain a reduced image block feature vector again, and so on, until the processing is terminated when i is greater than or equal to n, and then the image block feature vectors of each feature processing stage are processed to obtain the initial image features of the sample image.

[0092] For example, the size of the original sample image is 640*640, which is equivalent to taking every 4*4 as a block and outputting it as a whole. Then the input of the first feature processing stage becomes 160*160. When the first feature processing stage is given to the second feature processing stage, the image is reduced to 80*80, which is equivalent to outputting a size of 2*2 as a block. The second feature processing stage becomes 40*40 for the third feature processing stage, and the third feature processing stage becomes 20*20 for the fourth feature processing stage.

[0093] In the embodiments of this specification, the image processing model can be understood as a Swin Transformer model, and the encoder adopts the Swin Transformer model structure. The Swin Transformer model network can output scale features of four different stages when extracting image features; subsequently, the features proposed in these four stages can be upsampled and spliced ​​together along the channel dimension to obtain more accurate initial image features.

[0094] Therefore, the initial image features are determined by upsampling the image block feature vectors input at each feature processing stage and splicing them together along the channel dimension. The specific implementation method is as follows:

[0095] The step of processing the image block feature vectors of each feature processing stage to obtain the initial image features of the sample image includes:

[0096] Determine an image block feature vector for each feature processing stage except the first feature processing stage in the n feature processing stages;

[0097] Up-sampling the image block feature vectors of each feature processing stage except the first feature processing stage according to the feature size of the image block feature vectors of the first feature processing stage;

[0098] The image block feature vector of the first feature processing stage is concatenated with all the image block feature vectors after upsampling to obtain the initial image features of the sample image.

[0099] Among them, the purpose of upsampling is to enlarge the image.

[0100] Specifically, the image block feature vector of each feature processing stage except the first feature processing stage in the n feature processing stages is determined; then the image block feature vector of each feature processing stage except the first feature processing stage is upsampled (i.e., PatchExpand) according to the feature size of the image block feature vector of the first feature processing stage.

[0101] The image block feature vector of the first feature processing stage is concatenated with the feature vectors of all the image blocks after upsampling to obtain the initial image features of the sample image.

[0102] Continuing with the above example, if n is 4, then the image block feature vector of each feature processing stage except the first feature processing stage can be understood as the input image block feature vector of the second, third and fourth feature processing stages; then the feature size of the input image block feature vector of the second, third and fourth feature processing stages is upsampled, and then the input image block feature vector of the first feature processing stage is concatenated with the input image block feature vector of the second, third and fourth feature processing stages after upsampling to obtain the initial image features of the sample image.

[0103] That is, the output image size of the second feature processing stage is enlarged to the same size as the output image of the first feature processing stage; the third and fourth feature processing stages are similar operations.

[0104] Continuing with the above example, the input of the first feature processing stage is 160*160, the input of the second feature processing stage is 80*80, the input of the third stage is 40*40, and the input of the fourth stage is 20*20. Then the image sizes of the second, third, and fourth feature processing stages are all enlarged to 160*160.

[0105] Finally, the inputs of the four stages are concatenated along the channel dimension. For example, the input image block feature vector size of the first feature processing stage is 160x160x192, the input image block feature vector size of the second feature processing stage is 160x160x96 after upsampling, the input image block feature vector size of the third feature processing stage is 160x160x48 after upsampling, and the input image block feature vector size of the fourth feature processing stage is 160x160x24 after upsampling. After concatenation, it becomes 160x160x360.

[0106] In the embodiments of this specification, the image processing model is understood to be a Swin Transformer model. When the encoder adopts the Swin Transformer model structure for feature extraction, the image is first cut into several patches of preset sizes to become patch embeddings, and then the patch embeddings are input into an Encoder constructed according to the Swin Transformer model structure. The Encoder consists of four stages, and the scale of the extracted features is gradually reduced. The features proposed in the four stages are upsampled and spliced ​​together along the channel dimension to obtain relatively accurate initial image features of the sample image.

[0107] After obtaining the initial image features of the sample image, the initial image features are input into the decoder of the image processing model for feature extraction to obtain the target image features of the sample image. The specific implementation method is as follows:

[0108] The step of inputting the initial image features into the decoder of the image processing model for feature processing to obtain the target image features of the sample image includes:

[0109] The initial image features are input into the decoder of the image processing model for feature extraction, and up-sampled according to the size of the sample image to obtain the target image features of the sample image.

[0110] Among them, when the image processing model is understood as a Swin Transformer model, the decoder can be understood as being built using the Swin Transformer model structure. Its network structure is the same as the structure of each feature processing stage in the encoder, but does not require four stages of downsampling. It only further extracts the features after the encoder upsampling and splicing, and the feature size remains unchanged.

[0111] In specific implementation, after obtaining the target image features of the sample image, the target image features are input into the instance segmentation network and the semantic segmentation network of the image processing model to obtain the object mask sample image and the semantic segmentation sample image of the sample image. Subsequently, the image processing model can be obtained by training the sample labels of the object mask sample image, the semantic segmentation sample image and the sample image. The specific implementation method is as follows:

[0112] The step of obtaining the image processing model by training the sample labels of the object mask sample image, the semantic segmentation sample image, and the sample image includes:

[0113] Determining the number of images of the object mask sample images and the number of objects of the target objects included in the sample images;

[0114] In a case where the number of images is greater than the number of objects, matching the object mask sample images with target objects included in the sample images;

[0115] Determine the object mask sample images with corresponding relationships as target mask sample images, and determine the object mask sample images with no corresponding relationships as background mask sample images;

[0116] The image processing model is obtained by training according to the target mask sample image, the background mask sample image, the semantic segmentation sample image and the sample labels of the sample image.

[0117] In practical applications, firstly, the number of images of the object mask sample images and the number of objects of the target objects contained in the sample images are determined; when it is determined that the number of images is greater than the number of objects, it can be determined that there are object mask sample images that do not contain the target objects. At this time, the object mask sample images are matched with the target objects contained in the sample images, and the object mask sample images with corresponding relationships are determined as target mask sample images, that is, object mask sample images containing the target objects; the object mask sample images without corresponding relationships are determined as background mask sample images, that is, object mask sample images that do not contain the target objects; finally, according to the target mask sample images, the background mask sample images, the semantic segmentation sample images and the object attributes of the target objects contained in the sample images, the semantic segmentation sample images are determined as the background mask sample images. The image processing model is obtained by training based on the properties of the human body parts (such as the names of human body parts, eyes, hair, mouth, tops, pants, etc.), that is, the instance segmentation network of the image processing model is trained according to the target mask sample image and the background mask sample image, so that the instance segmentation network of the image processing model after training can predict the human body mask image in each image; the semantic segmentation network of the image processing model is trained according to the semantic segmentation sample image and the object attributes of the target object contained in the sample image, and the semantic segmentation network is adjusted through the relationship between the object attributes of the real target object contained in the sample image and the object attributes of the target object predicted in the semantic segmentation sample image, so that the semantic segmentation network of the image processing model after training can predict the semantic analysis of the human body in each image.

[0118] Specifically, the target image features of the sample image obtained by the encoder and decoder are input into the two heads of the image processing model (i.e., the instance segmentation network and the semantic segmentation network), where the instance segmentation network realizes instance segmentation of the human body, and the semantic segmentation network realizes semantic segmentation. The instance segmentation head outputs a HxW image of N channels, where each channel represents a mask image of each person, and N represents the maximum number of people in a picture. A maximum value N can be set during model training, which means that the model can only recognize N people at most. If there are more than N people in the picture who need precise part segmentation, the remaining people cannot be segmented. Generally speaking, there are a maximum of 12 people in a picture. If there are too many people, each person will be small, which will not be very friendly to the segmentation of human body parts, and the parsing results will also be poor.

[0119] When training an image processing model, the predicted human mask image and the Groundtruth (target object in the sample image) can be matched one by one using the binary matching method. If the number of target objects in the sample image is less than N, the remaining human mask images can be matched with the background mask image with all zeros.

[0120] In the embodiments of the present specification, sample images containing several human bodies and sample labels of the sample images (the sample labels are the target objects contained in the sample images and the semantic analysis of each part of each target object in the sample images) are trained through the encoder, decoder and two heads of the image processing model to obtain an image processing model with higher prediction effect. Subsequently, the semantic analysis of the human body and each part of the human body in each image can be quickly and accurately obtained based on the image processing model.

[0121] Step 206: Determine the target object and the object label of the target object according to the object mask image, the probability that the target object exists in the object mask image, and the semantic segmentation image.

[0122] Specifically, after obtaining the object mask image of the picture containing the target object, the probability of the target object existing in each object mask image, and the semantic segmentation image containing the object label, the target object and the object label of the target object can be quickly determined according to the object mask image of the picture containing the target object, the probability of the target object existing in each object mask image, and the semantic segmentation image containing the object label. The specific implementation method is as follows:

[0123] The determining the target object and the object label of the target object according to the object mask image, the probability that the target object exists in the object mask image, and the semantic segmentation image comprises:

[0124] determining a target object mask image from the object mask images according to a probability that the target object exists in the object mask image;

[0125] The target object and the object label of the target object are determined according to the target object mask image and the semantic segmentation image.

[0126] The target object mask image may be understood as an object mask image in which the probability of the target object existing is relatively high.

[0127] In specific implementation, firstly, a target object mask image is determined from a plurality of object mask images according to the probability of the target object existing in the object mask image; then, the target object and the object label of the target object are accurately determined according to the target object mask image and the semantic segmentation image.

[0128] In practical applications, the target object mask image can be determined based on the probability of the target object existing in the object mask image. According to the probability of the target object existing in the object mask image, an object mask image with a higher probability of the target object existing can be selected as the target object mask image, so that the subsequent determination of the target object is more accurate. The specific implementation method is as follows:

[0129] The step of determining a target object mask image from the object mask image according to the probability that the target object exists in the object mask image comprises:

[0130] According to the probability of the target object existing in the object mask image, an object mask image in the object mask image whose probability is less than a preset probability threshold is determined as a target object mask image.

[0131] The preset probability threshold may be set according to actual application, for example, to 0.7 or 0.8.

[0132] Taking the preset probability threshold of 0.7 as an example, the probability of the target object existing in each object mask image is first determined, and then the probability of the target object existing in each object mask image is compared with the preset probability threshold, and the object mask image with a probability less than the preset probability threshold is determined as the target object mask image. Subsequently, the target object and the object label of each target object can be accurately obtained based on the target object mask image.

[0133] Specifically, determining the target object and the object label of the target object according to the target object mask image and the semantic segmentation image includes:

[0134] determining the target object according to the target object mask image;

[0135] A Hadamard product operation is performed on the target object mask image and the semantic segmentation image to determine an object label of the target object.

[0136] The target object is determined from the target object mask image, and then the target object mask image and the semantic segmentation image are subjected to a Hadamard product operation to determine the object label of each target object.

[0137] In specific implementation, the image processing model instance segmentation outputs a mask (object mask image), and the mask is a HxW single-channel image (matrix). The range of pixels in the matrix is ​​generally between 0 and 1. The larger the value, the greater the probability that the pixel belongs to the target object. Since the image processing model outputs masks of N target objects, but not all images contain so many target objects. For example, N = 12, but there are only 4 people in this picture. Ideally, only 4 of the 12 masks are valid, and the remaining 8 masks should all be invalid masks or the values ​​of the masks are low. In order to ensure the efficiency of the calculation and the accuracy of the calculation results, a threshold can be set in advance, such as a preset threshold of 0.5, and invalid masks can be filtered out by the preset threshold.

[0138] Specifically, the mean of the matrix can be taken as the value of the entire mask to preset the threshold comparison. For example, the matrix A = [[0.7, 0.8], [0.8, 0.9]], the mean of the matrix is ​​the sum and average of all elements, that is, (0.7 + 0.8 + 0.8 + 0.9) / 4 = 0.8; if the preset threshold is 0.5, the matrix will not be filtered out.

[0139] In the embodiments of the present specification, the image processing method uses an image processing model to simultaneously predict the object mask image of each target object in the image and the semantic segmentation map of the entire image, that is, the same network is used to implement the two tasks of target object recognition and target object parsing, and the target object and the object label of the target object are obtained quickly and accurately; there is no need to perform two-stage processing on the image, thus avoiding the situation where the analysis result is inaccurate due to the influence of the detector in the two-stage processing.

[0140] The following combination Figure 3 , taking the application of the image processing method provided in this specification in human body analysis as an example, the image processing method is further described. Figure 3 A schematic diagram of a processing process of an image processing method provided by an embodiment of this specification is shown.

[0141] Figure 3Schematic diagram of the processing process of the image processing method in , which is composed of an encoder, a decoder, a head and inference.

[0142] In the specific implementation, the image containing multiple human bodies is subjected to an image block mapping operation (Patch Embedding), that is, the image is cut into 4x4 patches and converted into patch embeddings; then the patch embeddings are input into the Encoder constructed by SwinTransformer, which consists of four stages (i.e., Swin Transformer stage1, Swin Transformer stage2, Swin Transformer stage3, and Swin Transformer stage4). The scale of the features extracted by the four stages of the Encoder is gradually reduced, and then the features extracted by the four stages of the Encoder are upsampled (Patch Expand) respectively and spliced ​​together along the channel dimension, and then the spliced ​​features are input into the block of the Decoder constructed by SwinTransformer for feature extraction, and finally upsampled to the original image size.

[0143] Secondly, the features extracted by the Encoder and Decoder are output to two heads (i.e., the Semanticsegmentation head and the Instance segmentation head in the figure). The semantic segmentation head is used to implement semantic segmentation, and the instance segmentation head is used to implement instance segmentation of the human body. The instance segmentation head outputs an HxW image of N channels. Each channel represents a mask map of each person, and N represents the maximum number of people in a picture. The semantic segmentation head outputs the part label of each human body (such as knees, hair, clothes, etc.) in the picture containing multiple human bodies; then the predicted human body mask is filtered out according to the preset threshold to remove the background mask map (i.e. Figure 3 Then, the mask map of each person is multiplied by the predicted semantic segmentation map to obtain the parsed map of each human body in the picture containing the human body.

[0144] The image processing method provided in the embodiments of this specification uses a network to simultaneously predict the mask image of each person in the image and the semantic segmentation image of the entire image, thereby realizing the instance-level human body parsing task without the need for two stages or complicated post-processing. Furthermore, by decomposing the instance-level human body parsing task into global semantic segmentation and human body instance segmentation tasks, the same network is used to simultaneously realize these two tasks, thereby making the network structure simple and achieving better prediction results.

[0145] Corresponding to the above method embodiment, this specification also provides an image processing device embodiment, Figure 4 FIG. 1 is a schematic diagram showing the structure of a picture processing device provided by an embodiment of the present specification. Figure 4 As shown, the device comprises:

[0146] The picture acquisition module 402 is configured to acquire a picture containing a target object;

[0147] A model processing module 404 is configured to input the image into an image processing model to obtain an object mask image, a probability of a target object existing in the object mask image, and a semantic segmentation image including an object label;

[0148] The label determination module 406 is configured to determine the target object and the object label of the target object according to the object mask image, the probability that the target object exists in the object mask image, and the semantic segmentation image.

[0149] Optionally, the tag determination module 406 is further configured to:

[0150] determining a target object mask image from the object mask images according to a probability that the target object exists in the object mask image;

[0151] The target object and the object label of the target object are determined according to the target object mask image and the semantic segmentation image.

[0152] Optionally, the tag determination module 406 is further configured to:

[0153] According to the probability of the target object existing in the object mask image, an object mask image in the object mask image whose probability is less than a preset probability threshold is determined as a target object mask image.

[0154] Optionally, the tag determination module 406 is further configured to:

[0155] determining the target object according to the target object mask image;

[0156] A Hadamard product operation is performed on the target object mask image and the semantic segmentation image to determine an object label of the target object.

[0157] Optionally, the model processing module 404 is further configured to:

[0158] Acquire a sample image containing a target object and a sample label of the sample image, wherein the sample label is the target object contained in the sample image and an object attribute of the target object;

[0159] Segment the sample image according to a preset processing method to obtain a plurality of image block feature vectors of preset sizes;

[0160] Inputting the image block feature vector into the encoder and decoder of the image processing model for feature processing to obtain the target image feature of the sample image;

[0161] Inputting the target image features into the instance segmentation network and the semantic segmentation network of the image processing model respectively to obtain an object mask sample image and a semantic segmentation sample image;

[0162] The image processing model is obtained by training according to the object mask sample image, the semantic segmentation sample image and the sample labels of the sample image.

[0163] Optionally, the model processing module 404 is further configured to:

[0164] The sample image is segmented according to the image block mapping operation, and the sample image is segmented into a plurality of image block feature vectors of preset sizes.

[0165] Optionally, the model processing module 404 is further configured to:

[0166] Inputting the image block feature vector into an encoder of an image processing model for feature extraction to obtain initial image features of the sample image;

[0167] The initial image features are input into the decoder of the image processing model for feature processing to obtain the target image features of the sample image.

[0168] Optionally, the encoder includes n feature processing stages, and n is a positive integer;

[0169] Accordingly, the model processing module 404 is further configured to:

[0170] Inputting the image block feature vector into the i-th feature processing stage of the encoder of the image processing model, wherein the initial value of i is 1;

[0171] In the i-th feature processing stage, the image block feature vector is reduced according to a preset size to obtain a reduced image block feature vector;

[0172] Determine whether i is less than n;

[0173] If not, then i is incremented by 1, and the i-th feature processing stage of inputting the reduced image block feature vector into the encoder of the image processing model is continued;

[0174] The image block feature vectors of each feature processing stage are processed to obtain the initial image features of the sample image.

[0175] Optionally, the model processing module 404 is further configured to:

[0176] Determine an image block feature vector for each feature processing stage except the first feature processing stage in the n feature processing stages;

[0177] Up-sampling the image block feature vectors of each feature processing stage except the first feature processing stage according to the feature size of the image block feature vectors of the first feature processing stage;

[0178] The image block feature vector of the first feature processing stage is concatenated with all the image block feature vectors after upsampling to obtain the initial image features of the sample image.

[0179] Optionally, the model processing module 404 is further configured to:

[0180] The initial image features are input into the decoder of the image processing model for feature extraction, and up-sampled according to the size of the sample image to obtain the target image features of the sample image.

[0181] Optionally, the model processing module 404 is further configured to:

[0182] Determining the number of images of the object mask sample images and the number of objects of the target objects included in the sample images;

[0183] In a case where the number of images is greater than the number of objects, matching the object mask sample images with target objects included in the sample images;

[0184] Determine the object mask sample images with corresponding relationships as target mask sample images, and determine the object mask sample images with no corresponding relationships as background mask sample images;

[0185] The image processing model is obtained by training according to the target mask sample image, the background mask sample image, the semantic segmentation sample image and the sample labels of the sample image.

[0186] In the embodiments of the present specification, the image processing device uses an image processing model to simultaneously predict the object mask image of each target object in the image and the semantic segmentation map of the entire image, that is, the same network is used to implement the two tasks of target object recognition and target object parsing, and the target object and the object label of the target object are obtained quickly and accurately; there is no need to perform two-stage processing on the image, thus avoiding the situation where the analysis result is inaccurate due to the influence of the detector in the two-stage processing.

[0187] The above is a schematic scheme of an image processing device of this embodiment. It should be noted that the technical scheme of the image processing device and the technical scheme of the above-mentioned image processing method belong to the same concept, and the details not described in detail in the technical scheme of the image processing device can be referred to the description of the technical scheme of the above-mentioned image processing method.

[0188] Figure 5 The structure block diagram of a computing device 500 provided according to an embodiment of the present specification is shown. The components of the computing device 500 include but are not limited to a memory 510 and a processor 520. The processor 520 is connected to the memory 510 via a bus 530, and the database 550 is used to store data.

[0189] The computing device 500 also includes an access device 540 that enables the computing device 500 to communicate via one or more networks 560. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 540 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.

[0190] In one embodiment of the present specification, the above components of the computing device 500 and Figure 5 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 5 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.

[0191] The computing device 500 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 500 may also be a mobile or stationary server.

[0192] The processor 520 is used to execute the following computer executable instructions, which implement the steps of the above-mentioned image processing method when executed by the processor.

[0193] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above-mentioned image processing method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above-mentioned image processing method.

[0194] An embodiment of the present specification further provides a computer-readable storage medium storing computer-executable instructions, which can implement the steps of the above-mentioned image processing method when executed by a processor.

[0195] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned image processing method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned image processing method.

[0196] An embodiment of the present specification further provides a computer program, wherein when the computer program is executed in a computer, the computer is caused to execute the steps of the above-mentioned image processing method.

[0197] The above is an illustrative solution of a computer program of this embodiment. It should be noted that the technical solution of the computer program and the technical solution of the above-mentioned image processing method belong to the same concept, and the details not described in detail in the technical solution of the computer program can be referred to the description of the technical solution of the above-mentioned image processing method.

[0198] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0199] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0200] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0201] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0202] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.

Claims

1. A method for processing an image, comprising: Get the image containing the target object; Inputting the image into an image processing model to obtain an object mask image, a probability of the target object existing in the object mask image, and a semantic segmentation image containing an object label, The training steps of the image processing model are as follows: Acquire a sample image containing a target object and a sample label of the sample image, wherein the sample label is the target object contained in the sample image and an object attribute of the target object, The sample image is segmented according to a preset processing method to obtain a plurality of image block feature vectors of preset sizes, Input the image block feature vector into the encoder and decoder of the image processing model for feature processing to obtain the target image feature of the sample image, Input the target image features into the instance segmentation network and the semantic segmentation network of the image processing model respectively to obtain an object mask sample image and a semantic segmentation sample image, The image processing model is obtained by training the object mask sample image, the semantic segmentation sample image, and the sample labels of the sample image; The target object and the object label of the target object are determined according to the object mask image, the probability that the target object exists in the object mask image, and the semantic segmentation image.

2. The image processing method according to claim 1, wherein determining the target object and the object label of the target object according to the object mask image, the probability of the target object existing in the object mask image, and the semantic segmentation image comprises: determining a target object mask image from the object mask images according to a probability that the target object exists in the object mask image; The target object and the object label of the target object are determined according to the target object mask image and the semantic segmentation image.

3. The image processing method according to claim 2, wherein the step of determining the target object mask image from the object mask image according to the probability that the target object exists in the object mask image comprises: According to the probability of the target object existing in the object mask image, an object mask image in the object mask image whose probability is less than a preset probability threshold is determined as a target object mask image.

4. The image processing method according to claim 2, wherein determining the target object and the object label of the target object according to the target object mask image and the semantic segmentation image comprises: determining the target object according to the target object mask image; A Hadamard product operation is performed on the target object mask image and the semantic segmentation image to determine an object label of the target object.

5. The image processing method according to claim 1, wherein the step of segmenting the sample image according to a preset processing method to obtain a plurality of image block feature vectors of preset sizes comprises: The sample image is segmented according to the image block mapping operation, and the sample image is segmented into a plurality of image block feature vectors of preset sizes.

6. The image processing method according to claim 1 or 5, wherein the step of inputting the image block feature vector into an encoder and a decoder of an image processing model for feature processing to obtain target image features of the sample image comprises: Inputting the image block feature vector into an encoder of an image processing model for feature extraction to obtain initial image features of the sample image; The initial image features are input into the decoder of the image processing model for feature processing to obtain the target image features of the sample image.

7. The image processing method according to claim 6, wherein the encoder comprises n feature processing stages, and n is a positive integer; Accordingly, the step of inputting the image block feature vector into an encoder of a picture processing model for feature extraction to obtain initial image features of the sample picture includes: Inputting the image block feature vector into the i-th feature processing stage of the encoder of the picture processing model, wherein the initial value of i is 1; In the i-th feature processing stage, the image block feature vector is reduced according to a preset size to obtain a reduced image block feature vector; Determine whether i is less than n; If not, then i is incremented by 1, and the i-th feature processing stage of inputting the reduced image block feature vector into the encoder of the picture processing model is continued; The image block feature vectors of each feature processing stage are processed to obtain the initial image features of the sample image.

8. The image processing method according to claim 7, wherein the step of processing the image block feature vectors at each feature processing stage to obtain the initial image features of the sample image comprises: Determine an image block feature vector for each feature processing stage except the first feature processing stage in the n feature processing stages; Up-sampling the image block feature vectors of each feature processing stage except the first feature processing stage according to the feature size of the image block feature vectors of the first feature processing stage; The image block feature vector of the first feature processing stage is concatenated with all the image block feature vectors after upsampling to obtain the initial image features of the sample image.

9. The image processing method according to claim 6, wherein the step of inputting the initial image features into the decoder of the image processing model for feature processing to obtain the target image features of the sample image comprises: The initial image features are input into the decoder of the image processing model for feature extraction, and up-sampled according to the size of the sample image to obtain the target image features of the sample image.

10. The image processing method according to claim 1, wherein the image processing model is obtained by training according to the object mask sample image, the semantic segmentation sample image and the sample label of the sample image, comprising: Determining the number of images of the object mask sample images and the number of objects of the target objects included in the sample images; In a case where the number of images is greater than the number of objects, matching the object mask sample images with target objects included in the sample images; Determine the object mask sample images with corresponding relationships as target mask sample images, and determine the object mask sample images with no corresponding relationships as background mask sample images; The image processing model is obtained by training according to the target mask sample image, the background mask sample image, the semantic segmentation sample image and the sample labels of the sample image.

11. A picture processing device, comprising: A picture acquisition module, configured to acquire a picture containing a target object; a model processing module configured to input the image into an image processing model, obtain an object mask image, a probability of the target object existing in the object mask image, and a semantic segmentation image containing an object label, The training steps of the image processing model are as follows: Acquire a sample image containing a target object and a sample label of the sample image, wherein the sample label is the target object contained in the sample image and an object attribute of the target object, The sample image is segmented according to a preset processing method to obtain a plurality of image block feature vectors of preset sizes, Input the image block feature vector into the encoder and decoder of the image processing model for feature processing to obtain the target image feature of the sample image, Input the target image features into the instance segmentation network and the semantic segmentation network of the image processing model respectively to obtain an object mask sample image and a semantic segmentation sample image, The image processing model is obtained by training the object mask sample image, the semantic segmentation sample image, and the sample labels of the sample image; The label determination module is configured to determine the target object and the object label of the target object according to the object mask image, the probability that the target object exists in the object mask image, and the semantic segmentation image.

12. A computing device comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the image processing method according to any one of claims 1 to 10 are implemented.

13. A computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the image processing method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • System and method for dense human body posture estimation based on mask-RCNN

    CN110008915A

  • Image processing method and device, electronic equipment and computer readable storage medium

    CN111260666A

  • Panoramic segmentation method, system and device based on graph neural network and storage medium

    CN111428726A

  • Foreground target extraction method and device

    CN111833372A

  • Special clothing picture conversion method, terminal equipment and storage medium

    CN112419249A