WD1.5 Beta 2+Web UIで高画質アニメ絵生成環境構築

スポンサーリンク
Stable Diffusion
スポンサーリンク

高画質のStable Diffusion2.1をベースにアジア圏の実写やアニメ1500万枚以上から学習したモデルWD1.5 Beta 2を使ったWebUIでの画像生成環境をWindowsのローカル環境に構築してみます。プロンプトで簡単に高画質なアニメ画像が生成できます。

WD1.5 Beta 2の概要

WD1.5 Beta 2はStable Diffusion 2.1から直接トレーニングしたモデルで、他のプロジェクトからのモデルのマージを含んでいません。Aestheticバージョンはさらに微調整を加えて、美しい画像が生成できるようにしています。また、画像の特徴や属性でのタグ付けやAestheticな属性がキャプションとして付加されていることにより、比較的、目的のスタイルを生成しやすくなっています。

画像の生成例:

2023年3月11日更新:WD1.5Beta2に関して新しい記事をリリースしました。最新の情報はそちらをご参照ください。

WebUIのインストール

WebUIのインストールは下の記事をご参考におこなってください。

WD1.5 Beta2モデルの導入

WD1.5 Beta2モデルはHuggingFaceからダウンロードします。このフォルダの中の「wd-1-5-beta2-aesthetic-fp32.safetensors」のファイルをダウンロードします。

このファイルをWebUIの中の「\stable-diffusion-webui\models」のフォルダ中にコピーします。

WD1.5 Beta2での画像生成

それではwebUIを起動して画像を生成してみます。「stable-diffusion-webui」のフォルダの直下に入って、「webui-user.bat」を実行します。実行すると、「models」フォルダに入っていた「wd-1-5-beta2-aesthetic-fp32.safetensors」は「models\Stable-diffusion」に自動的に取り込まれます。(参考記事:Stable Diffusion WebUIのカスタム設定

> ./webui-user.bat

それでは、「txt2img」で画像を生成してみましょう。WD1.5 Beta2ではプロンプトの設定に少し癖があります。公式リリースの情報に従って、設定します。

タグには学習元の情報に基づく以下のプロンプトが使えます。

・投稿日 1995年~2010年:oldest、2010年~2015年:old、2015年~2020年:new、2020年以降:newest
・アーティスティックスタイルのスコア exceptional>best aesthetic>normal aesthetic>bad aesthetic
・投稿サイトのユーザー評価 masterpiece>best quality>high quality>medium quality>normal quality>low quality>worst quality
・画像分類 削除された画像:deleted、理想の女性像:waifu、実写:real life、アニメ:anime、インスタ:instagram

プロンプトには以下のものを後ろに追加するとよいようです。

アニメ絵の場合

(waifu, anime, exceptional, best aesthetic, new, newest, best quality, masterpiece, extremely detailed:1.2)

実写の場合

(waifu, realistic, real life, exceptional, best aesthetic, new, newest, best quality, masterpiece:1.2)

また、ネガティブプロンプトには以下のプロンプトを入れておいた方が無難でしょう。

lowres, ((bad anatomy)), ((bad hands)), text, missing finger, extra digits, fewer digits, blurry, ((mutated hands and fingers)), (poorly drawn face), ((mutation)), ((deformed face)), (ugly), ((bad proportions)), ((extra limbs)), extra face, (double head), (extra head), ((extra feet)), monster, logo, cropped, worst quality, jpeg, humpbacked, long body, long neck, ((jpeg artifacts)), deleted, old, oldest, ((censored)), ((bad aesthetic)), (mosaic censoring, bar censor, blur censor)

下のような画像が生成できました。(テニスのラケットを握るところは、まだ、なかなか難しいようでした。。。)

上記のプロンプト(chatGPTに良きに考えてもらっています。)

A cute girl ((swinging a tennis racket)) with a ponytail bounces a tennis ball on the court of her university campus, small breasts, a white tennis dress, athletic physique. As she prepares to serve, her eyes narrow in concentration and determination, making it clear that she takes the game seriously.
(waifu, anime, exceptional, best aesthetic, new, newest, best quality, masterpiece, extremely detailed:1.2)
Negative prompt: lowres, ((bad anatomy)), ((bad hands)), text, missing finger, extra digits, fewer digits, blurry, ((mutated hands and fingers)), (poorly drawn face), ((mutation)), ((deformed face)), (ugly), ((bad proportions)), ((extra limbs)), extra face, (double head), (extra head), ((extra feet)), monster, logo, cropped, worst quality, jpeg, humpbacked, long body, long neck, ((jpeg artifacts)), deleted, old, oldest, ((censored)), ((bad aesthetic)), (mosaic censoring, bar censor, blur censor)
Steps: 20, Sampler: DPM++ SDE Karras, CFG scale: 7, Seed: 211, Size: 560x640, Model hash: 711cd95c77, Model: wd-1-5-beta2-aesthetic-fp32

画像生成でエラーが起こる場合

以下のエラーが起こる場合、メッセージに従って、「settings」→「Stable-diffusion」の「Upcast cross attention layer to float32」にチェックを入れるとよいようです。

modules.devices.NansException: A tensor with all NaNs was produced in Unet. This could be either because there's not enough precision to represent the picture, or because your video card does not support half type. Try setting the "Upcast cross attention layer to float32" option in Settings > Stable Diffusion or using the --no-half commandline argument to fix this. Use --disable-nan-check commandline argument to disable this check.

Stable Diffusion
スポンサーリンク
鷹の目週末プログラマー

コメント