【初心者向け】Textual inversion「EasyNegative」の使い方!!!
![](https://blogcake.net/wp-content/uploads/2023/03/Stable-diffusion-easy-negative.jpg)
こんにちは、画像生成AIでひたすら猫のイラストを生成している じょじお(@jojio‗illust)です。
今日もStable Diffusion WebUIの記事です。
前回の記事で、プロンプトの入力の手間をスキップできる「Styles」機能について紹介しました。
![](https://blogcake.net/wp-content/uploads/2023/03/Stable-diffusion-style-300x158.jpg)
この記事では、前回とは違った視点で、ネガティブプロンプトの入力の手間をスキップできる機能、「Textual Inversion(テクスチュアルインバージョン)」について解説します!!!!
Stable Diffusionのプロンプトエンジニアリングの基本について理解したい方には、初心者向けのプロンプトガイドを作りましたのでそちらを見てください!
![](https://blogcake.net/wp-content/uploads/2023/03/stable-diffusion-prompt-guide2-300x158.jpg)
![](https://blogcake.net/wp-content/uploads/2023/02/eagle-eyecatch-300x158.jpg)
▲AI画像の大量ファイルをプロンプトと一緒に簡単に整理する方法はこちら。
![](https://blogcake.net/wp-content/uploads/2023/01/capture_01-300x158.jpg)
▲素材に関連する英単語100個以上まとめました。
![](https://blogcake.net/wp-content/uploads/2022/11/Midjourney-prompt-matome-300x158.jpg)
▲すべてのプロンプト関連記事はこちらにまとめています。
![](https://blogcake.net/wp-content/uploads/2023/01/midjourney2-300x158.jpg)
▲Midjourneyユーザー向け。専用Discordサーバーを作って画像生成作業を効率化する方法。
Textual invisionとは?
EasyNegativeは、Textual Inversion(テクスチュアルインバージョン)という仕組みでつくられたファイルです。
ですので、まずTextual Inversionについて簡単に解説します。
Textual Inversionは、モデルの追加学習の方法のひとつです。詳しい解説はこちら(https://textual-inversion.github.io/)にあります。
リンク先の内容を下に引用します。
We learn to generate specific concepts, like personal objects or artistic styles, by describing them using new “words” in the embedding space of pre-trained text-to-image models. These can be used in new sentences, just like any other word.
(DeepLによる訳)個人的な物や芸術的なスタイルのような特定の概念を、事前に訓練されたテキスト画像モデルの埋め込み空間で新しい 「言葉」 を使って記述することによって生成することを学ぶ。
これらは他の単語と同じように、新しい文で使用できます。
https://huggingface.co/docs/diffusers/training/text_inversion
この引用の説明を聞いてわかりましたでしょうか?
私はよくわからなかったので、海外の記事をいくつか読んだ私の解釈を、次の項で説明してみます。
Textual Inversionとは?
![](https://blogcake.net/wp-content/uploads/2023/03/colorful_teapot-1024x265.jpg)
Textual Inversionは、モデルに対して、追加の学習結果を適用できるStable Diffusionの機能です。
この追加の学習結果は、画像生成時に、事前に定義された特定のワード(トリガーワードと呼ぶ)で呼び出すことで適用できます。
私たちユーザーは、追加の学習結果(モデルファイル)を利用することで、いつもと同じモデルを使っているのに、いつもとはちょっと違った生成結果を得ることができます。
他にもある追加学習の手法
最近流行のLoRa(ローラ)も追加学習の手法のひとつです。
EasyNegativeとは?
![EasyNegativeなし](https://blogcake.net/wp-content/uploads/2023/03/115593836-masterpiece-best-quality-a-girl-looking-at-viewer-bangs-black-hair.jpg)
![EasyNegativeなし](https://blogcake.net/wp-content/uploads/2023/03/115593836-masterpiece-best-quality-a-girl-looking-at-viewer-bangs-black-hair_2.jpg)
「EasyNegative」に話を戻します。
「EasyNegative」は、先に説明したTextual Inversionの仕組みを使って追加学習させたファイルです。
EasyNegativeは、ネガティブプロンプトによく使われている言葉を追加学習させているため、EasyNegativeを使うことで、いつも長々と入力していたネガティブプロンプトを省略しても、入力した時と同様の効果を得られるというメリットがあります。
![](https://blogcake.net/wp-content/uploads/2023/02/jojio-profile-small-150x150.jpg)
「low quality, bad anatomy, うんたらかんたら( ^ω^)・・・」ってやつの入力が不要になります。
対応するモデル
EasyNegativeは、モデル「Counterfeit」の作者さんがCounterfeit用に作成したTextual Inversionファイルです。
Counterfeit以外のモデルでは、下記のモデルにて効果があることを検証済みのようです。
- Counterfeit-V2.0.safetensors
- anything-v4.0-pruned.safetensors
- AbyssOrangeMix2_sfw.safetensors
参考:https://huggingface.co/datasets/gsdf/EasyNegative/tree/main
![](https://blogcake.net/wp-content/uploads/2023/02/jojio-profile-small-150x150.jpg)
![](https://blogcake.net/wp-content/uploads/2023/02/jojio-profile-small-150x150.jpg)
![](https://blogcake.net/wp-content/uploads/2023/02/jojio-profile-small-150x150.jpg)
その他については情報がありませんでしたが、私の体感では2次元系のモデルではだいたい効果を実感できました。
![](https://blogcake.net/wp-content/uploads/2023/02/jojio-profile-small-150x150.jpg)
![](https://blogcake.net/wp-content/uploads/2023/02/jojio-profile-small-150x150.jpg)
![](https://blogcake.net/wp-content/uploads/2023/02/jojio-profile-small-150x150.jpg)
一方、写真系のモデルの一部のプロンプトでは、逆に作画が崩壊してしまうことがありました。
EasyNegativeの使い方は?
EasyNegativeのメリットがわかったところで早速使ってみたいと思います。
手順は簡単です。
EasyNegativeのファイルをダウンロードして所定のフォルダにセットし、「EasyNegative」というトリガーワードをネガティブプロンプトに含めるだけです。
手順
https://huggingface.co/datasets/gsdf/EasyNegative/tree/main
▲Hugging FaceのEasyNegativeのリポジトリにアクセスします。
![](https://blogcake.net/wp-content/uploads/2023/03/2023-03-13_20h07_43.jpg)
![](https://blogcake.net/wp-content/uploads/2023/03/2023-03-13_20h07_43.jpg)
▲safetensorsファイルをダウンロードします。
EasyNegative.safetensors
![](https://blogcake.net/wp-content/uploads/2023/03/2023-03-13_20h09_32.jpg)
![](https://blogcake.net/wp-content/uploads/2023/03/2023-03-13_20h09_32.jpg)
▲WebUIのインストールフォルダの中にある「embeddings」フォルダに、ダウンロードしたsafetensorsを格納します。
![](https://blogcake.net/wp-content/uploads/2023/03/2023-03-13_20h10_45.jpg)
![](https://blogcake.net/wp-content/uploads/2023/03/2023-03-13_20h10_45.jpg)
▲格納しました。
![](https://blogcake.net/wp-content/uploads/2023/03/2023-03-13_20h15_32.jpg)
![](https://blogcake.net/wp-content/uploads/2023/03/2023-03-13_20h15_32.jpg)
▲WebUIを起動して画像生成ボタンの下の「花札のようなアイコン」をクリックします。
![](https://blogcake.net/wp-content/uploads/2023/03/2023-03-13_20h17_45.jpg)
![](https://blogcake.net/wp-content/uploads/2023/03/2023-03-13_20h17_45.jpg)
▲するとTextual Inversionの項目が表示され、EasyNegativeが表示されます。
ネガティブプロンプトのテキストボックスをクリックし、アクティブにした状態で、EasyNegativeをクリックします(上図の赤枠)。
![](https://blogcake.net/wp-content/uploads/2023/03/2023-03-13_20h18_58.jpg)
![](https://blogcake.net/wp-content/uploads/2023/03/2023-03-13_20h18_58.jpg)
▲するとEasyNegativeに紐づけられているトリガーワードである「EasyNegative」という言葉が、ネガティブプロンプトに自動挿入されます。
これで準備完了です。この状態で、いつものようにプロンプトを入力して、画像生成を行います。
EasyNegativeの効果比較
同一シードを使って、「EasyNegativeを使う場合」と「使わない場合」を比較してみました。
モデルは「Counterfeit-V2.0.safetensors」です。
![EasyNegativeなし](https://blogcake.net/wp-content/uploads/2023/03/3189173938-masterpiece-best-quality-a-girl-shop-looking-at-viewer_2.jpg)
![EasyNegativeなし](https://blogcake.net/wp-content/uploads/2023/03/3189173938-masterpiece-best-quality-a-girl-shop-looking-at-viewer_2.jpg)
![EasyNegativeあり](https://blogcake.net/wp-content/uploads/2023/03/3189173938-masterpiece-best-quality-a-girl-shop-looking-at-viewer.jpg)
![EasyNegativeあり](https://blogcake.net/wp-content/uploads/2023/03/3189173938-masterpiece-best-quality-a-girl-shop-looking-at-viewer.jpg)
▲(左)ネガティブプロンプトなし、(右)ネガティブプロンプトに「EasyNegative」
![EasyNegativeなし](https://blogcake.net/wp-content/uploads/2023/03/115593836-masterpiece-best-quality-a-girl-looking-at-viewer-bangs-black-hair.jpg)
![EasyNegativeなし](https://blogcake.net/wp-content/uploads/2023/03/115593836-masterpiece-best-quality-a-girl-looking-at-viewer-bangs-black-hair.jpg)
![EasyNegativeなし](https://blogcake.net/wp-content/uploads/2023/03/115593836-masterpiece-best-quality-a-girl-looking-at-viewer-bangs-black-hair_2.jpg)
![EasyNegativeなし](https://blogcake.net/wp-content/uploads/2023/03/115593836-masterpiece-best-quality-a-girl-looking-at-viewer-bangs-black-hair_2.jpg)
▲(左)ネガティブプロンプトなし、(右)ネガティブプロンプトに「(EasyNegative:1.2)」
![](https://blogcake.net/wp-content/uploads/2023/02/jojio-profile-small-150x150.jpg)
![](https://blogcake.net/wp-content/uploads/2023/02/jojio-profile-small-150x150.jpg)
![](https://blogcake.net/wp-content/uploads/2023/02/jojio-profile-small-150x150.jpg)
明らかに結果が違いますね。
Easynegativeを強調構文を使って強調すると、より画像が鮮明になることもわかりました。
補足
ネガティブプロンプトに追加したいワードが他にもある場合は、「EasyNegative, 〇〇, ▲▲」のように追加しても大丈夫です。
また、通常のワードと同様、EasyNegativeというキーワードを「(EasyNegative:1.2)」のように強調することで効果を強めることもできます。
EasyNegativeをオフにする方法
EasyNegativeを使いたくないときは、トリガーワードをネガティブプロンプトに含めなければよいだけです。
また、永続的に使わない場合は、EasyNegativeのファイルごとEmbeddingsから削除しましょう。
Embeddings(Textual Inversion)の注意点
Embeddings(Textual Inversion)の注意点として、下記の点を見つけました。
Be very careful about which model you are using with your embeddings: they work well with the model you used during training, and not so well on different models.
(DeepL訳)エンベッディングは、学習時に使用したモデルと相性が良く、異なるモデルではあまり相性が良くないので、使用するモデルには十分注意してください。
https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Textual-Inversion
つまり、追加学習時に使用したモデルでないと効果を得られない可能性があるようです。
先述したように、今回紹介したEasyNegativeは、モデル「Counterfeit」の作者さんが作成したため、Counterfeitで追加学習を行いCounterfeit用に作成されたと思われます。
他のモデルでも効果を実感をできる場合もありますが、効果を得ることができないモデルもあるということを知っておきましょう。
モデルによっては推奨されるEmbeddings(Textual inversion)がある場合があるので、使用するモデルのドキュメントを確認するとよいでしょう。
その他のEmbeddings(Textual Inversion)
最後に、EasyNegative以外のEmbeddings(Textual Inversion)を紹介します。
Deep negative
Deep negativeも人気があるようです。
こちらもネガティブプロンプト省略を目的に作られたようです。
2次元系の術師様で使っている方を見かけました。公式のドキュメントをみるとリアル系のイラストでも使えるようです。CIVITAIからダウンロードできます。
- Deep Negative V1.x(DL数:20,872)
その他のEmbeddings(Textual Inversion)
その他のEmbeddings(Textual Inversion)については、Hugging FaceやCivitaiで見つけることができます。
Civitaiの使い方は下記の記事をご覧ください。
![](https://blogcake.net/wp-content/uploads/2023/03/Stable-diffusion-civitai-300x158.jpg)
![](https://blogcake.net/wp-content/uploads/2023/03/Stable-diffusion-civitai-300x158.jpg)
まとめ
以上、EasyNegativeの使い方についての紹介でした。
![](https://blogcake.net/wp-content/uploads/2023/03/Stable-diffusion-eagle-300x158.jpg)
![](https://blogcake.net/wp-content/uploads/2023/03/Stable-diffusion-eagle-300x158.jpg)
▲こちらも見てください!!!!!
![](https://blogcake.net/wp-content/uploads/2023/02/jojio-profile-small-150x150.jpg)
![](https://blogcake.net/wp-content/uploads/2023/02/jojio-profile-small-150x150.jpg)
![](https://blogcake.net/wp-content/uploads/2023/02/jojio-profile-small-150x150.jpg)
最後まで読んでくださってありがとうございます!
この記事がお役に立てましたら、シェアボタンからシェアしていただけたら嬉しいです!
コメント