Added option to show the progress percent value during a generation as part of the title on the tab on the browser. This should be useful for when doing a generation but you need to do something on another tab but still want to keep track of the progress.

This commit is contained in:
ZeroCool940711 2022-12-08 15:05:58 -07:00
parent 42d6b5d7b1
commit 3e87802c9f
No known key found for this signature in database
GPG Key ID: 4E4072992B5BC640
6 changed files with 50 additions and 27 deletions

View File

@ -56,6 +56,7 @@ general:
grid_quality: 95
n_rows: -1
no_verify_input: False
show_percent_in_tab_title: True
no_half: False
use_float16: False
precision: "autocast"

View File

@ -208,6 +208,11 @@ def layout():
st.session_state["defaults"].general.no_verify_input = st.checkbox("Do not Verify Input", value=st.session_state['defaults'].general.no_verify_input,
help="Do not verify input to check if it's too long. Default: False")
st.session_state["defaults"].general.show_percent_in_tab_title = st.checkbox("Show Percent in tab title", value=st.session_state['defaults'].general.show_percent_in_tab_title,
help="Add the progress percent value to the page title on the tab on your browser. "
"This is useful in case you need to know how the generation is going while doign something else"
"in another tab on your browser. Default: True")
st.session_state["defaults"].daisi_app.running_on_daisi_io = st.checkbox("Running on Daisi.io?", value=st.session_state['defaults'].daisi_app.running_on_daisi_io,
help="Specify if we are running on app.Daisi.io . Default: False")

View File

@ -18,7 +18,7 @@ from sd_utils import st, server_state, no_rerun, \
generation_callback, process_images, KDiffusionSampler, \
custom_models_available, RealESRGAN_available, GFPGAN_available, \
LDSR_available, load_models, hc, seed_to_int, logger, \
resize_image, get_matched_noise, CFGMaskedDenoiser, ImageFilter
resize_image, get_matched_noise, CFGMaskedDenoiser, ImageFilter, set_page_title
# streamlit imports
from streamlit.runtime.scriptrunner import StopException
@ -735,8 +735,12 @@ def layout():
#show a message when the generation is complete.
message.success('Render Complete: ' + info + '; Stats: ' + stats, icon="")
except (StopException, KeyError):
except (StopException,
#KeyError
):
logger.info(f"Received Streamlit StopException")
# reset the page title so the percent doesnt stay on it confusing the user.
set_page_title(f"Stable Diffusion Playground")
# this will render all the images at the end of the generation but its better if its moved to a second tab inside col2 and shown as a gallery.
# use the current col2 first tab to show the preview_img and update it as its generated.

View File

@ -1692,6 +1692,8 @@ def generation_callback(img, i=0):
if "progress_bar" in st.session_state:
try:
st.session_state["progress_bar"].progress(percent if percent < 100 else 100)
if st.session_state["defaults"].general.show_percent_in_tab_title:
set_page_title(f"({percent if percent < 100 else 100}%) Stable Diffusion Playground")
except UnboundLocalError as e:
#logger.error(e)
pass

View File

@ -19,7 +19,7 @@ from sd_utils import st, MemUsageMonitor, server_state, no_rerun, \
save_sample, generation_callback, process_images, \
KDiffusionSampler, \
custom_models_available, RealESRGAN_available, GFPGAN_available, \
LDSR_available, load_models, hc, seed_to_int, logger
LDSR_available, load_models, hc, seed_to_int, logger, set_page_title
# streamlit imports
from streamlit.runtime.scriptrunner import StopException
@ -670,30 +670,35 @@ def layout():
#print(st.session_state['use_RealESRGAN'])
#print(st.session_state['use_LDSR'])
#try:
#
try:
output_images, seeds, info, stats = txt2img(prompt, st.session_state.sampling_steps, sampler_name, st.session_state["batch_count"], st.session_state["batch_size"],
cfg_scale, seed, height, width, separate_prompts, normalize_prompt_weights, save_individual_images,
save_grid, group_by_prompt, save_as_jpg, st.session_state["use_GFPGAN"], st.session_state['GFPGAN_model'],
use_RealESRGAN=st.session_state["use_RealESRGAN"], RealESRGAN_model=st.session_state["RealESRGAN_model"],
use_LDSR=st.session_state["use_LDSR"], LDSR_model=st.session_state["LDSR_model"],
variant_amount=variant_amount, variant_seed=variant_seed, write_info_files=write_info_files,
use_stable_horde=use_stable_horde, stable_horde_key=stable_horde_key)
output_images, seeds, info, stats = txt2img(prompt, st.session_state.sampling_steps, sampler_name, st.session_state["batch_count"], st.session_state["batch_size"],
cfg_scale, seed, height, width, separate_prompts, normalize_prompt_weights, save_individual_images,
save_grid, group_by_prompt, save_as_jpg, st.session_state["use_GFPGAN"], st.session_state['GFPGAN_model'],
use_RealESRGAN=st.session_state["use_RealESRGAN"], RealESRGAN_model=st.session_state["RealESRGAN_model"],
use_LDSR=st.session_state["use_LDSR"], LDSR_model=st.session_state["LDSR_model"],
variant_amount=variant_amount, variant_seed=variant_seed, write_info_files=write_info_files,
use_stable_horde=use_stable_horde, stable_horde_key=stable_horde_key)
message.success('Render Complete: ' + info + '; Stats: ' + stats, icon="")
with gallery_tab:
logger.info(seeds)
st.session_state["gallery"].text = ""
sdGallery(output_images)
message.success('Render Complete: ' + info + '; Stats: ' + stats, icon="")
with gallery_tab:
logger.info(seeds)
st.session_state["gallery"].text = ""
sdGallery(output_images)
#except (StopException, KeyError):
#print(f"Received Streamlit StopException")
# this will render all the images at the end of the generation but its better if its moved to a second tab inside col2 and shown as a gallery.
# use the current col2 first tab to show the preview_img and update it as its generated.
#preview_image.image(output_images)
except (StopException,
#KeyError
):
print(f"Received Streamlit StopException")
# reset the page title so the percent doesnt stay on it confusing the user.
set_page_title(f"Stable Diffusion Playground")
# this will render all the images at the end of the generation but its better if its moved to a second tab inside col2 and shown as a gallery.
# use the current col2 first tab to show the preview_img and update it as its generated.
#preview_image.image(output_images)

View File

@ -24,7 +24,7 @@ https://gist.github.com/karpathy/00103b0037c5aaea32fe1da1af553355
from sd_utils import st, MemUsageMonitor, server_state, no_rerun, torch_gc, \
custom_models_available, RealESRGAN_available, GFPGAN_available, \
LDSR_available, hc, seed_to_int, logger, slerp, optimize_update_preview_frequency, \
load_learned_embed_in_clip, load_GFPGAN, RealESRGANModel
load_learned_embed_in_clip, load_GFPGAN, RealESRGANModel, set_page_title
# streamlit imports
@ -1082,6 +1082,9 @@ def diffuse(
if "progress_bar" in st.session_state:
st.session_state["progress_bar"].progress(total_percent if total_percent < 100 else 100)
if st.session_state["defaults"].general.show_percent_in_tab_title:
set_page_title(f"({percent if percent < 100 else 100}%) Stable Diffusion Playground")
except KeyError:
raise StopException
@ -1593,6 +1596,9 @@ def txt2vid(
video_path = save_video_to_disk(frames, seeds, sanitized_prompt, save_video=save_video, outdir=outdir)
except StopException:
# reset the page title so the percent doesnt stay on it confusing the user.
set_page_title(f"Stable Diffusion Playground")
if save_video_on_stop:
logger.info("Streamlit Stop Exception Received. Saving video")
video_path = save_video_to_disk(frames, seeds, sanitized_prompt, save_video=save_video, outdir=outdir)