diff options
author | AUTOMATIC <16777216c@gmail.com> | 2023-01-19 05:41:37 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2023-01-19 05:41:37 +0000 |
commit | 308b51012a5def38edb1c2e127e736c43aa6e1a3 (patch) | |
tree | 0a282b989894906bee946bab2df00c018810f765 /modules/progress.py | |
parent | 6620acff8c2d9eb07972b55eeee833e5ffe4f5bc (diff) | |
download | stable-diffusion-webui-gfx803-308b51012a5def38edb1c2e127e736c43aa6e1a3.tar.gz stable-diffusion-webui-gfx803-308b51012a5def38edb1c2e127e736c43aa6e1a3.tar.bz2 stable-diffusion-webui-gfx803-308b51012a5def38edb1c2e127e736c43aa6e1a3.zip |
fix an unlikely division by 0 error
Diffstat (limited to 'modules/progress.py')
-rw-r--r-- | modules/progress.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/modules/progress.py b/modules/progress.py index 3327b883..f9e005d3 100644 --- a/modules/progress.py +++ b/modules/progress.py @@ -67,10 +67,13 @@ def progressapi(req: ProgressRequest): progress = 0
- if shared.state.job_count > 0:
- progress += shared.state.job_no / shared.state.job_count
- if shared.state.sampling_steps > 0:
- progress += 1 / shared.state.job_count * shared.state.sampling_step / shared.state.sampling_steps
+ job_count, job_no = shared.state.job_count, shared.state.job_no
+ sampling_steps, sampling_step = shared.state.sampling_steps, shared.state.sampling_step
+
+ if job_count > 0:
+ progress += job_no / job_count
+ if sampling_steps > 0:
+ progress += 1 / job_count * sampling_step / sampling_steps
progress = min(progress, 1)
|