mirror of
https://github.com/huggingface/diffusers.git
synced 2026-01-27 17:22:53 +03:00
[bugfix] reduce float value error when adding noise (#9004)
* Update train_controlnet.py reduce float value error for bfloat16 * Update train_controlnet_sdxl.py * style --------- Co-authored-by: Sayak Paul <spsayakpaul@gmail.com> Co-authored-by: yiyixuxu <yixu310@gmail.com>
This commit is contained in:
@@ -1048,7 +1048,9 @@ def main(args):
|
||||
|
||||
# Add noise to the latents according to the noise magnitude at each timestep
|
||||
# (this is the forward diffusion process)
|
||||
noisy_latents = noise_scheduler.add_noise(latents, noise, timesteps)
|
||||
noisy_latents = noise_scheduler.add_noise(latents.float(), noise.float(), timesteps).to(
|
||||
dtype=weight_dtype
|
||||
)
|
||||
|
||||
# Get the text embedding for conditioning
|
||||
encoder_hidden_states = text_encoder(batch["input_ids"], return_dict=False)[0]
|
||||
|
||||
@@ -1210,7 +1210,9 @@ def main(args):
|
||||
|
||||
# Add noise to the latents according to the noise magnitude at each timestep
|
||||
# (this is the forward diffusion process)
|
||||
noisy_latents = noise_scheduler.add_noise(latents, noise, timesteps)
|
||||
noisy_latents = noise_scheduler.add_noise(latents.float(), noise.float(), timesteps).to(
|
||||
dtype=weight_dtype
|
||||
)
|
||||
|
||||
# ControlNet conditioning.
|
||||
controlnet_image = batch["conditioning_pixel_values"].to(dtype=weight_dtype)
|
||||
|
||||
Reference in New Issue
Block a user