> For the complete documentation index, see [llms.txt](https://unsloth.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unsloth.ai/docs/jp/moderu/tutorials/qwen-image-2512.md).

# ComfyUIでQwen-Image-2512をローカル実行する方法

ComfyUIを使ってQwen-Image-2512をローカルデバイスで実行するためのステップバイステップチュートリアル。

**Qwen-Image-2512** です は、Qwen のテキストから画像への基盤モデルの12月更新版です。このモデルは、最も高性能なオープンソースの拡散モデルであり、このガイドでは次の方法でローカル実行する方法を説明します [Unsloth](https://github.com/unslothai/unsloth) GGUF と ComfyUI です。

Qwen-Image-2512 機能: より実在感のある人物、風景やテクスチャのより豊かなディテール、そしてより正確なテキスト描画。 **アップロード:** [GGUF](https://huggingface.co/unsloth/Qwen-Image-2512-GGUF) • [FP8](https://huggingface.co/unsloth/Qwen-Image-2512-FP8) • [4-bit BnB](https://huggingface.co/unsloth/Qwen-Image-2512-unsloth-bnb-4bit)

量子化版は [Unsloth Dynamic](/docs/jp/ji-chu/dynamic-3.0-ggufs.md) という手法を使用しており、重要な層をより高い精度へアップキャストして精度をさらに回復します。Unsloth の day 0 対応を許可してくれた Qwen に感謝します。

## 📖 ComfyUI チュートリアル

実行には GPU は不要で、RAM だけの CPU でも動作します。最良の結果を得るには、使用可能な合計メモリ（RAM + VRAM / unified）が GGUF のサイズより大きいことを確認してください。例: 4-bit (Q4\_K\_M) `unsloth/Qwen-Image-Edit-2512-GGUF` は 13.1 GB なので、合計メモリは 13.2 GB 以上必要です。

[ComfyUI](https://github.com/Comfy-Org/ComfyUI) は、ノードベース（グラフ/フローチャート）インターフェースを使用するオープンソースの拡散モデルGUI、API、バックエンドです。このガイドではCUDA搭載マシンに焦点を当てますが、Apple や CPU で動かすための手順も同様です。

### #1. インストール & セットアップ

ComfyUI をインストールするには、Windows または Mac デバイス向けのデスクトップアプリをダウンロードできます [ここ](https://www.comfy.org/download)。それ以外の場合、GGUF モデルを実行するために ComfyUI をセットアップするには次を実行してください:

```bash
mkdir comfy_ggufs
cd comfy_ggufs
python -m venv .venv
source .venv/bin/activate

git clone https://github.com/Comfy-Org/ComfyUI.git
cd ComfyUI
pip install -r requirements.txt

cd custom_nodes
git clone https://github.com/city96/ComfyUI-GGUF
cd ComfyUI-GGUF
pip install -r requirements.txt
cd ../..
```

### #2. モデルのダウンロード

拡散モデルは通常3つのモデルを必要とします。画像のピクセル空間を潜在空間へエンコードする Variational AutoEncoder（VAE）、テキストを入力埋め込みへ変換するテキストエンコーダー、そして実際の拡散トランスフォーマーです。Unsloth の拡散 GGUF はすべて、こちらの [コレクションで見つけられます](https://huggingface.co/collections/unsloth/unsloth-diffusion-ggufs).

拡散モデルとテキストエンコーダーは GGUF 形式にできますが、通常 VAE には safetensors を使用します。 [Qwen のリポジトリ](https://huggingface.co/Qwen/Qwen-Image-2512/blob/main/text_encoder/config.json)によると、 [Qwen3-VL](/docs/jp/moderu/tutorials/qwen3-how-to-run-and-fine-tune/qwen3-vl-how-to-run-and-fine-tune.md)ではなく Qwen2.5-VL を使います。では、使用するモデルをダウンロードしましょう（注: さらに [FP8 アップロード](https://huggingface.co/unsloth/Qwen-Image-2512-FP8) も ComfyUI で使えます）:

```bash
cd models

## 拡散モデル
curl -L -C - -o unet/qwen-image-2512-Q4_K_M.gguf \\
  https://huggingface.co/unsloth/Qwen-Image-2512-GGUF/resolve/main/qwen-image-2512-Q4_K_M.gguf
curl -L -C - -o unet/qwen-image-edit-2511-Q4_K_M.gguf \\
  https://huggingface.co/unsloth/Qwen-Image-Edit-2511-GGUF/resolve/main/qwen-image-edit-2511-Q4_K_M.gguf
 
## テキストエンコーダー + Vision Tower + VAE   
curl -L -C - -o text_encoders/Qwen2.5-VL-7B-Instruct-UD-Q4_K_XL.gguf \\
  https://huggingface.co/unsloth/Qwen2.5-VL-7B-Instruct-GGUF/resolve/main/Qwen2.5-VL-7B-Instruct-UD-Q4_K_XL.gguf
curl -L -C - -o text_encoders/Qwen2.5-VL-7B-Instruct-mmproj-BF16.gguf \\
  https://huggingface.co/unsloth/Qwen2.5-VL-7B-Instruct-GGUF/resolve/main/mmproj-BF16.gguf
curl -L -C - -o vae/qwen_image_vae.safetensors \\
  https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI/resolve/main/split_files/vae/qwen_image_vae.safetensors
```

GGUF のアップロードはこちら: [Qwen-Image-2512](https://huggingface.co/unsloth/Qwen-Image-2512-GGUF), [Qwen-Image-Edit-2511](https://huggingface.co/unsloth/Qwen-Image-Edit-2511-GGUF)と [Qwen-Image-Layered](https://huggingface.co/unsloth/Qwen-Image-Layered-GGUF)

{% hint style="warning" %}
VAE と拡散モデルの形式は、上記以外のチェックポイントを使う場合、diffusers のチェックポイントとは異なることがあります。ComfyUI と互換性のあるチェックポイントのみを使用してください。
{% endhint %}

これらのファイルは、ComfyUI が認識できるように正しいフォルダに配置する必要があります。さらに、mmproj ファイルに保存されている vision tower は、テキストエンコーダーと同じ接頭辞を使用する必要があります。

後で使う参照画像もダウンロードしておきましょう:

```bash
curl -L -C - -o ../input/sloth1.jpg \\
    "https://unsloth.ai/cgi/image/_1d5a5685-2d88-44ca-b50f-ba432cd646ef_9CGCY8lvw4D9JkOdueqsk.jpeg?width=1920&quality=80&format=jpeg"

curl -L -C - -o ../input/sloth2.jpg \\
    "https://unsloth.ai/cgi/image/UnSloth_GPU_Front_-_Confetti_ArcSk-MR4MMN215UutOFZ.png?width=1920&quality=80&format=jpeg"
```

### #3. ワークフローとハイパーパラメータ

さらに詳しい情報については、こちらの詳細な [Run GGUFs in ComfyUI](/docs/jp/burogu/comfyui.md#workflow-and-hyperparameters-1) ガイド。

メインの ComfyUI ディレクトリに移動して、次を実行してください:

```bash
python main.py
```

{% hint style="info" %}
`python main.py --cpu` は CPU で実行しますが、遅くなります。
{% endhint %}

これにより、次へアクセスできるウェブサーバーが起動します `https://127.0.0.1:8188` 。クラウド上でこれを実行している場合は、ローカルマシンからアクセスするためにポートフォワーディングが設定されていることを確認する必要があります。

ワークフローは、出力画像に埋め込まれた JSON ファイル（PNG メタデータ）として、または別個の `.json` ファイルとして保存されます。以下が可能です:

* 画像を ComfyUI にドラッグ＆ドロップして、そのワークフローを読み込む
* メニューからワークフローをエクスポート/インポートする
* ワークフローを JSON ファイルとして共有する

以下に、ダウンロードして使える Qwen-Image-2512 と Qwen-Image-Edit-2511 の json ファイルの例を2つ示します:

{% file src="/files/efdca87440b0ca1f2a4e722b5750e717c4442470" %}

私たちのワークフローでは、デフォルトで **1024×1024** を実用的な中間点として使います。モデルはネイティブ解像度（1328×1328）をサポートしていますが、ネイティブで生成すると通常、実行時間が **\~50%**&#x7D04; 増えます。GGUF にはオーバーヘッドがあり、40 ステップ

{% hint style="warning" %}
は比較的長い実行時間なので、1024×1024 のほうが生成時間を現実的に保てます。必要なら、解像度を 1328 に上げることもできます。
{% endhint %}

{% hint style="info" %}
より実写的な結果にするには、「photorealistic」や「digital rendering」や「3d render」のようなキーワードは省き、代わりに「photograph」のような語を使ってください。 **自然言語で** 画像に入れたく *ない* ものを記述するのが最適です。キーワードを詰め込みすぎると、より具体的になるどころか結果が悪化することがあります。
{% endhint %}

{% file src="/files/b0fbabf67d0831d9ad00417c9d79037acb43fc52" %}

{% columns %}
{% column %}
ワークフローをゼロから設定する代わりに、こちらからワークフローをダウンロードできます。

Comfy ロゴ → File → Open → で次を選択して、ブラウザページに読み込んでください `unsloth_qwen_image_2512.json` という、先ほどダウンロードしたファイルです。下のように表示されるはずです:
{% endcolumn %}

{% column %}

<figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FqoxBnRlnYrmzLfZshE1Z%2FScreenshot%20from%202025-12-29%2014-37-00.png?alt=media&amp;token=1b1517b7-d44f-4e95-a5ed-759a4e0f74ec" alt="" width="254"><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

<figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FIg48mzpraPTu1O16X1ay%2FScreenshot%20from%202025-12-30%2015-27-35.png?alt=media&amp;token=c761e48a-18cd-4291-9f29-3c09f621729d" alt="" width="563"><figcaption></figcaption></figure>

このワークフローは、公式に ComfyUI が公開しているワークフローをベースにしていますが、GGUF ローダー拡張を使用し、テキストから画像への機能を示すために簡略化されています。&#x20;

### #4. 推論

ComfyUI は非常にカスタマイズ性が高いです。モデルを組み合わせて、非常に複雑なパイプラインを作成できます。基本的なテキストから画像へのセットアップでは、モデルを読み込み、プロンプトと画像の詳細を指定し、サンプリング戦略を決める必要があります。&#x20;

#### **モデルをアップロード + プロンプトを設定**

すでにモデルはダウンロード済みなので、正しいものを選ぶだけです。Unet Loader では `qwen-image-2512-Q4_K_M.gguf`を、CLIPLoader では `Qwen2.5-VL-7B-Instruct-UD-Q4_K_XL.gguf`を、Load VAE では `qwen_image_vae.safetensors`.&#x20;

{% hint style="info" %}
は比較的長い実行時間なので、1024×1024 のほうが生成時間を現実的に保てます。必要なら、解像度を 1328 に上げることもできます。
{% endhint %}

を選択してください。任意のプロンプトを設定でき、ネガティブプロンプトも指定できます。ネガティブプロンプトは、モデルにどの方向を避けるべきかを伝えるのに役立ちます。

{% hint style="info" %}
より実写的な結果にするには、「photorealistic」や「digital rendering」や「3d render」のようなキーワードは省き、代わりに「photograph」のような語を使ってください。 **自然言語で** 画像に入れたく *ない* ものを記述するのが最適です。キーワードを詰め込みすぎると、より具体的になるどころか結果が悪化することがあります。
{% endhint %}

#### **画像サイズ + サンプラーパラメータ**

Qwen Image モデルシリーズは、さまざまな画像サイズをサポートしています。幅と高さの値を設定することで長方形にできます。サンプラーパラメータでは、euler 以外のさまざまなサンプラーや、より多い/少ないサンプリングステップを試せます。ワークフローではステップ数を 40 に設定していますが、素早いテストなら 20 でも十分かもしれません。 `generate 後の control` 設定を randomize から fixed に変更して、異なる設定が出力にどう影響するか見てみるとよいでしょう。

#### **実行**

Run をクリックすると、約1分で画像が生成されます（20 ステップなら30秒）。その出力画像は保存できます。興味深いのは、Comfy ワークフロー全体のメタデータが画像に保存されることです。共有すれば、UI に読み込むことで誰でもどのように作成されたかを見ることができます。

<figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2F3fvZ7Y7dyOwwWfQXP4U9%2Funsloth_woman.png?alt=media&amp;token=bf131b12-be85-45c9-83bb-6a087decb8bb" alt="" width="188"><figcaption></figcaption></figure>

{% hint style="info" %}
ぼやけた/悪い画像が出る場合は、shift を 12〜13 に上げてください！ これで悪い出力のほとんどの問題が解決します。
{% endhint %}

#### **マルチ参照生成**

Qwen-Image-Edit-2511 の重要な機能の1つは、複数の画像を参照として使って生成を制御できるマルチ参照生成です。今回は `unsloth_qwen_image_edit_2511.json`を読み込みます。基本的には同じモデルをほとんど使いますが、 `qwen-image-2512-Q4_K_M.gguf` を `qwen-image-edit-2511-Q4_K_M.gguf` に切り替えます。もう1つの違いは、先ほどダウンロードした参照用画像を選ぶための追加ノードがあることです。プロンプトが `画像1` そして `画像2` の両方を参照していることに気づくでしょう。読み込んだら Run をクリックすると、見た目を保ちながら2つのユニークなナマケモノキャラクターを一緒に作成する出力が表示されます。

<div><figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FmHqctMHBGGtyTMh7VcxN%2Funsloth_diffusion1.png?alt=media&amp;token=c66059ae-4015-4fea-9181-75566bc7f03d" alt="" width="188"><figcaption><p>右側の画像から作成した最終結果:</p></figcaption></figure> <figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FvRbCNdlnmXOyM84YaF0b%2Fsloth%20gpu%20square.png?alt=media&amp;token=7b5c14ae-b5d7-4554-86e5-f8e2480bbb39" alt="" width="188"><figcaption></figcaption></figure> <figure><img src="https://735611837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxhOjnexMCB3dmuQFQ2Zq%2Fuploads%2FwAYdYspdgZGbxFePXf06%2Fsloth%20on%20gpu.jpg?alt=media&amp;token=1031686f-1f0d-423a-80ae-77127aaaa0bd" alt="" width="188"><figcaption></figcaption></figure></div>

## 🤗 D**iffusers チュートリアル**

また、 [Dynamic 4-bit BitsandBytes](https://huggingface.co/unsloth/Qwen-Image-2512-unsloth-bnb-4bit) 量子化版もアップロードしており、Hugging Face の `diffusers` ライブラリで実行できます。ここでも Unsloth Dynamic を使用しており、重要な層はより高い精度にアップキャストされています。

実行 `Qwen-Image-2512-unsloth-bnb-4bit` を、以下のコードで使います:

```python
from diffusers import DiffusionPipeline
import torch

pipe = DiffusionPipeline.from_pretrained(
    "unsloth/Qwen-Image-2512-unsloth-bnb-4bit",
    torch_dtype=torch.bfloat16,
).to('cuda')

# メモリ不足になった場合はコメントを外してください
# pipe.enable_model_cpu_offload() 

output = pipe(
    prompt="a kawaii sloth playing the drums",
    negative_prompt="blurry, unfocused",
    num_inference_steps=20,
    true_cfg_scale=4.0,
)

# 出力を保存
image = output.images[0]
image.save('sample.png')
```

## 🎨 **stable-diffusion.cpp チュートリアル**

stable-diffusion.cpp でモデルを実行したい場合は、こちらの [ステップごとのガイドをご覧ください](/docs/jp/moderu/tutorials/qwen-image-2512/stable-diffusion.cpp.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://unsloth.ai/docs/jp/moderu/tutorials/qwen-image-2512.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
