From 2b5334aa865a0900930f48d867c36b330d731b6f Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 30 Dec 2024 11:18:17 -0500 Subject: [PATCH] reenable preview sigma calculations Signed-off-by: Vladimir Mandic --- CHANGELOG.md | 4 +++- modules/shared_state.py | 18 +++++++++--------- scripts/xyz_grid_on.py | 1 + 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d07d45ff..6e9a5c251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log for SD.Next -## Update for 2024-12-29 +## Update for 2024-12-30 - **LoRA**: - **Sana** support @@ -11,6 +11,7 @@ - **LTXVideo** optimizations: full offload, quantization and tiling support - VAE tiling granular options in *settings -> variable auto encoder* - UI: live preview optimizations and error handling +- UI: live preview sigma calulations, thanks @Disty0 - UI: CSS optimizations when log view is disabled - Samplers: add flow shift options and separate dynamic thresholding from dynamic shifting - **Fixes** @@ -20,6 +21,7 @@ - interrogate caption with T5 - on-the-fly quantization using TorchAO - remove concurrent preview requests + - xyz grid recover on error - hires batch - sdxl refiner - kandinsky diff --git a/modules/shared_state.py b/modules/shared_state.py index 472e88856..dd3905de9 100644 --- a/modules/shared_state.py +++ b/modules/shared_state.py @@ -169,15 +169,15 @@ class State: try: sample = self.current_latent self.current_image_sampling_step = self.sampling_step - """ - 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)) - # RuntimeError: The size of tensor a (128) must match the size of tensor b (64) at non-singleton dimension 3 - if self.prediction_type in {"epsilon", "flow_prediction"}: - sample = original_sample - (self.current_noise_pred * self.current_sigma) - elif self.prediction_type == "v_prediction": - sample = self.current_noise_pred * (-self.current_sigma / (self.current_sigma**2 + 1) ** 0.5) + (original_sample / (self.current_sigma**2 + 1)) # pylint: disable=invalid-unary-operand-type - """ + try: + 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) + elif self.prediction_type == "v_prediction": + sample = self.current_noise_pred * (-self.current_sigma / (self.current_sigma**2 + 1) ** 0.5) + (original_sample / (self.current_sigma**2 + 1)) # pylint: disable=invalid-unary-operand-type + except Exception: + pass # ignore sigma errors image = sd_samplers.samples_to_image_grid(sample) if shared.opts.show_progress_grid else sd_samplers.sample_to_image(sample) self.assign_current_image(image) self.preview_busy = False diff --git a/scripts/xyz_grid_on.py b/scripts/xyz_grid_on.py index aa0897442..ba23356da 100644 --- a/scripts/xyz_grid_on.py +++ b/scripts/xyz_grid_on.py @@ -379,6 +379,7 @@ class Script(scripts.Script): ) if not processed.images: + active = False return processed # something broke, no further handling needed. # processed.images = (1)*grid + (z > 1 ? z : 0)*subgrids + (x*y*z)*images have_grid = 1 if include_grid else 0