Image processing method and training method based on generative adversarial network, electronic device, and medium
View Patent ↗Embodiments of the present disclosure disclose an image processing method, a training method for an image processing model, an electronic device and a medium. The image processing method comprises: inputting an image to be processed into an image processing model in response to a special effect trigger instruction; and outputting a target image from the image processing model, wherein the target image comprises a special effect object and a conflicting object corresponding to the special effect object is removed in the target image, wherein the image processing model is trained based on an image with the conflicting object removed and a target object superimposed, wherein the target object comprises an adjustable object having a same presentation effect as the special effect object, and the image with the conflicting object removed is generated by a generator trained based on a generative adversarial network.
1 . An image processing method, comprising:
inputting an image to be processed into an image processing model in response to a special effect trigger instruction; and
outputting a target image from the image processing model, wherein the target image comprises a special effect object and a conflicting object corresponding to the special effect object is removed in the target image,
wherein the image processing model is trained based on an image with the conflicting object removed and a target object superimposed, wherein the target object comprises an adjustable object having a same presentation effect as the special effect object, and the image with the conflicting object removed is generated by a generator trained based on a generative adversarial network, and the generator comprises a first generator and a second generator, and the image processing model is trained by: inputting an original image into the first generator to generate a first image with the conflicting object removed by the first generator, inputting the first image into the second generator to generate a second image comprising the special effect object by the second generator, generating the target object based on the special effect object in the second image, and superimposing the target object on the first image to obtain a third image, and training the image processing model based on the original image and the third image.
2 . The image processing method according to claim 1 , wherein:
the generative adversarial network comprises a first generative adversarial network and a second generative adversarial;
the first generator is comprised in the first generative adversarial network during a training process, and is trained together with the first generative adversarial network based on a first sample image and a second sample image without the conflicting object, wherein the first sample image is random; and
the second generator is comprised in the second generative adversarial network during the training process, and is trained together with the second generative adversarial network based on the first sample image and a third sample image comprising the special effect object.
3 . The image processing method according to claim 1 , wherein the target object comprises a special effect mask and the generating the target object based on the special effect object in the second image comprises:
obtaining key points of the special effect object in the second image and generating the special effect mask based on the key points.
4 . The image processing method according to claim 3 , further comprising: after generating the special effect mask based on the key points, adjusting the special effect mask based on an adjustment instruction,
wherein the superimposing the target object on the first image comprises superimposing the adjusted special effect mask on the first image.
5 . The image processing method according to claim 1 , wherein:
the image processing method is applied to a facial image beautification application, and
the special effect object comprises a first facial tissue object generated based on the image processing model and the conflicting object comprises a second facial tissue object contained in the image to be processed.
6 . A training method for an image processing model, comprising:
inputting an original image into a first generator to generate a first image with a conflicting object removed by the first generator, wherein the conflicting object corresponds to a special effect object;
inputting the first image into a second generator to generate a second image comprising the special effect object by the second generator;
generating a target object based on the special effect object in the second image, and superimposing the target object on the first images to obtain a third image, wherein the target object comprises an adjustable object having a same presentation effect as the special effect object; and
training the image processing model based on the original image and the third image,
wherein the first generator and the second generator are trained together with a generative adversarial network.
7 . An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs, which when executed by the one or more processors cause the one or more processors to implement the image processing method according to claim 1 .
8 . The electronic device according to claim 7 , wherein:
the generative adversarial network comprises a first generative adversarial network and a second generative adversarial;
the first generator is comprised in the first generative adversarial network during a training process, and is trained together with the first generative adversarial network based on random a first sample image and a second sample image without the conflicting object; and
the second generator is comprised in the second generative adversarial network during the training process, and is trained together with the second generative adversarial network based on the first sample image and a third sample image comprising the special effect object.
9 . The electronic device according to claim 7 , the target object comprises a special effect mask and the generating the target object based on the special effect object in the second image comprises:
obtaining key points of the special effect object in the second image and generating a special effect mask based on the key points.
10 . The electronic device according to claim 9 , the storage device further comprises a program, which when executed by the one or more processors cause the one or more processors to: adjust the special effect mask based on an adjustment instruction, after generating the special effect mask based on the key points,
wherein the superimposing the target object on the first image comprises superimposing the adjusted special effect mask on the first image.
11 . The electronic device according to claim 7 , wherein:
the image processing method is applied to a facial image beautification application, and
the special effect object comprises a first facial tissue object generated based on the image processing model and the conflicting object comprises a second facial tissue object contained in the image to be processed.
12 . A non-transitory computer readable storage medium, comprising computer executable instructions, which when executed by a computer processor cause the computer processor to execute the image processing method according to claim 1 .
13 . The non-transitory computer readable storage medium according to claim 12 , wherein:
the generative adversarial network comprises a first generative adversarial network and a second generative adversarial;
the first generator is comprised in the first generative adversarial network during a training process, and is trained together with the first generative adversarial network based on random a first sample image and a second sample image without the conflicting object; and
the second generator is comprised in the second generative adversarial network during the training process, and is trained together with the second generative adversarial network based on the first sample image and a third sample image comprising the special effect object.
14 . The non-transitory computer readable storage medium according to claim 12 , wherein the target object comprises a special effect mask and the generating the target object based on the special effect object in the second image comprises:
obtaining key points of the special effect object in the second image and generating a special effect mask based on the key points.
15 . The non-transitory computer readable storage medium according to claim 14 , the storage device further comprises a program, which when executed by the one or more processors cause the one or more processors to: adjust the special effect mask based on an adjustment instruction, after generating the special effect mask based on the key points,
wherein the superimposing the target object on the first image comprises superimposing the adjusted special effect mask on the first image.
16 . The non-transitory computer readable storage medium according to claim 12 , wherein:
the image processing method is applied to a facial image beautification application, and
the special effect object comprises a first facial tissue object generated based on the image processing model and the conflicting object comprises a second facial tissue object contained in the image to be processed.
17 . A electronic device, comprising:
one or more processors;
a storage device for storing one or more programs, which when executed by the one or more processors cause the one or more processors to implement the training method according to claim 6 .
18 . A non-transitory computer readable storage medium, comprising computer executable instructions, which when executed by a computer processor cause the computer processor to execute the model training method according to claim 6 .