Skip to content

Commit

Permalink
fix lightning inference and unit tests after rescale_cfg added. (#113)
Browse files Browse the repository at this point in the history
Co-authored-by: Juan Acevedo <[email protected]>
  • Loading branch information
entrpn and jfacevedo-google authored Sep 27, 2024
1 parent 0015075 commit 0c2700c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/maxdiffusion/generate_sdxl.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ def apply_classifier_free_guidance(noise_pred, guidance_scale):
if config.do_classifier_free_guidance:
noise_pred, noise_prediction_text = apply_classifier_free_guidance(noise_pred, guidance_scale)

# Based on 3.4. in https://arxiv.org/pdf/2305.08891.pdf
# Helps solve overexposure problem when terminal SNR approaches zero.
# Empirical values recomended from the paper are guidance_scale=7.5 and guidance_rescale=0.7
noise_pred = jax.lax.cond(
guidance_rescale[0] > 0,
lambda _: rescale_noise_cfg(noise_pred, noise_prediction_text, guidance_rescale),
lambda _: noise_pred,
operand=None
)
# Based on 3.4. in https://arxiv.org/pdf/2305.08891.pdf
# Helps solve overexposure problem when terminal SNR approaches zero.
# Empirical values recomended from the paper are guidance_scale=7.5 and guidance_rescale=0.7
noise_pred = jax.lax.cond(
guidance_rescale[0] > 0,
lambda _: rescale_noise_cfg(noise_pred, noise_prediction_text, guidance_rescale),
lambda _: noise_pred,
operand=None
)

latents, scheduler_state = pipeline.scheduler.step(scheduler_state, noise_pred, t, latents).to_tuple()

Expand Down
Binary file modified src/maxdiffusion/tests/images/test_sdxl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test_lightning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0c2700c

Please sign in to comment.