見出し画像

Stable Diffusion web UIのLoRAにLyCORIS追加してみた!

こんいちは、あるいは、こんばんは!
昼夜逆転というのか回転して訳わからない生活を送っています。
何しろ、気になったことをついつい調べていると、時間がメルティングぁぅぇぃ・・・。

LyCORISモデルなるものを使用できるように、Stable Diffusion環境を調整してみました。
きっかけは、これと言っていないですが、 来るべきに備えて? (単に気になっただけ)です
詳細は勉強不足で、仕組みやら違いやらの解説できません。

LyCORISモデル

モデルやらLoRAやらを探して行きつく先に、civitaiというものがあります。
膨大な量のリンク集の解説記事もありますよ。

Stable Diffusion Web UI のセットアップ

Stable Diffusion Web UI 自体の実装は、詳細な解説記事などがたくさんあります。ここでは説明しませんが、参考になりそうな情報を提供しますね。

【YouTube】
日本一わかりやすいStableDiffusion WebUI AUTOMATIC1111(ローカル版)のインストール方法と基本的な使い方
は、非常に分かりやすいのではないかと思いますよ。

一番の難関は、Python環境の実装と思います。
xformersはエラーが出たまま、放置しています。
わたしには原因がわかりません。

Stable Diffusion Web UI の起動

わたしの環境では以下のようにしてStable Diffusionを立ち上げます。

conda activate py310
cd /Users/user/Dropbox/GitHub/clone/stable-diffusion-webui
python launch.py --skip-python-version-check

Anacondaを導入してpy310という仮想環境に、Python 3.10を入れています。
ワーキングディレクトリをドロップボックス内のGitHubからダウンロード(git clone)するフォルダにStable Diffusion Web UI が格納されています。
pythonでlaunch.pyを走らせます。

しばらくすると、

Running on local URL:  http://127.0.0.1:7860

のように表示されますので、ウェブブラウザから
http://127.0.0.1:7860
にアクセスします。

拡張機能としてLyCORISを導入するよ

配布先の情報です。
KohakuBlueleaf 様の a1111-sd-webui-locon を導入します。

(以下のURLをコピーします)
https://github.com/KohakuBlueleaf/a1111-sd-webui-locon

Stable Diffusionを立ち上げて、
①タブが並んでいるところの「Extensions(拡張機能)」を選択
②さらにタブが並んでいますので「Install from URL(URLからインストール)」を選択
③「URL for extension's git repository(拡張機能のリポジトリのURL)」に、上記のURLを貼り付けます。
Install(インストール)してみましょう!

①Extensions(拡張機能)
②Install from URL(URLからインストール)
③URL for extension's git repository(拡張機能のリポジトリのURL)
④Install(インストール)

ありがちなエラーメッセージ・・・
今後も拡張機能入れるのに障害が出そうです(> <;)

根本的な課題解決は わたしにはできないため、ダウンロード(git clone)してからLocal directory name(ローカルディレクトリ)を指定しようと思います。
わたしの環境では・・・(中略)・・・
extensionsのディレクトリに移動し、git cloneにてダウンロードしました。
(GitHubからダウンロードすることも可能ですよ)

cd /Users/user/Dropbox/GitHub/clone/stable-diffusion-webui/extensions
git clone https://github.com/KohakuBlueleaf/a1111-sd-webui-locon

Local directory name(ローカルディレクトリ)」にa1111-sd-webui-loconフォルダのパスを入力します。
(私の環境では以下)
C:/Users/user/Dropbox/GitHub/clone/stable-diffusion-webui/extensions/a1111-sd-webui-locon

「すでにディレクトリがありますよ」エラーが出てしまい良くわからず、「Avairable(拡張機能リスト)」でloconを検索したらヒットしました。

拡張機能リストにもともとリストアップされているのかもしれません。

Install(インストール)」を押すと、「すでにディレクトリがありますよ」エラーが・・・(--;)
とりあえずUIを再起動したら・・・入っていたようです!!

Installed(インストール済)にリストアップされています

LyCORIS使ってみよう!

LyCORISモデルは、LoRAフォルダ内に保存します。

# わたしのLoraフォルダパス
"C:\Users\user\Dropbox\GitHub\clone\stable-diffusion-webui\models\Lora"

LoRAと同じように花札ボタンを押して選択すると適用されますよ。

花札っぽいボタンを押す
Loraタブを開いて使用するLyCORISを選択
→ Promptに影響度 = 1で入力されます

civitaiでLyCORISを検索して、使ったみたよ!

使用したLyCORISモデル
They challenged FX | LoHa (LyCORIS)
https://civitai.com/models/25706/they-challenged-fx-or-loha-lycoris

Prompt:
<lora:theyChallengedFXLoha_v10:1>

まず、txt2imgでキャラクター画像を生成します(左)。

Prompt:
(masterpiece, best quality:1.2), aberration, upright, standing, looking at viewer, (full body view:1.3), 1 girl, hakurei reimu,
Negative prompt:
(EasyNegative:1.5), (ng_deepnegative_v1_75t:0.75), (worst quality, low quality, normal quality:1.4),
Other settings:
Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 2961448116, Size: 512x512, Model hash: 6e430eb514, Model: anything-v4.5-pruned, Denoising strength: 0.75, Mask blur: 4

同じプロンプトでimg2imgをします(中)。
LyCORISを加えてimg2imgをします(右)。

  左側:txt2img        真ん中:img2img    右側:img2img (LyCORIS)

AIが考える風景画:ChatGPT x Stable Diffusion

最後に風景画を作成してみました。
せっかくなので、ChatGPTに構想を考えていただきました。

以下、長くなるため読み飛ばしてください(- -;)

ファンタジー世界の荘厳な風景画を構想しています。 何か目を惹くようなものを英語で表現してくれませんか。 具体的に、形容詞をふんだんに使ってください。 数個の単語で、カンマで区切って、とても多くの様々な単語を駆使して表現してください。 パステルカラーのきれいな風景画をお願いします。 さいごに日本語で簡潔に解説をお願いします。

わたし

Sure, here's an even more elaborate description of a pastel-colored fantasy landscape that might catch your eye, using a variety of adjectives and commas to separate them:
The mesmerizing pastel panorama that unfolds before you is nothing short of breathtaking. Towering, snow-capped peaks, reminiscent of spun sugar, reach up into the fluffy, cotton-candy clouds, while the lush, verdant forest below, with its delicate foliage and gnarled trunks, exudes a tranquil, ethereal charm. The air is alive with a faint, wispy mist that gives the scenery an almost mystical quality, as if it were a world conjured from a dream.But it's the details that truly captivate your senses. The wildflowers that carpet the landscape range in hue from the palest pink to the deepest lavender, their soft petals caressing the gentle breeze. A crystal-clear lake, as smooth and inviting as polished glass, sparkles in the soft, warm light, casting prismatic reflections across the surrounding landscape. And a majestic castle, its spires and turrets gleaming in the pastel hues of the setting sun, stands sentinel atop a nearby hill, evoking a sense of timelessness and grandeur.
As you take in the scene, you can feel a sense of enchantment and wonder filling the air, as if you've stumbled upon a secret, mystical world that's hidden away from the rest of reality. It's a place of beauty, tranquility, and limitless potential, where the boundaries between dreams and reality seem to blur.
解説:この文章は、美しいファンタジー世界の景色をパステルカラーで表現しています。綿菓子のような雪を被った山々、繊細な葉や枝があり、幻想的な魅力を漂わせる緑豊かな森林、妖精の国のような霧、桜や藤色の花々、美しく光り輝く湖、そして壮大な城が、日没時の柔らかな光の中で鮮やかな色合いで描かれています。この文章は、読者を魅了し、夢の世界に連れて行ってくれるような、詩的な表現を使用しています。

ChatGPT

AIとAIによるアート作品

ChatGPTが考えたAIアート

parameters

Prompt:
The mesmerizing pastel panorama that unfolds before you is nothing short of breathtaking. Towering, snow-capped peaks, reminiscent of spun sugar, reach up into the fluffy, cotton-candy clouds, while the lush, verdant forest below, with its delicate foliage and gnarled trunks, exudes a tranquil, ethereal charm. The air is alive with a faint, wispy mist that gives the scenery an almost mystical quality, as if it were a world conjured from a dream….
<lora:claudeMonetPainting_v3:1>
Negative prompt:
(EasyNegative:1.5), (ng_deepnegative_v1_75t:0.75), (worst quality, low quality, normal quality:1.4),
Other settings:
Steps: 30, Sampler: DPM++ SDE Karras, CFG scale: 8, Seed: 4094992083, Size: 1280x670, Model hash: 16c6ca45b1, Model: HyperBombMix-fp16-no-ema

まとめ

細かく見るとおかしなところがあると思います。
絵心がないわたしでも、なんちゃってアートができますが、レタッチ技術やモデルの構築・調整、ペイント技術なども勉強していきたいものです。
やりたいこと、たくさんあって、概日リズム崩壊しちゃいますね。。。




この記事が参加している募集

やってみた

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