diff options
author | Anastasius <anastasiuspernat@gmail.com> | 2022-10-18 17:38:07 +0000 |
---|---|---|
committer | AUTOMATIC1111 <16777216c@gmail.com> | 2022-10-19 06:39:28 +0000 |
commit | 442dbedc159bb7e9cf94f0c3626f8a409e0a50eb (patch) | |
tree | 68a9d5c5b6cf8a1b4c0f104e2b9fd3bc9c5cee06 /modules/ui.py | |
parent | bcfbb33e50a48b237d8d961cc2be038db53774d5 (diff) | |
download | stable-diffusion-webui-gfx803-442dbedc159bb7e9cf94f0c3626f8a409e0a50eb.tar.gz stable-diffusion-webui-gfx803-442dbedc159bb7e9cf94f0c3626f8a409e0a50eb.tar.bz2 stable-diffusion-webui-gfx803-442dbedc159bb7e9cf94f0c3626f8a409e0a50eb.zip |
Estimated time displayed if jobs take more 60 sec
Diffstat (limited to 'modules/ui.py')
-rw-r--r-- | modules/ui.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/modules/ui.py b/modules/ui.py index 9a54aa16..fa54110b 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -261,13 +261,17 @@ def wrap_gradio_call(func, extra_outputs=None): return f
-def calc_time_left(progress):
+def calc_time_left(progress, threshold, label, force_display):
if progress == 0:
- return "N/A"
+ return ""
else:
time_since_start = time.time() - shared.state.time_start
eta = (time_since_start/progress)
- return time.strftime('%H:%M:%S', time.gmtime(eta-time_since_start))
+ eta_relative = eta-time_since_start
+ if eta_relative > threshold or force_display:
+ return label + time.strftime('%H:%M:%S', time.gmtime(eta_relative))
+ else:
+ return ""
def check_progress_call(id_part):
@@ -281,13 +285,15 @@ def check_progress_call(id_part): if shared.state.sampling_steps > 0:
progress += 1 / shared.state.job_count * shared.state.sampling_step / shared.state.sampling_steps
- time_left = calc_time_left( progress )
+ time_left = calc_time_left( progress, 60, " ETA:", shared.state.time_left_force_display )
+ if time_left != "":
+ shared.state.time_left_force_display = True
progress = min(progress, 1)
progressbar = ""
if opts.show_progressbar:
- progressbar = f"""<div class='progressDiv'><div class='progress' style="overflow:hidden;width:{progress * 100}%">{str(int(progress*100))+"% ETA:"+time_left if progress > 0.01 else ""}</div></div>"""
+ progressbar = f"""<div class='progressDiv'><div class='progress' style="overflow:hidden;width:{progress * 100}%">{str(int(progress*100))+"%"+time_left if progress > 0.01 else ""}</div></div>"""
image = gr_show(False)
preview_visibility = gr_show(False)
@@ -320,6 +326,7 @@ def check_progress_call_initial(id_part): shared.state.current_image = None
shared.state.textinfo = None
shared.state.time_start = time.time()
+ shared.state.time_left_force_display = False
return check_progress_call(id_part)
|