# FLUX.2 Klein

FLUX.2 Klein 由 Black Forest Labs 推出，是 FLUX.1 的继任者，在相同图像质量下提供 **快 20–60 倍**。而 FLUX.1 每张图像需要 10–30 秒，FLUX.2 Klein 在 **低于 0.5 秒** 在 RTX 4090 上生成。它是一个 32B 的 Diffusion Transformer (DiT) 模型，采用 Apache 2.0 许可证，截至 2026 年 1 月，甚至在 Ollama 中有实验性支持。

## 主要特性

* **< 0.5 秒 生成**：比 FLUX.1 快 20–60×
* **32B DiT 架构**：与 FLUX.1 相同的质量 dev
* **Apache 2.0 许可证**：完全商业使用
* **Ollama 支持**：通过 Ollama 的实验性图像生成（2026 年 1 月）
* **兼容 ComfyUI**：可作为 FLUX.1 工作流的即插即用替代品
* **LoRA + ControlNet**：社区适配器可用

## 要求

| 组件   | 最低            | 推荐            |
| ---- | ------------- | ------------- |
| GPU  | RTX 3090 24GB | RTX 4090 24GB |
| 显存   | 16GB（支持卸载）    | 24GB          |
| 内存   | 32GB          | 64GB          |
| 磁盘   | 40GB          | 60GB          |
| CUDA | 12.0+         | 12.1+         |

**推荐的 Clore.ai GPU**：RTX 4090 24GB（约 $0.5–2/天）— 次级别生成

### 速度比较：FLUX.1 vs FLUX.2 Klein

| GPU      | FLUX.1 dev（20 步） | FLUX.2 Klein | 加速倍数 |
| -------- | ---------------- | ------------ | ---- |
| 速度       | \~25 秒           | ≈1.2 秒       | 20×  |
| 512x512  | ≈12 秒            | ≈0.4 秒       | 30×  |
| RTX 5090 | ≈8 秒             | ≈0.25 秒      | 32×  |
| H100     | \~5 秒            | ≈0.15 秒      | 33×  |

## 使用 diffusers 的快速入门

```python
import torch
from diffusers import FluxPipeline

pipe = FluxPipeline.from_pretrained(
    "black-forest-labs/FLUX.2-klein",
    torch_dtype=torch.bfloat16
)
pipe.to("cuda")

# 在 < 0.5 秒内生成图像！
image = pipe(
    prompt="一个赛博朋克风格的 GPU 挖矿机架在霓虹灯服务器室中，照片级真实感",
    height=1024,
    width=1024,
    num_inference_steps=4,  # Klein 只需 4 步！
    guidance_scale=3.5,
).images[0]

image.save("output.png")
```

### 节省内存模式（16GB GPU）

```python
pipe = FluxPipeline.from_pretrained(
    "black-forest-labs/FLUX.2-klein",
    torch_dtype=torch.bfloat16
)
pipe.enable_model_cpu_offload()  # 适配 16GB
pipe.vae.enable_tiling()         # 省约 ~2GB

image = pipe("日落时的山地风景", num_inference_steps=4).images[0]
```

## IC-Light 可作为 ComfyUI 节点使用：

FLUX.2 Klein 可作为现有 FLUX.1 ComfyUI 工作流的即插即用替代品：

1. 下载 FLUX.2 Klein 检查点到 `ComfyUI/models/diffusion_models/`
2. 在你的工作流中，将检查点节点更改为指向 FLUX.2 Klein
3. 将步数减少到 4（而不是 FLUX.1 的 20–50）
4. 将指导尺度设置为 3.0–4.0

```bash
# 为 ComfyUI 下载模型
cd ComfyUI/models/diffusion_models/
wget https://huggingface.co/black-forest-labs/FLUX.2-klein/resolve/main/flux2-klein.safetensors
```

## 批量生成

凭借次秒级生成，FLUX.2 Klein 可实现大规模批处理：

```python
import torch
from diffusers import FluxPipeline

pipe = FluxPipeline.from_pretrained(
    "black-forest-labs/FLUX.2-klein", torch_dtype=torch.bfloat16
).to("cuda")

prompts = [
    "一辆红色跑车在山路上，电影感",
    "一个舒适的咖啡馆内部，温暖的灯光",
    "一名宇航员悬浮在地球上空，超真实",
    "秋天的中世纪城堡，奇幻艺术",
    # … 再添加数百个
]

for i, prompt in enumerate(prompts):
    image = pipe(prompt, num_inference_steps=4, guidance_scale=3.5).images[0]
    image.save(f"batch_{i:04d}.png")
    print(f"已生成 {i+1}/{len(prompts)}")

# 在 RTX 4090 上：不到 1 分钟生成约 100 张图像！
```

## 支持 LoRA

```python
pipe = FluxPipeline.from_pretrained(
    "black-forest-labs/FLUX.2-klein", torch_dtype=torch.bfloat16
).to("cuda")

# 加载在 FLUX 架构上训练的 LoRA
pipe.load_lora_weights("your-lora/flux2-style-lora", weight_name="lora.safetensors")
pipe.fuse_lora(lora_scale=0.8)

image = pipe("以训练风格的人像", num_inference_steps=4).images[0]
```

## 给 Clore.ai 用户的提示

* **批处理之王**：在 0.4 秒/图像 时，你可以在 RTX 4090 上每小时生成 10,000+ 张图像
* **仅 4 步**：不要使用更多步数 — Klein 针对 4 步进行了优化（更多步数不会提升质量）
* **与 FLUX.1 相同的 LoRA**：大多数 FLUX.1 LoRA 与 Klein 兼容
* **ComfyUI 即插即用**：只需替换检查点，将步数改为 4
* **RTX 3090 也可行**：1.2 秒/图像 在 $0.3/天 下仍然很不错

## # 使用固定种子以获得一致结果

| 问题            | 解决方案                                                          |
| ------------- | ------------------------------------------------------------- |
| 24GB 上出现 OOM  | 使用 `enable_model_cpu_offload()` + `vae.enable_tiling()`       |
| 图像模糊          | 确保已安装 `num_inference_steps=4`，不是更少。检查 guidance\_scale 3.0–4.0 |
| 首次生成缓慢        | 正常 — 模型在首次调用时加载（约 30 秒）。之后：次秒级                                |
| ComfyUI 检查点错误 | 确保你有 `.safetensors` 文件，而不是 diffusers 格式                       |

## 延伸阅读

* [FLUX.1 指南](/guides/guides_v2-zh/tu-xiang-sheng-cheng/flux.md) — 原始 FLUX 指南，包含 LoRA 和 ControlNet 细节
* [ComfyUI 指南](/guides/guides_v2-zh/tu-xiang-sheng-cheng/comfyui.md) — ComfyUI 设置和工作流
* [Black Forest Labs 博客](https://blackforestlabs.ai/)
* [HuggingFace 模型](https://huggingface.co/black-forest-labs/FLUX.2-klein)


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-zh/tu-xiang-sheng-cheng/flux2-klein.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
