メインコンテンツへスキップ
見出し画像

ComfyUIでStable Diffusion 3.5に触れてみる(1-Large編)

    ※ Last update 11-4-2024
    ※ (11-4) 2.のワークフローを再修正しました。画質が変わるので、なるべくこちらに変更してください🙇(11-3との違いはディレクトリ設定のみ)
    ※ SD 3.5 MediumとLarge/Large Turboは互換性がありませんが、Text EncoderとVAEは共通です。
    ※ Comfy Org版のモデルはText Encoderも内蔵していますが、ワークフローでは使用していません(内蔵のt5xxlはfp8版です)。



    ■ 0. 概要

    ▼ 0-0. はじめに

     本記事では「Stable Diffusion 3.5」の「Large」を利用してみます。「Medium」と「Large Turbo」については続きの記事を参照してください。

    ▼ 0-1. Stable Diffusion 3.5の情報

     日本時間の10-22-2024夜に、「Stable Diffusion 3.5 Large」と「Stable Diffusion 3.5 Large Turbo」が公開され、一週間後に「Stable Diffusion 3.5 Medium」も公開されました。

     Stable Diffusion 3.5のリリースと同時にComfyUIがサポートしたので、さっそく利用してみます。

     参考まで、ComfyUI_examplesにはLargeとMediumの、ワークフロー込みの画像が掲載されています(Large Turboは扱っていない模様)。



    ■ 1. 利用の手順

    ▼ 1-1. 留意点

     モデルの種類が混乱しないよう、Text Encoder以外はデフォルトの場所にディレクトリを作成して、その下に設置する方針をとっています。

    ▼ 1-2. モデルのダウンロード(Comfy Org版)

     下記のURLへアクセスします。

    stable-diffusion-3.5-fp8
    https://huggingface.co/Comfy-Org/stable-diffusion-3.5-fp8 

     モデルをダウンロードして設置していきます。

    • sd3.5_large_fp8_scaled.safetensors
      → ComfyUI\models\checkpoints\sd35l へ移動
      (※補足:このモデルはclip_g、clip_l、t5xxl_fp8を含んでいるので、外付の代わりに用いることもできます)

     Text Encoderは、既にダウンロードしている場合は流用できます。なお、「t5xxl_fp8_e4m3fn_scaled」については「the scaled one is an experimental checkpoint by us」との説明がありましたが、詳細は不明です。

    • text_encoders\clip_g.safetensors
      text_encoders\clip_l.safetensors
      text_encoders\t5xxl_*.safetensors (いずれか、メインRAMが十分ならfp16を選択)
      → ComfyUI\models\clip へ移動

     最後にワークフローです。

    • sd3.5-t2i-fp16-workflow.json
      sd3.5-t2i-fp8-scaled-workflow.json

      → いずれかをダウンロード(違いはText Encoderモデルの初期設定値のみ?)

    ▼ 1-3. 画像の生成

     ComfyUIを更新してから起動します。先ほどダウンロードしたワークフローをUI上にドラッグ&ドロップしてください。

     Text Encoderの設定の「t5xxl」を、実在するファイル名に設定しないとエラーが出ます。

    画像
    リストから使用するt5xxlを選択する

     最後に「Queue Prompt」をクリックすると生成が開始されます。

    画像
    生成を行ったところ

     先述のとおり、このモデルはText Encorderを含んでいる(t5xxlはfp8)ので、CLIPをCheckpointからつなげても動作します。

    画像
    Text Encoderの接続を変更



    ■ 2. シンプルなワークフロー(修正版)

    ▼ 2-1. 概要

     Comfy OrgとStability AIのワークフローを参考に、単純なワークフローを作成しました。Comfy Org版には含まれていないノードを追加して、画質が向上していると思います。改造、再公開等は自由です。

    画像
    ワークフローの全体

    ▼ 2-2. 画像の生成

     これを使用すると、表紙と同じ画像が生成できると思います。異なるモデルを使用した場合は出力も変わります。

    画像
    Create a vibrant, anime-style illustration of a crisp autumn day in a maple-filled park. In the foreground, place a cheerful little girl with big, expressive eyes and auburn braids, wearing a cozy sweater dress and a red scarf. Have her holding a wooden sign that's slightly too big for her, decorated with falling maple leaves. On the sign, write in adorable, wobbly handwritten text: "Welcom to SD 3.5!" Include seasonal park elements in the background, such as maple trees with red and gold leaves, a stone path covered in fallen leaves, and other visitors taking photos of the autumn colors. The scene should be illuminated by warm afternoon sunlight filtering through the colorful canopy, creating a magical autumn atmosphere.

    ▼ 2-3. 分割モデル版

     Text EncoderやVAEを含まないModelに対応したバージョンも用意しました。Model、Text Encoder、VAEを選択した上でご利用ください。VAEのダウンロードは続編の記事の4-4.を参照してください。

    • Model → ComfyUI\models\unet\sd35l へ設置

    • VAE → ComfyUI\models\vae\sd35 へ設置

    画像
    ワークフローの全体

     ModelのLoaderを差し替えることで、GGUFやNF4にも対応できます。ComfyUIの対応方法は、下記の記事を参考にしてください。



    ■ 3. おまけ

    ▼ 3-1. おまけ画像

     プロンプトは使い回しですが、何もないのも寂しいので載せておきます。

    画像
    A young Japanese woman hiking in the mountains. She's a 'yama girl' (mountain girl), wearing fashionable yet functional hiking gear - colorful quick-dry pants, a lightweight jacket, and a cute mountaineering hat. She carries a stylish backpack and trekking poles. The background shows a breathtaking Japanese mountain landscape with lush greenery, perhaps a glimpse of Mt. Fuji in the distance. The hiker is smiling, enjoying the scenic view from a mountain trail. The scene captures the essence of the yama girl trend - a blend of outdoor activity and fashion.
    画像
    A cheerful anime girl with long, flowing dark brown hair, crouching with knees pulled close. She's wearing a cute outfit: a pastel pink frilly blouse draping over her knees, and a white tulle mini skirt with lace trim. Her bow-accented ankle boots are visible as she balances on her toes. Viewed diagonally, her bright eyes and warm smile are prominent as she looks at the viewer with friendliness and curiosity. Behind her, an alpine meadow stretches out, dotted with wildflowers. Snow-capped Alps pierce the sky, with a quaint resort town in the valley. The late afternoon sun casts a warm glow, highlighting her silhouette. The image is in a soft, watercolor style, emphasizing the dreamy atmosphere of the scene.



    ■ 4. 公式・準公式モデル(Large/L Turbo)

    ▼ 4-1. 概要

     参考まで、各モデルへのリンクと、ワークフローに設定されていた初期値を掲載します。なお、公式モデルはアクセス許可を取る必要がありますので、その必要が無いURLも追記しておきます。

    ▼ 4-2. 公式モデル(Large)

    Stable Diffusion 3.5 Large
    https://huggingface.co/stabilityai/stable-diffusion-3.5-large 

    steps: 40
    cfg: 4.5
    sampler_name: dpmpp_2m
    scheduler: sgm_uniform
    shift (ModelSamplingSD3): 3.0

    Civitaiのコピー:
    https://civitai.com/models/878387?modelVersionId=983309 

    ▼ 4-3. 公式モデル(Large Turbo)

    Stable Diffusion 3.5 Large Turbo
    https://huggingface.co/stabilityai/stable-diffusion-3.5-large-turbo 

    steps: 4
    cfg: 1.0
    sampler_name: dpmpp_2m
    scheduler: sgm_uniform
    shift (ModelSamplingSD3): 3.0

    Civitaiのコピー:
    https://civitai.com/models/878645?modelVersionId=983611 

    ▼ 4-4. Comfy Org版モデル(Large-fp8)

    stable-diffusion-3.5-fp8
    https://huggingface.co/Comfy-Org/stable-diffusion-3.5-fp8 

    steps: 30
    cfg: 5.5
    sampler_name: euler
    scheduler: sgm_uniform



    ■ 5. その他のSD 3.5モデル

    ▼ 5-1. 概要

     Comfy Org版以外の、コンバート済み等のモデルです。「Modelのみ」となっている場合、Text EncoderやVAEは含まれていません。

    ▼ 5-2. モデル一覧

    LargeとLarge Turboのマージ(FP16-Modelのみ)
    SD 3.5 Fusion (8 step merge)
    https://civitai.com/models/880208 

    Large/Large Turbo-fp8(FP8-Modelのみ)
    Stable Diffusion 3.5 fp8 models (SD3.5)
    https://civitai.com/models/879701 

    Large-gguf(GGUF-Modelのみ)
    stable-diffusion-3.5-large-gguf
    https://huggingface.co/city96/stable-diffusion-3.5-large-gguf 

    Large Turbo-gguf(GGUF-Modelのみ)
    stable-diffusion-3.5-large-turbo-gguf
    https://huggingface.co/city96/stable-diffusion-3.5-large-turbo-gguf 



    ■ 6. 旧ワークフローとの相違

    ▼ 6-1. 概要

     2.で公開していたワークフローはComfy Org版をベースにしていました。一方、Stability AI公式のワークフローもチェックし、Negative Prompt側にいくつかのノードが付いているのも確認済みでした。

    公式ワークフローでここの値が違う
    SD 3.5 Large / Medium pic.twitter.com/3ZNYI3PXoF

    — まゆひらa (@riddi0908) October 29, 2024

     試しにこれらのノードを加えてみたところ、ネガティブプロンプトが空であっても出力が変化しました。下記の画像は旧ワークフローです。

    画像
    旧ワークフローはNegative側にPrompt以外のノードが付いていない

    ▼ 6-2. 旧ワークフローで生成した画像

     2.と3.に掲載していた画像を残しておきます。

    画像
    Create a vibrant, anime-style illustration of a crisp autumn day in a maple-filled park. In the foreground, place a cheerful little girl with big, expressive eyes and auburn braids, wearing a cozy sweater dress and a red scarf. Have her holding a wooden sign that's slightly too big for her, decorated with falling maple leaves. On the sign, write in adorable, wobbly handwritten text: "Welcom to SD 3.5!" Include seasonal park elements in the background, such as maple trees with red and gold leaves, a stone path covered in fallen leaves, and other visitors taking photos of the autumn colors. The scene should be illuminated by warm afternoon sunlight filtering through the colorful canopy, creating a magical autumn atmosphere.
    画像
    A young Japanese woman hiking in the mountains. She's a 'yama girl' (mountain girl), wearing fashionable yet functional hiking gear - colorful quick-dry pants, a lightweight jacket, and a cute mountaineering hat. She carries a stylish backpack and trekking poles. The background shows a breathtaking Japanese mountain landscape with lush greenery, perhaps a glimpse of Mt. Fuji in the distance. The hiker is smiling, enjoying the scenic view from a mountain trail. The scene captures the essence of the yama girl trend - a blend of outdoor activity and fashion.
    画像
    A cheerful anime girl with long, flowing dark brown hair, crouching with knees pulled close. She's wearing a cute outfit: a pastel pink frilly blouse draping over her knees, and a white tulle mini skirt with lace trim. Her bow-accented ankle boots are visible as she balances on her toes. Viewed diagonally, her bright eyes and warm smile are prominent as she looks at the viewer with friendliness and curiosity. Behind her, an alpine meadow stretches out, dotted with wildflowers. Snow-capped Alps pierce the sky, with a quaint resort town in the valley. The late afternoon sun casts a warm glow, highlighting her silhouette. The image is in a soft, watercolor style, emphasizing the dreamy atmosphere of the scene.



    ■ 7. その他

     私が書いた他の記事は、メニューよりたどってください。

     noteのアカウントはメインの@Mayu_Hiraizumiに紐付けていますが、記事に関することはサブアカウントの@riddi0908までお願いします。

     
     
    5060Ti (16GB) と 3060 (12GB) を所持。記載が無い限り文章は手書きです。記事に関することは X の riddi0908 までお願いします。質問箱は気まぐれにお返事します。

    あなたへのおすすめ