pub struct VaeDecoderConfig {
pub out_channels: usize,
pub latent_channels: usize,
pub block_out_channels: Vec<usize>,
pub layers_per_block: usize,
pub norm_num_groups: usize,
pub sample_size: usize,
pub scaling_factor: f64,
}Expand description
Frozen config for the Stable-Diffusion VAE decoder.
Mirrors the decoder-relevant subset of AutoencoderKL.config for
runwayml/stable-diffusion-v1-5. The defaults match SD 1.5 exactly.
Fields§
§out_channels: usizeNumber of input channels of the image the encoder consumes (and therefore of the image the decoder produces). For SD 1.5: 3.
latent_channels: usizeNumber of latent channels. For SD 1.5: 4.
block_out_channels: Vec<usize>Per-block-level output channel counts (in encoder order: from
the highest-resolution block out). For SD 1.5: [128, 256, 512, 512]. The decoder walks these in reverse, so the first block
after conv_in has block_out_channels[-1] channels (= 512).
layers_per_block: usizeNumber of resnet layers in each Encoder / Decoder up- or
down-block. The decoder’s UpDecoderBlock2D uses
layers_per_block + 1 resnets (the diffusers convention). For
SD 1.5: 2 (so each up-block has 3 resnets).
norm_num_groups: usizeNumber of GroupNorm groups (decoder-internal norm1 / norm2 /
conv_norm_out). For SD 1.5: 32.
sample_size: usizeSpatial size the encoder accepts (and the decoder produces). For SD 1.5: 512.
scaling_factor: f64VAE latent scaling factor. The decoder pre-divides the latent by
this value (matching AutoencoderKL.decode). For SD 1.5: 0.18215.
Implementations§
Source§impl VaeDecoderConfig
impl VaeDecoderConfig
Sourcepub fn validate(&self) -> FerrotorchResult<()>
pub fn validate(&self) -> FerrotorchResult<()>
Validate field bounds (positive sizes, channels divisible by
norm_num_groups, at least one resolution).
§Errors
Returns FerrotorchError::InvalidArgument for any out-of-bounds
or arithmetic-incompatible field.
Sourcepub fn resnets_per_up_block(&self) -> usize
pub fn resnets_per_up_block(&self) -> usize
Number of resnets in each UpDecoderBlock2D (the diffusers
convention is layers_per_block + 1).
Sourcepub fn num_up_blocks(&self) -> usize
pub fn num_up_blocks(&self) -> usize
Number of up-blocks (== number of down-blocks the encoder used,
== block_out_channels.len()).
Sourcepub fn from_json_str(s: &str) -> FerrotorchResult<Self>
pub fn from_json_str(s: &str) -> FerrotorchResult<Self>
Parse a vae/config.json document into a VaeDecoderConfig.
Recognised keys (all optional — anything missing falls back to the SD-1.5 defaults):
out_channels,latent_channels,block_out_channels,layers_per_block,norm_num_groups,sample_size,scaling_factor.
§Errors
Returns FerrotorchError::InvalidArgument on malformed JSON or
a wrong-type field (e.g. block_out_channels not an array of
integers).
Sourcepub fn from_file(path: &Path) -> FerrotorchResult<Self>
pub fn from_file(path: &Path) -> FerrotorchResult<Self>
Parse a vae/config.json file from disk.
§Errors
Returns FerrotorchError::InvalidArgument for I/O or parse
failures (file missing, malformed JSON, wrong-type field).
Trait Implementations§
Source§impl Clone for VaeDecoderConfig
impl Clone for VaeDecoderConfig
Source§fn clone(&self) -> VaeDecoderConfig
fn clone(&self) -> VaeDecoderConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VaeDecoderConfig
impl Debug for VaeDecoderConfig
Auto Trait Implementations§
impl Freeze for VaeDecoderConfig
impl RefUnwindSafe for VaeDecoderConfig
impl Send for VaeDecoderConfig
impl Sync for VaeDecoderConfig
impl Unpin for VaeDecoderConfig
impl UnsafeUnpin for VaeDecoderConfig
impl UnwindSafe for VaeDecoderConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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