Flux2Model<T>
Models & Types · AiDotNet.Diffusion.TextToImage
FLUX.2 model for next-generation text-to-image generation by Black Forest Labs.
Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → Flux2Model<T>
For Beginners
FLUX.2 is the improved version of FLUX.1, generating even better images with sharper details and more accurate text rendering.
How FLUX.2 works:
- Text is encoded by CLIP ViT-L/14 and T5-XXL encoders (dual encoder design)
- A hybrid MMDiT with 19 joint blocks + 38 single blocks processes tokens
- Improved rectified flow matching enables efficient 28-step generation
- A 16-channel VAE decodes latents to high-resolution images
Model variants:
- FLUX.2 [pro]: Best quality, API-only, not open-source
- FLUX.2 [dev]: Open-weight, guidance-distilled, non-commercial license
- FLUX.2 [schnell]: Fast 1-4 step generation, Apache 2.0 license
Key improvements over FLUX.1:
- Better text rendering and prompt adherence
- Higher image quality at fewer inference steps (28 vs 50)
- Improved color accuracy and composition
- Enhanced fine detail generation
Technical characteristics:
- 12B parameters in the transformer
- Hybrid architecture: 19 double-stream + 38 single-stream blocks
- Hidden size: 3072, 24 attention heads
- Dual text encoders: CLIP ViT-L/14 (768-dim) + T5-XXL (4096-dim)
- 16 latent channels with improved VAE
- Rotary Position Embeddings (RoPE)
- Improved rectified flow with optimized noise schedule
Limitations:
- Very high VRAM requirements (~24GB for dev)
- pro variant is API-only
- Newer model with evolving community support
How It Works
FLUX.2 is the successor to FLUX.1, featuring improved image quality, better text rendering, enhanced prompt adherence, and faster inference. It maintains the hybrid MMDiT architecture with improvements to the attention mechanism, flow matching schedule, and training procedure.
Reference: Black Forest Labs, “FLUX.2 Technical Report”, 2025
Example
// Create FLUX.2 dev (open-weight variant)
var flux2 = new Flux2Model<float>();
// Create FLUX.2 schnell for fast generation
var flux2Schnell = new Flux2Model<float>(variant: FluxVariant.Schnell);
// Generate an image
var image = flux2.GenerateFromText(
prompt: "A photorealistic landscape with aurora borealis over snow-capped mountains",
width: 1024,
height: 1024,
numInferenceSteps: 28,
guidanceScale: 3.5,
seed: 42);
Constructors
| Constructor | Summary |
|---|---|
Flux2Model(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, FluxDoubleStreamPredictor<T> predictor, StandardVAE<T> vae, IConditioningModule<T> conditioner, FluxVariant variant, int? seed) |
Initializes a new instance of Flux2Model with full customization support. |
Properties
| Property | Summary |
|---|---|
FluxVariant Variant { get; } |
Gets the model variant (Dev, Schnell, or Pro). |
IConditioningModule<T> Conditioner { get; } |
|
INoisePredictor<T> NoisePredictor { get; } |
|
IVAEModel<T> VAE { get; } |
|
bool IsGuidanceFree { get; } |
Gets whether this variant supports guidance-free generation. |
int LatentChannels { get; } |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |
|
Tensor<T> GenerateFromText(string prompt, string negativePrompt, int width, int height, int numInferenceSteps, double? guidanceScale, int? seed) |
|
Tensor<T> ImageToImage(Tensor<T> inputImage, string prompt, string negativePrompt, double strength, int numInferenceSteps, double? guidanceScale, int? seed) |
Fields
| Field | Summary |
|---|---|
int DefaultHeight |
Default image height for FLUX.2 (1024x1024). |
int DefaultWidth |
Default image width for FLUX.2 (1024x1024). |