Skip to content

Clarification on where noise is added to VAE latent before diffusion #32

Description

@RosNayak

Hi, really impressive work!

While exploring the codebase, I’m trying to precisely understand the point at which noise is injected into the VAE latent space before diffusion.
From what I gather, encode_first_stage produces the latent representation of the input image, but it’s not immediately obvious where in the pipeline the noise is applied to this latent before it is passed to the UNet for denoising during the diffusion process.

init_cnt = model.get_first_stage_encoding(model.encode_first_stage(init_cnt)) cnt_z_enc, _ = sampler.encode_ddim(init_cnt.clone(), num_steps=ddim_inversion_steps, unconditional_conditioning=uc, \ end_step=time_idx_dict[ddim_inversion_steps-1-start_step], \ callback_ddim_timesteps=save_feature_timesteps, img_callback=ddim_sampler_callback)

Could you please clarify:

  1. When is the latent noised?
  2. Which module or function specifically handles this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions