Add a config to force pure noise step at a set rate

This commit is contained in:
Jaret Burkett committed 2026-09-09 11:26:28 -06:00
1 parent 4a41f146a3
commit b1bf3e4381
2 files changed
+8

No files matched your search

+5
View File
@@ -1296,6 +1296,11 @@ class BaseSDTrainProcess(BaseTrainProcess):
timestep_indices = timestep_indices.long() timestep_indices = timestep_indices.long()
else: else:
raise ValueError(f"Unknown content_or_style {content_or_style}") raise ValueError(f"Unknown content_or_style {content_or_style}")
if self.train_config.first_timestep_chance > 0.0:
# index 0 is full noise; per-sample chance to force it
force_first = torch.rand((batch_size,), device=timestep_indices.device) < self.train_config.first_timestep_chance
timestep_indices = torch.where(force_first, torch.zeros_like(timestep_indices), timestep_indices)
with self.timer('convert_timestep_indices_to_timesteps'): with self.timer('convert_timestep_indices_to_timesteps'):
# convert the timestep_indices to a timestep # convert the timestep_indices to a timestep
timesteps = self.sd.noise_scheduler.timesteps[timestep_indices.long()] timesteps = self.sd.noise_scheduler.timesteps[timestep_indices.long()]
+3
View File
@@ -552,6 +552,9 @@ class TrainConfig:
self.target_norm_std = kwargs.get('target_norm_std', None) self.target_norm_std = kwargs.get('target_norm_std', None)
self.target_norm_std_value = kwargs.get('target_norm_std_value', 1.0) self.target_norm_std_value = kwargs.get('target_norm_std_value', 1.0)
self.timestep_type = kwargs.get('timestep_type', 'sigmoid') # sigmoid, linear, lognorm_blend, next_sample, weighted, one_step self.timestep_type = kwargs.get('timestep_type', 'sigmoid') # sigmoid, linear, lognorm_blend, next_sample, weighted, one_step
self.first_timestep_chance = kwargs.get('first_timestep_chance', 0.0)
self.next_sample_timesteps = kwargs.get('next_sample_timesteps', 8) self.next_sample_timesteps = kwargs.get('next_sample_timesteps', 8)
self.linear_timesteps = kwargs.get('linear_timesteps', False) self.linear_timesteps = kwargs.get('linear_timesteps', False)
self.linear_timesteps2 = kwargs.get('linear_timesteps2', False) self.linear_timesteps2 = kwargs.get('linear_timesteps2', False)