Method and apparatus for generating image
AssigneeBaidu Online Network Technology (Beijing) Co., Ltd.
InventorsTao He, Gang Zhang, Jingtuo Liu
Life of this patent
Estimating the term…
Abstract
A method and an apparatus for generating an image are provided. A specific embodiment of the method comprises: acquiring a to-be-processed facial image, the image resolution of the to-be-processed facial image being lower than a preset first resolution threshold; and inputting the to-be-processed facial image into a pre-trained generativemodel to generate a processed facial image. The generative model updates a model parameter using a loss function in a training process, and the loss function is determined based on a probability of an image group being positive sample data, the image group composed of a facial sample image and a facial generative image. According to this embodiment, authenticity of the generated facial image is enhanced.
Claims13
A method for generating an image, comprising:
- acquiring a to-be-processed facial image, an image resolution of the to-be-processed facial image being lower than a preset first resolution threshold;
- and
- inputting the to-be-processed facial image into a pre-trained generative model to generate a processed facial image, wherein the generative model is obtained through the following training:
- inputting a facial sample image into an initial generative model, and outputting, by the initial generative model, a facial generative image, an image resolution of the facial sample image being lower than the first resolution threshold;
- inputting a 2-tuple composed of a pixel matrix of the facial sample image and a pixel matrix of the facial generative image into a pre-trained discriminative model, and outputting, by the discriminative model, a probability of an image group being positive sample data, the image group composed of the facial sample image and the facial generative image, and the positive sample data comprising a first real facial image whose image resolution higher than a second resolution threshold and a second real facial image whose image resolution lower than the first resolution threshold which is generated based on the first real facial image;
- and
- obtaining a loss function of the initial generative model based on the probability, and updating a model parameter of the initial generative model using the loss function to obtain the generative model.
An apparatus for generating an image, comprising:
- at least one processor;
- and
- a memory storing instructions, the instructions when executed by the at least one processor, cause the at least one processor to perform operations, the operations comprising:
- acquiring a to-be-processed facial image, an image resolution of the to-be-processed facial image being lower than a preset first resolution threshold;
- inputting the to-be-processed facial image into a pre-trained generative model to generate a processed facial image;
- and
- training the generative model, wherein,
- the generative model is obtained through the following training:
- inputting a facial sample image into an initial generative model, and output, by the initial generative model, a facial generative image, an image resolution of the facial sample image being lower than the first resolution threshold;
- inputting a 2-tuple composed of a pixel matrix of the facial sample image and a pixel matrix of the facial generative image into a pre-trained discriminative model, and outputting, by the discriminative model, a probability of an image group being positive sample data, the image group composed of the facial sample image and the facial generative image, and the positive sample data comprising a first real facial image whose image resolution higher than a second resolution threshold and a second real facial image whose image resolution lower than the first resolution threshold which is generated based on the first real facial image;
- and
- obtaining a loss function of the initial generative model based on the probability, and updating a model parameter of the initial generative model using the loss function to obtain the generative model.
A non-transitory computer storage medium, storing a computer program, wherein the computer program, when executed by a processor, cause the processor to perform operations, the operations comprising:
- acquiring a to-be-processed facial image, an image resolution of the to-be-processed facial image being lower than a preset first resolution threshold;
- and
- inputting the to-be-processed facial image into a pre-trained generative model to generate a processed facial image, wherein the generative model is obtained through the following training:
- inputting a facial sample image into an initial generative model, and outputting, by the initial generative model, a facial generative image, an image resolution of the facial sample image being lower than the first resolution threshold;
- inputting a 2-tuple composed of a pixel matrix of the facial sample image and a pixel matrix of the facial generative image into a pre-trained discriminative model, and outputting, by the discriminative model, a probability of an image group being positive sample data, the image group composed of the facial sample image and the facial generative image, and the positive sample data comprising a first real facial image whose image resolution higher than a second resolution threshold and a second real facial image whose image resolution lower than the first resolution threshold which is generated based on the first real facial image;
- and
- obtaining a loss function of the initial generative model based on the probability, and updating a model parameter of the initial generative model using the loss function to obtain the generative model.
Dependencies are inferred from the claim text.