diff options
author | Anastasius <anastasiuspernat@gmail.com> | 2022-10-17 20:35:20 +0000 |
---|---|---|
committer | AUTOMATIC1111 <16777216c@gmail.com> | 2022-10-19 06:39:28 +0000 |
commit | bcfbb33e50a48b237d8d961cc2be038db53774d5 (patch) | |
tree | 0ad330a15641cf31bba1e527016d8c2c4f40f12b /modules/ui.py | |
parent | 2fd7935ef4ed296db5dfd8c7fea99244816f8cf0 (diff) | |
download | stable-diffusion-webui-gfx803-bcfbb33e50a48b237d8d961cc2be038db53774d5.tar.gz stable-diffusion-webui-gfx803-bcfbb33e50a48b237d8d961cc2be038db53774d5.tar.bz2 stable-diffusion-webui-gfx803-bcfbb33e50a48b237d8d961cc2be038db53774d5.zip |
Added time left estimation
Diffstat (limited to 'modules/ui.py')
-rw-r--r-- | modules/ui.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/modules/ui.py b/modules/ui.py index ca46343f..9a54aa16 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -261,6 +261,15 @@ def wrap_gradio_call(func, extra_outputs=None): return f
+def calc_time_left(progress):
+ if progress == 0:
+ return "N/A"
+ 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))
+
+
def check_progress_call(id_part):
if shared.state.job_count == 0:
return "", gr_show(False), gr_show(False), gr_show(False)
@@ -272,11 +281,13 @@ 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 )
+
progress = min(progress, 1)
progressbar = ""
if opts.show_progressbar:
- progressbar = f"""<div class='progressDiv'><div class='progress' style="width:{progress * 100}%">{str(int(progress*100))+"%" 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))+"% ETA:"+time_left if progress > 0.01 else ""}</div></div>"""
image = gr_show(False)
preview_visibility = gr_show(False)
@@ -308,6 +319,7 @@ def check_progress_call_initial(id_part): shared.state.current_latent = None
shared.state.current_image = None
shared.state.textinfo = None
+ shared.state.time_start = time.time()
return check_progress_call(id_part)
|