From f5c9e68dbf2fc31139ea6f9d298e7dc89c4b1f5a Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 30 Jun 2025 12:58:54 +0000 Subject: [PATCH] Fix division by zero in multi-diffusion pipeline with creativity values Co-authored-by: kent Revert unnecessary validation changes in multi-diffusion Fix in python instead of graphbuilder tidy(ui): remove extraneous comment --- invokeai/app/util/step_callback.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/invokeai/app/util/step_callback.py b/invokeai/app/util/step_callback.py index 451f48e055..1a6570f6ae 100644 --- a/invokeai/app/util/step_callback.py +++ b/invokeai/app/util/step_callback.py @@ -123,7 +123,11 @@ def calc_percentage(intermediate_state: PipelineIntermediateState) -> float: if total_steps == 0: return 0.0 if order == 2: - return floor(step / 2) / floor(total_steps / 2) + # Prevent division by zero when total_steps is 1 or 2 + denominator = floor(total_steps / 2) + if denominator == 0: + return 0.0 + return floor(step / 2) / denominator # order == 1 return step / total_steps