diff --git a/modules/processing_callbacks.py b/modules/processing_callbacks.py index 39a6c66d8..048f53d52 100644 --- a/modules/processing_callbacks.py +++ b/modules/processing_callbacks.py @@ -109,9 +109,9 @@ def diffusers_callback(pipe, step: int = 0, timestep: int = 0, kwargs: dict = {} shared.state.current_noise_pred = kwargs.get("noise_pred", None) if shared.state.current_noise_pred is None: shared.state.current_noise_pred = kwargs.get("predicted_image_embedding", None) - if hasattr(pipe, "scheduler") and hasattr(pipe.scheduler, "sigmas"): - shared.state.current_sigma = pipe.scheduler.sigmas[step] - shared.state.current_sigma_next = pipe.scheduler.sigmas[step + 1] + if hasattr(pipe, "scheduler") and hasattr(pipe.scheduler, "sigmas") and hasattr(pipe.scheduler, "step_index"): + shared.state.current_sigma = pipe.scheduler.sigmas[pipe.scheduler.step_index - 1] + shared.state.current_sigma_next = pipe.scheduler.sigmas[pipe.scheduler.step_index] except Exception as e: shared.log.error(f'Callback: {e}') if shared.cmd_opts.profile and shared.profiler is not None: diff --git a/modules/shared_state.py b/modules/shared_state.py index bab30e5e3..b375a42e9 100644 --- a/modules/shared_state.py +++ b/modules/shared_state.py @@ -165,7 +165,7 @@ class State: self.current_image_sampling_step = self.sampling_step if self.disable_preview: return - if self.job == "txt2img" and self.current_noise_pred is not None and self.current_sigma is not None and self.current_sigma_next is not None: + if self.current_noise_pred is not None and self.current_sigma is not None and self.current_sigma_next is not None: original_sample = sample - (self.current_noise_pred * (self.current_sigma_next-self.current_sigma)) if self.prediction_type in {"epsilon", "flow_prediction"}: sample = original_sample - (self.current_noise_pred * self.current_sigma)