@@ -3087,6 +3087,11 @@ def add_training_arguments(parser: argparse.ArgumentParser, support_dreambooth:
3087
3087
default = None ,
3088
3088
help = "enable noise offset with this value (if enabled, around 0.1 is recommended) / Noise offsetを有効にしてこの値を設定する(有効にする場合は0.1程度を推奨)" ,
3089
3089
)
3090
+ parser .add_argument (
3091
+ "--noise_offset_random_strength" ,
3092
+ action = "store_true" ,
3093
+ help = "use random strength between 0~noise_offset for noise offset. / noise offsetにおいて、0からnoise_offsetの間でランダムな強度を使用します。" ,
3094
+ )
3090
3095
parser .add_argument (
3091
3096
"--multires_noise_iterations" ,
3092
3097
type = int ,
@@ -3100,6 +3105,12 @@ def add_training_arguments(parser: argparse.ArgumentParser, support_dreambooth:
3100
3105
help = "enable input perturbation noise. used for regularization. recommended value: around 0.1 (from arxiv.org/abs/2301.11706) "
3101
3106
+ "/ input perturbation noiseを有効にする。正則化に使用される。推奨値: 0.1程度 (arxiv.org/abs/2301.11706 より)" ,
3102
3107
)
3108
+ parser .add_argument (
3109
+ "--ip_noise_gamma_random_strength" ,
3110
+ action = "store_true" ,
3111
+ help = "Use random strength between 0~ip_noise_gamma for input perturbation noise."
3112
+ + "/ input perturbation noiseにおいて、0からip_noise_gammaの間でランダムな強度を使用します。" ,
3113
+ )
3103
3114
# parser.add_argument(
3104
3115
# "--perlin_noise",
3105
3116
# type=int,
@@ -4656,7 +4667,11 @@ def get_noise_noisy_latents_and_timesteps(args, noise_scheduler, latents):
4656
4667
# Sample noise that we'll add to the latents
4657
4668
noise = torch .randn_like (latents , device = latents .device )
4658
4669
if args .noise_offset :
4659
- noise = custom_train_functions .apply_noise_offset (latents , noise , args .noise_offset , args .adaptive_noise_scale )
4670
+ if args .noise_offset_random_strength :
4671
+ noise_offset = torch .rand (1 , device = latents .device ) * args .noise_offset
4672
+ else :
4673
+ noise_offset = args .noise_offset
4674
+ noise = custom_train_functions .apply_noise_offset (latents , noise , noise_offset , args .adaptive_noise_scale )
4660
4675
if args .multires_noise_iterations :
4661
4676
noise = custom_train_functions .pyramid_noise_like (
4662
4677
noise , latents .device , args .multires_noise_iterations , args .multires_noise_discount
@@ -4673,7 +4688,11 @@ def get_noise_noisy_latents_and_timesteps(args, noise_scheduler, latents):
4673
4688
# Add noise to the latents according to the noise magnitude at each timestep
4674
4689
# (this is the forward diffusion process)
4675
4690
if args .ip_noise_gamma :
4676
- noisy_latents = noise_scheduler .add_noise (latents , noise + args .ip_noise_gamma * torch .randn_like (latents ), timesteps )
4691
+ if args .ip_noise_gamma_random_strength :
4692
+ strength = torch .rand (1 , device = latents .device ) * args .ip_noise_gamma
4693
+ else :
4694
+ strength = args .ip_noise_gamma
4695
+ noisy_latents = noise_scheduler .add_noise (latents , noise + strength * torch .randn_like (latents ), timesteps )
4677
4696
else :
4678
4697
noisy_latents = noise_scheduler .add_noise (latents , noise , timesteps )
4679
4698
0 commit comments