In the part Stable Diffusion with 🧨 Diffusers, there is this line.
What is “0.18215” and why i should do this?
And the code for generating without pipeline is not working for stable_1.5. It only generate normal picture after i accidentally add one line of code.
from tqdm.auto import tqdm
from torch import autocast
scheduler.set_timesteps(num_inference_steps) # i add this one
for t in tqdm(scheduler.timesteps):
latent_model_input = torch.cat([latents] * 2)
latent_model_input = scheduler.scale_model_input(latent_model_input, t)
with torch.no_grad():
noise_pred = unet(latent_model_input, t, encoder_hidden_states=text_embeddings).sample
noise_pred_uncond, noise_pred_text = noise_pred.chunk(2)
noise_pred = noise_pred_uncond + guidance_scale * (noise_pred_text - noise_pred_uncond)
latents = scheduler.step(noise_pred, t, latents).prev_sample
Thank you!