LuminaImage2Model<T>

Models & Types · AiDotNet.Diffusion.TextToImage

Lumina Image 2.0 model for high-resolution text-to-image generation.

Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → LuminaImage2Model<T>

For Beginners

Lumina Image 2.0 is an open-source model from the Lumina framework.

How Lumina Image 2.0 works:

  1. Text is encoded by Gemma 2B for strong multilingual understanding
  2. A Flag-DiT (Flow-Aware Generative DiT) processes tokens with flow matching
  3. Multi-resolution support handles different aspect ratios natively
  4. A 16-channel VAE decodes latents to high-resolution images

Key characteristics:

  • Flag-DiT architecture with flow-aware generation
  • Gemma 2B text encoder
  • Native multi-resolution and aspect ratio support
  • 2B parameters in the transformer
  • 16 latent channels
  • Up to 2K resolution generation

Advantages:

  • Open-source with permissive license
  • Native multi-resolution support
  • Good quality-to-compute ratio
  • Flexible aspect ratio handling

How It Works

Lumina Image 2.0 uses a Flag-DiT (Flow-Aware Generative DiT) architecture with improved multi-resolution support and efficient attention mechanisms. It features Gemma text encoding and flow matching training for generating images up to 2K resolution with excellent detail.

Reference: Gao et al., “Lumina-Image: High-Resolution Image Generation with Flow-Aware Generative Transformers”, 2024

Example

var options = new DiffusionModelOptions<float> { LatentChannels = 16, DefaultInferenceSteps = 28 };
var noise = Tensor<float>.CreateRandom(new[] { 1, 16, 128, 128 });
var trainX = Tensor<float>.CreateRandom(4, 8);
var trainY = Tensor<float>.CreateRandom(4, 2);
var result = new AiModelBuilder<float, Tensor<float>, Tensor<float>>()
    .ConfigureModel(new LuminaImage2Model<float>(options: options))
    .Build(trainX, trainY);
var generated = result.Predict(noise);

Constructors

Constructor Summary
LuminaImage2Model(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, FlagDiTPredictor<T> predictor, StandardVAE<T> vae, IConditioningModule<T> conditioner, int? seed)

Properties

Property Summary
IConditioningModule<T> Conditioner { get; }
INoisePredictor<T> NoisePredictor { get; }
IVAEModel<T> VAE { get; }
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
int DefaultWidth