Skip to content

Commit

Permalink
Fixed LDSR, now it should work both txt2img and img2img (#1402)
Browse files Browse the repository at this point in the history
- Removed slider values for batch_count and batch_size as they are now a
text_input instead of a slider.
- Removed the checkbox to disable the preview image, instead users
should increase the frequency at which it is displayed if they have
performance issues, after a certain point it no longer affects
performance.
- Removed GFPGAN GitHub dependency, we can now use pip to install a
fixed version of it.
- Fixed LDSR, now it should work both txt2img and img2img
  • Loading branch information
ZeroCool940711 committed Oct 3, 2022
2 parents a06c408 + 393a695 commit f230e32
Show file tree
Hide file tree
Showing 7 changed files with 416 additions and 420 deletions.
46 changes: 24 additions & 22 deletions configs/webui/webui_streamlit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,18 @@ txt2img:
seed: ""
batch_count:
value: 1
min_value: 1
max_value: 100
step: 1

batch_size:
value: 1
min_value: 1
max_value: 5
step: 1

sampling_steps:
value: 30
min_value: 10
max_value: 250
step: 10

LDSR_config:
sampling_steps: 50
preDownScale: 1
postDownScale: 1
downsample_method: "Lanczos"

default_sampler: "k_euler"
separate_prompts: False
Expand All @@ -114,6 +111,7 @@ txt2img:
use_RealESRGAN: False
use_LDSR: False
RealESRGAN_model: "RealESRGAN_x4plus"
use_upscaling: False

variant_amount:
value: 0.0
Expand Down Expand Up @@ -148,15 +146,9 @@ txt2vid:

batch_count:
value: 1
min_value: 1
max_value: 100
step: 1

batch_size:
value: 1
min_value: 1
max_value: 5
step: 1

sampling_steps:
value: 30
Expand Down Expand Up @@ -187,6 +179,7 @@ txt2vid:
use_GFPGAN: False
use_RealESRGAN: False
RealESRGAN_model: "RealESRGAN_x4plus"
use_upscaling: False
variant_amount:
value: 0.0
min_value: 0.0
Expand All @@ -212,6 +205,12 @@ txt2vid:
beta_scheduler_type: "linear"
max_frames: 100

LDSR_config:
sampling_steps: 50
preDownScale: 1
postDownScale: 1
downsample_method: "Lanczos"

img2img:
prompt:
sampler_name: "k_euler"
Expand Down Expand Up @@ -251,15 +250,9 @@ img2img:

batch_count:
value: 1
min_value: 1
max_value: 100
step: 1

batch_size:
value: 1
min_value: 1
max_value: 5
step: 1

sampling_steps:
value: 30
Expand All @@ -279,6 +272,12 @@ img2img:
max_value: 500
step: 10

LDSR_config:
sampling_steps: 50
preDownScale: 1
postDownScale: 1
downsample_method: "Lanczos"

loopback: True
random_seed_loopback: True
separate_prompts: False
Expand All @@ -292,6 +291,7 @@ img2img:
use_GFPGAN: False
use_RealESRGAN: False
RealESRGAN_model: "RealESRGAN_x4plus"
use_upscaling: False
variant_amount: 0.0
variant_seed: ""
write_info_files: True
Expand All @@ -313,4 +313,6 @@ textual_inversion:

daisi_app:
running_on_daisi_io: False


model_manager:
value: 0
2 changes: 1 addition & 1 deletion environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ dependencies:
- -e .
- -e git+https://github.com/CompVis/taming-transformers#egg=taming-transformers
- -e git+https://github.com/openai/CLIP#egg=clip
- -e git+https://github.com/TencentARC/GFPGAN#egg=GFPGAN
- -e git+https://github.com/hlky/k-diffusion-sd#egg=k_diffusion
- -e git+https://github.com/devilismyfriend/latent-diffusion#egg=latent-diffusion
- accelerate==0.12.0
Expand All @@ -45,6 +44,7 @@ dependencies:
- ftfy==6.1.1
- fairscale==0.4.4
- gradio==3.1.6
- gfpgan==1.3.8
- hydralit==1.0.14
- hydralit_components==1.0.10
- imageio-ffmpeg==0.4.2
Expand Down
161 changes: 42 additions & 119 deletions scripts/Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ def layout():
(Not properly implemented and currently not working, check this \
link 'https://github.com/huggingface/diffusers/pull/537' for more information on it ). Default: False")

st.session_state["defaults"].general.update_preview = st.checkbox("Update Preview Image", value=st.session_state['defaults'].general.update_preview,
help="Enables the preview image to be updated and shown to the user on the UI during the generation.\
If checked, once you save the settings an option to specify the frequency at which the image is updated\
in steps will be shown, this is helpful to reduce the negative effect this option has on performance. \
Default: True")
if st.session_state["defaults"].general.update_preview:
st.session_state["defaults"].general.update_preview_frequency = int(st.text_input("Update Preview Frequency", value=st.session_state['defaults'].general.update_preview_frequency,
help="Specify the frequency at which the image is updated in steps, this is helpful to reduce the \
negative effect updating the preview image has on performance. Default: 10"))
#st.session_state["defaults"].general.update_preview = st.checkbox("Update Preview Image", value=st.session_state['defaults'].general.update_preview,
#help="Enables the preview image to be updated and shown to the user on the UI during the generation.\
#If checked, once you save the settings an option to specify the frequency at which the image is updated\
#in steps will be shown, this is helpful to reduce the negative effect this option has on performance. \
#Default: True")
st.session_state["defaults"].general.update_preview = True
st.session_state["defaults"].general.update_preview_frequency = int(st.text_input("Update Preview Frequency", value=st.session_state['defaults'].general.update_preview_frequency,
help="Specify the frequency at which the image is updated in steps, this is helpful to reduce the \
negative effect updating the preview image has on performance. Default: 10"))

with col3:
st.title("Others")
Expand Down Expand Up @@ -222,7 +222,7 @@ def layout():
at https://huggingface.co/settings/tokens. Default: None")

with txt2img_tab:
col1, col2, col3, col4, col5 = st.columns(5, gap='large')
col1, col2, col3, col4, col5 = st.columns(5, gap='medium')

with col1:
st.title("Slider Parameters")
Expand Down Expand Up @@ -277,51 +277,28 @@ def layout():
st.session_state["defaults"].txt2img.sampling_steps.step = int(st.text_input("Sampling Slider Steps",
value=st.session_state['defaults'].txt2img.sampling_steps.step,
help="Set the default value for the number of steps on the sampling steps slider. Default is: 10"))

with col3:
# Batch Count
st.session_state["defaults"].txt2img.batch_count.value = int(st.text_input("Default Batch Count",
value=st.session_state['defaults'].txt2img.batch_count.value,
help="Set the default batch count to use. Default is: 1"))

st.session_state["defaults"].txt2img.batch_count.min_value = int(st.text_input("Minimum Batch Count",
value=st.session_state['defaults'].txt2img.batch_count.min_value,
help="Set the default minimum value for the batch count slider. Default is: 1"))

st.session_state["defaults"].txt2img.batch_count.max_value = int(st.text_input("Maximum Batch Count",
value=st.session_state['defaults'].txt2img.batch_count.max_value,
help="Set the default maximum value for the batch count slider. Default is: 100"))

st.session_state["defaults"].txt2img.batch_count.step = int(st.text_input("Batch Count Slider Steps",
value=st.session_state['defaults'].txt2img.batch_count.step,
help="Set the default value for the number of steps on the batch count slider. Default is: 10"))

# Batch Size
st.session_state["defaults"].txt2img.batch_size.value = int(st.text_input("Default Batch Size",
value=st.session_state['defaults'].txt2img.batch_size.value,
help="Set the default batch size to use. Default is: 1"))

st.session_state["defaults"].txt2img.batch_size.min_value = int(st.text_input("Minimum Batch Size",
value=st.session_state['defaults'].txt2img.batch_size.min_value,
help="Set the default minimum value for the batch size slider. Default is: 1"))

st.session_state["defaults"].txt2img.batch_size.max_value = int(st.text_input("Maximum Batch Size",
value=st.session_state['defaults'].txt2img.batch_size.max_value,
help="Set the default maximum value for the batch size slider. Default is: 5"))

st.session_state["defaults"].txt2img.batch_size.step = int(st.text_input("Batch Size Slider Steps",
value=st.session_state['defaults'].txt2img.batch_size.step,
help="Set the default value for the number of steps on the batch size slider. Default is: 1"))

with col4:
with col3:
st.title("General Parameters")

# Batch Count
st.session_state["batch_count"] = st.text_input("Batch count.", value=st.session_state['defaults'].txt2img.batch_count.value,
help="How many iterations or batches of images to generate in total.")

st.session_state["batch_size"] = st.text_input("Batch size", value=st.session_state.defaults.txt2img.batch_size.value,
help="How many images are at once in a batch.\
It increases the VRAM usage a lot but if you have enough VRAM it can reduce the time it \
takes to finish generation as more images are generated at once.\
Default: 1")

default_sampler_list = ["k_lms", "k_euler", "k_euler_a", "k_dpm_2", "k_dpm_2_a", "k_heun", "PLMS", "DDIM"]
st.session_state["defaults"].txt2img.default_sampler = st.selectbox("Default Sampler",
default_sampler_list, index=default_sampler_list.index(st.session_state['defaults'].txt2img.default_sampler),
help="Defaut sampler to use for txt2img. Default: k_euler")

st.session_state['defaults'].txt2img.seed = st.text_input("Default Seed", value=st.session_state['defaults'].txt2img.seed, help="Default seed.")

with col4:

st.session_state["defaults"].txt2img.separate_prompts = st.checkbox("Separate Prompts",
value=st.session_state['defaults'].txt2img.separate_prompts, help="Separate Prompts. Default: False")
Expand Down Expand Up @@ -351,9 +328,7 @@ def layout():
st.session_state["defaults"].txt2img.use_RealESRGAN = st.checkbox("Use RealESRGAN", value=st.session_state['defaults'].txt2img.use_RealESRGAN,
help="Choose to use RealESRGAN. Default: False")

st.session_state["defaults"].txt2img.update_preview = st.checkbox("Update Preview Image", value=st.session_state['defaults'].txt2img.update_preview,
help="Choose to update the preview image during generation. Default: True")

st.session_state["defaults"].txt2img.update_preview = True
st.session_state["defaults"].txt2img.update_preview_frequency = int(st.text_input("Preview Image Update Frequency",
value=st.session_state['defaults'].txt2img.update_preview_frequency,
help="Set the default value for the frrquency of the preview image updates. Default is: 10"))
Expand Down Expand Up @@ -471,38 +446,14 @@ def layout():
help="Set the default value for the number of steps on the sampling steps slider. Default is: 10"))

# Batch Count
st.session_state["defaults"].img2img.batch_count.value = int(st.text_input("Default Img2Img Batch Count",
value=st.session_state['defaults'].img2img.batch_count.value,
help="Set the default batch count to use. Default is: 1"))

st.session_state["defaults"].img2img.batch_count.min_value = int(st.text_input("Minimum Img2Img Batch Count",
value=st.session_state['defaults'].img2img.batch_count.min_value,
help="Set the default minimum value for the batch count slider. Default is: 1"))

st.session_state["defaults"].img2img.batch_count.max_value = int(st.text_input("Maximum Img2Img Batch Count",
value=st.session_state['defaults'].img2img.batch_count.max_value,
help="Set the default maximum value for the batch count slider. Default is: 100"))

st.session_state["defaults"].img2img.batch_count.step = int(st.text_input("Img2Img Batch Count Slider Steps",
value=st.session_state['defaults'].img2img.batch_count.step,
help="Set the default value for the number of steps on the batch count slider. Default is: 10"))

# Batch Size
st.session_state["defaults"].img2img.batch_size.value = int(st.text_input("Default Img2Img Batch Size",
value=st.session_state['defaults'].img2img.batch_size.value,
help="Set the default batch size to use. Default is: 1"))

st.session_state["defaults"].img2img.batch_size.min_value = int(st.text_input("Minimum Img2Img Batch Size",
value=st.session_state['defaults'].img2img.batch_size.min_value,
help="Set the default minimum value for the batch size slider. Default is: 1"))

st.session_state["defaults"].img2img.batch_size.max_value = int(st.text_input("Maximum Img2Img Batch Size",
value=st.session_state['defaults'].img2img.batch_size.max_value,
help="Set the default maximum value for the batch size slider. Default is: 5"))

st.session_state["defaults"].img2img.batch_size.step = int(st.text_input("Img2Img Batch Size Slider Steps",
value=st.session_state['defaults'].img2img.batch_size.step,
help="Set the default value for the number of steps on the batch size slider. Default is: 1"))
st.session_state["batch_count"] = st.text_input("Batch count.", value=st.session_state['defaults'].txt2img.batch_count.value,
help="How many iterations or batches of images to generate in total.")

st.session_state["batch_size"] = st.text_input("Batch size", value=st.session_state.defaults.txt2img.batch_size.value,
help="How many images are at once in a batch.\
It increases the VRAM usage a lot but if you have enough VRAM it can reduce the time it \
takes to finish generation as more images are generated at once.\
Default: 1")
with col4:
# Inference Steps
st.session_state["defaults"].img2img.num_inference_steps.value = int(st.text_input("Default Inference Steps",
Expand Down Expand Up @@ -580,9 +531,7 @@ def layout():
st.session_state["defaults"].img2img.use_RealESRGAN = st.checkbox("Img2Img Use RealESRGAN", value=st.session_state['defaults'].img2img.use_RealESRGAN,
help="Choose to use RealESRGAN. Default: False")

st.session_state["defaults"].img2img.update_preview = st.checkbox("Update Img2Img Preview Image", value=st.session_state['defaults'].img2img.update_preview,
help="Choose to update the preview image during generation. Default: True")

st.session_state["defaults"].img2img.update_preview = True
st.session_state["defaults"].img2img.update_preview_frequency = int(st.text_input("Img2Img Preview Image Update Frequency",
value=st.session_state['defaults'].img2img.update_preview_frequency,
help="Set the default value for the frrquency of the preview image updates. Default is: 10"))
Expand Down Expand Up @@ -686,38 +635,14 @@ def layout():
help="Set the default value for the number of steps on the sampling steps slider. Default is: 10"))

# Batch Count
st.session_state["defaults"].txt2vid.batch_count.value = int(st.text_input("Default txt2vid Batch Count",
value=st.session_state['defaults'].txt2vid.batch_count.value,
help="Set the default batch count to use. Default is: 1"))

st.session_state["defaults"].txt2vid.batch_count.min_value = int(st.text_input("Minimum txt2vid Batch Count",
value=st.session_state['defaults'].img2img.batch_count.min_value,
help="Set the default minimum value for the batch count slider. Default is: 1"))

st.session_state["defaults"].img2img.batch_count.max_value = int(st.text_input("Maximum txt2vid Batch Count",
value=st.session_state['defaults'].txt2vid.batch_count.max_value,
help="Set the default maximum value for the batch count slider. Default is: 100"))

st.session_state["defaults"].txt2vid.batch_count.step = int(st.text_input("txt2vid Batch Count Slider Steps",
value=st.session_state['defaults'].txt2vid.batch_count.step,
help="Set the default value for the number of steps on the batch count slider. Default is: 10"))

# Batch Size
st.session_state["defaults"].txt2vid.batch_size.value = int(st.text_input("Default txt2vid Batch Size",
value=st.session_state['defaults'].txt2vid.batch_size.value,
help="Set the default batch size to use. Default is: 1"))

st.session_state["defaults"].txt2vid.batch_size.min_value = int(st.text_input("Minimum txt2vid Batch Size",
value=st.session_state['defaults'].txt2vid.batch_size.min_value,
help="Set the default minimum value for the batch size slider. Default is: 1"))

st.session_state["defaults"].txt2vid.batch_size.max_value = int(st.text_input("Maximum txt2vid Batch Size",
value=st.session_state['defaults'].txt2vid.batch_size.max_value,
help="Set the default maximum value for the batch size slider. Default is: 5"))

st.session_state["defaults"].txt2vid.batch_size.step = int(st.text_input("txt2vid Batch Size Slider Steps",
value=st.session_state['defaults'].txt2vid.batch_size.step,
help="Set the default value for the number of steps on the batch size slider. Default is: 1"))
st.session_state["batch_count"] = st.text_input("Batch count.", value=st.session_state['defaults'].txt2img.batch_count.value,
help="How many iterations or batches of images to generate in total.")

st.session_state["batch_size"] = st.text_input("Batch size", value=st.session_state.defaults.txt2img.batch_size.value,
help="How many images are at once in a batch.\
It increases the VRAM usage a lot but if you have enough VRAM it can reduce the time it \
takes to finish generation as more images are generated at once.\
Default: 1")

# Inference Steps
st.session_state["defaults"].txt2vid.num_inference_steps.value = int(st.text_input("Default Txt2Vid Inference Steps",
Expand Down Expand Up @@ -790,9 +715,7 @@ def layout():
st.session_state["defaults"].txt2vid.use_RealESRGAN = st.checkbox("txt2vid Use RealESRGAN", value=st.session_state['defaults'].txt2vid.use_RealESRGAN,
help="Choose to use RealESRGAN. Default: False")

st.session_state["defaults"].txt2vid.update_preview = st.checkbox("Update txt2vid Preview Image", value=st.session_state['defaults'].txt2vid.update_preview,
help="Choose to update the preview image during generation. Default: True")

st.session_state["defaults"].txt2vid.update_preview = True
st.session_state["defaults"].txt2vid.update_preview_frequency = int(st.text_input("txt2vid Preview Image Update Frequency",
value=st.session_state['defaults'].txt2vid.update_preview_frequency,
help="Set the default value for the frrquency of the preview image updates. Default is: 10"))
Expand Down
Loading

0 comments on commit f230e32

Please sign in to comment.