pub struct VaeEncoder { /* private fields */ }Expand description
The encoder half of a latent diffusion model’s autoencoder.
Only image-to-image work needs one: text-to-image starts from noise, and
the encoder is what turns a starting picture into the latent the sampler
then partially renoises. The architecture mirrors VaeDecoder — a stem,
a ladder that halves the resolution at each rung, and a middle pair of
residual blocks around one self-attention — and its keys sit under
encoder. in the same file.
Implementations§
Source§impl VaeEncoder
impl VaeEncoder
Sourcepub fn load(
path: impl AsRef<Path>,
prefix: &str,
config: VaeConfig,
) -> Result<Self, NetworkError>
pub fn load( path: impl AsRef<Path>, prefix: &str, config: VaeConfig, ) -> Result<Self, NetworkError>
Reads an encoder out of a checkpoint under the diffusers key names.
path and prefix mean what they do for VaeDecoder::load, with
"encoder." in place of "decoder.".
Sourcepub fn read(
file: &mut ShardedSafeTensors,
prefix: &str,
config: VaeConfig,
) -> Result<Self, NetworkError>
pub fn read( file: &mut ShardedSafeTensors, prefix: &str, config: VaeConfig, ) -> Result<Self, NetworkError>
The same, from a checkpoint that is already open.
Sourcepub fn encode(&self, image: &FeatureMap) -> Result<FeatureMap, NetworkError>
pub fn encode(&self, image: &FeatureMap) -> Result<FeatureMap, NetworkError>
Encodes an image whose values sit in roughly [-1, 1] into the latent
the sampler works on, scale and shift already applied.
The result is the distribution’s mean rather than a draw from it, which is what image-to-image wants: the noise it needs is added afterwards, at the level the run starts from.
Trait Implementations§
Source§impl Clone for VaeEncoder
impl Clone for VaeEncoder
Auto Trait Implementations§
impl Forget for VaeEncoder
impl Freeze for VaeEncoder
impl Move for VaeEncoder
impl RefUnwindSafe for VaeEncoder
impl Send for VaeEncoder
impl Sync for VaeEncoder
impl Unpin for VaeEncoder
impl UnsafeUnpin for VaeEncoder
impl UnwindSafe for VaeEncoder
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> 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