PASDModel<T>
Models & Types · AiDotNet.Diffusion.SuperResolution
PASD: Pixel-Aware Stable Diffusion for real-world image super-resolution.
Inheritance: DiffusionModelBase<T> → LatentDiffusionModelBase<T> → PASDModel<T>
For Beginners
When upscaling images, it’s crucial to keep the original structure intact while adding detail. PASD weaves the low-resolution image information directly into the diffusion model’s attention mechanism, ensuring the output matches the input’s structure perfectly while adding sharp, realistic details.
How It Works
PASD uses pixel-aware cross-attention to inject low-resolution structural information directly into the diffusion U-Net’s attention layers. This ensures the super-resolved image preserves the original structure while generating realistic high-frequency details.
Technical specifications:
- Architecture: SD2.1 U-Net with pixel-aware cross-attention
- Text encoder: OpenCLIP ViT-H/14 (1024-dim) — uses image captions for guidance
- Pixel-aware attention: LR features injected into cross-attention at every layer
- Scale factor: 4x upscaling
- Personalized stylization also supported
Reference: Yang et al., “Pixel-Aware Stable Diffusion for Realistic Image Super-resolution and Personalized Stylization”, 2024
Example
var options = new DiffusionModelOptions<float> { LatentChannels = 4, DefaultInferenceSteps = 20 };
var lowRes = Tensor<float>.CreateRandom(new[] { 1, 4, 32, 32 });
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 PASDModel<float>(options: options))
.Build(trainX, trainY);
var highRes = result.Predict(lowRes);
Constructors
| Constructor | Summary |
|---|---|
PASDModel(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() |