Welcome FLUX.3 Image Klein in Diffusers
https://huggingface.co/blog/flux-3📌 FLUX.3 Image Klein 開源發布,Diffusers 當天就能跑
TL;DR:Black Forest Labs 開源新一代影像模型 FLUX.3 Image Klein,一個模型同時處理文生圖、多參考圖編輯與版面控制,程式碼、量化權重與 LoRA 訓練腳本一次到位。
多數開源影像模型發布時只丟出一份模型權重,剩下的自己摸索。這次 Black Forest Labs 連「用 bounding box 指定物件要畫在哪裡」的 prompt 語法都寫進了官方文件,而且 Hugging Face 的 Diffusers 團隊在發布當天就把它接進 ModularPipeline,複製貼上就能跑。
🤔 一個模型,三種任務
FLUX.3 Image Klein 把文字生圖(text-to-image)、多張參考圖的圖生圖(multi-reference image-to-image),以及這次新加入的「版面控制」(layout control)整合進同一個模型。版面控制讓你在 prompt 裡寫入 JSON 格式的區域列表,指定畫面中每個部分要出現在哪個位置,或是指定參考圖裡的某個元素該移動到新畫面的哪裡。
官方開放的兩個 checkpoint 列在 FLUX.3 Image Klein collection 中:
| Checkpoint | 說明 | 預設設定 |
|---|---|---|
black-forest-labs/flux-3-image-klein | 時間步蒸餾(time step distilled)版本,推論快 | 16 步,不使用 CFG |
black-forest-labs/flux-3-image-klein-base | 基礎模型 | 50 步,使用 CFG |
🧩 怎麼用:從安裝到版面控制
安裝最新版 diffusers 與 transformers(因為文字編碼器用的是 Qwen3-VL),接著載入蒸餾版 checkpoint:
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")
文生圖時,官方提示指南建議把主體、場景、光線、構圖與風格都寫進完整的場景描述裡,效果會比短句子更好。蒸餾版預設 16 步產生 1024×1024 影像,可透過 height、width、num_inference_steps 調整。
圖生圖則是把參考圖傳入 image 參數,prompt 寫成「你想要的結果圖的描述」,並包含要做的改動。若傳入多張參考圖,可在 prompt 中用 <ref_image_0>、<ref_image_1> 依序指稱它們,例如把一張狐狸的圖和一張木椅的圖合成「狐狸坐在木椅上」的新畫面。
版面控制則是在 caption 後面接一段 JSON 區域列表,每個區域有 id、bbox(格式為 [y_min, x_min, y_max, x_max],y 在前,採 0 到 1000 的正規化座標)與 desc,caption 裡用 <id> 指稱該區域。因為座標是正規化的,同一組 bbox 在任何輸出尺寸下都通用。如果是編輯既有參考圖,每個區域還要多給 src_bbox(來源位置)與 tgt_bbox(目標位置),兩者相同就代表該元素原地不動,不同則代表要把它搬過去,其餘區域維持原狀。
📊 跑起來多快、多重
蒸餾版 checkpoint 在 H100 上產生一張 1024×1024 影像約需 2 秒。對於記憶體較小的 GPU,官方也提供 NVFP4 與 FP8 量化權重,可透過 from_single_file 直接載入。基礎模型則需要 50 步並搭配 CFG,速度較慢,但它才是用來做 LoRA 微調的對象。
⚠️ 微調與部署的限制
要做 LoRA 微調,官方建議使用基礎模型而非蒸餾版;蒸餾版本身已經針對快速推論做過最佳化,直接拿去微調不是官方建議的路徑。此外,完整的多參考圖與版面控制功能仍仰賴正確撰寫 JSON 區域描述,格式稍有出錯就可能影響生成結果。
🎯 實務啟示
對工程師來說,這次發布的價值不只是模型本身,而是「Modular Diffusers pipeline」這個設計:可以把管線裡的區塊拆開或替換成自訂模組。再加上官方同步給出 LoRA 訓練腳本與量化權重,想要在特定風格或任務上做客製化、或是把模型塞進較小的 GPU,都有現成的路徑可以直接試,不用自己從零拼湊推論與訓練流程。
🔗 來源
- 標題:Welcome FLUX.3 Image Klein in Diffusers
- 作者/機構:Hugging Face(Black Forest Labs 模型)
- 連結:https://huggingface.co/blog/flux-3
#FLUX3 #BlackForestLabs #Diffusers #ImageGeneration #OpenSource #LoRA #TextToImage #ImageToImage #HuggingFace #GenerativeAI
原始資料 HuggingFace Blog · 收集於 2026-10-15
摘要原文
Back to Articles Welcome FLUX.3 Image Klein in Diffusers: The latest open image generation model from Black Forest Labs Published October 15, 2026 Update on GitHub Upvote 21 +15 Aritra Roy Gosthipaty ariG23498 Follow Sayak Paul sayakpaul Follow Linoy Tsaban linoyts Follow Black Forest Labs FLUX.3 Image Klein is here, and it runs in Diffusers from day one. One model does text-to-image and multi-reference image-to-image, and it adds something new, the layout control . You write bounding boxes into the prompt to say where each part of the image should go, or which parts of a reference image to move. Both open checkpoints are in the FLUX.3 Image Klein collection : Checkpoint What it is Defaults black-forest-labs/flux-3-image-klein Time step distilled, for fast inference 16 steps, no CFG black-forest-labs/flux-3-image-klein-base Base model 50 steps, CFG You can head on to the Hugging Face space and generate some images right now! TL;DR One model for text-to-image, multi-reference image-to-image, and bounding-box layout control. The distilled checkpoint makes a 1024 × 1024 image in about 2 seconds on an H100. NVFP4 and FP8 weights load with from_single_file , for smaller GPUs. LoRA training scripts for both text-to-image and image editing. Ships as a Modular Diffusers pipeline, so you can pop blocks out or add your own. Contents Getting started What FLUX.3 can do Base model and quantized variants LoRA finetuning What it costs to run The architecture Modular Diffusers Try it Getting started Install the latest diffusers and transformers (for the Qwen3-VL text encoder): pip install -U diffusers transformers Load the distilled checkpoint and generate an image: 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" ) What FLUX.3 can do Text-to-image FLUX.3 responds best to a full scene description with the subject, the setting, the light, the composition, and the style. The official prompting guide from Black Forest Labs has more tips. The distilled checkpoint generates a 1024 × 1024 image in 16 steps by default. Pass height , width , or num_inference_steps to change them. 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" ) Text to image Image-to-image Pass a reference image (or more) with the image argument. Write the prompt as a caption of the image you want , with the change included. 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, # from the previous text to image example generator=torch.Generator().manual_seed( 0 ), output= "images" , )[ 0 ] night.save( "night.png" ) Image to image With several references, refer to them in the prompt as <ref_image_0> , <ref_image_1> , ... in the order they are passed to image : 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" ) <ref_image_0> : a red fox <ref_image_1> : a wooden bench The fox on the bench Layout control Add a JSON list of regions after the caption. Each region has an id , a bbox , and a desc , and the caption mentions it as <id> . Boxes are written as [y_min, x_min, y_max, x_max] , y first , on a 0–1000 scale. Because the scale is normalized, the same box works at any image size. Placing regions in a new image 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 ] Each region's desc is drawn inside its bbox Moving regions within a reference image For edits, each region says where its content comes from ( src_bbox in the reference) and where it goes ( tgt_bbox in the output). A region with the same two boxes stays where it is. This example moves the knitted knight up and to the left, and pins the backdrop, the cliff, the needle, the dragon, and the fire: 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 ] The knight moves from its src_bbox to its tgt_bbox , and the rest of the scene stays put Base model and quantized variants Base model Everything above uses the distilled checkpoint. The base checkpoint runs 50 steps with classifier-free guidance, and it's the one to fine-tune (see LoRA finetuning ). 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.
由 claude-code/sonnet 自動生成