Stable Diffusion Web GUIの拡張機能であるDynamic Promptの使い方をまとめました。

ざっくり出来ることがこちらです!
- 一つのカテゴリ(例えば髪の色)をランダムで選択させる
- 選択肢は事前に用意もでき、簡単に指定できる
- プロンプトが思いつかない場合の追加がしてもらえる。
イメージがわかないかもしれませんが、こんな方を中心に便利な機能です。
- どうしても画像がある時点からワンパターンになってしまう。
- 色々試したいがプロンプトの編集が面倒
- ジャンルごとの品質を高めるプロンプトを探すのが面倒



知っておいて損はない。むしろ知らないなら絶対便利に思える機能です!
インストール方法
他の拡張機能と同様です。
※画面は日本語化パッチを外しています。
拡張機能(Extensions)タブ
Extensionsのタブのさらに「Available」タブを選択する。
下記のURLが設定されていることを確認し、「Load from:」ボタンを押してください。
https://raw.githubusercontent.com/wiki/AUTOMATIC1111/stable-diffusion-webui/Extensions-index.md


一覧が表示されますので、ブラウザ検索で「dynamic」と検索してください。
幾つか該当しますが、下記の機能をインストールします。(例は既にインストール済み画面)


そして、Setting画面から「Reload UI」を押すと「txt2img」タブに下記が現れます。
これでインストール完了です。


デフォルトで「Dynamic Prompts enabled」がチェックONになっているはずです。
常時ONでも構いません。
使い方
動的な選択
複数要素からランダムに1つ
例えば、ドレスの色を「赤」、「青」、「金髪」から選択したい場合、下記のようにプロンプトを記載できます。
{red | blue | white} dress


複数要素から指定個数
例えば、ドレスの色を「赤」、「青」、「金髪」から2色選択したい場合、下記のように記載できます。
{2$$red | blue | white} dress




指定数をランダムに
例えば、ドレスの色を「赤」、「青」、「金髪」からランダム個数選択したい場合、下記のように記載できます。
{1-3$$red | blue | white} dress


さらに、指定する区切り文字をカンマ(デフォルト)から”and”に変更できます。
{2$$and$$ red | blue | white } dress







どちらが主体の色になるかといった訳でもなさそうです
ランダム割合を指定
例えば、ドレスの色を「赤」を3対、「青」を1といった指定ができます。(小数点も可能)
{3::red | blue} dress


ワイルドカード指定
要領は一緒ですが、都度タイピングするのが面倒であれば事前にファイルに定義できます。
例えば、「髪の毛の色」といった定義ファイルに、出力したい色を定義しておけます。
「色」でも良いのですが、服の色と髪の色では指定が違うといった場合は、分けたほうがよいです。
\stable-diffusion-webui\extensions\sd-dynamic-prompts\wildcards



例えば、下記のテキストファイルを配置した場合で説明します。
red
blue
green
pink
magenta
orange color
white
black
grey
髪の毛の色をワイルドカード指定
先ほど作成したファイルでドレスの色を指定してみます。
__color__ dress, 1girl,


先程の動的指定とネストできます
例えば、明るい色と暗い色で定義を分けていた場合
{ __bright_color__ | __dark_colors__ } dress, 1girl,
それぞれ、2対1の割合で下記だすなら下記です。
{ 2::__bright_color__ | __dark_colors__ } dress, 1girl,
また、ワイルドカードを記載している中でも再帰的に処理できます。
red
blue
yellow
gray
black
__bright_color__
__dark_colors__
さらに、PythonやC言語の形式でのコメントまで許容されています。
# これはコメントです
// これもコメントです
{ A | /* さらにこれもこめんと */ B }
組合せ出力
今回のように、全ての組合せを出力する方法があります。
下記のチェックをONにしてください。


インストールしたフォルダの配下に「ui-config.json」があります。そちらを修正してください。
"img2img/Batch count/value": 1,
"img2img/Batch count/minimum": 1,
"img2img/Batch count/maximum": 100,
"img2img/Batch count/step": 1,



上げるとスライダーでは指定しづらくなります。
マジックプロンプト
頭にある情景を言葉にするのも結構難しいものです。
ましてや、それをプロンプトにしていくにはあれこれ検索したりツールを使ったり翻訳したりする必要があります。
これは、文章からそういったプロンプトを補ってくれるツールです。
画面では、下記で指定します。


項目 | 内容 |
---|---|
Magic prompt | マジックプロンプト機能の利用を制御 |
Max magic prompt length | 追加されるプロンプトの長さ |
Magic prompt creativity | 生成されたプロンプトの質感を調整 |
Magic prompt model | プロンプトを生成する言語モデル ※幾つか追加されないものがあり (Windowsのウィルスソフトと干渉?) |
I’m feeling lucky | lexica.artのAPIを使用してプロンプトを生成 似たようが画像からプロンプトを取ってくるらしい |
Attention grabber | 追加生成されたプロンプトの強調度合いを調整 |
いろいろオプションがあったので試してみます。
A mech-warrior in a post-apocalyptic setting.


先ずはモデルの適用





元の絵も品質が高かったですが、よりシャープにツヤ感等もでています。
PromptMagic項目 | 設定値 |
---|---|
Max magic prompt length | 100 |
Magic prompt creativity | 0.7 |
I’m feeling lucky | OFF |
Attension grabber(min) | 1.1 |
Attension grabber(max) | 1.5 |
a highly detailed epic cinematic concept art CG render digital painting artwork costume design: Samus Aran, Warrior, Warrior, Warrior, Warrior, Warrior, Warrior, Warrior, Warrior, By Greg Rutkowski, Ilya Kuvshinov, WLOP, Stanley Artgerm Lau, Ruan Jia and Fenghua Zhong, trending on ArtStation, subtle muted cinematic colors, made in Maya, Blender and



先ずは「Magic prompt creativity」から変更します。




2.0で突然全身になりました。しかし、3.0でまた同じ構図に戻ります。
それぞれのプロンプト(展開してください)
A mech-warrior in a post-apocalyptic setting. a highly detailed epic cinematic concept art CG render digital painting artwork costume design: Samus Aran, Warrior, Warrior, Warrior, Warrior, Warrior, Warrior, Warrior, Warrior, By Greg Rutkowski, Ilya Kuvshinov, WLOP, Stanley Artgerm Lau, Ruan Jia and Fenghua Zhong, trending on ArtStation, subtle muted cinematic colors, made in Maya, Blender and
A mech-warrior in a post-apocalyptic setting. a highly detailed epic cinematic concept art CG render digital painting artwork costume design: Samus Aran from Metroid, By Greg Rutkowski, Ilya Kuvshinov, WLOP, Stanley Artgerm Lau, Ruan Jia and Fenghua Zhong, trending on ArtStation, subtle muted cinematic colors, made in Maya, Blender and Photoshop, octane render, excellent composition, cinematic atmosphere, dynamic dramatic
A mech-warrior in a post-apocalyptic setting. a highly detailed epic cinematic concept art cg render, made in maya, blender and photoshop, octane render, excellent composition, cinematic dystopian brutalist atmosphere, dynamic dramatic cinematic lighting, aesthetic, very inspirational, arthouse, y Greg Rutkowski, Ilya Kuvshinov, WLOP, Stanley Artgerm Lau, Ruan Jia and Fenghua Zhong, (symmetry:1.21) portrait of the n
A mech-warrior in a post-apocalyptic setting. a highly detailed epic cinematic concept art cg render, made in maya, blender and photoshop, octane render, excellent composition, cinematic dystopian brutalist atmosphere, dynamic dramatic cinematic lighting, aesthetic, very inspirational, arthouse, y greg rutkowski, zabrocki, karlkka, jayison devadas, trending on artstation, 8 k, ultra wide angle, zenith view
A mech-warrior in a post-apocalyptic setting. cyberpunk steampunk sci style, sci tech city in the background, ultra real artgerm style masterpiece intricate masterpiece painted in neon colors, digital light grading 3 d infrared octane render trending backlit artstation masterpiece pinterest gsociety. 3 d rendering, greeling rukapetya, character sheet sheet, fantasy art painting character design character concept pose, full length full figure photo of woman, close skin
A mech-warrior in a post-apocalyptic setting. cyberpunk steve argers-gate is standing over the giant fire of war against humanity through sheer fury & rage designed well detailed futuristic machines, volatus is a massive towering mountain looming in back, daniel john pierce gonzel edric lebowie jacquero raul del tino marí del meja nee paz ruan wood, dark on design character hair long flowing long gauntlets long with skin



クリエイティブ度が上がっているのか?判断つかなかったので次は下げてみます。





手前にこちらを向いた女性が現れました!
徐々に数値を下げますが、後ろのロボットすら消えてしまいました。



いつから女性が現れたのか、気になったので0.7までの付近も探ります


どうやら0.5から0.6の間で大きく絵柄が変化しています。



というか、0.5の構図は0.4につながっていませんね(^_^;)



次に、I’m feeling luckyにチェックをつけてみます!





これはラッキーなのでしょうか。いい腹筋です
最後にプロンプトの重要度(Attention grabber)を試しましたが、このモデルでは差が出ませんでした。
よって、次のモデルに切り替えます





渋く厳ついおっさんですね。。



先ずはminを1.1→1.2に変化させます


A mech-warrior in (a post-apocalyptic setting:1.34). endprompt] "I'm a warrior." The voice was loud and commanding. The man behind the desk was a man in his mid-forties, his hair a thick, thick bun, He had the look of an old man, but he had a certain charm about him. "You're just a soldier." "You're a warrior," the man responded. "I'm not



次は1.3にしてみます。


A mech-warrior in (a post-apocalyptic setting:1.39). endprompt] "I'm a warrior." The voice was loud and commanding. The man behind the desk was a man in his mid-forties, his hair a thick, thick bun, He had the look of an old man, but he had a certain charm about him. "You're just a soldier." "You're a warrior," the man responded. "I'm not



プロンプトを見ての通り、こちらは強度が加えられているだけです
まとめ
魅力的な機能から、やや使い勝手の難しいものもありました。



下記が私の使用感ですので、よかったら参考にしてください。
機能 | 内容 |
---|---|
動的な選択 | ワイルドカードにする前の検証で使えそうです。 数キーワードを限定したい場合等にもこちらが良さそうです。 |
ワイルドカード指定 | 基本、こちらがメインになりそうです。 プロンプト作成で気になるワードがみつかれば、随時ワイルドカードに追加といった状態になりそうです。 |
マジックプロンプト | どちらかというと神頼み的な感じになってしまいます。 品質系のプロンプトを決めた後に可変ワードを入れてた流れがそう思わせるのかもしれません。ただ、プロンプトの発掘的な形で行き詰まって利用し、蓄える。 もしくは、最初の基本的なプロンプトを見つけるまでの利用ならアリかもしれません。 |



最後までご覧いただきありがとうございました!
コメント