Generative image filling using a reference image
Embodiments include systems and methods for generative image filling based on text and a reference image. In one aspect, the system obtains an input image, a reference image, and a text prompt. Then, the system encodes the reference image to obtain an image embedding and encodes the text prompt to obtain a text embedding. Subsequently, a composite image is generated based on the input image, the image embedding, and the text embedding.
1 . A method comprising:
obtaining an input image, a mask, a reference image, and a text prompt, wherein the mask indicates a region of the input image, and the text comprises guidance for editing the region of the input image based on the reference image;
encoding, using an image encoder, the reference image to obtain an image embedding;
encoding, using a text encoder, the text prompt to obtain a text embedding; and
generating, using an image generation model, a composite image based on the input image, the image embedding, and the text embedding, wherein the composite image includes content from the input image outside the region indicated by the mask and content from the reference image within the region indicated by the mask.
2 . The method of claim 1 , wherein generating the composite image comprises:
providing the image embedding and the text embedding as guidance for the image generation model.
3 . The method of claim 1 , wherein:
the composite image includes content corresponding to the reference image in a region corresponding to a mask.
4 . The method of claim 1 , wherein:
the composite image includes content corresponding to the input image in a region outside of a mask.
5 . The method of claim 1 , wherein:
the text prompt describes an object in the reference image.
6 . The method of claim 1 , wherein:
the reference image comprises a portion of the input image.
7 . The method of claim 1 , wherein:
the reference image comprises a style from the input image.
8 . The method of claim 1 , wherein:
the composite image includes an object described by the text prompt with a style from the reference image.
9 . The method of claim 1 , further comprising:
receiving a mask from a user, wherein the mask indicates a region generated by the image generation model based on the reference image.
10 . The method of claim 1 , further comprising:
generating a mask based on the input image, the reference image, or the text prompt, wherein the mask indicates a region generated by the image generation model.
11 . A method comprising:
obtaining an input image, a mask, and a reference image, wherein the mask indicates a region of the input image;
inserting the reference image into the input image based on the mask to obtain a combined input image;
encoding, using an image encoder, the reference image to obtain an image embedding; and
generating, using an image generation model, a composite image based on the combined input image and the image embedding, wherein the composite image includes content from the input image outside the region indicated by the mask and content from the reference image within the region indicated by the mask.
12 . The method of claim 11 , further comprising:
performing, by the image generation model, a self-attention operation on the combined input image, wherein the composite image is generated based on the self-attention operation.
13 . The method of claim 11 , further comprising:
obtaining a text prompt; and
encoding, using a text encoder, the text prompt to obtain a text embedding, wherein the composite image is generated based on the text embedding.
14 . The method of claim 11 , wherein:
the reference image is inserted into the input image in a region outside of a mask.
15 . An apparatus comprising:
at least one memory;
at least one processor coupled to the at least one memory, wherein the processor is configured to execute instructions stored in the at least one memory;
an image encoder configured to encode a reference image to obtain an image embedding;
a text encoder configured to encode a text prompt to obtain a text embedding; and
an image generation model configured to generate a composite image based on an input image, the image embedding, and the text embedding.
16 . The system of aspect 15 , wherein:
the image generation model comprises a diffusion model.
17 . The system of aspect 15 , wherein:
the image generation model comprises a self-attention layer configured to operate on a combination of the input image and the reference image.
18 . The system of aspect 15 , wherein:
the image encoder and the text encoder are components of a multimodal encoder.
19 . The system of aspect 15 , wherein:
the image generation model uses the image embedding and the text embedding for classifier-free guidance.
20 . The system of aspect 15 , further comprising:
a user interface configured to obtain a selection input from a user, wherein a mask is created based on the selection input.