
FLUX.2 [klein] 9B-KV 是 FLUX.2 [klein] 9B 的优化版本,支持 KV 缓存以加速多参考图编辑。该版本在首次去噪步骤中缓存参考图像的键值对,消除后续步骤中的冗余计算,显著加快多图像编辑工作流程。
有关 FLUX.2 [klein] 的更多信息,请阅读我们的 博客文章。
在标准图像编辑中,参考图像令牌会在每个去噪步骤中被处理。借助 KV 缓存:
这在以下场景中尤为有益:
我们在 GitHub 仓库 中提供了参考实现。
FLUX.2 [klein] 9B-KV 可通过 BFL API 在 bfl.ai 获取。
要将 FLUX.2 [klein] 9B-KV 与 🧨 Diffusers Python 库配合使用,请先安装或升级 diffusers:
pip install git+https://github.com/huggingface/diffusers.git然后您可以使用 Flux2KleinKVPipeline 来运行模型:
import torch
from diffusers import Flux2KleinKVPipeline
device = "cuda"
dtype = torch.bfloat16
model_path = "black-forest-labs/FLUX.2-klein-9b-kv"
pipe = Flux2KleinKVPipeline.from_pretrained(model_path, torch_dtype=dtype)
pipe.to(device)
# Text-to-image (no reference image)
print("Generating text-to-image...")
image = pipe(
prompt="A cat holding a sign that says hello world",
height=1024,
width=1024,
num_inference_steps=4,
generator=torch.Generator(device=device).manual_seed(0),
).images[0]
image.save("t2i_output.png")
print("Saved t2i_output.png")
# Image-to-image with KV cache (using the generated image as reference)
print("Generating image-to-image with KV cache...")
image_kv = pipe(
prompt="A cat dressed like a wizard",
image=image,
height=1024,
width=1024,
num_inference_steps=4,
generator=torch.Generator(device=device).manual_seed(0),
).images[0]
image_kv.save("kv_output.png")
print("Saved kv_output.png")本模型及其衍生产品不得在许可范围外使用,包括用于非法、欺诈、诽谤、滥用或其他违反行为,具体详见我们的使用政策。
FLUX.2 [klein] 9B-KV模型大小约为29GB VRAM,可在NVIDIA RTX 5090及更高配置的显卡上运行。
Black Forest Labs致力于负责任的模型开发与部署。在发布FLUX.2 [klein] 9B-KV之前,我们评估并缓解了多项风险,包括儿童性虐待材料(CSAM)和非自愿私密图像(NCII)。有关我们的缓解措施、评估流程、内容来源特征及政策的详细信息,请参阅我们的文章:Capable, Open, and Safe: Combating AI Misuse。
如报告安全问题,请联系safety@blackforestlabs.ai。
本模型遵循FLUX Non-Commercial License。
本项目可能包含项目、产品或服务的商标或徽标。在本项目的修改版本中使用Black Forest Labs和FLUX的商标或徽标时,不得引起混淆,也不得暗示获得赞助或认可。任何第三方商标、知识产权或徽标的使用均受第三方政策的约束。