Black Forest Labs 于 2026 年 10 月 15 日正式发布 FLUX.3 Image Klein 模型。该模型即日起支持在 Hugging Face Diffusers 库中运行,具备文本生成图像、多参考图像编辑以及全新的布局控制功能。

FLUX.3 Image Klein 的核心特性在于引入了基于边界框(Bounding Box)的布局控制机制。用户可以在提示词中嵌入 JSON 格式的坐标数据,精确指定图像各元素的位置,或定义参考图像中特定区域的移动路径。
目前,两个开放检查点已上线 FLUX.3 Image Klein 集合:
| 检查点名称 | 技术规格 | 默认推理参数 |
|---|---|---|
| black-forest-labs/flux-3-image-klein | 时间步蒸馏版本,针对快速推断优化 | 16 个步骤,无 CFG |
| black-forest-labs/flux-3-image-klein-base | 基础模型 | 50 个步骤,启用 CFG |
核心功能概览
- 单一模型支持文本到图像、多参考图像到图像及边界框布局控制。
- 蒸馏检查点在 H100 GPU 上生成 1024 × 1024 分辨率图像耗时约 2 秒。
- 通过
from_single_file支持 NVFP4 和 FP8 权重加载,适配显存较小的 GPU。 - 提供用于文本到图像和图像编辑任务的 LoRA 训练脚本。
- 采用模块化 Diffusers 管道架构,允许用户替换或添加自定义组件。
快速开始
首先安装最新版本的 diffusers 和 transformers 库(需包含 Qwen3-VL 文本编码器支持):
pip install -U diffusers transformers
加载蒸馏检查点并生成图像的示例代码如下:
import torch
from diffusers import ModularPipeline
pipe = ModularPipeline.from_pretrained("black-forest-labs/flux-3-image-klein")
pipe.load_components(dtype=torch.bfloat16)
pipe.to("cuda")
pipe(prompt="a red fox", output="images")[0].save("fox.png")
功能详解
文本生成图像
FLUX.3 对包含主题、场景、光照、构图及风格的完整描述响应效果最佳。官方提示指南提供了更多细节建议。默认情况下,蒸馏检查点以 16 个步骤生成 1024 × 1024 像素图像,用户可通过参数调整高度、宽度或推理步数。
prompt = (
"A wide-angle wildlife photograph of a red fox standing alert in a snow-covered forest clearing at golden hour. "
"The fox is centered in the frame, its thick orange winter coat contrasting with the fresh white snow, breath "
"visible in the cold air. Snow-laden pine trees fill the softly blurred background, and low warm sunlight rakes "
"across the scene from the left, casting long blue shadows."
)
fox = pipe(
prompt=prompt,
generator=torch.Generator().manual_seed(0),
output="images"
)[0]
fox.save("fox.png")
| 文本生成图像示例 |
图像到图像转换
通过 image 参数传入一个或多个参考图像,并在提示词中描述期望的变化。
prompt = (
"The same red fox in the same snow-covered forest clearing, now at night under a full moon: cool blue "
"moonlight, deep shadows, stars visible through the pine branches, the fox's eyes catching the light."
)
night = pipe(
prompt=prompt,
image=fox,
generator=torch.Generator().manual_seed(0),
output="images",
)[0]
night.save("night.png")
| 图像到图像转换示例 |
对于多参考图像场景,可在提示词中使用 <ref_image_0>, <ref_image_1> 等标签引用按顺序传入的图像。
red_fox = pipe(prompt="a red fox", generator=torch.Generator().manual_seed(0), output="images")[0]
bench = pipe(prompt="a wooden bench", generator=torch.Generator().manual_seed(0), output="images")[0]
combined = pipe(
prompt="The fox from <ref_image_0> sitting on the wooden bench from <ref_image_1> in a snowy setting.",
image=[red_fox, bench],
output="images",
)[0]
combined.save("combined.png")
| 参考图像 1 | 参考图像 2 | 合成结果 |
布局控制
用户可在提示词后附加一个 JSON 列表来定义区域。每个区域包含 ID、边界框(bbox)和描述(desc),提示词中通过 <id> 引用对应区域。
边界框格式为 [y_min, x_min, y_max, x_max],数值范围为 0–1000。由于尺度归一化,同一边界框适用于任意图像尺寸。
在新图像中定位区域
layout_prompt = (
"Minimalist graphic illustration featuring a black silhouette of a person <silhouette_1> centered against a "
"solid, vibrant chartreuse background <background_1>. The figure is captured in a dynamic, mid-stride running "
"pose, facing toward the left side of the frame. "
'[{"id": "background_1", "bbox": [0, 0, 1000, 1000], "desc": "A flat field of neon yellow-green with a subtle '
'paper texture and fine, organic grain."}, {"id": "silhouette_1", "bbox": [150, 150, 850, 850], "desc": "A '
"black silhouette of a person in motion, made of dense stippled ink. The leading edges are solid; the trailing "
'arm and leg dissolve into coarse square pixels and scattered dots."}]'
)
runner = pipe(prompt=layout_prompt, generator=torch.Generator().manual_seed(0), output="images")[0]
| 每个区域的 desc 在其 bbox 范围内绘制 |
在参考图像中移动区域
在编辑模式下,每个区域需指定内容来源(src_bbox)和目标位置(tgt_bbox)。若两者相同,则区域保持原位。
以下示例将针织骑士移至左上角,同时固定背景、悬崖、针、龙和火线的位置:
from diffusers.utils import load_image
knight_image = load_image("knight_orig.png")
edit_prompt = (
"In <ref_image_0>, move the miniature grey amigurumi knight figure <knight_1> upwards and to the left along the "
"yarn cliff <cliff_1>. Keep the rest of the image completely unchanged, preserving the blurred yarn backdrop "
"<backdrop_1>, the large knitted dragon <dragon_1>, and the fiery orange thread <fire_1>. "
'[{"id": "knight_1", "from": "ref_image_0", "src_bbox": [500, 150, 850, 350], "tgt_bbox": [194, 55, 544, 255], '
'"desc": "A miniature amigurumi knight crocheted from thick grey woolen yarn."}, '
'{"id": "backdrop_1", "from": "ref_image_0", "src_bbox": [0, 0, 1000, 1000], "tgt_bbox": [0, 0, 1000, 1000], '
'"desc": "A soft, out-of-focus backdrop of cream and indigo knitted yarn."}, '
'{"id": "cliff_1", "from": "ref_image_0", "src_bbox": [300, 0, 1000, 450], "tgt_bbox": [300, 0, 1000, 450], '
'"desc": "A steep cliff of stacked yarn skeins in mustard, terracotta, and indigo."}, '
'{"id": "needle_1", "from": "ref_image_0", "src_bbox": [420, 250, 550, 450], "tgt_bbox": [420, 250, 550, 450], '
'"desc": "An oversized polished steel tapestry needle."}, '
'{"id": "dragon_1", "from": "ref_image_0", "src_bbox": [100, 600, 950, 1000], "tgt_bbox": [100, 600, 950, 1000], '
'"desc": "A large, fluffy knitted dragon in terracotta and mustard yarn."}, '
'{"id": "fire_1", "from": "ref_image_0", "src_bbox": [350, 400, 650, 650], "tgt_bbox": [350, 400, 650, 650], '
'"desc": "Curled puffs of fiery orange angora thread suspended in mid-air."}]'
)
moved = pipe(prompt=edit_prompt, image=knight_image, generator=torch.Generator().manual_seed(0), output="images")[0]
| 骑士从 src_bbox 移动到 tgt_bbox,其余场景保持不变 |
基础模型与量化变体
基础模型使用
上述示例均使用蒸馏检查点。基础检查点运行 50 个步骤并启用分类器自由引导(CFG),适用于微调任务。
pipe = ModularPipeline.from_pretrained("black-forest-labs/flux-3-image-klein-base")
pipe.load_components(dtype={"vae": torch.float32, "default": torch.bfloat16})
pipe.to("cuda")
pipe.guider = pipe.guider.new(guidance_scale=5.0)
image = pipe(prompt=prompt, output="images")[0]
单文件格式与量化
Black Forest Labs 还提供 Transformer 的单文件格式,包括 bf16、fp8r(排列式 FP8)和 nvfp4 两种量化格式。加载时需指定其他组件名称,避免重复下载 bf16 Transformer。
from diffusers import BFLQuantizationConfig, Flux3Transformer2DModel, ModularPipeline
model_id = "black-forest-labs/flux-3-image-klein-base"
variant = "fp8r"
transformer = Flux3Transformer2DModel.from_single_file(
f"https://huggingface.co/{model_id}/blob/main/variants/{variant}/model.safetensors",
config=model_id,
subfolder="transformer",
quantization_config=BFLQuantizationConfig(compute_dtype=torch.bfloat16),
dtype=torch.bfloat16,
)
pipe = ModularPipeline.from_pretrained(model_id)
pipe.load_components(dtype=torch.bfloat16)
pipe.update_components(transformer=transformer)
pipe.to("cuda")
若要加载未量化的单文件,请使用 URL:https://huggingface.co/{model_id}/blob/main/model.safetensors,并移除 quantization_config 参数。





