Skip to main content

DiffusionConfig

Struct DiffusionConfig 

Source
pub struct DiffusionConfig {
Show 25 fields pub num_views: usize, pub guidance_scale: f64, pub num_inference_steps: usize, pub upsampler_steps: usize, pub image_size: usize, pub latent_size: usize, pub latent_channels: usize, pub unet_in_channels: usize, pub unet_out_channels: usize, pub cross_attention_dim: usize, pub clip_embed_dim: usize, pub time_embed_dim: usize, pub base_channels: usize, pub channel_mult: Vec<usize>, pub layers_per_block: usize, pub attention_head_dim: Vec<usize>, pub transformer_layers_per_block: Vec<usize>, pub norm_num_groups: usize, pub norm_eps: f64, pub camera_pose_dim: usize, pub use_linear_projection: bool, pub vae_scale_factor: f64, pub use_flash_attention: bool, pub flash_attention_block_size: usize, pub upsampler_mode: Option<UpsamplerMode>,
}
Expand description

Full configuration for the multi-view diffusion model.

Contains all hyperparameters for the diffusion pipeline, including U-Net architecture, attention settings, CFG parameters, and optional upsampling.

§Examples

use oxigaf_diffusion::DiffusionConfig;

// Use default configuration (256×256, guidance_scale=3.0)
let config = DiffusionConfig::default();

// Customize guidance scale for stronger conditioning
let mut config = DiffusionConfig::default();
config.guidance_scale = 7.5;

// Enable upsampling for 512×512 output
use oxigaf_diffusion::UpsamplerMode;
config.upsampler_mode = Some(UpsamplerMode::SdX2);

Fields§

§num_views: usize

Number of views to generate simultaneously (default: 4).

§guidance_scale: f64

Classifier-free guidance scale for IP-Adapter conditioning (default: 3.0).

Controls the strength of reference image conditioning. Must be >= 1.0. Higher values increase identity preservation but may reduce diversity.

  • 1.0: No guidance (pure conditional)
  • 3.0-7.5: Balanced (recommended)
  • >10.0: Strong conditioning (may oversaturate)
§num_inference_steps: usize

Number of DDIM denoising steps (default: 50).

§upsampler_steps: usize

Number of latent upsampler denoising steps (default: 10).

§image_size: usize

Input/output image resolution before upscaling (default: 256).

§latent_size: usize

Latent spatial size (image_size / 8).

§latent_channels: usize

Number of latent channels produced by the VAE (default: 4).

§unet_in_channels: usize

U-Net input channels: latent_channels + normal-map latent channels (default: 8).

§unet_out_channels: usize

U-Net output channels (default: 4).

§cross_attention_dim: usize

Cross-attention dimension (SD 2.1 = 1024).

§clip_embed_dim: usize

CLIP image embedding dimension (ViT-H/14 = 1280).

§time_embed_dim: usize

Time embedding dimension (default: 1280).

§base_channels: usize

Base channels for the U-Net (default: 320).

§channel_mult: Vec<usize>

Channel multipliers per U-Net stage.

§layers_per_block: usize

Layers per block in the U-Net.

§attention_head_dim: Vec<usize>

Number of attention heads per head-dim for each stage.

§transformer_layers_per_block: Vec<usize>

Number of transformer blocks per attention stage.

§norm_num_groups: usize

Group-norm number of groups (default: 32).

§norm_eps: f64

Group-norm epsilon.

§camera_pose_dim: usize

Camera pose input dimension (4×3 flattened = 12).

§use_linear_projection: bool

Whether to use linear projection in spatial transformer.

§vae_scale_factor: f64

VAE scaling factor for latent space.

§use_flash_attention: bool

Whether to use flash attention for memory-efficient O(N) attention. When enabled, uses block-wise computation with online softmax. Falls back to standard O(N^2) attention when disabled. Default: true (when feature is enabled).

§flash_attention_block_size: usize

Block size for flash attention tiled computation. Larger blocks use more memory but may be faster due to better cache utilization. Default: 64.

§upsampler_mode: Option<UpsamplerMode>

Upsampler mode for latent upsampling (32×32 → 64×64).

  • None: No upsampling, output is 256×256
  • Some(SdX2): Use sd-x2-latent-upscaler, output is 512×512
  • Some(BilinearVae): Use bilinear upsampling, output is 512×512

Default: None (256×256 output).

Implementations§

Source§

impl DiffusionConfig

Source

pub fn stage_channels(&self, stage: usize) -> usize

Channel count for a given U-Net stage index.

Source

pub fn num_stages(&self) -> usize

Total number of U-Net stages.

Trait Implementations§

Source§

impl Clone for DiffusionConfig

Source§

fn clone(&self) -> DiffusionConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DiffusionConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DiffusionConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,