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); }