mirror of
https://github.com/finegrain-ai/refiners.git
synced 2024-11-21 21:58:47 +00:00
Remove additional noise in final sample of DDIM inference process
This commit is contained in:
parent
a1f50f3f9d
commit
17d9701dde
|
@ -52,6 +52,12 @@ class DDIM(Scheduler):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
predicted_x = (x - sqrt(1 - current_scale_factor**2) * noise) / current_scale_factor
|
predicted_x = (x - sqrt(1 - current_scale_factor**2) * noise) / current_scale_factor
|
||||||
denoised_x = previous_scale_factor * predicted_x + sqrt(1 - previous_scale_factor**2) * noise
|
noise_factor = sqrt(1 - previous_scale_factor**2)
|
||||||
|
|
||||||
|
# Do not add noise at the last step to avoid visual artifacts.
|
||||||
|
if step == self.num_inference_steps - 1:
|
||||||
|
noise_factor = 0
|
||||||
|
|
||||||
|
denoised_x = previous_scale_factor * predicted_x + noise_factor * noise
|
||||||
|
|
||||||
return denoised_x
|
return denoised_x
|
||||||
|
|
|
@ -46,7 +46,6 @@ def test_ddim_diffusers():
|
||||||
beta_schedule="scaled_linear",
|
beta_schedule="scaled_linear",
|
||||||
beta_start=0.00085,
|
beta_start=0.00085,
|
||||||
num_train_timesteps=1000,
|
num_train_timesteps=1000,
|
||||||
set_alpha_to_one=False,
|
|
||||||
steps_offset=1,
|
steps_offset=1,
|
||||||
clip_sample=False,
|
clip_sample=False,
|
||||||
)
|
)
|
||||||
|
@ -103,7 +102,6 @@ def test_scheduler_remove_noise():
|
||||||
beta_schedule="scaled_linear",
|
beta_schedule="scaled_linear",
|
||||||
beta_start=0.00085,
|
beta_start=0.00085,
|
||||||
num_train_timesteps=1000,
|
num_train_timesteps=1000,
|
||||||
set_alpha_to_one=False,
|
|
||||||
steps_offset=1,
|
steps_offset=1,
|
||||||
clip_sample=False,
|
clip_sample=False,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue