LatentDiffusionModelBase<T>
Base Classes · AiDotNet.Diffusion
Base class for latent diffusion models that operate in a compressed latent space.
Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T>
Implements: IGeneratedParameterRegistrar<T>, ILatentDiffusionModel<T>
Known derived types: ARDiffusionModel<T>, AnyEditModel<T>, AudioDiffusionModelBase<T>, AuraFlowModel<T>, AutoRegressiveMaskedDiffusion<T>, BlendedDiffusionModel<T>, BrushEditModel<T>, BrushNetModel<T>, BrushNetXModel<T>, CATDMModel<T>, CCSRModel<T>, CatVTONModel<T>, CogView4Model<T>, ConsisLoRAModel<T>, ConsistencyModel<T>, ControlARModel<T>, ControlNeXtModel<T>, ControlNetFluxModel<T>, ControlNetInpaintingModel<T>, ControlNetLiteModel<T>, ControlNetModel<T>, ControlNetPlusPlusFluxModel<T>, ControlNetPlusPlusModel<T>, ControlNetQRModel<T>, ControlNetSD3Model<T>, ControlNetTileModel<T>, ControlNetUnionModel<T>, ControlNetUnionProModel<T>, ControlNetXSModel<T>, CubeDiffModel<T>, CycleGANTurboModel<T>, DMD2Model<T>, DallE2Model<T>, DallE3Model<T>, DeepFloydIFModel<T>, DiffBIRModel<T>, DiffEditModel<T>, DiffPanoModel<T>, DreamFusionModel<T>, EDiffIModel<T>, EasyConsistencyModel<T>, EmuEdit<T>, FashionVDMModel<T>, FlashDiffusionModel<T>, FlowEditModel<T>, FlowMapModel<T>, Flux1Model<T>, Flux2Model<T>, Flux2SchnellModel<T>, FluxInpaintingModel<T>, FluxSchnellModel<T>, FreeInpaintModel<T>, HDPainterModel<T>, HiDreamModel<T>, HunyuanDiTModel<T>, HyperSDModel<T>, ICEditModel<T>, IDMVTONModel<T>, IPAdapterFaceIDModel<T>, IPAdapterFaceIDPlusModel<T> (+106 more)
For Beginners
This is the foundation for latent diffusion models like Stable Diffusion. It combines a VAE (for compression), a noise predictor (for denoising), and optional conditioning (for guided generation from text or images).
How It Works
This abstract base class provides common functionality for all latent diffusion models, including encoding/decoding, text-to-image generation, image-to-image transformation, and inpainting.
Properties
| Property | Summary |
|---|---|
DiffusionTrainingSampleSpace TrainingSampleSpace { get; set; } |
What this model’s training samples are: images its VAE encodes (the default), or latents already encoded. |
IConditioningModule<T> Conditioner { get; } |
|
INoisePredictor<T> NoisePredictor { get; } |
|
IVAEModel<T> VAE { get; } |
|
bool SupportsInpainting { get; } |
|
bool SupportsNegativePrompt { get; } |
|
double GuidanceScale { get; } |
|
int LatentChannels { get; } |
Methods
| Method | Summary |
|---|---|
IEnumerable<Tensor<T>> GetParameterChunks() |
Streams the network’s trainable weight tensors per-tensor without materialising a flat aggregate, mirroring PyTorch’s nn.Module.parameters() generator pattern. |
Tensor<T> DecodeFromLatent(Tensor<T> latent) |
|
Tensor<T> EncodeToLatent(Tensor<T> image, bool sampleMode) |
|
Tensor<T> Generate(int[] shape, int numInferenceSteps, int? seed) |
|
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) |
|
Tensor<T> Inpaint(Tensor<T> inputImage, Tensor<T> mask, string prompt, string negativePrompt, int numInferenceSteps, double? guidanceScale, int? seed) |
|
Tensor<T> Predict(Tensor<T> input) |
|
Tensor<T> PredictNoise(Tensor<T> noisySample, int timestep) |
|
ValueTask<Tensor<T>> GenerateAsync(int[] shape, int numInferenceSteps, int? seed, CancellationToken cancellationToken) |
Async overload of Generate for latent diffusion (text encoder → noise predictor → VAE decode pipeline). |
void SetGuidanceScale(double scale) |
|
void SetParameterChunks(IEnumerable<Tensor<T>> chunks) |
Streaming counterpart to SetParameters: distributes per-tensor chunks to the live registry component in the SAME stable manifest order GetParameterChunks yields them — without materializing a flat aggregate. |