Skip to content

Commit

Permalink
The Merge (#1730)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroCool940711 committed Jan 7, 2023
2 parents 5291437 + 55df5b3 commit 571fb89
Show file tree
Hide file tree
Showing 26 changed files with 3,071 additions and 1,393 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,17 @@ condaenv.*.requirements.txt
!/src/components/*
!/src/pages/*
/src/*
/inputs
/outputs
/model_cache
/log/**/*.png
/log/webui/*
/log/log.csv
/flagged/*
/gfpgan/*
/models/*
/webui/flet/assets/uploads/
/webui/flet/assets/outputs/

z_version_env.tmp
scripts/bridgeData.py
/user_data/*
Expand Down
10 changes: 9 additions & 1 deletion configs/webui/webui_flet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
# -option_list
# slider
# -value
# -value_type 'int', 'float'
# -min
# -max
# -step
Expand All @@ -56,15 +57,20 @@ webui_page:
default_text_size:
display: slider
value: !!int '20'
value_type: 'int'
min: !!int '10'
max: !!int '32'
step: !!float '2.0'
max_message_history:
display: slider
value: !!int '20'
value_type: 'int'
min: !!int '1'
max: !!int '100'
step: !!int '1'
theme_color:
display: textinput
value: !!str 'blue'

general_page:
huggingface_token:
Expand Down Expand Up @@ -176,7 +182,9 @@ performance_page:
keep_all_models_loaded:
display: bool
value: !!bool 'false'
#no_verify_input: False
no_verify_input:
display: bool
value: !!bool 'false'
#no_half: False
#use_float16: False
#precision: "autocast"
Expand Down
10 changes: 10 additions & 0 deletions configs/webui/webui_streamlit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ general:
grid_quality: 95
n_rows: -1
no_verify_input: False
show_percent_in_tab_title: True
enable_suggestions: True
no_half: False
use_float16: False
precision: "autocast"
Expand Down Expand Up @@ -427,3 +429,11 @@ model_manager:
ldsr_model:
file_name: "model.ckpt"
download_link: "https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1"

sygil:
model_name: "Sygil Diffusion 0.1"
save_location: "./models/custom"
files:
sd_wd_ld_trinart_merged:
file_name: "sygil-diffusion-v0.1_365608_lora.ckpt"
download_link: "https://huggingface.co/Sygil/Sygil-Diffusion-v0.1/resolve/main/sygil-diffusion-v0.1_365608_lora.ckpt"
8 changes: 8 additions & 0 deletions scripts/Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ 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"].general.enable_suggestions = st.checkbox("Enable Suggestions Box", value=st.session_state['defaults'].general.enable_suggestions,
help="Adds a suggestion box under the prompt when clicked. 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")
Expand Down
17 changes: 13 additions & 4 deletions scripts/img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
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
Expand Down Expand Up @@ -82,6 +82,8 @@ def img2img(prompt: str = '', init_info: any = None, init_info_mask: any = None,
sampler = KDiffusionSampler(server_state["model"],'dpm_2_ancestral')
elif sampler_name == 'k_dpm_2':
sampler = KDiffusionSampler(server_state["model"],'dpm_2')
elif sampler_name == 'k_dpmpp_2m':
sampler = KDiffusionSampler(server_state["model"],'dpmpp_2m')
elif sampler_name == 'k_euler_a':
sampler = KDiffusionSampler(server_state["model"],'euler_ancestral')
elif sampler_name == 'k_euler':
Expand Down Expand Up @@ -377,7 +379,10 @@ def layout():
#prompt = st.text_area("Input Text","")
placeholder = "A corgi wearing a top hat as an oil painting."
prompt = st.text_area("Input Text","", placeholder=placeholder, height=54)
sygil_suggestions.suggestion_area(placeholder)

if "defaults" in st.session_state:
if st.session_state["defaults"].general.enable_suggestions:
sygil_suggestions.suggestion_area(placeholder)

if "defaults" in st.session_state:
if st.session_state['defaults'].admin.global_negative_prompt:
Expand Down Expand Up @@ -411,7 +416,7 @@ def layout():
min_value=st.session_state['defaults'].img2img.sampling_steps.min_value,
step=st.session_state['defaults'].img2img.sampling_steps.step)

sampler_name_list = ["k_lms", "k_euler", "k_euler_a", "k_dpm_2", "k_dpm_2_a", "k_heun", "PLMS", "DDIM"]
sampler_name_list = ["k_lms", "k_euler", "k_euler_a", "k_dpm_2", "k_dpm_2_a", "k_dpmpp_2m", "k_heun", "PLMS", "DDIM"]
st.session_state["sampler_name"] = st.selectbox("Sampling method",sampler_name_list,
index=sampler_name_list.index(st.session_state['defaults'].img2img.sampler_name), help="Sampling method to use.")

Expand Down Expand Up @@ -733,8 +738,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.
Expand Down
7 changes: 6 additions & 1 deletion scripts/sd_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
except:
pass

# disable diffusers telemetry
os.environ["DISABLE_TELEMETRY"] = "YES"

# remove some annoying deprecation warnings that show every now and then.
warnings.filterwarnings("ignore", category=DeprecationWarning)
warnings.filterwarnings("ignore", category=UserWarning)
Expand Down Expand Up @@ -941,7 +944,7 @@ def load_model_from_config(self):
global_step = pl_sd["global_step"]
sd = pl_sd["state_dict"]
config = OmegaConf.load(self.yamlPath)
model = instantiate_from_config(config.model)
model = instantiate_from_config(config.model, personalization_config="")
m, u = model.load_state_dict(sd, strict=False)
model.cuda()
model.eval()
Expand Down Expand Up @@ -1692,6 +1695,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
Expand Down
64 changes: 37 additions & 27 deletions scripts/txt2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
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
Expand Down Expand Up @@ -316,6 +316,8 @@ def txt2img(prompt: str, ddim_steps: int, sampler_name: str, n_iter: int, batch_
sampler = KDiffusionSampler(server_state["model"],'dpm_2_ancestral')
elif sampler_name == 'k_dpm_2':
sampler = KDiffusionSampler(server_state["model"],'dpm_2')
elif sampler_name == 'k_dpmpp_2m':
sampler = KDiffusionSampler(server_state["model"],'dpmpp_2m')
elif sampler_name == 'k_euler_a':
sampler = KDiffusionSampler(server_state["model"],'euler_ancestral')
elif sampler_name == 'k_euler':
Expand Down Expand Up @@ -425,7 +427,10 @@ def layout():
#prompt = st.text_area("Input Text","")
placeholder = "A corgi wearing a top hat as an oil painting."
prompt = st.text_area("Input Text","", placeholder=placeholder, height=54)
sygil_suggestions.suggestion_area(placeholder)

if "defaults" in st.session_state:
if st.session_state["defaults"].general.enable_suggestions:
sygil_suggestions.suggestion_area(placeholder)

if "defaults" in st.session_state:
if st.session_state['defaults'].admin.global_negative_prompt:
Expand Down Expand Up @@ -519,7 +524,7 @@ def layout():
step=st.session_state['defaults'].txt2img.sampling_steps.step,
help="Set the default number of sampling steps to use. Default is: 30 (with k_euler)")

sampler_name_list = ["k_lms", "k_euler", "k_euler_a", "k_dpm_2", "k_dpm_2_a", "k_heun", "PLMS", "DDIM"]
sampler_name_list = ["k_lms", "k_euler", "k_euler_a", "k_dpm_2", "k_dpm_2_a", "k_dpmpp_2m", "k_heun", "PLMS", "DDIM"]
sampler_name = st.selectbox("Sampling method", sampler_name_list,
index=sampler_name_list.index(st.session_state['defaults'].txt2img.default_sampler), help="Sampling method to use. Default: k_euler")

Expand Down Expand Up @@ -668,30 +673,35 @@ def layout():

#print(st.session_state['use_RealESRGAN'])
#print(st.session_state['use_LDSR'])
#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)

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")
try:


# 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)
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)


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)


0 comments on commit 571fb89

Please sign in to comment.