見出し画像

<学習シリーズ>Stable Diffusionでpromptを学んでみた

1.概要

 本記事は”学習シリーズ”として自分の勉強備忘録用になります。

 AIを用いてテキストから画像を生成するAI Generated Artが活発となり、特に2022年8月23日にstable diffusionがOSSとして公開されてから隆盛を極めております。
 「自分が生成したい画像」をAIで作成するため「最適なPrompt」の記法をトライアルしました。なお画像生成方法は下記記事をご確認ください。

2.学習1:ラマの画像生成をマネしてみた

 Zhong氏の記事では理想の画像を生成するためのpromptを試行錯誤しており、今回はこの記事から画像生成を学びました。
 なおZhong氏はDALL-E2を使用しておりますが、私はstable diffusionを使用しました。

 出力結果の構成としては、上にZhong氏の写真(DALL-E2)、下に私が作成した画像(stable diffusion)を示します。

2-1.シンプルなprompt

 シンプルなpromptで実行した結果は下記の通りです。

【結果まとめ】
●DALL-E2はアニメ風だがstable diffsionは初めからリアル画に近かった。ただstable diffsionはラマが存在しない写真も出てきた。
●"realistic of "をつけるとDALL-E2ではそれっぽい写真は出たが切り抜き画像のような感じになった。
●"realistic of "をつけるとstable diffusionの方は"playing"の部分が十分に認識されずラマとバスケットボールの画像が表示されているだけになった。

【promptまとめ】

  • llama playing basketball

  • realistic photo of llama playing basketball


llama playing basketball

realistic photo of llama playing basketball

2-2.改善prompt/Zhong氏コメントまとめ

 Zhong氏コメントより重要そうな部分を抜粋しました。

【Zhong氏コメントのまとめ】
●Zhong氏のお気に入りのワードは「dramatic backlighting
●DALL・E2には「まさに自分が欲しいもの」を伝える必要がある
 ー>画風(今回は映画スチール:Film still)、着せたい服、撮影の向き・距離、情景
●DALL・E2は構図の作成が上手くない
 ー>「llama dunking a basketball」でpromptを与えてもラマ-リング-ボールの関係を正しく理解できていない。
 ー>間違った例だとテクスチャーもごっちゃになりリングのネットが毛皮になったりもする。
●DALL・E2ではリアルな顔の生成は困難である(出典
 ー>ディープフェイク生成防止のため
 ー>いくつかの画像ではラマの顔がつぶれて表示された
●DALL・E2は角度や撮影(shots)に関してはルーズに解釈される
 ー>Zhong氏より、‘in the distance’ や ‘extreme long shot’と入れてもフレーム内にラマ全身を収める画像生成は難しかった。
●DALL・E2はスペリング(意味のある文字列記載)ができない
●DALL・E2は複雑だったり稚拙な言葉のpromptは予測できない
 ー>「A low angle, long shot, indoors, dramatic backlighting, professional photo of a llama wearing a jersey, dunking a basketball.」だとラマはでない
 ー>「fluffy」を入れると性能低下によりまともな画像がでなかった
 ー>「詰め込みすぎず冗長にならないよう明確に欲しいものを記載する
●DALL・E2はStyle(流派・様式・画風)の転写が得意
 ー>例として‘Abstract painting of….’、‘Vaporwave’、‘Digital art’、‘Screen
shots from the Miyazaki anime movie’などがある。
●Zhong氏Final Prompt「“Film still of a llama in a jersey dunking a basketball like Michael Jordan, low angle, show from below, tilted frame, 35°, Dutch angle, extreme long shot, high detail, indoors, dramatic backlighting.”」

【promptまとめ】

  • Film still of a llama dunking a basketball, low angle, extreme long shot, indoors, dramatic backlighting.

  • film still of an alpaca wearing a jersey, dunking a basketball, low angle, long shot, indoors, dramatic backlighting, high detail.

  • film still of a llama in a jersey dunking a basketball like Michael Jordan, low angle, show from below, tilted frame, 35°, Dutch angle, extreme long shot, high detail, indoors, dramatic backlighting.”

  • Abstract painting of a llama in a jersey dunking a basketball like Michael Jordan, shot from below, tilted frame, 35°, Dutch angle, extreme long shot, high detail, dramatic backlighting, indoors. In the background is a stadium full of people.

  • Film still of a llama in a jersey dunking a basketball like Michael Jordan, dramatic backlighting, vibrant sunset, vaporwave.

  • llama in a jersey dunking a basketball like Michael Jordan, shot from below, tilted frame, 35°, Dutch angle, extreme long shot, high detail, dramatic backlighting, epic, digital art

  • Film still of a llama in a jersey dunking a basketball like Michael Jordan, low angle, show from below, tilted frame, 35°, Dutch angle, extreme long shot, high detail, indoors, dramatic backlighting.


【Film still of a llama dunking a basketball, low angle, extreme long shot, indoors, dramatic backlighting.】

【film still of an alpaca wearing a jersey, dunking a basketball, low angle, long shot, indoors, dramatic backlighting, high detail.】

【film still of a llama in a jersey dunking a basketball like Michael Jordan, low angle, show from below, tilted frame, 35°, Dutch angle, extreme long shot, high detail, indoors, dramatic backlighting.】

【Abstract painting of a llama in a jersey dunking a basketball like Michael Jordan, shot from below, tilted frame, 35°, Dutch angle, extreme long shot, high detail, dramatic backlighting, indoors. In the background is a stadium full of people.】

【Film still of a llama in a jersey dunking a basketball like Michael Jordan, dramatic backlighting, vibrant sunset, vaporwave.】

【llama in a jersey dunking a basketball like Michael Jordan, shot from below, tilted frame, 35°, Dutch angle, extreme long shot, high detail, dramatic backlighting, epic, digital art】

【Film still of a llama in a jersey dunking a basketball like Michael Jordan, low angle, show from below, tilted frame, 35°, Dutch angle, extreme long shot, high detail, indoors, dramatic backlighting.】

2-3.所感:DALL-E2とStable diffusionの違い

 Promptに関してはDALL-E2を参照してStable diffusionに適用してもよさそうではあるが、Stable diffusion側の特徴もしっかりつかまないと期待する絵は出力できなさそうである。

3.学習2:自分の好きな画像を生成してみた

 前回の学習をベースに自分が表現したい画像を生成してみます。私が一番好きな動物はコツメカワウソです。よって①コツメカワウソ、②可愛い感じ、③アートっぽい感じ の画像を生成させてみました。

3-1.シンプルなprompt

 とりあえずシンプルに結果を出力してみました。

【出力に関する所感】
●何も書いてなくても水辺が多い。"on the rock"ってしても水の中にいる子もいる。
●水辺に近いからか全部ウェット。元画像みたいに乾いた状態の方がほしい
●DALL-E2のように顔がつぶれることはないけど微妙にきもいやつが多い。あと野良感が強くてちょっと怖い
●特に指定は指定してないが首から上だけの画像が多く体全体の絵が少ない(DALL-E2にもあったが角度やshotsの指定をしても全体を表示させるのは難しかった)。

【promptまとめ】

  • little otters

  • realistic photo of little otters

  • little otter gazing at here

  • little otter gazing at here on the rock


【little otters】

【realistic photo of little otters】

【little otter gazing at here】

【little otter gazing at here on the rock】

3-2.promptに修飾語を追加

 より可愛く表示させたいため詳細を追加していきました。追加した修飾語は"fluffy(ふわふわした)※", "round eye(丸い目)", "looking up(見上げる)", "full body(全身)", "dry(乾燥した)"などです。
※DALL-E2のLlamaだと「fluffyという単語は結果を最悪にした」ことを後で気づきましたが、今回のstable diffusionでは悪影響はありませんでした。

【出力に関する所感】
●今見れば「gazing at here」と「looking up」という同時にできないprompt書いてた。この場合は先に書いている方が強いかも
●"dry"と書いてもウェット感は消えずに水辺からも脱出できないし、"full body"と書いても全身がでてこない。DALL-E2の例でもある通り「角度や撮影(shots)」に関しては感度が低い可能性がある。
●個人的に一番好きなのは下図だがアート感は全然ない。

【promptまとめ】

  • fluffy little otter gazing at here on the rock

  • fluffy little otter gazing at here ,round eye

  • fluffy little otter gazing at here ,round eye, looking up

  • fluffy little otter gazing at here,dry ,round eye, looking up

  • fluffy little otter gazing at here,dry ,round eye, looking up, full body

  • cute fluffy little otter gazing at here,dry ,round eye, looking up, full body


【fluffy little otter gazing at here on the rock】

【fluffy little otter gazing at here ,round eye】

【fluffy little otter gazing at here ,round eye, looking up】

【fluffy little otter gazing at here,dry ,round eye, looking up】

【fluffy little otter gazing at here,dry ,round eye, looking up, full body】

【cute fluffy little otter gazing at here,dry ,round eye, looking up, full body】

3-3.promptにスタイルを追加

 DALL-E2でも得意であるスタイルの追加をしてアートっぽい絵にしていきます。絵に詳しくないのでとりあえず”油絵”をベースにしながら背景も追加していきました。
 追加した単語は"oil painting(油絵)", "vibrant sunset(鮮やかな夕日・夕焼け)", "Dutch angle(ダッチアングル)", "in space(宇宙で)"です。

【出力に関する所感】
●スタイルを追加することでグッとアートっぽくなった。
●油絵だけだとまだ「コツメカワウソの油絵」だが、背景をつけるとそれとの構図が生まれた(ような気がする)。

【promptまとめ】

  • oil painting of fluffy little otter gazing at here,dry ,round eye, looking up, full body

  • oil painting of fluffy little otter gazing at here, dry ,round eye, looking up, full body, vibrant sunset

  • oil painting of fluffy little otter gazing at here, dry ,round eye, looking up, full body, Dutch angle

  • oil painting of fluffy little otter gazing at here, dry ,round eye, looking up, full body, in space


【oil painting of fluffy little otter gazing at here,dry ,round eye, looking up, full body】

【oil painting of fluffy little otter gazing at here, dry ,round eye, looking up, full body, vibrant sunset】

【oil painting of fluffy little otter gazing at here, dry ,round eye, looking up, full body, Dutch angle】

【oil painting of fluffy little otter gazing at here, dry ,round eye, looking up, full body, in space】

3-4.マイベストフォト

 タイトルにもしてる通り好きなのはこれらでした。

4.学習3:img2promptでリバースエンジニアリング

 Promptの入力方法を学びましたがまだ自分が欲しいpromptを自在に作れるほどではありません。すでに逆の操作として画像からpromptを生成するサービスを提供している人がいるためそちらでも試してみました。

 前章で作成した画像からどのようなpromptが生成されるか確認します。

  • Origin1:oil painting of fluffy little otter gazing at here,dry ,round eye, looking up, full body

  • img2p1:a painting of a sea otter sitting on a rock, an airbrush painting by Valerie Petts, featured on deviantart, photorealism, oil on canvas, acrylic art, detailed painting

  • Origin2:oil painting of fluffy little otter gazing at here, dry ,round eye, looking up, full body, in space

  • img2p2:a painting of two otters with a blue background, a fine art painting by Lisa Frank, featured on pixiv, massurrealism, storybook illustration, airbrush art, oil on canvas

  • Origin3:oil painting of fluffy little otter gazing at here, dry ,round eye, looking up, full body, vibrant sunset

  • img2p3:a painting of a sea lion in a circle, an airbrush painting by Lorraine Fox, featured on deviantart, metaphysical painting, oil on canvas, acrylic art, airbrush art

 用語もそうですが"Valerie Petts"や"Lorraine Fox"などアーティストの名前も入ってきております。画風が似ているかはよくわかりませんがアーティスト名を入れるとスタイルに大きく影響するかもしれません。

5.学習4:他の人のPromptを参考

シンプルですが他の人のアイデアを模倣しながら構図の作り方を学びます。



参考資料1:技術

参考資料2:絵画

あとがき

 遊びのつもりだったけど出力したい表現を考えるのめちゃくちゃ頭使うし、語彙力が低すぎて思ってた以上にしんどかった。
 あといろいろな人が既にfine tuningしたいろいろなサービス出してて早すぎる・・・・・

この記事が気に入ったらサポートをしてみませんか?