Skip to content

Commit

Permalink
Fix the issue (keras-team#2102): Add cast to float32 from float16 int…
Browse files Browse the repository at this point in the history
…o Stable Diffusion
  • Loading branch information
y-vectorfield committed Oct 26, 2023
1 parent 832e2d9 commit cc214e6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions keras_cv/models/stable_diffusion/stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ def generate_image(
+ unconditional_guidance_scale * (latent - unconditional_latent)
)
a_t, a_prev = alphas[index], alphas_prev[index]
if latent.dtype == "float16":
latent = ops.cast(latent, "float32")
pred_x0 = (latent_prev - math.sqrt(1 - a_t) * latent) / math.sqrt(
a_t
)
Expand Down

0 comments on commit cc214e6

Please sign in to comment.