FLUX.2 klein

FLUX.2 klein 4B is a text-to-image model by Black Forest Labs: a 4-billion-parameter rectified-flow transformer, step-distilled to sample in four steps. LibreYOLO runs it through its diffusers pipeline behind the LibreGen factory, where it is the default model.

Tác vụ
image generation
Kích thước
4b at 1024 px
Cài đặt
pip install "libreyolo[gen]"
Bậc hỗ trợ
Bậc song hành, từ v1.7.0. Một bề mặt sản phẩm riêng với factory và contract riêng.
Thượng nguồn
FLUX.2 klein 4B của Black Forest Labs, Apache-2.0. Bài báo, mã nguồn
Giấy phép
Mã nguồn MIT, trọng số Apache-2.0. Sử dụng thương mại

Install

bash
pip install "libreyolo[gen]"

The gen extra installs diffusers, transformers and accelerate. FLUX.2 klein loads as the diffusers Flux2KleinPipeline, which needs diffusers 0.38.0 or later. Importing LibreGen imports none of them; they load on first use.

Generation runs on a CUDA GPU or on Apple silicon through MPS. device="auto" picks CUDA, then MPS, then the CPU, where the pipeline loads in fp32 and image generation is not practical.

Predict

Python
from libreyolo import LibreGen # Needs a CUDA GPU or Apple silicon (MPS); generation is not practical on CPU.model = LibreGen("flux2-klein-4b")   # weights download on first useresult = model("a red fox sleeping in fresh snow", seed=0) result.save("fox.png")               # the PNG also records prompt, seed and settingsprint(result.generated.array.shape)  # (1024, 1024, 3)
CLI
# Saves the image as .png under runs/generate/predict.libreyolo generate prompt="a red fox sleeping in fresh snow" model=flux2-klein-4b seed=0
Settings
from libreyolo import LibreGen model = LibreGen("flux2-klein-4b") result = model("a red fox sleeping in fresh snow", imgsz=(768, 1024))  # height, widthresult = model("a red fox sleeping in fresh snow", steps=8)            # more sampling steps # Two prompts, two images each (seeds 0 and 1), written to runs/generate/predict.results = model(    ["a red fox sleeping in fresh snow", "a lighthouse on a rocky coast"],    seed=0,    n=2,    save=True,)
Results
from libreyolo import LibreGen model = LibreGen("flux2-klein-4b")result = model("a red fox sleeping in fresh snow", seed=0) g = result.generatedprint(g.array.shape, g.array.dtype)   # (1024, 1024, 3) uint8, RGBprint(g.prompt, g.seed)               # what to pass to make it againprint(g.params)                       # model, imgsz, steps, guidance g.image.save("fox.jpg")               # a PIL imageprint(result.summary())               # one JSON-ready row

One prompt with n=1 returns a Results; a list of prompts or n > 1 returns a flat list in prompt order, and stream=True a generator. A string is always a prompt, never a path. result.generated is a GeneratedImage: array is the (H, W, 3) uint8 RGB image and image the same image as a PIL.Image, prompt the text, seed the integer that reproduces it, and params the model, imgsz and every setting in effect, defaults included. result.save(path) writes the image, and a PNG also stores prompt, seed and params as JSON in a libreyolo text chunk. result.plot() returns the image. save=True writes each image to a new runs/generate/predict folder per call, the file named after its index, prompt and seed; output_path names the file instead, for one prompt with n=1.

The first call downloads about 16 GB at a pinned revision, with nothing gated and no Hugging Face login, from Black Forest Labs' repository black-forest-labs/FLUX.2-klein-4B into weights/LibreFlux2Klein4b/. Only the pipeline's component folders are fetched, not the repository's single-file checkpoint. LibreGen(path) loads a local directory that holds a Flux2KleinPipeline in the diffusers layout instead, such as an offline copy or a fine-tune made with upstream tooling. flux2-klein, flux.2-klein and flux.2-klein-4b are aliases of flux2-klein-4b, and LibreGen() with no argument loads it.

A seed, with the same model and settings, gives the same image. Image i of a prompt uses seed + i, and every prompt in a list starts from the same seed. Without a seed, a fresh one is drawn for each prompt and recorded in result.generated.seed. The seed drives a random generator on the CPU, so the starting noise is the same on every device; the image can still differ across devices and precisions by numerical error.

Image-conditioned generation, which FLUX.2 klein supports upstream, is not available yet: source= raises NotImplementedError.

Settings

Every setting has a default, so all are optional. A name the model does not have raises TypeError and lists the supported ones.

SettingDefaultMeaning
imgsz1024Output size: an int for a square image, or (height, width). Each side is rounded up to a multiple of 16, with a warning.
steps4Sampling steps. The distilled checkpoint is trained for 4.
guidance1.0Fixed. The checkpoint is step-distilled and runs without guidance, so any other value raises ValueError.

The constructor takes device, dtype and offload. dtype="auto" is bf16 on CUDA (fp16 on a GPU without bf16), bf16 on MPS from macOS 14, and fp32 on the CPU and on older macOS; "bf16", "fp16" and "fp32" force one. offload=True keeps idle pipeline components off the GPU; it needs CUDA and raises on any other device. model.pipeline is the loaded diffusers Flux2KleinPipeline, for anything the LibreGen call does not cover.

Export

Tác vụONNXTorchScriptExecuTorchTensorRTOpenVINOPaddleMNNRKNNncnnTFLiteCoreMLCore AI
Image generationImage generation to ONNX: không được hỗ trợImage generation to TorchScript: không được hỗ trợImage generation to ExecuTorch: không được hỗ trợImage generation to TensorRT: không được hỗ trợImage generation to OpenVINO: không được hỗ trợImage generation to Paddle: không được hỗ trợImage generation to MNN: không được hỗ trợImage generation to RKNN: không được hỗ trợImage generation to ncnn: không được hỗ trợImage generation to TFLite: không được hỗ trợImage generation to CoreML: không được hỗ trợImage generation to Core AI: không được hỗ trợ

Export is not implemented: the model is a sampling loop over several networks, and LibreYOLO has no exportable graph contract for that yet (ADR 0030 in the library). export(), train() and val() raise NotImplementedError. train(data=...) is reserved for fine-tuning on captioned images, and val(data=...) for generation metrics on a captioned image set.

Licensing

Hãy kiểm tra giấy phép trong repo Hugging Face của trọng số cụ thể mà bạn tải xuống. Mỗi checkpoint trong tổ chức LibreYOLO đều có giấy phép riêng và giấy phép có thể khác nhau trong cùng một họ. Repo đó là nguồn có thẩm quyền; phần tóm tắt dưới đây mô tả các điều khoản áp dụng khi trang này được kiểm chứng lần gần nhất.

Đây là phần mô tả các giấy phép liên quan, không phải tư vấn pháp lý. Nếu câu trả lời có ý nghĩa về mặt thương mại, hãy tự đọc các giấy phép và tham khảo cố vấn của riêng bạn.

Công trình gốc
FLUX.2 klein 4B, Black Forest Labs
Giấy phép thượng nguồn
Apache-2.0
Nguồn thượng nguồn
github.com/black-forest-labs/flux2
Mã nguồn LibreYOLO
MIT
Trọng số
Apache-2.0, do tác giả phân phối. LibreYOLO không lưu trữ hoặc sao chép chúng.
Diễn giải
Apache-2.0 is a permissive license, so these weights can be used in commercial and closed-source products. It asks you to keep its license text and attribution notices with any copy of the weights you redistribute, and it grants a patent license. Black Forest Labs declares Apache-2.0 on the Hugging Face repository LibreYOLO downloads, black-forest-labs/FLUX.2-klein-4B, in its license tag and LICENSE.md, and its model card calls the model fully open under Apache 2.0. The license is not uniform across FLUX.2: Black Forest Labs releases the klein 9B models and FLUX.2 dev under its FLUX Non-Commercial License, and LibreYOLO does not load those. LibreYOLO's adapter is its own MIT code that calls the Apache-2.0 diffusers Flux2KleinPipeline; no upstream source is ported. The weights are not redistributed: they download from that repository at revision e7b7dc27f91deacad38e78976d1f2b499d76a294, component folders only.

FLUX.2 klein is the work of Black Forest Labs. Its reference code is black-forest-labs/flux2 and its weights are black-forest-labs/FLUX.2-klein-4B, both Apache-2.0. The same repository supplies the FLUX.2 VAE that Speridlabs Idol reads its input through. LibreYOLO adds no content filter; the model card lists the uses Black Forest Labs excludes.

Citation

@misc{flux-2-2025,
    author={Black Forest Labs},
    title={{FLUX.2: Frontier Visual Intelligence}},
    year={2025},
    howpublished={\url{https://bfl.ai/blog/flux-2}},
}

Được sao chép từ khối trích dẫn của tác giả tại github.com/black-forest-labs/flux2#citation.

Đã kiểm chứng với LibreYOLO v1.7.0. Các bảng hỗ trợ, checkpoint và số liệu benchmark trên trang này được tạo từ thư viện đã phát hành và trọng số đã công bố, không phải viết thủ công.