Image processing method, device, electronic device and storage medium
Through the mask prediction model and the mask quality unified model, the problem of low image segmentation efficiency, poor fineness and high cost in the prior art is solved, and the image segmentation effect with high precision and low cost is achieved.
Patent Information
- Application Number
- CN202010145504.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-05
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2040-03-05
AI Technical Summary
The existing edge-based image segmentation method is inefficient, has poor fineness, and is costly, especially requires a large amount of fine labeling data to train the model.
By using the mask prediction model and the mask quality unified model, the image outline data is first obtained, then the fineness of the outline data is adjusted, and finally the model is obtained through the target image to generate the final target image.
This improves the fineness of image segmentation, reduces the cost of image segmentation, and avoids dependence on a large amount of fine label data.
Smart Images

Figure CN113362351B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and specifically to an image processing method, and also to an image processing device, an electronic device, and a storage medium. Background Art
[0002] Image segmentation is widely used in poster design, ID photos, image editing, medical image processing and other fields. Image segmentation is a basic operation in image processing and editing. It is the process of dividing an image into several specific regions with unique properties and proposing targets of interest. Existing image segmentation methods include region-based segmentation methods, edge-based segmentation methods, etc. Among them, the basic process of edge-based segmentation methods is: first, obtain the edge of the target image in the image to be processed, and then segment the image according to the edge of the target image to obtain the target image.
[0003] Existing edge-based segmentation methods can generally be divided into the following categories: the first category is interactive cutouts, such as cutouts based on computer image processing software; the second category is intelligent cutouts, such as automatic intelligent cutouts through online cutout software; and the third category is deep learning-based cutouts. Among the above-mentioned existing edge-based segmentation methods, the first category of segmentation methods requires a lot of user participation, is inefficient, and has poor precision; the second category of segmentation methods does not require a lot of user participation, but the effect is relatively general, and usually cannot finely segment the image; the third category of segmentation methods requires obtaining the fine contour of the target image in the image to be processed, so that a large number of sample images with finely labeled sample target image contour data are used to train the image segmentation model, resulting in a high cost for graphic segmentation. Summary of the invention
[0004] The present application provides an image processing method, device, electronic device and storage medium to improve the precision of image segmentation and reduce the cost of graphic segmentation.
[0005] The present application provides an image processing method, comprising:
[0006] Obtaining an image to be processed;
[0007] Inputting the image to be processed into a mask prediction model to obtain a first mask image corresponding to a target object in the image to be processed, wherein the mask prediction model is used to obtain image contour data corresponding to the target object according to the image to be processed, and obtain the first mask image according to the image contour data of the target object;
[0008] Inputting the first mask image and the image to be processed into a unified mask quality model to obtain a second mask image, wherein the unified mask quality model is used to adjust the fineness of the image contour data of the first mask image to a target fineness, and obtain a second mask image whose image semantic information is consistent with the image semantic information of the image to be processed;
[0009] The image to be processed and the second mask image are input into a target image acquisition model to obtain an image corresponding to the target object. The target image acquisition model is used to obtain an image corresponding to the target object based on the image to be processed and the second mask image.
[0010] Optionally, obtaining a first mask image corresponding to the target object in the image to be processed includes:
[0011] Obtaining image contour data corresponding to the target object;
[0012] The first mask image is obtained according to the image contour data of the target object.
[0013] Optionally, obtaining image contour data corresponding to the target object includes:
[0014] Downsampling the image to be processed to obtain a downsampled image to be processed;
[0015] According to the downsampled image to be processed, image contour data corresponding to the target object is obtained.
[0016] Optionally, downsampling the image to be processed to obtain the downsampled image to be processed includes:
[0017] Obtaining a specified downsampling coefficient for the image to be processed;
[0018] The image to be processed is downsampled according to the specified downsampling coefficient to obtain the downsampled image to be processed.
[0019] Optionally, obtaining image contour data corresponding to the target object based on the downsampled image to be processed includes: performing image contour extraction on the target object in the downsampled image to be processed to obtain image contour data corresponding to the target object.
[0020] Optionally, the method further includes: providing an image corresponding to the target object to a client.
[0021] Optionally, the method further includes: obtaining a request message sent by the client to obtain an image corresponding to the target object;
[0022] The providing the image corresponding to the target object to the client includes: providing the image corresponding to the target object to the client in response to the request message.
[0023] Optionally, it further includes: displaying an image corresponding to the target object. Optionally, the step of inputting the first mask image and the image to be processed into a unified mask quality model to obtain a second mask image includes: if the fineness of the image contour data of the first mask image is less than the target fineness, the fineness of the image contour data of the first mask image is increased to the target fineness to obtain the second mask image.
[0024] Optionally, adjusting the fineness of the image contour data of the first mask image to a target fineness to obtain a second mask image includes: if the fineness of the image contour data of the first mask image is greater than the target fineness, reducing the fineness of the image contour data of the first mask image to the target fineness to obtain a second mask image.
[0025] Optionally, also include:
[0026] Obtaining the fineness of the image contour data of the first mask image;
[0027] The fineness of the image contour data of the first mask image is compared with the target fineness.
[0028] Optionally, also include:
[0029] Obtaining a sample image, and obtaining a sample first mask image corresponding to a target object in the sample image;
[0030] Obtaining a target second mask image for the sample image and the sample first mask image;
[0031] The unified mask quality model is obtained according to the sample image, the sample first mask image and the target second mask image.
[0032] Optionally, also include:
[0033] Obtaining a sample image, and obtaining a sample second mask image corresponding to the target object in the sample image;
[0034] For the sample image and the sample second mask image, obtaining a target image corresponding to the target object in the sample image;
[0035] A target image acquisition model is obtained according to the sample image, the sample second mask image, and the target image.
[0036] In another aspect, the present application further provides an image processing device, comprising:
[0037] A unit for obtaining an image to be processed, used for obtaining an image to be processed;
[0038] a first mask image obtaining unit, configured to input the image to be processed into a mask prediction model to obtain a first mask image corresponding to a target object in the image to be processed, wherein the mask prediction model is configured to obtain image contour data corresponding to the target object according to the image to be processed, and obtain the first mask image according to the image contour data of the target object;
[0039] a second mask image obtaining unit, configured to input the first mask image and the image to be processed into a unified mask quality model to obtain a second mask image, wherein the unified mask quality model is configured to adjust the fineness of the image contour data of the first mask image to a target fineness to obtain a second mask image whose image semantic information is consistent with the image semantic information of the image to be processed;
[0040] The target image acquisition unit is used to input the image to be processed and the second mask image into a target image acquisition model to obtain an image corresponding to the target object. The target image acquisition model is used to obtain an image corresponding to the target object based on the image to be processed and the second mask image.
[0041] In another aspect, the present application further provides an electronic device, comprising:
[0042] Processor; and
[0043] A memory is used to store a program for an image processing method. After the device is powered on and the program for the image processing method is run by the processor, the following steps are performed:
[0044] Obtaining an image to be processed;
[0045] Inputting the image to be processed into a mask prediction model to obtain a first mask image corresponding to a target object in the image to be processed, wherein the mask prediction model is used to obtain image contour data corresponding to the target object according to the image to be processed, and obtain the first mask image according to the image contour data of the target object;
[0046] Inputting the first mask image and the image to be processed into a unified mask quality model to obtain a second mask image, wherein the unified mask quality model is used to adjust the fineness of the image contour data of the first mask image to a target fineness, and obtain a second mask image whose image semantic information is consistent with the image semantic information of the image to be processed;
[0047] The image to be processed and the second mask image are input into a target image acquisition model to obtain an image corresponding to the target object. The target image acquisition model is used to obtain an image corresponding to the target object based on the image to be processed and the second mask image.
[0048] In another aspect, the present application further provides a storage device storing a program for the image processing method, wherein the program is executed by a processor to perform the following steps:
[0049] Obtaining an image to be processed;
[0050] Inputting the image to be processed into a mask prediction model to obtain a first mask image corresponding to a target object in the image to be processed, wherein the mask prediction model is used to obtain image contour data corresponding to the target object according to the image to be processed, and obtain the first mask image according to the image contour data of the target object;
[0051] Inputting the first mask image and the image to be processed into a unified mask quality model to obtain a second mask image, wherein the unified mask quality model is used to adjust the fineness of the image contour data of the first mask image to a target fineness, and obtain a second mask image whose image semantic information is consistent with the image semantic information of the image to be processed;
[0052] The image to be processed and the second mask image are input into a target image acquisition model to obtain an image corresponding to the target object. The target image acquisition model is used to obtain an image corresponding to the target object based on the image to be processed and the second mask image.
[0053] On the other hand, the present application also provides a processing method for a mask prediction model, including:
[0054] Obtain a sample image;
[0055] For the sample image, obtaining first image contour data and second image contour data corresponding to the target object in the sample image, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches the specified fineness threshold;
[0056] obtaining a mask image corresponding to the target object when the first image contour data is obtained, and obtaining a mask image corresponding to the target object when the second image contour data is obtained;
[0057] A mask prediction model is obtained based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained. The mask prediction model is used to obtain the image contour data corresponding to the target object in the image to be processed based on the image to be processed, and to obtain a first mask image corresponding to the target object based on the image contour data of the target object.
[0058] Optionally, the obtaining, for the sample image, first image contour data and second image contour data corresponding to the target object in the sample image includes:
[0059] Downsampling the sample image to obtain a downsampled sample image;
[0060] The first image contour data and the second image contour data are obtained according to the downsampled sample image.
[0061] Optionally, downsampling the sample image to obtain a downsampled sample image includes:
[0062] Obtaining a specified downsampling coefficient for the sample image;
[0063] The sample image is downsampled according to the specified downsampling coefficient to obtain a downsampled sample image.
[0064] Optionally, obtaining the first image contour data and the second image contour data according to the downsampled sample image includes: performing image contour extraction on the target object in the downsampled sample image to obtain the first image contour data and the second image contour data.
[0065] On the other hand, the present application further provides a processing device for a mask prediction model, comprising:
[0066] A sample image obtaining unit, used for obtaining a sample image;
[0067] An image contour obtaining unit, configured to obtain, for the sample image, first image contour data and second image contour data corresponding to a target object in the sample image, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches a specified fineness threshold;
[0068] a mask image obtaining unit, configured to obtain a mask image corresponding to the target object when obtaining the first image contour data, and to obtain a mask image corresponding to the target object when obtaining the second image contour data;
[0069] A mask prediction model obtaining unit is used to obtain a mask prediction model based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained. The mask prediction model is used to obtain image contour data corresponding to the target object in the image to be processed based on the image to be processed, and to obtain a first mask image corresponding to the target object based on the image contour data of the target object.
[0070] In another aspect, the present application further provides an electronic device, comprising:
[0071] Processor; and
[0072] A memory is used to store a program for a processing method for a mask prediction model. After the device is powered on and the processor runs the program for the processing method for the mask prediction model, the following steps are performed:
[0073] Obtain a sample image;
[0074] For the sample image, obtaining first image contour data and second image contour data corresponding to the target object in the sample image, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches the specified fineness threshold;
[0075] obtaining a mask image corresponding to the target object when the first image contour data is obtained, and obtaining a mask image corresponding to the target object when the second image contour data is obtained;
[0076] A mask prediction model is obtained based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained. The mask prediction model is used to obtain the image contour data corresponding to the target object in the image to be processed based on the image to be processed, and to obtain a first mask image corresponding to the target object based on the image contour data of the target object.
[0077] On the other hand, the present application further provides a storage device storing a program for a processing method for a mask prediction model, wherein the program is executed by a processor to perform the following steps:
[0078] Obtain a sample image;
[0079] For the sample image, obtaining first image contour data and second image contour data corresponding to the target object in the sample image, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches the specified fineness threshold;
[0080] obtaining a mask image corresponding to the target object when the first image contour data is obtained, and obtaining a mask image corresponding to the target object when the second image contour data is obtained;
[0081] A mask prediction model is obtained based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained. The mask prediction model is used to obtain the image contour data corresponding to the target object in the image to be processed based on the image to be processed, and to obtain a first mask image corresponding to the target object based on the image contour data of the target object.
[0082] Compared with the prior art, this application has the following advantages:
[0083] The image processing method provided by the present application, after the image to be processed is input into the mask prediction model, the mask prediction model obtains the image contour data corresponding to the target object according to the image to be processed, and obtains the first mask image according to the image contour data of the target object; after obtaining the first mask image, the fineness of the image contour data of the first mask image is further adjusted to the target fineness, and the second mask image is obtained, the target fineness is data determined according to the first fineness interval and the second fineness interval, and the image corresponding to the target object is obtained according to the image to be processed and the second mask image. The data processing method provided by the present application first obtains the first mask image according to the image contour data of the target object, and then adjusts the fineness of the image contour data of the first mask image to the target fineness to obtain the second mask image, so as to ensure that the fineness of the image corresponding to the target object is obtained according to the image to be processed and the second mask image. When obtaining the first mask image according to the image contour data of the target object, it is not necessary to require the image contour data of the target object to have a relatively high fineness, so there is no need to use a large number of sample images with finely annotated image contour data to train the mask prediction model, reducing the cost of image segmentation.
[0084] The present application provides a processing method for a mask prediction model. First, a sample image is obtained; secondly, for the sample image, first image contour data and second image contour data corresponding to a target object in the sample image are obtained, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches a specified fineness threshold; thirdly, a mask image corresponding to the target object when the first image contour data is obtained, and a mask image corresponding to the target object when the second image contour data is obtained; finally, a mask prediction model is obtained based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained, wherein the mask prediction model is used to obtain image contour data corresponding to the target object in the image to be processed according to the image to be processed, and obtain a first mask image corresponding to the target object according to the image contour data of the target object. The processing method for the mask prediction model provided in the present application utilizes the first image contour data whose data fineness does not reach the specified fineness threshold and the second image contour data whose data fineness reaches the specified fineness threshold in the process of obtaining the mask prediction model, thereby reducing the cost of obtaining the mask prediction model. BRIEF DESCRIPTION OF THE DRAWINGS
[0085] Figure 1 This is a first schematic diagram of an application scenario embodiment of the image processing method provided in the present application.
[0086] Figure 1A This is a second schematic diagram of an application scenario embodiment of the image processing method provided in the present application.
[0087] Figure 2 This is a flowchart of an image processing method provided in the first embodiment of the present application.
[0088] Figure 3 This is a flowchart of a method for obtaining image contour data corresponding to a target object provided in the first embodiment of the present application.
[0089] Figure 4 This is a schematic diagram of an image processing device provided in the second embodiment of the present application.
[0090] Figure 5 A schematic diagram of an electronic device provided in an embodiment of the present application.
[0091] Figure 6 This is a flowchart of a processing method for a mask prediction model provided in the fifth embodiment of the present application.
[0092] Figure 7It is a schematic diagram of a processing device for a mask prediction model provided in the second embodiment of the present application. DETAILED DESCRIPTION
[0093] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application 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 the present application, so the present application is not limited by the specific implementation disclosed below.
[0094] In order to more clearly demonstrate the image processing method provided by the present application, the application scenarios of the image processing method provided by the present application are first introduced. Some embodiments provided by the present application can be applied to scenarios where image segmentation is performed through interaction between a client and a server, such as Figure 1 As shown, it is the first schematic diagram of the application scenario embodiment of the image processing method provided by the present application. In the application scenario embodiment of the image processing method provided by the present application, the client is an application or program installed on a computing device that needs to cooperate with the server to run. Among them, in the application scenario embodiment of the image processing method provided, the computing device generally includes: a computer, a smart phone, etc., and the application or program installed on the computing device that needs to cooperate with the server to run: generally includes: a client of an image processing APP (Application) installed on a smart phone, a client of an image processing application installed on a computer, and a client of a web version of a prior image processing tool running on a web page, etc. This application specifically takes the application scenario in which the client of an image processing application installed on a computer interacts with the server to perform image segmentation as an example, and describes in detail the application scenario of the image processing method provided by the present application:
[0095] First, the client 101 of the image processing application installed on the computer sends the image to be processed to the server 102, and sends a request message for obtaining the image corresponding to the target object. In general, the image to be processed is a photo obtained by an image acquisition device, a picture synthesized by an image synthesis software, an image obtained by an image editing software, and an image corresponding to a video frame in a video, etc. In the application scenario embodiment of the image processing method provided by the present application, the application scenario embodiment of the image processing method provided by the present application is specifically described in detail by taking the image to be processed as a photo obtained by an image acquisition device as an example, that is, the image to be processed is a photo to be processed. Accordingly, in the application scenario embodiment of the image processing method provided by the present application, the target object can be a pre-selected object, or it can be an object selected in the image to be processed after performing target detection on the image to be processed. In the application scenario embodiment of the image processing method provided by the present application, the target object is specifically a person object in the photo to be processed. It should be further explained that in the application scenario embodiment of the image processing method provided by the present application, the target object can be only a specified object in the image, such as a specified person object in the image to be processed, or it can be a combination of multiple specified objects, such as a combination of multiple specified people in the image to be processed, a combination of people and other objects, such as a combination of people and their handheld objects, a combination of people and their accessories, etc. It can also be a class of specified objects, such as objects belonging to the same category in the image to be processed, such as all pet objects in the image to be processed, all vehicles in the image to be processed, etc.
[0096] Secondly, the server 102 inputs the photo to be processed into the mask prediction model to obtain a first mask image corresponding to the person object in the photo to be processed. The mask prediction model is used to obtain the image contour data corresponding to the person object according to the photo to be processed, and obtain the first mask image according to the image contour data of the person object. Among them, the mask image in the application scenario embodiment of the image processing method provided by the present application is an image used to partially or completely shield the photo to be processed to control the shielded image from participating in the image processing, and is used to indicate the image of the target area corresponding to the mask image in the photo to be processed is segmented from the photo to be processed. In the application scenario embodiment of the image processing method provided by the present application, it is often necessary to perform image preprocessing such as image enhancement and image denoising on the photo to be processed. If the target object is an object selected in the image to be processed after target detection is performed on the image to be processed, target detection based on deep neural networks is commonly used, such as: target detection based on R-CNN (Region-CNN, based on convolutional neural network), etc.
[0097] In order to obtain a mask prediction model, in an application scenario embodiment of the image processing method provided in the present application, it is necessary to first train the mask prediction model, and the specific training steps are as follows: obtain a sample image; for the sample image, obtain first image contour data and second image contour data corresponding to the person object in the sample image, the first image contour data being image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data being image contour data whose data fineness reaches a specified fineness threshold; obtain a mask image corresponding to the person object when the first image contour data is obtained, and obtain a mask image corresponding to the person object when the second image contour data is obtained; obtain a mask prediction model based on the first image contour data, the second image contour data, the mask image corresponding to the person object when the first image contour data is obtained, and the mask image corresponding to the person object when the second image contour data is obtained, the mask prediction model is used to obtain image contour data corresponding to the person object in the photo to be processed based on the photo to be processed, and obtain a first mask image corresponding to the person object based on the image contour data of the person object. The training method of the mask prediction model provided by the present application utilizes both the first image contour data whose data fineness does not reach the specified fineness threshold and the second image contour data whose data fineness reaches the specified fineness threshold in the process of obtaining the mask prediction model, thereby reducing the cost of obtaining the mask prediction model. In the application scenario embodiment of the image processing method provided by the present application, the fineness of the image contour data refers to the accuracy and fineness of the image contour data.
[0098] In the application scenario embodiment of the image processing method provided by the present application, the process of obtaining the first mask image corresponding to the person object in the photo to be processed is: obtaining a specified downsampling coefficient for the photo to be processed, downsampling the photo to be processed according to the specified downsampling coefficient, and obtaining the downsampled photo to be processed; in the downsampled photo to be processed, image contour extraction is performed on the person object to obtain the image contour data corresponding to the person object, and the first mask image is obtained according to the image contour data of the person object. In the application scenario embodiment of the image processing method provided by the present application, downsampling is a process of reducing the image area to make the image conform to the size of the display area, or generating a thumbnail of the corresponding image. Specifically, the process of downsampling the photo to be processed is as follows: for a photo to be processed with a resolution of N*M, if the downsampling coefficient is k, it means that one pixel is taken every k pixels in each row and column in the photo to be processed to form an image, and the downsampled photo to be processed is obtained.
[0099] It should be noted that in the application scenario embodiment of the image processing method provided in the present application, the specified fineness threshold is a boundary value pre-set for the image contour data and used to determine the accuracy of the image contour data.
[0100] Again, the server 102 adjusts the fineness of the image contour data of the first mask image to the target fineness to obtain a second mask image. The specific adjustment process is: inputting the first mask image and the photo to be processed into the unified mask quality model to obtain the second mask image, wherein the unified mask quality model is used to adjust the fineness of the image contour data of the first mask image to the target fineness, and obtain a second mask image whose image semantic information is consistent with the image semantic information of the photo to be processed.
[0101] It should be noted that the target fineness is data determined based on the first fineness interval and the second fineness interval. The first fineness interval is the fineness interval of the image contour data of the first mask image obtained by the mask prediction model when the fineness of the image contour data of the human object does not reach the specified fineness threshold, and the second fineness interval is the fineness interval of the image contour data of the first mask image obtained by the mask prediction model when the fineness of the image contour data of the human object reaches the specified fineness threshold. Specifically, first, the fineness of the image contour data of the first mask image is obtained; then, the fineness of the image contour data of the first mask image is compared with the target fineness; finally, if the fineness of the image contour data of the first mask image is less than the target fineness, the fineness of the image contour data of the first mask image is increased to the target fineness to obtain the second mask image; if the fineness of the image contour data of the first mask image is greater than the target fineness, the fineness of the image contour data of the first mask image is reduced to the target fineness to obtain the second mask image. In the process of adjusting the fineness of the image contour data of the first mask image to the target fineness to obtain the second mask image, it is necessary to ensure that the shape semantic information of the second mask image and the photo to be processed are consistent. Therefore, in this process, the photo to be processed needs to be used as a reference image.
[0102] Finally, the server 102 obtains the image corresponding to the person object based on the photo to be processed and the second mask image, and provides the image corresponding to the person object to the client 101 in response to the request message. After obtaining the image corresponding to the person object, the client 101 will display the image corresponding to the person object. In the application scenario embodiment of the image processing method provided in the present application, the process of obtaining the image corresponding to the person object is to input the photo to be processed and the second mask image into the target image acquisition model to obtain the image corresponding to the person object. The target image acquisition model is used to obtain the image corresponding to the person object based on the photo to be processed and the second mask image. Among them, the specific process of obtaining the image corresponding to the person object based on the photo to be processed and the second mask image is generally to multiply the second mask image with the photo to be processed to obtain the image corresponding to the person object.
[0103] In summary, in the application scenario embodiment of the image processing method provided by the present application, the process in which the server performs image processing on the photo to be processed to obtain an image corresponding to the person object is as follows:
[0104] Please refer to Figure 1A , which is a second schematic diagram of an application scenario embodiment of the image processing method provided in this application.
[0105] First, obtain a photo to be processed. Second, input the photo to be processed into the mask prediction model to obtain a first mask image corresponding to the person object in the photo to be processed. Third, input the first mask image and the photo to be processed into the mask quality unified model to obtain a second mask image. Finally, input the photo to be processed and the second mask image into the target image acquisition model to obtain an image corresponding to the person object.
[0106] The application scenarios of the image processing method provided by this application are not specifically limited in the embodiments of this application, such as: the image processing method provided by this application can also be applied to scenarios where the server and the client work alone. The application scenario of the above-mentioned image processing method is only an embodiment of the application scenario of the image processing method provided by this application. The purpose of providing this application scenario embodiment is to facilitate the understanding of the image processing method provided by this application, and it is not used to limit the image processing method provided by this application. Other application scenarios of the image processing method provided in the embodiments of this application are not described one by one.
[0107] First embodiment
[0108] The first embodiment of the present application provides an image processing method, as follows: Figure 2-Figure 3 Provide explanation.
[0109] Please refer to Figure 2 , which is a flowchart of an image processing method provided in the first embodiment of the present application.
[0110] In step S201, an image to be processed is obtained.
[0111] In the first embodiment of the present application, the images to be processed are generally photos obtained by an image acquisition device, pictures synthesized by image synthesis software, and images obtained by image editing software, such as: photos taken by a mobile phone camera, and pictures obtained by synthesizing two or more pictures by image synthesis software.
[0112] In step S202, the image to be processed is input into the mask prediction model to obtain a first mask image corresponding to the target object in the image to be processed. The mask prediction model is used to obtain image contour data corresponding to the target object based on the image to be processed, and obtain the first mask image based on the image contour data of the target object.
[0113] In the first embodiment of the present application, the target object in the image to be processed is a pre-selected object, or it can be an object selected in the image to be processed after target detection is performed on the image to be processed. For example, when the image to be processed is a selfie of a certain user, the target object in the image to be processed is generally the person object corresponding to the user in the selfie. The mask image is an image used to partially or completely shield the photo to be processed to control the shielded image from participating in image processing, and is used to indicate that the image of the target area corresponding to the mask image in the photo to be processed is segmented from the photo to be processed.
[0114] In the first embodiment of the present application, the process of obtaining the first mask image corresponding to the target object in the image to be processed is: obtaining image contour data corresponding to the target object, and obtaining the first mask image according to the image contour data of the target object. In order to reduce the amount of calculation of the image processing method provided in the first embodiment of the present application, the image contour data corresponding to the target object can be obtained by the following steps, please refer to Figure 3 , which is a flowchart of a method for obtaining image contour data corresponding to a target object provided in the first embodiment of the present application.
[0115] In step S301, the image to be processed is downsampled to obtain the downsampled image to be processed.
[0116] Downsampling is a process of reducing the image area to make the image fit the size of the display area, or generating a thumbnail of the corresponding image. In the first embodiment of the present application, the process of downsampling the image to be processed and obtaining the downsampled image to be processed is: obtaining a specified downsampling coefficient for the image to be processed; downsampling the image to be processed according to the specified downsampling coefficient to obtain the downsampled image to be processed. Specifically, the process of downsampling the image to be processed is as follows: for a 1000*1000 resolution image to be processed, if the downsampling coefficient is 20, it means that in each row and column of the image to be processed, one pixel is taken for every 20 pixels to form an image, and the resolution of the downsampled image to be processed is 50*50.
[0117] In step S302, image contour data corresponding to the target object is obtained according to the downsampled image to be processed.
[0118] In the first embodiment of the present application, the process of obtaining image contour data corresponding to the target object based on the downsampled image to be processed includes: extracting the image contour of the target object in the downsampled image to be processed to obtain the image contour data corresponding to the target object.
[0119] In step S203, the first mask image and the image to be processed are input into a unified mask quality model to obtain a second mask image. The unified mask quality model is used to adjust the fineness of the image contour data of the first mask image to the target fineness, and obtain a second mask image whose image semantic information is consistent with the image semantic information of the image to be processed.
[0120] In the first embodiment of the present application, the target fineness is the fineness determined according to the first fineness interval and the second fineness interval, wherein the first fineness interval is the fineness interval of the image contour data of the first mask image obtained by the mask prediction model when the fineness of the image contour data of the target object does not reach the specified fineness threshold, and the second fineness interval is the fineness interval of the image contour data of the first mask image obtained by the mask prediction model when the fineness of the image contour data of the target object reaches the specified fineness threshold. In the first embodiment of the present application, the fineness of the image contour data refers to the precision and density of the image contour data, and the specified fineness threshold is a boundary value pre-set for the image contour data for determining the precision and density of the image contour data.
[0121] In the first embodiment of the present application, before obtaining the second mask image, it is necessary to first obtain a unified mask quality model. Specifically, first, a sample image is obtained, and a sample first mask image corresponding to a target object in the sample image is obtained. Then, for the sample image and the sample first mask image, a target second mask image is obtained. Finally, according to the sample image, the sample first mask image and the target second mask image, a unified mask quality model is obtained.
[0122] In the first embodiment of the present application, the steps of obtaining the second mask image are: first, obtaining the fineness of the image contour data of the first mask image, and comparing the fineness of the image contour data of the first mask image with the target fineness. Then, if the fineness of the image contour data of the first mask image is less than the target fineness, the fineness of the image contour data of the first mask image is increased to the target fineness to obtain the second mask image; if the fineness of the image contour data of the first mask image is greater than the target fineness, the fineness of the image contour data of the first mask image is reduced to the target fineness to obtain the second mask image.
[0123] In step S204, the image to be processed and the second mask image are input into the target image acquisition model to obtain an image corresponding to the target object. The target image acquisition model obtains the image corresponding to the target object based on the image to be processed and the second mask image.
[0124] If in the first embodiment of the present application, the above-mentioned step of obtaining the image corresponding to the target object is a step performed after the server obtains the request message sent by the client to obtain the image corresponding to the target object, after the server obtains the image corresponding to the target object, the image corresponding to the target object can be provided to the client in response to the request message. If in the first embodiment of the present application, the above-mentioned step of obtaining the image corresponding to the target object is a step performed on the client, then, after obtaining the image corresponding to the target object, the image corresponding to the target object must be further displayed. In the first embodiment of the present application, the client is an application or program installed on a computing device that needs to cooperate with the server and stores the image processing method for steps S201-S204. Among them, the computing device generally includes: a computer, a smart phone, etc., and the application or program installed on the computing device that needs to cooperate with the server generally includes: a client of an image processing APP installed on a smart phone, a client of an image processing application installed on a computer, and a client of a web version of a prior image processing tool running on a web page, etc.
[0125] In the first embodiment of the present application, since the image corresponding to the target object is obtained by inputting the image to be processed and the second mask image into the target image acquisition model, before this, the target image acquisition model needs to be obtained in the first embodiment of the present application. The specific process is: first, a sample image is obtained, and a sample second mask image corresponding to the target object in the sample image is obtained. Then, for the sample image and the sample second mask image, a target image corresponding to the target object in the sample image is obtained. Finally, according to the sample image, the sample second mask image, and the target image, a target image acquisition model is obtained.
[0126] The image processing method provided by the present application, after the image to be processed is input into the mask prediction model, the mask prediction model obtains the image contour data corresponding to the target object according to the image to be processed, and obtains the first mask image according to the image contour data of the target object; after obtaining the first mask image, the fineness of the image contour data of the first mask image is further adjusted to the target fineness, and the second mask image is obtained, the target fineness is data determined according to the first fineness interval and the second fineness interval, and the image corresponding to the target object is obtained according to the image to be processed and the second mask image. The data processing method provided by the present application first obtains the first mask image according to the image contour data of the target object, and then adjusts the fineness of the image contour data of the first mask image to the target fineness to obtain the second mask image, so as to ensure that the fineness of the image corresponding to the target object is obtained according to the image to be processed and the second mask image. When obtaining the first mask image according to the image contour data of the target object, it is not necessary to require the image contour data of the target object to have a relatively high fineness, so there is no need to use a large number of sample images with finely annotated image contour data to train the mask prediction model, reducing the cost of image segmentation.
[0127] Second embodiment
[0128] Corresponding to the image processing method provided in the application scenario embodiment and the first embodiment of the present application, the second embodiment of the present application also provides an image processing device. Since the device embodiment is basically similar to the application scenario embodiment and the first embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the application scenario embodiment and the first embodiment. The device embodiment described below is only exemplary.
[0129] Please refer to Figure 4 , which is a schematic diagram of an image processing device provided in the second embodiment of the present application.
[0130] The image processing device comprises:
[0131] The image to be processed obtaining unit 401 is used to obtain the image to be processed;
[0132] A first mask image obtaining unit 402 is used to input the image to be processed into a mask prediction model to obtain a first mask image corresponding to the target object in the image to be processed, wherein the mask prediction model is used to obtain image contour data corresponding to the target object according to the image to be processed, and obtain the first mask image according to the image contour data of the target object;
[0133] A second mask image obtaining unit 403 is used to input the first mask image and the image to be processed into a unified mask quality model to obtain a second mask image, wherein the unified mask quality model is used to adjust the fineness of the image contour data of the first mask image to a target fineness to obtain a second mask image whose image semantic information is consistent with the image semantic information of the image to be processed;
[0134] The target image acquisition unit 404 is used to input the image to be processed and the second mask image into the target image acquisition model to obtain the image corresponding to the target object. The target image acquisition model is used to obtain the image corresponding to the target object based on the image to be processed and the second mask image.
[0135] Optionally, the first mask image obtaining unit 402 is specifically configured to obtain image contour data corresponding to the target object; and obtain the first mask image according to the image contour data of the target object.
[0136] Optionally, obtaining image contour data corresponding to the target object includes:
[0137] Downsampling the image to be processed to obtain a downsampled image to be processed;
[0138] According to the downsampled image to be processed, image contour data corresponding to the target object is obtained.
[0139] Optionally, downsampling the image to be processed to obtain the downsampled image to be processed includes:
[0140] Obtaining a specified downsampling coefficient for the image to be processed;
[0141] The image to be processed is downsampled according to the specified downsampling coefficient to obtain the downsampled image to be processed.
[0142] Optionally, obtaining image contour data corresponding to the target object based on the downsampled image to be processed includes: performing image contour extraction on the target object in the downsampled image to be processed to obtain image contour data corresponding to the target object.
[0143] Optionally, the image processing device provided in the second embodiment of the present application further includes: a target object providing unit, configured to provide an image corresponding to the target object to a client.
[0144] Optionally, the image processing device provided in the second embodiment of the present application further includes: a request message obtaining unit, configured to obtain a request message sent by the client to request obtaining the image corresponding to the target object;
[0145] The target object providing unit is specifically configured to provide the image corresponding to the target object to the client in response to the request message.
[0146] Optionally, the image processing device provided in the second embodiment of the present application further includes: a target image display unit, used to display the image corresponding to the target object.
[0147] Optionally, the second mask image obtaining unit 403 is specifically configured to increase the fineness of the image contour data of the first mask image to the target fineness to obtain the second mask image if the fineness of the image contour data of the first mask image is less than the target fineness.
[0148] Optionally, the second mask image obtaining unit 403 is specifically configured to reduce the fineness of the image contour data of the first mask image to the target fineness if the fineness of the image contour data of the first mask image is greater than the target fineness, so as to obtain the second mask image.
[0149] Optionally, the image processing device provided in the second embodiment of the present application further includes:
[0150] A fineness obtaining unit, used for obtaining the fineness of the image contour data of the first mask image;
[0151] The fineness comparison unit is used to compare the fineness of the image contour data of the first mask image with the target fineness.
[0152] Optionally, the image processing device provided in the second embodiment of the present application further includes:
[0153] A first sample obtaining unit, used to obtain a sample image and obtain a sample first mask image corresponding to a target object in the sample image;
[0154] A target second mask image obtaining unit, configured to obtain a target second mask image based on the sample image and the sample first mask image;
[0155] The unified mask quality model obtaining unit is used to obtain the unified mask quality model according to the sample image, the sample first mask image and the target second mask image.
[0156] Optionally, the image processing device provided in the second embodiment of the present application further includes:
[0157] A second sample obtaining unit, used to obtain a sample image and obtain a sample second mask image corresponding to the target object in the sample image;
[0158] A target image obtaining unit, configured to obtain a target image corresponding to a target object in the sample image with respect to the sample image and the sample second mask image;
[0159] The target image acquisition model unit is used to obtain a target image acquisition model according to the sample image, the sample second mask image, and the target image.
[0160] In the image processing device provided in the second embodiment of the present application, after the image to be processed is input into the mask prediction model, the mask prediction model obtains the image contour data corresponding to the target object according to the image to be processed, and obtains the first mask image according to the image contour data of the target object; after obtaining the first mask image, the fineness of the image contour data of the first mask image is further adjusted to the target fineness, and the second mask image is obtained, and the target fineness is data determined according to the first fineness interval and the second fineness interval, and the image corresponding to the target object is obtained according to the image to be processed and the second mask image. The data processing device provided by the present application first obtains the first mask image according to the image contour data of the target object, and then adjusts the fineness of the image contour data of the first mask image to the target fineness to obtain the second mask image, so as to ensure that the fineness of the image corresponding to the target object is obtained according to the image to be processed and the second mask image. When obtaining the first mask image according to the image contour data of the target object, it is not necessary to require the image contour data of the target object to have a relatively high fineness, so that there is no need to use a large number of sample images with finely annotated image contour data to train the mask prediction model, thereby reducing the cost of image segmentation.
[0161] Third embodiment
[0162] Corresponding to the application scenario embodiment of the present application and the image processing method provided in the first embodiment, the third embodiment of the present application provides an electronic device.
[0163] As shown in 5, Figure 5 A schematic diagram of an electronic device provided in an embodiment of the present application.
[0164] The electronic device includes:
[0165] Processor 501; and
[0166] The memory 502 is used to store the program of the image processing method. After the device is powered on and passes the program of the image processing method, the following steps are performed:
[0167] Obtaining an image to be processed;
[0168] Inputting the image to be processed into a mask prediction model to obtain a first mask image corresponding to a target object in the image to be processed, wherein the mask prediction model is used to obtain image contour data corresponding to the target object according to the image to be processed, and obtain the first mask image according to the image contour data of the target object;
[0169] Inputting the first mask image and the image to be processed into a unified mask quality model to obtain a second mask image, wherein the unified mask quality model is used to adjust the fineness of the image contour data of the first mask image to a target fineness, and obtain a second mask image whose image semantic information is consistent with the image semantic information of the image to be processed;
[0170] The image to be processed and the second mask image are input into a target image acquisition model to obtain an image corresponding to the target object. The target image acquisition model is used to obtain an image corresponding to the target object based on the image to be processed and the second mask image.
[0171] The image processing electronic device provided in the third embodiment of the present application, after the image to be processed is input into the mask prediction model, the mask prediction model obtains the image contour data corresponding to the target object according to the image to be processed, and obtains the first mask image according to the image contour data of the target object; after obtaining the first mask image, the fineness of the image contour data of the first mask image is further adjusted to the target fineness, and the second mask image is obtained, the target fineness is data determined according to the first fineness interval and the second fineness interval, and the image corresponding to the target object is obtained according to the image to be processed and the second mask image. The data processing electronic device provided by the present application first obtains the first mask image according to the image contour data of the target object, and then adjusts the fineness of the image contour data of the first mask image to the target fineness to obtain the second mask image, so as to ensure that the fineness of the image corresponding to the target object is obtained according to the image to be processed and the second mask image. When obtaining the first mask image according to the image contour data of the target object, it is not necessary to require the image contour data of the target object to have a relatively high fineness, so that there is no need to use a large number of sample images with finely annotated image contour data to train the mask prediction model, reducing the cost of image segmentation.
[0172] In the first embodiment of the present application, the specific process of obtaining the image corresponding to the human object based on the image to be processed and the second mask image is generally to multiply the second mask image by the image to be processed to obtain the image corresponding to the human object.
[0173] It should be noted that for the detailed description of the electronic device provided in the third embodiment of the present application, reference can be made to the relevant description of the application scenario embodiment of the present application and the first embodiment, which will not be repeated here.
[0174] Fourth embodiment
[0175] Corresponding to the application scenario embodiment of the present application and the image processing method provided in the first embodiment, the fourth embodiment of the present application provides a storage medium storing a program for the image processing method, the program is executed by a processor, and the following steps are performed:
[0176] Obtaining an image to be processed;
[0177] Inputting the image to be processed into a mask prediction model to obtain a first mask image corresponding to a target object in the image to be processed, wherein the mask prediction model is used to obtain image contour data corresponding to the target object according to the image to be processed, and obtain the first mask image according to the image contour data of the target object;
[0178] Inputting the first mask image and the image to be processed into a unified mask quality model to obtain a second mask image, wherein the unified mask quality model is used to adjust the fineness of the image contour data of the first mask image to a target fineness, and obtain a second mask image whose image semantic information is consistent with the image semantic information of the image to be processed; inputting the image to be processed and the second mask image into a target image acquisition model to obtain an image corresponding to the target object, wherein the target image acquisition model is used to;
[0179] An image corresponding to the target object is obtained according to the image to be processed and the second mask image.
[0180] The image processing storage medium provided in the fourth embodiment of the present application, after the image to be processed is input into the mask prediction model, the mask prediction model obtains the image contour data corresponding to the target object according to the image to be processed, and obtains the first mask image according to the image contour data of the target object; after obtaining the first mask image, the fineness of the image contour data of the first mask image is further adjusted to the target fineness, and the second mask image is obtained, and the target fineness is data determined according to the first fineness interval and the second fineness interval, and the image corresponding to the target object is obtained according to the image to be processed and the second mask image. The data processing storage medium provided in the present application first obtains the first mask image according to the image contour data of the target object, and then adjusts the fineness of the image contour data of the first mask image to the target fineness to obtain the second mask image, so as to ensure that the fineness of the image corresponding to the target object is obtained according to the image to be processed and the second mask image. When obtaining the first mask image according to the image contour data of the target object, it is not necessary to require the image contour data of the target object to have a relatively high fineness, so that there is no need to use a large number of sample images with finely annotated image contour data to train the mask prediction model, reducing the cost of image segmentation.
[0181] It should be noted that for the detailed description of the storage medium provided in the fourth embodiment of the present application, reference can be made to the relevant description of the application scenario embodiment of the present application and the first embodiment, which will not be repeated here.
[0182] Fifth embodiment
[0183] The fifth embodiment of the present application provides a processing method for a mask prediction model, which is as follows: Figure 6 Explanation
[0184] Please refer to Figure 6 , which is a flowchart of a processing method for a mask prediction model provided in the fifth embodiment of the present application.
[0185] In step S601, a sample image is obtained.
[0186] In step S602, for the sample image, first image contour data and second image contour data corresponding to the target object in the sample image are obtained, the first image contour data being image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data being image contour data whose data fineness reaches a specified fineness threshold.
[0187] In the fifth embodiment of the present application, for a sample image, first image contour data and second image contour data corresponding to a target object in the sample image are obtained, including: downsampling the sample image to obtain a downsampled sample image; and obtaining the first image contour data and the second image contour data based on the downsampled sample image.
[0188] In the fifth embodiment of the present application, downsampling the sample image to obtain the downsampled sample image includes: obtaining a specified downsampling coefficient for the sample image; and downsampling the sample image according to the specified downsampling coefficient to obtain the downsampled sample image.
[0189] In the fifth embodiment of the present application, first image contour data and second image contour data are obtained according to the downsampled sample image, including: in the downsampled sample image, image contour extraction is performed on the target object to obtain the first image contour data and the second image contour data.
[0190] The fifth embodiment of the present application provides a processing method for a mask prediction model. First, a sample image is obtained; secondly, for the sample image, first image contour data and second image contour data corresponding to a target object in the sample image are obtained, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches a specified fineness threshold; thirdly, a mask image corresponding to the target object when the first image contour data is obtained, and a mask image corresponding to the target object when the second image contour data is obtained; finally, a mask prediction model is obtained based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained, wherein the mask prediction model is used to obtain image contour data corresponding to the target object in the image to be processed according to the image to be processed, and obtain a first mask image corresponding to the target object according to the image contour data of the target object. The processing method for the mask prediction model provided in the present application utilizes the first image contour data whose data fineness does not reach the specified fineness threshold and the second image contour data whose data fineness reaches the specified fineness threshold in the process of obtaining the mask prediction model, thereby reducing the cost of obtaining the mask prediction model.
[0191] Sixth embodiment
[0192] Corresponding to the method for processing a mask prediction model provided in the fifth embodiment of the present application, the sixth embodiment of the present application also provides a device for processing a mask prediction model. Since the device embodiment is basically similar to the fifth embodiment of the method, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The device embodiment described below is only illustrative.
[0193] Please refer to Figure 7 , which is a schematic diagram of a processing device for a mask prediction model provided in the second embodiment of the present application.
[0194] The processing device for the mask prediction model includes:
[0195] The sample image obtaining unit 701 is used to obtain a sample image;
[0196] An image contour obtaining unit 702 is configured to obtain, for the sample image, first image contour data and second image contour data corresponding to a target object in the sample image, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches a specified fineness threshold;
[0197] A mask image obtaining unit 703, configured to obtain a mask image corresponding to the target object when the first image contour data is obtained, and to obtain a mask image corresponding to the target object when the second image contour data is obtained;
[0198] The mask prediction model obtaining unit 704 is used to obtain a mask prediction model based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained. The mask prediction model is used to obtain the image contour data corresponding to the target object in the image to be processed based on the image to be processed, and to obtain the first mask image corresponding to the target object based on the image contour data of the target object.
[0199] Optionally, the image contour obtaining unit 702 is specifically configured to downsample the sample image to obtain a downsampled sample image; and obtain the first image contour data and the second image contour data according to the downsampled sample image.
[0200] Optionally, downsampling the sample image to obtain a downsampled sample image includes:
[0201] Obtaining a specified downsampling coefficient for the sample image;
[0202] The sample image is downsampled according to the specified downsampling coefficient to obtain a downsampled sample image.
[0203] Optionally, obtaining the first image contour data and the second image contour data according to the downsampled sample image includes: performing image contour extraction on the target object in the downsampled sample image to obtain the first image contour data and the second image contour data.
[0204] The sixth embodiment of the present application provides a processing device for a mask prediction model, first, obtaining a sample image; secondly, for the sample image, obtaining first image contour data and second image contour data corresponding to a target object in the sample image, the first image contour data being image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data being image contour data whose data fineness reaches a specified fineness threshold; thirdly, obtaining a mask image corresponding to the target object when the first image contour data is obtained, and obtaining a mask image corresponding to the target object when the second image contour data is obtained; finally, obtaining a mask prediction model based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained, the mask prediction model being used to obtain image contour data corresponding to the target object in the image to be processed based on the image to be processed, and obtaining a first mask image corresponding to the target object based on the image contour data of the target object. The processing device for the mask prediction model provided in the present application utilizes the first image contour data whose data fineness does not reach the specified fineness threshold and the second image contour data whose data fineness reaches the specified fineness threshold in the process of obtaining the mask prediction model, thereby reducing the cost of obtaining the mask prediction model.
[0205] Seventh embodiment
[0206] Corresponding to the method for processing the mask prediction model provided in the fifth embodiment of the present application, the seventh embodiment of the present application provides an electronic device.
[0207] As shown in 5, Figure 5 A schematic diagram of an electronic device provided in an embodiment of the present application.
[0208] The electronic device includes:
[0209] Processor 501; and
[0210] The memory 502 is used to store a program of a method for processing a mask prediction model. After the device is powered on and the program of the method for processing a mask prediction model is passed, the following steps are performed:
[0211] Obtain a sample image;
[0212] For the sample image, obtaining first image contour data and second image contour data corresponding to the target object in the sample image, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches the specified fineness threshold;
[0213] obtaining a mask image corresponding to the target object when the first image contour data is obtained, and obtaining a mask image corresponding to the target object when the second image contour data is obtained;
[0214] A mask prediction model is obtained based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained. The mask prediction model is used to obtain the image contour data corresponding to the target object in the image to be processed based on the image to be processed, and to obtain a first mask image corresponding to the target object based on the image contour data of the target object.
[0215] The seventh embodiment of the present application provides an electronic device for processing a mask prediction model. First, a sample image is obtained. Second, for the sample image, first image contour data and second image contour data corresponding to a target object in the sample image are obtained, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches a specified fineness threshold. Third, a mask image corresponding to the target object is obtained when the first image contour data is obtained, and a mask image corresponding to the target object is obtained when the second image contour data is obtained. Finally, a mask prediction model is obtained based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained. The mask prediction model is used to obtain image contour data corresponding to the target object in the image to be processed according to the image to be processed, and obtain a first mask image corresponding to the target object according to the image contour data of the target object. The processing electronic device for the mask prediction model provided in the present application utilizes both the first image contour data whose data fineness does not reach the specified fineness threshold and the second image contour data whose data fineness reaches the specified fineness threshold in the process of obtaining the mask prediction model, thereby reducing the cost of obtaining the mask prediction model.
[0216] It should be noted that for the detailed description of the electronic device provided in the seventh embodiment of the present application, reference can be made to the relevant description of the fifth embodiment of the present application, which will not be repeated here.
[0217] Eighth embodiment
[0218] Corresponding to the method for processing the mask prediction model provided in the fifth embodiment of the present application, the eighth embodiment of the present application provides a storage medium storing a program for the method for processing the mask prediction model, the program is executed by a processor, and the following steps are performed:
[0219] Obtain a sample image;
[0220] For the sample image, obtaining first image contour data and second image contour data corresponding to the target object in the sample image, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches the specified fineness threshold;
[0221] obtaining a mask image corresponding to the target object when the first image contour data is obtained, and obtaining a mask image corresponding to the target object when the second image contour data is obtained;
[0222] A mask prediction model is obtained based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained. The mask prediction model is used to obtain the image contour data corresponding to the target object in the image to be processed based on the image to be processed, and to obtain a first mask image corresponding to the target object based on the image contour data of the target object.
[0223] The eighth embodiment of the present application provides a processing storage medium for a mask prediction model. First, a sample image is obtained. Second, for the sample image, first image contour data and second image contour data corresponding to a target object in the sample image are obtained, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches a specified fineness threshold. Third, a mask image corresponding to the target object is obtained when the first image contour data is obtained, and a mask image corresponding to the target object is obtained when the second image contour data is obtained. Finally, a mask prediction model is obtained based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained. The mask prediction model is used to obtain image contour data corresponding to the target object in the image to be processed according to the image to be processed, and obtain a first mask image corresponding to the target object according to the image contour data of the target object. The processing storage medium for the mask prediction model provided in the present application utilizes both the first image contour data whose data fineness does not reach the specified fineness threshold and the second image contour data whose data fineness reaches the specified fineness threshold in the process of obtaining the mask prediction model, thereby reducing the cost of obtaining the mask prediction model.
[0224] It should be noted that for the detailed description of the storage medium provided in the eighth embodiment of the present application, reference can be made to the relevant description of the fifth embodiment of the present application, and will not be repeated here.
[0225] Although the present application is disclosed as above in the preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.
[0226] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0227] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0228] 1. Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer-readable media does not include non-transitory media such as modulated data signals and carrier waves.
[0229] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
Claims
1. An image processing method, characterized in that: include: Obtaining an image to be processed; Inputting the image to be processed into a mask prediction model to obtain a first mask image corresponding to a target object in the image to be processed, wherein the mask prediction model is used to obtain image contour data corresponding to the target object according to the image to be processed, and obtain the first mask image according to the image contour data of the target object; Inputting the first mask image and the image to be processed into a unified mask quality model to obtain a second mask image, wherein the unified mask quality model is used to adjust the fineness of image contour data of the first mask image to a target fineness, and obtain a second mask image whose image semantic information is consistent with the image semantic information of the image to be processed; Inputting the image to be processed and the second mask image into a target image acquisition model to obtain an image corresponding to the target object, wherein the target image acquisition model is used to obtain the image corresponding to the target object according to the image to be processed and the second mask image; Wherein, adjusting the fineness of the image contour data of the first mask image to the target fineness includes: increasing or decreasing the fineness of the image contour data of the first mask image so that the fineness of the image contour data of the first mask image is adjusted to the target fineness.
2. The image processing method according to claim 1, characterized in that: The obtaining of a first mask image corresponding to the target object in the image to be processed includes: Obtaining image contour data corresponding to the target object; The first mask image is obtained according to the image contour data of the target object.
3. The image processing method according to claim 2, characterized in that: The obtaining of image contour data corresponding to the target object comprises: Downsampling the image to be processed to obtain a downsampled image to be processed; According to the downsampled image to be processed, image contour data corresponding to the target object is obtained.
4. The image processing method according to claim 3, characterized in that: The step of downsampling the image to be processed to obtain the downsampled image to be processed includes: Obtaining a specified downsampling coefficient for the image to be processed; The image to be processed is downsampled according to the specified downsampling coefficient to obtain the downsampled image to be processed.
5. The image processing method according to claim 3, characterized in that: The obtaining of image contour data corresponding to the target object according to the downsampled image to be processed includes: extracting image contours of the target object in the downsampled image to be processed to obtain image contour data corresponding to the target object.
6. The image processing method according to claim 1, characterized in that: Also includes: The image corresponding to the target object is provided to the client.
7. The image processing method according to claim 6, characterized in that: Also includes: Obtaining a request message sent by the client to obtain an image corresponding to the target object; The providing the image corresponding to the target object to the client includes: providing the image corresponding to the target object to the client in response to the request message.
8. The image processing method according to claim 1, characterized in that: Also includes: The image corresponding to the target object is displayed.
9. The image processing method according to claim 1, characterized in that: The step of inputting the first mask image and the image to be processed into a unified mask quality model to obtain a second mask image includes: if the fineness of the image contour data of the first mask image is less than the target fineness, then increasing the fineness of the image contour data of the first mask image to the target fineness to obtain the second mask image.
10. The image processing method according to claim 1, characterized in that: The step of inputting the first mask image and the image to be processed into a unified mask quality model to obtain a second mask image includes: if the fineness of the image contour data of the first mask image is greater than the target fineness, reducing the fineness of the image contour data of the first mask image to the target fineness to obtain the second mask image.
11. The image processing method according to claim 9 or 10, characterized in that: Also includes: Obtaining the fineness of the image contour data of the first mask image; The fineness of the image contour data of the first mask image is compared with the target fineness.
12. The image processing method according to claim 1, characterized in that: Also includes: Obtaining a sample image, and obtaining a sample first mask image corresponding to a target object in the sample image; Obtaining a target second mask image for the sample image and the sample first mask image; The unified mask quality model is obtained according to the sample image, the sample first mask image and the target second mask image.
13. The image processing method according to claim 1, characterized in that: Also includes: Obtaining a sample image, and obtaining a sample second mask image corresponding to the target object in the sample image; For the sample image and the sample second mask image, obtaining a target image corresponding to the target object in the sample image; A target image acquisition model is obtained according to the sample image, the sample second mask image, and the target image.
14. An image processing device, characterized in that: include: A unit for obtaining an image to be processed, used for obtaining an image to be processed; a first mask image obtaining unit, configured to input the image to be processed into a mask prediction model to obtain a first mask image corresponding to a target object in the image to be processed, wherein the mask prediction model is configured to obtain image contour data corresponding to the target object according to the image to be processed, and obtain the first mask image according to the image contour data of the target object; a second mask image obtaining unit, configured to input the first mask image and the image to be processed into a unified mask quality model to obtain a second mask image, wherein the unified mask quality model is configured to adjust the fineness of image contour data of the first mask image to a target fineness to obtain a second mask image whose image semantic information is consistent with that of the image to be processed; a target image obtaining unit, configured to input the image to be processed and the second mask image into a target image obtaining model to obtain an image corresponding to the target object, wherein the target image obtaining model is configured to obtain an image corresponding to the target object based on the image to be processed and the second mask image; The second mask image obtaining unit is further configured to increase or decrease the fineness of the image contour data of the first mask image, so that the fineness of the image contour data of the first mask image is adjusted to the target fineness.
15. An electronic device, characterized in that: include: processor; as well as A memory is used to store a program for an image processing method. After the device is powered on and the program for the image processing method is run by the processor, the following steps are performed: Obtaining an image to be processed; Inputting the image to be processed into a mask prediction model to obtain a first mask image corresponding to a target object in the image to be processed, wherein the mask prediction model is used to obtain image contour data corresponding to the target object according to the image to be processed, and obtain the first mask image according to the image contour data of the target object; Inputting the first mask image and the image to be processed into a unified mask quality model to obtain a second mask image, wherein the unified mask quality model is used to adjust the fineness of image contour data of the first mask image to a target fineness, and obtain a second mask image whose image semantic information is consistent with the image semantic information of the image to be processed; Inputting the image to be processed and the second mask image into a target image acquisition model to obtain an image corresponding to the target object, wherein the target image acquisition model is used to obtain the image corresponding to the target object according to the image to be processed and the second mask image; Wherein, adjusting the fineness of the image contour data of the first mask image to the target fineness includes: increasing or decreasing the fineness of the image contour data of the first mask image so that the fineness of the image contour data of the first mask image is adjusted to the target fineness.
16. A storage device, characterized in that: A program for an image processing method is stored, and the program is run by a processor to perform the following steps: Obtaining an image to be processed; Inputting the image to be processed into a mask prediction model to obtain a first mask image corresponding to a target object in the image to be processed, wherein the mask prediction model is used to obtain image contour data corresponding to the target object according to the image to be processed, and obtain the first mask image according to the image contour data of the target object; Inputting the first mask image and the image to be processed into a unified mask quality model to obtain a second mask image, wherein the unified mask quality model is used to adjust the fineness of image contour data of the first mask image to a target fineness, and obtain a second mask image whose image semantic information is consistent with the image semantic information of the image to be processed; Inputting the image to be processed and the second mask image into a target image acquisition model to obtain an image corresponding to the target object, wherein the target image acquisition model is used to obtain the image corresponding to the target object according to the image to be processed and the second mask image; Wherein, adjusting the fineness of the image contour data of the first mask image to the target fineness includes: increasing or decreasing the fineness of the image contour data of the first mask image so that the fineness of the image contour data of the first mask image is adjusted to the target fineness.
17. A processing method for a mask prediction model, characterized in that: include: Obtain a sample image; For the sample image, obtaining first image contour data and second image contour data corresponding to the target object in the sample image, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches the specified fineness threshold; obtaining a mask image corresponding to the target object when the first image contour data is obtained, and obtaining a mask image corresponding to the target object when the second image contour data is obtained; A mask prediction model is obtained based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained. The mask prediction model is used to obtain the image contour data corresponding to the target object in the image to be processed based on the image to be processed, and to obtain a first mask image corresponding to the target object based on the image contour data of the target object.
18. The processing method for the mask prediction model according to claim 17, characterized in that: The step of obtaining, for the sample image, first image contour data and second image contour data corresponding to the target object in the sample image includes: Downsampling the sample image to obtain a downsampled sample image; The first image contour data and the second image contour data are obtained according to the downsampled sample image.
19. The processing method for the mask prediction model according to claim 18, characterized in that: The step of downsampling the sample image to obtain a downsampled sample image includes: Obtaining a specified downsampling coefficient for the sample image; The sample image is downsampled according to the specified downsampling coefficient to obtain a downsampled sample image.
20. The processing method for the mask prediction model according to claim 18, characterized in that: The obtaining of the first image contour data and the second image contour data according to the downsampled sample image includes: performing image contour extraction on the target object in the downsampled sample image to obtain the first image contour data and the second image contour data.
21. A processing device for a mask prediction model, characterized in that: include: A sample image obtaining unit, used for obtaining a sample image; An image contour obtaining unit, configured to obtain, for the sample image, first image contour data and second image contour data corresponding to a target object in the sample image, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches a specified fineness threshold; a mask image obtaining unit, configured to obtain a mask image corresponding to the target object when obtaining the first image contour data, and to obtain a mask image corresponding to the target object when obtaining the second image contour data; A mask prediction model obtaining unit is used to obtain a mask prediction model based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained. The mask prediction model is used to obtain image contour data corresponding to the target object in the image to be processed based on the image to be processed, and to obtain a first mask image corresponding to the target object based on the image contour data of the target object.
22. An electronic device, characterized in that: include: processor; as well as A memory is used to store a program of a processing method for a mask prediction model. After the device is powered on and the program of the processing method for the mask prediction model is run by the processor, the following steps are performed: Obtain a sample image; For the sample image, obtaining first image contour data and second image contour data corresponding to the target object in the sample image, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches the specified fineness threshold; obtaining a mask image corresponding to the target object when the first image contour data is obtained, and obtaining a mask image corresponding to the target object when the second image contour data is obtained; A mask prediction model is obtained based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained. The mask prediction model is used to obtain the image contour data corresponding to the target object in the image to be processed based on the image to be processed, and to obtain a first mask image corresponding to the target object based on the image contour data of the target object.
23. A storage device, characterized in that: A program is stored with a processing method for a mask prediction model, and the program is executed by a processor to perform the following steps: Obtain a sample image; For the sample image, obtaining first image contour data and second image contour data corresponding to the target object in the sample image, wherein the first image contour data is image contour data whose data fineness does not reach a specified fineness threshold, and the second image contour data is image contour data whose data fineness reaches the specified fineness threshold; obtaining a mask image corresponding to the target object when the first image contour data is obtained, and obtaining a mask image corresponding to the target object when the second image contour data is obtained; A mask prediction model is obtained based on the first image contour data, the second image contour data, the mask image corresponding to the target object when the first image contour data is obtained, and the mask image corresponding to the target object when the second image contour data is obtained. The mask prediction model is used to obtain the image contour data corresponding to the target object in the image to be processed based on the image to be processed, and to obtain a first mask image corresponding to the target object based on the image contour data of the target object.
Citation Information
Patent Citations
Image processing method and device, and mobile terminal
CN108961279A
Utilizing deep learning for automatic digital image segmentation and stylization
US20170213112A1