CycleGANTurboModel<T>

Models & Types · AiDotNet.Diffusion.ImageEditing

CycleGAN-Turbo model combining CycleGAN unpaired translation with a diffusion backbone.

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

For Beginners

CycleGAN-Turbo translates images between two styles (like photos to paintings, summer to winter) using a single fast step. Unlike traditional CycleGAN, it leverages a pre-trained SDXL model for much higher quality results.

How It Works

Combines the unpaired image-to-image translation paradigm of CycleGAN with a pre-trained SDXL diffusion model backbone. Uses cycle consistency loss on a diffusion U-Net to enable single-step unpaired domain translation with high fidelity.

Technical specifications:

  • Base model: SDXL U-Net with cycle consistency fine-tuning
  • Text encoders: CLIP ViT-L/14 + OpenCLIP ViT-G/14 (2048 context)
  • Input channels: 8 (4 source latent + 4 target latent)
  • Inference: Single-step (1 NFE)
  • Guidance: 1.0 (single-step, no CFG needed)
  • Training: Cycle consistency + adversarial loss on SDXL

Reference: Parmar et al., “One-Step Image Translation with Text-to-Image Models”, 2024

Example

var options = new DiffusionModelOptions<float> { LatentChannels = 4, DefaultInferenceSteps = 1 };
var input = Tensor<float>.CreateRandom(new[] { 1, 4, 64, 64 });
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 CycleGANTurboModel<float>(options: options))
    .Build(trainX, trainY);
var translated = result.Predict(input);

Constructors

Constructor Summary
CycleGANTurboModel(NeuralNetworkArchitecture<T> architecture, DiffusionModelOptions<T> options, INoiseScheduler<T> scheduler, UNetNoisePredictor<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()