OmniGen2<T>

Models & Types · AiDotNet.VisionLanguage.Unified

OmniGen2: dual-path architecture with parameter decoupling.

Inheritance: NeuralNetworkBase<T> → VisionLanguageModelBase<T> → OmniGen2<T>

Implements: IUnifiedVisionModel<T>

For Beginners

OmniGen2 is a unified model for image generation using dual-path architecture with parameter decoupling. Default values follow the original paper settings.

How It Works

OmniGen2 (THU, 2025) advances unified image generation with a dual-path architecture that decouples understanding and generation parameters. One path handles visual comprehension while the other specializes in image generation via diffusion, allowing each path to be independently optimized while sharing a common language backbone for instruction following.

References:

  • Paper: “OmniGen2: Advancing Unified Image Generation with Dual-Path Architecture” (THU, 2025)

Example

// Create an OmniGen2 model for unified image generation
// with dual-path architecture and parameter decoupling
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.TwoDimensional,
    taskType: NeuralNetworkTaskType.ImageClassification,
    inputHeight: 224, inputWidth: 224, inputDepth: 3, outputSize: 512);
            
// ONNX inference mode with pre-trained model
var model = new OmniGen2<double>(architecture, "omnigen2.onnx");
            
// Training mode with native layers
var trainModel = new OmniGen2<double>(architecture, new OmniGen2Options());

Constructors

Constructor Summary
OmniGen2(NeuralNetworkArchitecture<T> architecture, OmniGen2Options options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer)
OmniGen2(NeuralNetworkArchitecture<T> architecture, string modelPath, OmniGen2Options options)

Properties

Property Summary
bool SupportsGeneration { get; }
int DecoderEmbeddingDim { get; }
int EmbeddingDimension { get; }
int MaxGenerationLength { get; }

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()
Tensor<T> EncodeImage(Tensor<T> image)
Tensor<T> GenerateFromImage(Tensor<T> image, string prompt) Generates text from image using OmniGen2’s understanding path.
Tensor<T> GenerateImage(string textDescription) Generates an image from text using OmniGen2’s rectified flow generation path.