Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,26 @@ package com.google.firebase.ai.type
public class ImagenControlType internal constructor(internal val value: String) {
public companion object {

/** Use edge detection to ensure the new image follow the same outlines */
/**
* Use edge detection to ensure the new image follows the same outlines as the reference image.
*/
@JvmField public val CANNY: ImagenControlType = ImagenControlType("CONTROL_TYPE_CANNY")

/** Use enhanced edge detection to ensure the new image follow similar outlines */
/**
* Use enhanced edge detection to ensure the new image follows the same outlines as the
* reference image.
*/
@JvmField public val SCRIBBLE: ImagenControlType = ImagenControlType("CONTROL_TYPE_SCRIBBLE")

/** Use face mesh control to ensure that the new image has the same facial expressions */
/**
* Use face mesh control to ensure that the new image has the same facial expressions as the
* reference image.
*/
@JvmField public val FACE_MESH: ImagenControlType = ImagenControlType("CONTROL_TYPE_FACE_MESH")

/**
* Use color superpixels to ensure that the new image is similar in shape and color to the
* original
* reference image.
*/
@JvmField
public val COLOR_SUPERPIXEL: ImagenControlType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ImagenEditMode private constructor(internal val value: String) {
/** Removes an element from an image */
@JvmField
public val INPAINT_REMOVAL: ImagenEditMode = ImagenEditMode("EDIT_MODE_INPAINT_REMOVAL")
/** Extend the borders of an image outwards */
/** Extends the borders of an image outwards */
@JvmField public val OUTPAINT: ImagenEditMode = ImagenEditMode("EDIT_MODE_OUTPAINT")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ internal constructor(
* @param referenceId the reference ID for this image, to be referenced in the prompt
* @param enableComputation requests that the reference image be generated serverside instead of
* provided
* @param superpixelRegionSize if type is COLOR_SUPERPIXEL and [enableComputation] is true, this
* will control the size of each superpixel region in pixels for the generated referenced image
* @param superpixelRuler if type is COLOR_SUPERPIXEL and [enableComputation] is true, this will
* control the superpixel smoothness factor for the generated referenced image
* @param superpixelRegionSize if type is [ImagenControlType.COLOR_SUPERPIXEL] and
* [enableComputation] is true, this will control the size of each superpixel region in pixels for
* the generated referenced image
* @param superpixelRuler if type is [ImagenControlType.COLOR_SUPERPIXEL] and [enableComputation] is
* true, this will control the superpixel smoothness factor for the generated referenced image
*/
@PublicPreviewAPI
public class ImagenControlReference(
Expand All @@ -102,9 +103,8 @@ public class ImagenControlReference(
) {}

/**
* Represents a reference image for Imagen editing which will mask of a region to be edited. This
* image (generated or provided) should contain only black and white pixels, with black representing
* parts of the image which should not change.
* Represents a mask for Imagen editing. This image (generated or provided) should contain only
* black and white pixels, with black representing parts of the image which should not change.
*/
@PublicPreviewAPI
public abstract class ImagenMaskReference
Expand All @@ -113,17 +113,16 @@ internal constructor(maskConfig: ImagenMaskConfig, image: ImagenInlineImage? = n

public companion object {
/**
* Generates these two reference images in order:
* Generates two reference images of [ImagenRawImage] and [ImagenRawMask]. These images are
* generated in this order:
* * One [ImagenRawImage] containing the original image, padded out to the new dimensions with
* black pixels, with the original image placed at the given placement
* * One [ImagenRawMask] of the same dimensions containing white everywhere except at the
* placement original image.
*
* This is the format expected by Imagen for outpainting requests.
* placement original image. This is the format expected by Imagen for outpainting requests.
*
* @param image the original image
* @param newDimensions the new dimensions for outpainting. This *must* be more than the
* original image.
* @param newDimensions the new dimensions for outpainting. These new dimensions *must* be more
* than the original image.
* @param newPosition the placement of the original image within the new outpainted image.
*/
@JvmOverloads
Expand Down Expand Up @@ -190,8 +189,8 @@ internal constructor(maskConfig: ImagenMaskConfig, image: ImagenInlineImage? = n
/**
* A generated mask image which will auto-detect and mask out the background. The background will be
* white, and the foreground black
* @param dilation the amount to dilate the mask, this can help smooth the borders of an edit and
* make it seem more convincing. For example, 0.05 would dilate the mask 5%.
* @param dilation the amount to dilate the mask. This can help smooth the borders of an edit and
* make it seem more convincing. For example, `0.05` will dilate the mask 5%.
*/
@PublicPreviewAPI
public class ImagenBackgroundMask(dilation: Double? = null) :
Expand All @@ -200,21 +199,20 @@ public class ImagenBackgroundMask(dilation: Double? = null) :
/**
* A generated mask image which will auto-detect and mask out the foreground. The background will be
* black, and the foreground white
* @param dilation the amount to dilate the mask, this can help smooth the borders of an edit and
* make it seem more convincing. For example, 0.05 would dilate the mask 5%.
* @param dilation the amount to dilate the mask. This can help smooth the borders of an edit and
* make it seem more convincing. For example, `0.05` will dilate the mask 5%.
*/
@PublicPreviewAPI
public class ImagenForegroundMask(dilation: Double? = null) :
ImagenMaskReference(maskConfig = ImagenMaskConfig(ImagenMaskMode.FOREGROUND, dilation)) {}

/**
* Represents a reference image for Imagen editing which will mask of a region to be edited. This
* image should contain only black and white pixels, with black representing parts of the image
* which should not change.
* Represents a mask for Imagen editing. This image should contain only black and white pixels, with
* black representing parts of the image which should not change.
*
* @param mask the mask image
* @param dilation the amount to dilate the mask, this can help smooth the borders of an edit and
* make it seem more convincing. For example, 0.05 would dilate the mask 5%.
* @param dilation the amount to dilate the mask. This can help smooth the borders of an edit and
* make it seem more convincing. For example, `0.05` will dilate the mask 5%.
*/
@PublicPreviewAPI
public class ImagenRawMask(mask: ImagenInlineImage, dilation: Double? = null) :
Expand All @@ -226,11 +224,11 @@ public class ImagenRawMask(mask: ImagenInlineImage, dilation: Double? = null) :
/**
* Represents a generated mask for Imagen editing which masks out certain objects using object
* detection.
* @param classes the list of segmentation IDs for objects to detect and mask out. See
* [here](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/imagen-api-edit#segment-ids)
* for a list of segmentation IDs
* @param dilation the amount to dilate the mask, this can help smooth the borders of an edit and
* make it seem more convincing. For example, 0.05 would dilate the mask 5%.
* @param classes the list of segmentation IDs for objects to detect and mask out. Find a
* [list of segmentation IDs](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/imagen-api-edit#segment-ids)
* in the Vertex AI documentation.
* @param dilation the amount to dilate the mask. This can help smooth the borders of an edit and
* make it seem more convincing. For example, `0.05` will dilate the mask 5%.
*/
@PublicPreviewAPI
public class ImagenSemanticMask(classes: List<Int>, dilation: Double? = null) :
Expand Down