Skip to content

Conversation

@yiyixuxu
Copy link
Collaborator

@yiyixuxu yiyixuxu commented Jan 15, 2026

testing script

from diffusers import Flux2KleinPipeline
import torch

device = "cuda"
dtype = torch.bfloat16

# 4b-base
repo_id = "black-forest-labs/FLUX.2-klein-base-4B"

pipeline = Flux2KleinPipeline.from_pretrained(repo_id, torch_dtype=dtype)
pipeline.enable_model_cpu_offload()

prompt = "a photo of a forest with mist swirling around the tree trunks. The word 'FLUX.2' is painted over it in big, red brush strokes with visible texture"
height = 768
width = 1360
num_inference_steps = 50
guidance_scale = 4.0
generator = torch.Generator(device=device).manual_seed(42)

out = pipeline(
    prompt=prompt,
    height=height,
    width=width,
    num_inference_steps=num_inference_steps,
    guidance_scale=guidance_scale,
    generator=generator
).images[0]

out.save("output_4b_base.png")

# 9b-base
repo_id = "black-forest-labs/FLUX.2-klein-base-9B"

pipeline = Flux2KleinPipeline.from_pretrained(repo_id, torch_dtype=dtype)
pipeline.enable_model_cpu_offload()

prompt = "a photo of a forest with mist swirling around the tree trunks. The word 'FLUX.2' is painted over it in big, red brush strokes with visible texture"
height = 768
width = 1360
num_inference_steps = 50
guidance_scale = 4.0
generator = torch.Generator(device=device).manual_seed(42)

out = pipeline(
    prompt=prompt,
    height=height,
    width=width,
    num_inference_steps=num_inference_steps,
    guidance_scale=guidance_scale,
    generator=generator
).images[0]

out.save("output_9b_base.png")


# 4b

repo_id = "black-forest-labs/FLUX.2-klein-4B"
pipeline = Flux2KleinPipeline.from_pretrained(repo_id, torch_dtype=dtype)
pipeline.enable_model_cpu_offload()
num_inference_steps = 4
guidance_scale = 1.0
generator = torch.Generator(device=device).manual_seed(42)

out = pipeline(
    prompt=prompt,
    height=height,
    width=width,
    num_inference_steps=num_inference_steps,
    guidance_scale=guidance_scale,
    generator=generator
).images[0]

out.save("output_4b.png")


# 9b
repo_id = "black-forest-labs/FLUX.2-klein-9B"
pipeline = Flux2KleinPipeline.from_pretrained(repo_id, torch_dtype=dtype)
pipeline.enable_model_cpu_offload()
num_inference_steps = 4
guidance_scale = 1.0
generator = torch.Generator(device=device).manual_seed(42)

out = pipeline(
    prompt=prompt,
    height=height,
    width=width,
    num_inference_steps=num_inference_steps,
    guidance_scale=guidance_scale,
    generator=generator
).images[0]

out.save("output_9b.png")

yiyixuxu and others added 11 commits January 15, 2026 17:03
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
* tests

* up

* tests

* up
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
Co-authored-by: dg845 <58458699+dg845@users.noreply.github.com>
* initial commit

* initial commit

* remove remote text encoder

* initial commit

* initial commit

* initial commit

* revert

* img2img fix

* text encoder + tokenizer

* text encoder + tokenizer

* update readme

* guidance

* guidance

* guidance

* test

* test

* revert changes not needed for the non klein model

* Update examples/dreambooth/train_dreambooth_lora_flux2_klein.py

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>

* fix guidance

* fix validation

* fix validation

* fix validation

* fix path

* space

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@PierrunoYT
Copy link

D:\pinokio\api\flux-2-klein-pinokio.git>conda_hook & conda deactivate & conda deactivate & conda deactivate & conda activate base & D:\pinokio\api\flux-2-klein-pinokio.git\env\Scripts\activate D:\pinokio\api\flux-2-klein-pinokio.git\env && python app.py
Traceback (most recent call last):
File "D:\pinokio\api\flux-2-klein-pinokio.git\app.py", line 3, in
from diffusers import Flux2KleinPipeline
ImportError: cannot import name 'Flux2KleinPipeline' from 'diffusers' (D:\pinokio\api\flux-2-klein-pinokio.git\env\lib\site-packages\diffusers_init_.py)

@varadtechx
Copy link

D:\pinokio\api\flux-2-klein-pinokio.git>conda_hook & conda deactivate & conda deactivate & conda deactivate & conda activate base & D:\pinokio\api\flux-2-klein-pinokio.git\env\Scripts\activate D:\pinokio\api\flux-2-klein-pinokio.git\env && python app.py Traceback (most recent call last): File "D:\pinokio\api\flux-2-klein-pinokio.git\app.py", line 3, in from diffusers import Flux2KleinPipeline ImportError: cannot import name 'Flux2KleinPipeline' from 'diffusers' (D:\pinokio\api\flux-2-klein-pinokio.git\env\lib\site-packages\diffusers__init__.py)

Use this branch for building diffusers

@yiyixuxu
Copy link
Collaborator Author

@bot /style

@github-actions
Copy link
Contributor

github-actions bot commented Jan 15, 2026

Style bot fixed some files and pushed the changes.

Copy link

@cjkindel cjkindel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there guidance/enforcement that Diffusers can provide to prevent the confusion that comes from initial pipelines being generic (ex: Flux2Pipeline) instead of specific (ex: Flux2DevPipeline) so that subsequent pipeline naming matches the pattern?

Griptape's customers experience some confusion on this, they see pipelines like Flux2Pipeline and it is not obvious that the pipeline is for [dev] models only, not [klein].

(Not specific to Flux.2, seeing this anti-pattern across pipelines)


model_description = f"""
# Flux DreamBooth LoRA - {repo_id}
# Flux.2 DreamBooth LoRA - {repo_id}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should this clarify [dev]?

@yiyixuxu
Copy link
Collaborator Author

hey @cjkindel

thanks for your feedback, however we don't really know these release plans ahead of time and it's hard to plan around that

You can use DiffusionPipeline.from_pretrained(repo_id) , which automatically resolves to the correct pipeline class based on the model_index.json on the repo .

or AutoPipeline (see https://huggingface.co/docs/diffusers/tutorials/autopipeline) if they want to work with a different task

they don't need to know the specific pipeline name at all.

@yiyixuxu yiyixuxu merged commit 61f1756 into main Jan 15, 2026
30 of 36 checks passed
@yiyixuxu yiyixuxu deleted the flux2-klein branch January 15, 2026 19:11
@Bili-Sakura
Copy link

Bili-Sakura commented Jan 16, 2026

will the flux.2 Klein Image to Image pipeline also come in days @yiyixuxu @cjkindel

@asomoza
Copy link
Member

asomoza commented Jan 16, 2026

@Bili-Sakura can you please open a new issue with this feature request?

@muljanis45
Copy link

Does Flux2 Klein actually use Qwen 3 VL?

The readme says Flux2 Klein uses "Qwen VL" as text encoder, but the pipeline code imports:

from transformers import Qwen2TokenizerFast, Qwen3ForCausalLM

which is text only i guess? am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.