Skip to content

Add Flux2KleinImg2ImgPipeline for FLUX.2 Klein #14042

Description

@Sainava

Is your feature request related to a problem? Please describe.
Currently, the diffusers library supports the base text-to-image Flux2KleinPipeline, but it lacks native support for Image-to-Image generation (Img2Img) for the FLUX.2 Klein architecture. Because Klein uses a highly optimized, compact structure (single text encoder, specific VAE patchification, and built-in batch normalization), users cannot simply drop Klein weights into the standard FluxImg2ImgPipeline without hitting shape mismatches and crashes.

Describe the solution you'd like.
I would like to add a dedicated Flux2KleinImg2ImgPipeline. This pipeline will:

  • Adapt standard Img2Img logic (calculating sliced timesteps and scaling noise via FlowMatchEulerDiscreteScheduler) to the specific packing constraints of the Klein architecture.
  • Maintain Klein-specific safety optimizations, such as area-based image resizing (capping at 1024x1024) to prevent OOM errors on consumer hardware.
  • Include standard pipeline safety checks, such as strength boundary validation and batch-size divisibility checks.

Describe alternatives you've considered.

  • Alternative 1: Modifying the base Flux2KleinPipeline to handle both T2I and I2I. This was rejected because diffusers design philosophy strongly prefers keeping pipelines atomic and focused for readability and maintainability.
  • Alternative 2: Routing users to the base FluxImg2ImgPipeline. This was rejected because the architectural differences (e.g., dual vs. single text encoders, differing vae_scale_factors) make them fundamentally incompatible without heavy conditional logic.

Additional context.
I have already implemented this pipeline locally. The matrix math, packing/unpacking dimension integrity, and strength validations have been successfully verified using isolated CPU mock tests. I will open a Pull Request resolving this issue shortly!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions