ImagenModel

@PublicPreviewAPI
class ImagenModel


Represents a generative model (like Imagen), capable of generating images based on various input types.

Summary

Public functions

suspend ImagenGenerationResponse<ImagenInlineImage>
editImage(
    referenceImages: List<ImagenReferenceImage>,
    prompt: String,
    config: ImagenEditingConfig?
)

Generates an image from a single or set of base images, returning the result directly to the caller.

suspend ImagenGenerationResponse<ImagenInlineImage>

Generates an image, returning the result directly to the caller.

suspend ImagenGenerationResponse<ImagenInlineImage>
inpaintImage(
    image: ImagenInlineImage,
    prompt: String,
    mask: ImagenMaskReference,
    config: ImagenEditingConfig
)

Generates an image by inpainting a masked off part of a base image.

suspend ImagenGenerationResponse<ImagenInlineImage>
outpaintImage(
    image: ImagenInlineImage,
    newDimensions: Dimensions,
    newPosition: ImagenImagePlacement,
    prompt: String,
    config: ImagenEditingConfig?
)

Generates an image by outpainting the given image, extending its content beyond the original borders using context from the original image, and optionally, the prompt.

Public functions

editImage

suspend fun editImage(
    referenceImages: List<ImagenReferenceImage>,
    prompt: String,
    config: ImagenEditingConfig? = null
): ImagenGenerationResponse<ImagenInlineImage>

Generates an image from a single or set of base images, returning the result directly to the caller.

Parameters
referenceImages: List<ImagenReferenceImage>

the image inputs given to the model as a prompt

prompt: String

the text input given to the model as a prompt

config: ImagenEditingConfig? = null

the editing configuration settings

generateImages

suspend fun generateImages(prompt: String): ImagenGenerationResponse<ImagenInlineImage>

Generates an image, returning the result directly to the caller.

Parameters
prompt: String

The input(s) given to the model as a prompt.

inpaintImage

suspend fun inpaintImage(
    image: ImagenInlineImage,
    prompt: String,
    mask: ImagenMaskReference,
    config: ImagenEditingConfig
): ImagenGenerationResponse<ImagenInlineImage>

Generates an image by inpainting a masked off part of a base image. Inpainting is the process of filling in missing or masked off parts of the image using context from the original image and prompt.

Parameters
image: ImagenInlineImage

the base image

prompt: String

the text input given to the model as a prompt

mask: ImagenMaskReference

the mask which defines where in the image can be painted by Imagen.

config: ImagenEditingConfig

the editing configuration settings, it should include an ImagenEditMode

outpaintImage

suspend fun outpaintImage(
    image: ImagenInlineImage,
    newDimensions: Dimensions,
    newPosition: ImagenImagePlacement = ImagenImagePlacement.CENTER,
    prompt: String = "",
    config: ImagenEditingConfig? = null
): ImagenGenerationResponse<ImagenInlineImage>

Generates an image by outpainting the given image, extending its content beyond the original borders using context from the original image, and optionally, the prompt.

Parameters
image: ImagenInlineImage

the base image

newDimensions: Dimensions

the new dimensions for the image, must be larger than the original image.

newPosition: ImagenImagePlacement = ImagenImagePlacement.CENTER

the placement of the base image within the new image. This can either be coordinates (0,0 is the top left corner) or an alignment (ex: ImagenImagePlacement.BOTTOM_CENTER)

prompt: String = ""

optional, can be used to specify the background generated if context is insufficient

config: ImagenEditingConfig? = null

the editing configuration settings