今回は、Stable Diffusion web UIで、LyCORISを使う方法を紹介します。
※2023/05/30追加
LyCORISの使い方が変わったようです。
コメントにて教えていただきました。ありがとうございます。
記事の方も、新しい方法に更新しました。
LyCORISについて
LyCORIS(Lora beYond Conventional methods, Other Rank adaptation Implementations for Stable diffusion.)は、LoRAのように、ほかのモデルに対して追加学習を行なうことができます。
LyCORISでは、AIコスプレイヤーのような画像、そのモデルの絵柄で描いたアニメキャラの画像、などを生成することができます。
たとえば、「ウマ娘 プリティーダービー」の「ミホノブルボン」のLyCORIS(https://civitai.com/models/8940/mihono-bourbon-umamusume)を実写系のモデルで使った場合は、次のようになります。

LyCORISの入手方法
LyCORISのモデルファイルは、CIVITAI(https://civitai.com/)などからダウンロードできます。
CIVITAIの漏瑚マークをクリックし、「LyCORIS」を選択します。
これで、表示をLyCORISのみに絞り込むことができます。

LyCORISを使うための準備
では、LyCORISを使う準備をしてみましょう。
「Stable Diffusion web UI」で「LyCORIS」を使うには、「a1111-sd-webui-lycoris」という拡張機能を使います。
a1111-sd-webui-lycoris:https://github.com/KohakuBlueleaf/a1111-sd-webui-lycoris
また、今回はベースのモデルとして「Chilloutmix」、LyCORISに「Mihono Bourbon (umamusume)」を使おうと思います。ここは、好みのものをお使いください。
- CIVITAI[Chilloutmix]:https://civitai.com/models/6424/chilloutmix
- CIVITAI[Mihono Bourbon (umamusume)]:https://civitai.com/models/8940/mihono-bourbon-umamusume
Google Colab上の「Stable Diffusion web UI」で、LyCORISを使う場合
もし、Google Colab上のStable Diffusion web UIでLyCORISを使うのでしたら、次のコードを実行します。
!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
%cd /content/stable-diffusion-webui/extensions/
!git clone https://github.com/KohakuBlueleaf/a1111-sd-webui-lycoris.git
%mkdir -p /content/stable-diffusion-webui/models/LyCORIS/
!wget https://civitai.com/api/download/models/11745 -O /content/stable-diffusion-webui/models/Stable-diffusion/Chilloutmix-Ni-pruned-fp32-fix.safetensors
!wget https://civitai.com/api/download/models/23083 -O /content/stable-diffusion-webui/models/LyCORIS/mihonoBourbon_loha.safetensors
%cd /content/stable-diffusion-webui/
!python launch.py --share --xformers --enable-insecure-extension-access
(※2023/06/26 エラーが発生するようになってしまったので、コードを更新しました)
しばらく待って、Running on public URLというのが表示されたら、その後ろのリンクを開きます。
また、Google ColabでStable Diffusion web UIを使う方法について、くわしく知りたい場合はこちらをご覧ください。
ローカルの「Stable Diffusion web UI」で、LyCORISを使う場合
ローカルの「Stable Diffusion web UI」でLyCORISを使う場合、「Stable Diffusion web UI」の画面から設定できます。
(Colabを使った場合でもこの方法は使えますが、「Stable Diffusion web UI」を起動するたびに設定しなくてはならないので、おすすめはできません)
では、「Stable Diffusion web UI」でLyCORISを使うために、拡張機能「a1111-sd-webui-lycoris」をインストールしてみましょう。
「Extensions」→「Install from URL」と選択し、以下のURLを「URL for extension’s git repository」に貼り付けます。
https://github.com/KohakuBlueleaf/a1111-sd-webui-lycoris

「Install」をクリックすると、installed into xxxxxx. Use Installed tab to restart.と表示されます。

さらに、「Installed」タブを選択し、「Apply and restart UI」をクリックすることで、拡張機能が適用されます。

また、さきほど紹介したモデルも、「models」フォルダの中に「LyCORIS」というフォルダを作成して、そこに配置します。
- CIVITAI[Chilloutmix]:https://civitai.com/models/6424/chilloutmix
- CIVITAI[Mihono Bourbon (umamusume)]:https://civitai.com/models/8940/mihono-bourbon-umamusume
stable-diffusion-webui/
|-- models/
| |-- LyCORIS/
| | `-- mihonoBourbon_loha.safetensors
| |-- Stable-diffusion/
| | `-- Chilloutmix-Ni-pruned-fp32-fix.safetensors
| `-- ...省略...
`-- ...省略...
ここでもう一度、Stable Diffusion web UIを実行しなおしておきましょう。
私の環境では、実行しなおさないと、extra networksを開いたとき、LyCORISをうまく読み込むことができませんでした。
LyCORISを使って画像生成してみよう
では、LyCORISを使って、実際に画像生成してみましょう。
Stable Diffusion web UI上で、LyCORISを使う方法を、これから紹介していこうと思います。
LyCORISを使うのに、まずTrigger Wordsというものが必要です。
Trigger Wordsは、LyCORISのダウンロードページに書かれています。
たとえば、今回使いたいLyCORISの「Mihono Bourbon (umamusume)」では、「mihono bourbon \(umamusume\)
」というのが、Trigger Wordsになっています。

Trigger Wordsをクリックすることで、コピーできます。

コピーしたTrigger Wordsは、プロンプトに入力しましょう。

さらに、①Generateの下のextra networksのアイコンをクリックして、②LyCORISを選択します。
③使いたいLyCORISのファイルをクリックすると、④プロンプトに画像のように追加されます。

また、lyco:mihonoBourbon_loha:の後ろの数値は、どのくらい適用するかの数値(重み)です。
この数値が大きすぎても、いいイラストが生成できないので、微妙な調節が必要になります。
これも含めてさまざまな設定がありますが、たいていはLyCORISのダウンロードページに、どんな設定にするといいのかが書かれていると思います。

まとめ
今回はStable Diffusion web UI上でLyCORISを使う方法を紹介しました。
LyCORISをつかうことで、LoRAのようにモデルに追加学習をすることができ、Stable Diffusion web UI上で使うには、拡張機能「a1111-sd-webui-locon」が必要になります。
いくつか設定が必要ですが、どんなふうに設定すればいいのかは、おそらくLyCORISのダウンロードページに書かれています。