mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-06 15:59:16 +08:00
Fix CFG
This commit is contained in:
1 parent
b8d99713f3
commit
caa914830a
1 file changed
+2
-2
@@ -210,7 +210,7 @@ class StableDiffusion(nn.Module):
|
|||||||
|
|
||||||
# perform guidance
|
# perform guidance
|
||||||
noise_pred_uncond, noise_pred_text = noise_pred.chunk(2)
|
noise_pred_uncond, noise_pred_text = noise_pred.chunk(2)
|
||||||
noise_pred = noise_pred_uncond + guidance_scale * (noise_pred_text - noise_pred_uncond)
|
noise_pred = noise_pred_text + guidance_scale * (noise_pred_text - noise_pred_uncond)
|
||||||
|
|
||||||
# w(t), sigma_t^2
|
# w(t), sigma_t^2
|
||||||
w = 1 - self.alphas[t]
|
w = 1 - self.alphas[t]
|
||||||
@@ -266,7 +266,7 @@ class StableDiffusion(nn.Module):
|
|||||||
|
|
||||||
# perform guidance
|
# perform guidance
|
||||||
noise_pred_uncond, noise_pred_text = noise_pred.chunk(2)
|
noise_pred_uncond, noise_pred_text = noise_pred.chunk(2)
|
||||||
noise_pred = noise_pred_uncond + guidance_scale * (noise_pred_text - noise_pred_uncond)
|
noise_pred = noise_pred_text + guidance_scale * (noise_pred_text - noise_pred_uncond)
|
||||||
|
|
||||||
# compute the previous noisy sample x_t -> x_t-1
|
# compute the previous noisy sample x_t -> x_t-1
|
||||||
latents = self.scheduler.step(noise_pred, t, latents)["prev_sample"] # type: ignore
|
latents = self.scheduler.step(noise_pred, t, latents)["prev_sample"] # type: ignore
|
||||||
|
|||||||
Reference in new issue
Block a user