Performs image generation from a text prompt.
Nested Classes
class | ImageGenerator.ConditionOptions | Options for setting up the conditions types and the plugin models | |
class | ImageGenerator.ImageGeneratorOptions | Options for setting up an ImageGenerator . |
Public Methods
void |
close()
Closes and cleans up the task runners.
|
MPImage |
createConditionImage(MPImage sourceConditionImage, ImageGenerator.ConditionOptions.ConditionType conditionType)
Create the condition image of specified condition type from the source image.
|
static ImageGenerator |
createFromOptions(Context context, ImageGenerator.ImageGeneratorOptions generatorOptions)
Creates an
ImageGenerator instance from an ImageGenerator.ImageGeneratorOptions . |
static ImageGenerator |
createFromOptions(Context context, ImageGenerator.ImageGeneratorOptions generatorOptions, ImageGenerator.ConditionOptions conditionOptions)
Creates an
ImageGenerator instance, from ImageGenerator.ImageGeneratorOptions and ImageGenerator.ConditionOptions , if plugin models are used to generate an image based on the condition image. |
ImageGeneratorResult |
execute(boolean showResult)
Executes one iteration of image generation.
|
ImageGeneratorResult |
generate(String prompt, MPImage sourceConditionImage, ImageGenerator.ConditionOptions.ConditionType conditionType, int iterations, int seed)
Generates an image based on the source image for iterations and the given random seed.
|
ImageGeneratorResult | |
void | |
void |
setInputs(String prompt, MPImage sourceConditionImage, ImageGenerator.ConditionOptions.ConditionType conditionType, int iterations, int seed)
Sets the inputs of the ImageGenerator.
|
Inherited Methods
Public Methods
public void close ()
Closes and cleans up the task runners.
public MPImage createConditionImage (MPImage sourceConditionImage, ImageGenerator.ConditionOptions.ConditionType conditionType)
Create the condition image of specified condition type from the source image. Currently support face landmarks, depth image and edge image as the condition image.
Parameters
sourceConditionImage | The source image used to create the condition image. |
---|---|
conditionType | The ImageGenerator.ConditionOptions.ConditionType specifying the type of
condition image.
|
public static ImageGenerator createFromOptions (Context context, ImageGenerator.ImageGeneratorOptions generatorOptions)
Creates an ImageGenerator
instance from an ImageGenerator.ImageGeneratorOptions
.
Parameters
context | an Android ERROR(/Context) . |
---|---|
generatorOptions | an ImageGenerator.ImageGeneratorOptions instance. |
Throws
if there is an error during ImageGenerator creation.
|
public static ImageGenerator createFromOptions (Context context, ImageGenerator.ImageGeneratorOptions generatorOptions, ImageGenerator.ConditionOptions conditionOptions)
Creates an ImageGenerator
instance, from ImageGenerator.ImageGeneratorOptions
and ImageGenerator.ConditionOptions
, if plugin models are used to generate an image based on the condition image.
Parameters
context | an Android ERROR(/Context) . |
---|---|
generatorOptions | an ImageGenerator.ImageGeneratorOptions instance. |
conditionOptions | an ImageGenerator.ConditionOptions instance. |
Throws
if there is an error during ImageGenerator creation.
|
public ImageGeneratorResult execute (boolean showResult)
Executes one iteration of image generation. The method must be called iterations
times
to generate the final image. Must call ERROR(/setInputs)
before calling this method.
This is an iterative API, which must be called iteratively.
This API is useful for showing the intermediate image generation results and the image generation progress. Note that requesting the intermediate results will result in a larger latency. Consider using the e2e API instead for latency consideration.
Example usage:
imageGenerator.setInputs(prompt, iterations, seed); for (int step = 0; step < iterations; step++) { ImageGeneratorResult result = imageGenerator.execute(true); }
Parameters
showResult | Whether to get the generated image result in the intermediate iterations. If false, null is returned. The generated image result is always returned at the last iteration, regardless of showResult value. |
---|
public ImageGeneratorResult generate (String prompt, MPImage sourceConditionImage, ImageGenerator.ConditionOptions.ConditionType conditionType, int iterations, int seed)
Generates an image based on the source image for iterations and the given random seed. Only valid when the ImageGenerator is created with condition options.
This is an e2e API, which runs iterations
to generate an image. Consider using the
iterative API instead to fetch the intermediate results.
Parameters
prompt | The text prompt describing the image to be generated. |
---|---|
sourceConditionImage | The source image used to create the condition image, which is used as a guidance for the image generation. |
conditionType | The ImageGenerator.ConditionOptions.ConditionType specifying the type of
condition image. |
iterations | The total iterations to generate the image. |
seed | The random seed used during image generation. |
public ImageGeneratorResult generate (String prompt, int iterations, int seed)
Generates an image for iterations and the given random seed. Only valid when the ImageGenerator is created without condition options.
This is an e2e API, which runs iterations
to generate an image. Consider using the
iterative API instead to fetch the intermediate results.
Parameters
prompt | The text prompt describing the image to be generated. |
---|---|
iterations | The total iterations to generate the image. |
seed | The random seed used during image generation. |
public void setInputs (String prompt, int iterations, int seed)
Sets the inputs of the ImageGenerator. There is ERROR(/setInputs)
and ERROR(/execute)
method
pair for iterative usage. Users must call ERROR(/setInputs)
before ERROR(/execute)
. Only valid
when the ImageGenerator is created without condition options.
Parameters
prompt | The text prompt describing the image to be generated. |
---|---|
iterations | The total iterations to generate the image. |
seed | The random seed used during image generation. |
public void setInputs (String prompt, MPImage sourceConditionImage, ImageGenerator.ConditionOptions.ConditionType conditionType, int iterations, int seed)
Sets the inputs of the ImageGenerator. For iterative usage, use ERROR(/setInputs)
and ERROR(/execute)
in pairs. Users must call ERROR(/setInputs)
before ERROR(/execute)
. Only valid when
the ImageGenerator is created with condition options.
Parameters
prompt | The text prompt describing the image to be generated. |
---|---|
sourceConditionImage | The source image used to create the condition image, which is used as a guidance for the image generation. |
conditionType | The ImageGenerator.ConditionOptions.ConditionType specifying the type of
condition image. |
iterations | The total iterations to generate the image. |
seed | The random seed used during image generation. |