テキスト プロンプトから画像を生成します。
ネストされたクラス
クラス | ImageGenerator.ConditionOptions | 条件タイプとプラグイン モデルを設定するオプション | |
クラス | ImageGenerator.ImageGeneratorOptions | ImageGenerator の設定オプション。 |
パブリック メソッド
継承されるメソッド
パブリック メソッド
public void close ()
タスクランナーを閉じてクリーンアップします。
public MPImage createConditionImage (MPImage sourceConditionImage, ImageGenerator.ConditionOptions.ConditionType conditionType)
ソース画像から、指定された条件タイプの条件画像を作成します。現在、条件画像として、顔のランドマーク、奥行き画像、エッジ画像がサポートされています。
パラメータ
sourceConditionImage | 条件画像の作成に使用されるソース画像。 |
---|---|
conditionType | 条件画像のタイプを指定する ImageGenerator.ConditionOptions.ConditionType 。 |
public static ImageGenerator createFromOptions (コンテキスト コンテキスト、ImageGenerator.ImageGeneratorOptions generatorOptions)
ImageGenerator.ImageGeneratorOptions
から ImageGenerator
インスタンスを作成します。
パラメータ
コンテキスト | Android ERROR(/Context) 。 |
---|---|
generatorOptions | ImageGenerator.ImageGeneratorOptions インスタンス。 |
例外
ImageGenerator の作成中にエラーが発生した場合。 |
public static ImageGenerator createFromOptions (コンテキスト コンテキスト、ImageGenerator.ImageGeneratorOptions generatorOptions、ImageGenerator.ConditionOptions conditionOptions)
プラグイン モデルを使用して条件画像に基づいて画像を生成する場合、ImageGenerator.ImageGeneratorOptions
と ImageGenerator.ConditionOptions
から ImageGenerator
インスタンスを作成します。
パラメータ
コンテキスト | Android ERROR(/Context) 。 |
---|---|
generatorOptions | ImageGenerator.ImageGeneratorOptions インスタンス。 |
conditionOptions | ImageGenerator.ConditionOptions インスタンス。 |
例外
ImageGenerator の作成中にエラーが発生した場合。 |
public ImageGeneratorResult execute (boolean showResult)
画像生成の反復処理を 1 回実行します。このメソッドは、最終的な画像を生成するために iterations
回呼び出される必要があります。このメソッドを呼び出す前に ERROR(/setInputs)
を呼び出す必要があります。
これはイテレーション API であり、イテレーションで呼び出す必要があります。
この API は、中間画像生成結果と画像生成の進行状況を表示するのに便利です。中間結果をリクエストすると、レイテンシが大きくなることに注意してください。レイテンシを考慮して、代わりに e2e API の使用を検討してください。
使用例:
imageGenerator.setInputs(prompt, iterations, seed); for (int step = 0; step < iterations; step++) { ImageGeneratorResult の結果 = imageGenerator.execute(true); }
パラメータ
showResult | 中間の反復処理で生成された画像の結果を取得するかどうかを指定します。false の場合、null が返されます。生成された画像の結果は、showResult の値に関係なく、常に最後の反復処理で返されます。 |
---|
public ImageGeneratorResult generate (String prompt, MPImage sourceConditionImage, ImageGenerator.ConditionOptions.ConditionType conditionType, int iterations, int seed)
反復処理のソース画像と指定されたランダムシードに基づいて画像を生成します。条件オプションを指定して ImageGenerator を作成した場合にのみ有効です。
これは e2e API で、iterations
を実行して画像を生成します。中間結果を取得するには、代わりに反復 API を使用することを検討してください。
パラメータ
プロンプト | 生成される画像を説明するテキスト プロンプト。 |
---|---|
sourceConditionImage | 条件画像の作成に使用されるソース画像。画像生成のガイダンスとして使用されます。 |
conditionType | 条件画像のタイプを指定する ImageGenerator.ConditionOptions.ConditionType 。 |
iterations | 画像を生成するための反復処理の合計数。 |
シード | 画像生成時に使用されるランダムシード。 |
public ImageGeneratorResult generate (String prompt, int iterations, int seed)
反復処理と指定されたランダムシードの画像を生成します。ImageGenerator が条件オプションなしで作成された場合にのみ有効です。
これは e2e API で、iterations
を実行して画像を生成します。中間結果を取得するには、代わりに反復 API を使用することを検討してください。
パラメータ
プロンプト | 生成される画像を説明するテキスト プロンプト。 |
---|---|
iterations | 画像を生成するための反復処理の合計数。 |
シード | 画像生成時に使用されるランダムシード。 |
public void setInputs (String prompt, int iterations, int seed)
ImageGenerator の入力を設定します。繰り返し使用するため、ERROR(/setInputs)
と ERROR(/execute)
のメソッドのペアがあります。ユーザーは ERROR(/execute)
より前に ERROR(/setInputs)
を呼び出す必要があります。条件オプションなしで ImageGenerator が作成された場合にのみ有効です。
パラメータ
プロンプト | 生成される画像を説明するテキスト プロンプト。 |
---|---|
iterations | 画像を生成するための反復処理の合計数。 |
シード | 画像生成時に使用されるランダムシード。 |
public void setInputs (String プロンプト, MPImage sourceConditionImage, ImageGenerator.ConditionOptions.ConditionType conditionType, int iterations, int seed)
ImageGenerator の入力を設定します。繰り返し使用する場合は、ERROR(/setInputs)
と ERROR(/execute)
をペアで使用します。ユーザーは ERROR(/execute)
より前に ERROR(/setInputs)
を呼び出す必要があります。条件オプションを指定して ImageGenerator を作成した場合にのみ有効です。
パラメータ
プロンプト | 生成される画像を説明するテキスト プロンプト。 |
---|---|
sourceConditionImage | 条件画像の作成に使用されるソース画像。画像生成のガイダンスとして使用されます。 |
conditionType | 条件画像のタイプを指定する ImageGenerator.ConditionOptions.ConditionType 。 |
iterations | 画像を生成するための反復処理の合計数。 |
シード | 画像生成時に使用されるランダムシード。 |