Move IP noise gamma to noise creation to remove complexity and align noise for target loss

This commit is contained in:
rockerBOO
2025-03-18 21:36:55 -04:00
parent 6f4d365775
commit b81bcd0b01
2 changed files with 13 additions and 15 deletions

View File

@@ -350,6 +350,15 @@ class FluxNetworkTrainer(train_network.NetworkTrainer):
):
# Sample noise that we'll add to the latents
noise = torch.randn_like(latents)
# Add noise to the latents according to the noise magnitude at each timestep
# (this is the forward diffusion process)
if args.ip_noise_gamma:
if args.ip_noise_gamma_random_strength:
noise = noise + (torch.rand(1, device=latents.device) * args.ip_noise_gamma) * torch.randn_like(latents)
else:
noise = noise + args.ip_noise_gamma * torch.randn_like(latents)
bsz = latents.shape[0]
# get noisy model input and timesteps