diff --git a/.env_docker.example b/.env_docker.example
new file mode 100644
index 0000000..5a34945
--- /dev/null
+++ b/.env_docker.example
@@ -0,0 +1,14 @@
+# Force miniconda to attempt to update on every container restart
+# instead only when changes are detected
+CONDA_FORCE_UPDATE=false
+
+# Validate the model files on every container restart
+# (useful to set to false after you're sure the model files are already in place)
+VALIDATE_MODELS=true
+
+#Automatically relaunch the webui on crashes
+WEBUI_RELAUNCH=true
+
+#Pass cli arguments to webui.py e.g:
+#WEBUI_ARGS=--gpu=1 --esrgan-gpu=1 --gfpgan-gpu=1
+WEBUI_ARGS=
diff --git a/entrypoint.sh b/entrypoint.sh
old mode 100644
new mode 100755
diff --git a/frontend/frontend.py b/frontend/frontend.py
index d0b973e..41e8672 100644
--- a/frontend/frontend.py
+++ b/frontend/frontend.py
@@ -4,12 +4,14 @@ from frontend.job_manager import JobManager
import frontend.ui_functions as uifn
import uuid
-def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda x: x, txt2img_defaults={}, RealESRGAN=True, GFPGAN=True,LDSR=True,
+
+def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x, imgproc=lambda x: x, txt2img_defaults={},
+ RealESRGAN=True, GFPGAN=True, LDSR=True,
txt2img_toggles={}, txt2img_toggle_defaults='k_euler', show_embeddings=False, img2img_defaults={},
img2img_toggles={}, img2img_toggle_defaults={}, sample_img2img=None, img2img_mask_modes=None,
- img2img_resize_modes=None, imgproc_defaults={},imgproc_mode_toggles={},user_defaults={}, run_GFPGAN=lambda x: x, run_RealESRGAN=lambda x: x,
+ img2img_resize_modes=None, imgproc_defaults={}, imgproc_mode_toggles={}, user_defaults={},
+ run_GFPGAN=lambda x: x, run_RealESRGAN=lambda x: x,
job_manager: JobManager = None) -> gr.Blocks:
-
with gr.Blocks(css=css(opt), analytics_enabled=False, title="Stable Diffusion WebUI") as demo:
with gr.Tabs(elem_id='tabss') as tabs:
with gr.TabItem("Text-to-Image", id='txt2img_tab'):
@@ -40,34 +42,37 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
txt2img_job_ui = job_manager.draw_gradio_ui() if job_manager else None
- txt2img_dimensions_info_text_box = gr.Textbox(label="Aspect ratio (4:3 = 1.333 | 16:9 = 1.777 | 21:9 = 2.333)")
+ txt2img_dimensions_info_text_box = gr.Textbox(
+ label="Aspect ratio (4:3 = 1.333 | 16:9 = 1.777 | 21:9 = 2.333)")
with gr.Column():
with gr.Box():
- output_txt2img_gallery = gr.Gallery(label="Images", elem_id="txt2img_gallery_output").style(grid=[4, 4])
- gr.Markdown("Select an image from the gallery, then click one of the buttons below to perform an action.")
+ output_txt2img_gallery = gr.Gallery(label="Images", elem_id="txt2img_gallery_output").style(
+ grid=[4, 4])
+ gr.Markdown(
+ "Select an image from the gallery, then click one of the buttons below to perform an action.")
with gr.Row(elem_id='txt2img_actions_row'):
gr.Button("Copy to clipboard").click(fn=None,
- inputs=output_txt2img_gallery,
- outputs=[],
- #_js=js_copy_to_clipboard( 'txt2img_gallery_output')
- )
+ inputs=output_txt2img_gallery,
+ outputs=[],
+ # _js=js_copy_to_clipboard( 'txt2img_gallery_output')
+ )
output_txt2img_copy_to_input_btn = gr.Button("Push to img2img")
- output_txt2img_to_imglab = gr.Button("Send to Lab",visible=True)
+ output_txt2img_to_imglab = gr.Button("Send to Lab", visible=True)
- output_txt2img_params = gr.Highlightedtext(label="Generation parameters", interactive=False, elem_id='highlight')
+ output_txt2img_params = gr.Highlightedtext(label="Generation parameters", interactive=False,
+ elem_id='highlight')
with gr.Group():
with gr.Row(elem_id='txt2img_output_row'):
output_txt2img_copy_params = gr.Button("Copy full parameters").click(
inputs=[output_txt2img_params], outputs=[],
_js=js_copy_txt2img_output,
- fn=None, show_progress=False)
+ fn=None, show_progress=False)
output_txt2img_seed = gr.Number(label='Seed', interactive=False, visible=False)
output_txt2img_copy_seed = gr.Button("Copy only seed").click(
inputs=[output_txt2img_seed], outputs=[],
_js='(x) => navigator.clipboard.writeText(x)', fn=None, show_progress=False)
output_txt2img_stats = gr.HTML(label='Stats')
with gr.Column():
-
txt2img_steps = gr.Slider(minimum=1, maximum=250, step=1, label="Sampling Steps",
value=txt2img_defaults['ddim_steps'])
txt2img_sampling = gr.Dropdown(label='Sampling method (k_lms is default k-diffusion sampler)',
@@ -93,7 +98,8 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
choices=['RealESRGAN_x4plus',
'RealESRGAN_x4plus_anime_6B'],
value='RealESRGAN_x4plus',
- visible=False)#RealESRGAN is not None # invisible until removed) # TODO: Feels like I shouldnt slot it in here.
+ visible=False) # RealESRGAN is not None # invisible until removed) # TODO: Feels like I shouldnt slot it in here.
+
txt2img_ddim_eta = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label="DDIM ETA",
value=txt2img_defaults['ddim_eta'], visible=False)
txt2img_variant_amount = gr.Slider(minimum=0.0, maximum=1.0, label='Variation Amount',
@@ -133,7 +139,8 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
# txt2img_width.change(fn=uifn.update_dimensions_info, inputs=[txt2img_width, txt2img_height], outputs=txt2img_dimensions_info_text_box)
# txt2img_height.change(fn=uifn.update_dimensions_info, inputs=[txt2img_width, txt2img_height], outputs=txt2img_dimensions_info_text_box)
- live_prompt_params = [txt2img_prompt, txt2img_width, txt2img_height, txt2img_steps, txt2img_seed, txt2img_batch_count, txt2img_cfg]
+ live_prompt_params = [txt2img_prompt, txt2img_width, txt2img_height, txt2img_steps, txt2img_seed,
+ txt2img_batch_count, txt2img_cfg]
txt2img_prompt.change(
fn=None,
inputs=live_prompt_params,
@@ -141,7 +148,6 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
_js=js_parse_prompt
)
-
with gr.TabItem("Image-to-Image Unified", id="img2img_tab"):
with gr.Row(elem_id="prompt_row"):
img2img_prompt = gr.Textbox(label="Prompt",
@@ -158,39 +164,58 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
with gr.Row().style(equal_height=False):
with gr.Column():
gr.Markdown('#### Img2Img Input')
- img2img_image_mask = gr.Image(value=sample_img2img, source="upload", interactive=True,
- type="pil", tool="sketch", elem_id="img2img_editor", image_mode="RGBA"
- )
- img2img_image_editor = gr.Image(value=sample_img2img, source="upload", interactive=False,
- type="pil", tool="sketch", visible=False, image_mode="RGBA",
- elem_id="img2img_mask")
+ img2img_image_mask = gr.Image(
+ value=sample_img2img,
+ source="upload",
+ interactive=True,
+ type="pil", tool="sketch",
+ elem_id="img2img_mask",
+ image_mode="RGBA"
+ )
+ img2img_image_editor = gr.Image(
+ value=sample_img2img,
+ source="upload",
+ interactive=True,
+ type="pil",
+ tool="select",
+ visible=False,
+ image_mode="RGBA",
+ elem_id="img2img_editor"
+ )
with gr.Tabs():
with gr.TabItem("Editor Options"):
with gr.Row():
- img2img_image_editor_mode = gr.Radio(choices=["Mask", "Crop", "Uncrop"], label="Image Editor Mode",
- value="Mask", elem_id='edit_mode_select', visible=False)
+ # disable Uncrop for now
+ # choices=["Mask", "Crop", "Uncrop"]
+ img2img_image_editor_mode = gr.Radio(choices=["Mask", "Crop"],
+ label="Image Editor Mode",
+ value="Mask", elem_id='edit_mode_select',
+ visible=True)
img2img_mask = gr.Radio(choices=["Keep masked area", "Regenerate only masked area"],
- label="Mask Mode", type="index",
- value=img2img_mask_modes[img2img_defaults['mask_mode']], visible=True)
+ label="Mask Mode", type="index",
+ value=img2img_mask_modes[img2img_defaults['mask_mode']],
+ visible=True)
img2img_mask_blur_strength = gr.Slider(minimum=1, maximum=10, step=1,
- label="How much blurry should the mask be? (to avoid hard edges)",
- value=3, visible=False)
+ label="How much blurry should the mask be? (to avoid hard edges)",
+ value=3, visible=False)
img2img_resize = gr.Radio(label="Resize mode",
- choices=["Just resize", "Crop and resize", "Resize and fill"],
- type="index",
- value=img2img_resize_modes[img2img_defaults['resize_mode']], visible=False)
+ choices=["Just resize", "Crop and resize",
+ "Resize and fill"],
+ type="index",
+ value=img2img_resize_modes[
+ img2img_defaults['resize_mode']], visible=False)
img2img_painterro_btn = gr.Button("Advanced Editor")
with gr.TabItem("Hints"):
img2img_help = gr.Markdown(visible=False, value=uifn.help_text)
-
with gr.Column():
gr.Markdown('#### Img2Img Results')
- output_img2img_gallery = gr.Gallery(label="Images", elem_id="img2img_gallery_output").style(grid=[4,4,4])
+ output_img2img_gallery = gr.Gallery(label="Images", elem_id="img2img_gallery_output").style(
+ grid=[4, 4, 4])
img2img_job_ui = job_manager.draw_gradio_ui() if job_manager else None
with gr.Tabs():
with gr.TabItem("Generated image actions", id="img2img_actions_tab"):
@@ -206,7 +231,8 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
with gr.Row():
output_img2img_copy_params = gr.Button("Copy full parameters").click(
inputs=output_img2img_params, outputs=[],
- _js='(x) => {navigator.clipboard.writeText(x.replace(": ",":"))}', fn=None, show_progress=False)
+ _js='(x) => {navigator.clipboard.writeText(x.replace(": ",":"))}', fn=None,
+ show_progress=False)
output_img2img_seed = gr.Number(label='Seed', interactive=False, visible=False)
output_img2img_copy_seed = gr.Button("Copy only seed").click(
inputs=output_img2img_seed, outputs=[],
@@ -229,7 +255,8 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
img2img_batch_count = gr.Slider(minimum=1, maximum=50, step=1,
label='Batch count (how many batches of images to generate)',
value=img2img_defaults['n_iter'])
- img2img_dimensions_info_text_box = gr.Textbox(label="Aspect ratio (4:3 = 1.333 | 16:9 = 1.777 | 21:9 = 2.333)")
+ img2img_dimensions_info_text_box = gr.Textbox(
+ label="Aspect ratio (4:3 = 1.333 | 16:9 = 1.777 | 21:9 = 2.333)")
with gr.Column():
img2img_steps = gr.Slider(minimum=1, maximum=250, step=1, label="Sampling Steps",
value=img2img_defaults['ddim_steps'])
@@ -310,7 +337,8 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
img2img_realesrgan_model_name, img2img_batch_count, img2img_cfg,
img2img_denoising, img2img_seed, img2img_height, img2img_width, img2img_resize,
img2img_image_editor, img2img_image_mask, img2img_embeddings]
- img2img_outputs = [output_img2img_gallery, output_img2img_seed, output_img2img_params, output_img2img_stats]
+ img2img_outputs = [output_img2img_gallery, output_img2img_seed, output_img2img_params,
+ output_img2img_stats]
# If a JobManager was passed in then wrap the Generate functions
if img2img_job_ui:
@@ -325,15 +353,16 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
img2img_inputs,
img2img_outputs
)
+
def img2img_submit_params():
- #print([img2img_prompt, img2img_image_editor_mode, img2img_mask,
+ # print([img2img_prompt, img2img_image_editor_mode, img2img_mask,
# img2img_mask_blur_strength, img2img_steps, img2img_sampling, img2img_toggles,
# img2img_realesrgan_model_name, img2img_batch_count, img2img_cfg,
# img2img_denoising, img2img_seed, img2img_height, img2img_width, img2img_resize,
# img2img_image_editor, img2img_image_mask, img2img_embeddings])
return (img2img_func,
- img2img_inputs,
- img2img_outputs)
+ img2img_inputs,
+ img2img_outputs)
img2img_btn_editor.click(*img2img_submit_params())
@@ -348,26 +377,31 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
_js=call_JS("Painterro.init", toId="img2img_editor")
)
- img2img_width.change(fn=uifn.update_dimensions_info, inputs=[img2img_width, img2img_height], outputs=img2img_dimensions_info_text_box)
- img2img_height.change(fn=uifn.update_dimensions_info, inputs=[img2img_width, img2img_height], outputs=img2img_dimensions_info_text_box)
-
- with gr.TabItem("Image Lab", id='imgproc_tab'):
- gr.Markdown("Post-process results")
- with gr.Row():
- with gr.Column():
- with gr.Tabs():
- with gr.TabItem('Single Image'):
- imgproc_source = gr.Image(label="Source", source="upload", interactive=True, type="pil",elem_id="imglab_input")
+ img2img_width.change(fn=uifn.update_dimensions_info, inputs=[img2img_width, img2img_height],
+ outputs=img2img_dimensions_info_text_box)
+ img2img_height.change(fn=uifn.update_dimensions_info, inputs=[img2img_width, img2img_height],
+ outputs=img2img_dimensions_info_text_box)
- #gfpgan_strength = gr.Slider(minimum=0.0, maximum=1.0, step=0.001, label="Effect strength",
+ with gr.TabItem("Image Lab", id='imgproc_tab'):
+ gr.Markdown("Post-process results")
+ with gr.Row():
+ with gr.Column():
+ with gr.Tabs():
+ with gr.TabItem('Single Image'):
+ imgproc_source = gr.Image(label="Source", source="upload", interactive=True, type="pil",
+ elem_id="imglab_input")
+
+ # gfpgan_strength = gr.Slider(minimum=0.0, maximum=1.0, step=0.001, label="Effect strength",
# value=gfpgan_defaults['strength'])
- #select folder with images to process
- with gr.TabItem('Batch Process'):
- imgproc_folder = gr.File(label="Batch Process", file_count="multiple",source="upload", interactive=True, type="file")
- imgproc_pngnfo = gr.Textbox(label="PNG Metadata", placeholder="PngNfo", visible=False, max_lines=5)
- with gr.Row():
- imgproc_btn = gr.Button("Process", variant="primary")
- gr.HTML("""
+ # select folder with images to process
+ with gr.TabItem('Batch Process'):
+ imgproc_folder = gr.File(label="Batch Process", file_count="multiple", source="upload",
+ interactive=True, type="file")
+ imgproc_pngnfo = gr.Textbox(label="PNG Metadata", placeholder="PngNfo", visible=False,
+ max_lines=5)
+ with gr.Row():
+ imgproc_btn = gr.Button("Process", variant="primary")
+ gr.HTML("""
Upscale Modes Guide
@@ -381,142 +415,170 @@ def draw_gradio_ui(opt, img2img=lambda x: x, txt2img=lambda x: x,imgproc=lambda
A 8X upscaler with high VRAM usage, uses GoBig to add details and then uses a Latent Diffusion model to upscale the image, this will result in less artifacting/sharpeninng, use the settings to feed GoBig settings that will contribute to the result, this mode is considerbly slower
""")
- with gr.Column():
- with gr.Tabs():
- with gr.TabItem('Output'):
- imgproc_output = gr.Gallery(label="Output", elem_id="imgproc_gallery_output")
- with gr.Row(elem_id="proc_options_row"):
- with gr.Box():
- with gr.Column():
- gr.Markdown("Processor Selection")
- imgproc_toggles = gr.CheckboxGroup(label = '',choices=imgproc_mode_toggles, type="index")
- #.change toggles to show options
- #imgproc_toggles.change()
- with gr.Box(visible=False) as gfpgan_group:
+ with gr.Column():
+ with gr.Tabs():
+ with gr.TabItem('Output'):
+ imgproc_output = gr.Gallery(label="Output", elem_id="imgproc_gallery_output")
+ with gr.Row(elem_id="proc_options_row"):
+ with gr.Box():
+ with gr.Column():
+ gr.Markdown("Processor Selection")
+ imgproc_toggles = gr.CheckboxGroup(label='', choices=imgproc_mode_toggles,
+ type="index")
+ # .change toggles to show options
+ # imgproc_toggles.change()
+ with gr.Box(visible=False) as gfpgan_group:
- gfpgan_defaults = {
- 'strength': 100,
- }
+ gfpgan_defaults = {
+ 'strength': 100,
+ }
- if 'gfpgan' in user_defaults:
- gfpgan_defaults.update(user_defaults['gfpgan'])
- if GFPGAN is None:
- gr.HTML("""
+ if 'gfpgan' in user_defaults:
+ gfpgan_defaults.update(user_defaults['gfpgan'])
+ if GFPGAN is None:
+ gr.HTML("""
Please download GFPGAN to activate face fixing features, instructions are available at the Github
""")
- #gr.Markdown("")
- #gr.Markdown(" Please download GFPGAN to activate face fixing features, instructions are available at the Github")
- with gr.Column():
- gr.Markdown("GFPGAN Settings")
- imgproc_gfpgan_strength = gr.Slider(minimum=0.0, maximum=1.0, step=0.001, label="Effect strength",
- value=gfpgan_defaults['strength'],visible=GFPGAN is not None)
- with gr.Box(visible=False) as upscale_group:
+ # gr.Markdown("")
+ # gr.Markdown(" Please download GFPGAN to activate face fixing features, instructions are available at the Github")
+ with gr.Column():
+ gr.Markdown("GFPGAN Settings")
+ imgproc_gfpgan_strength = gr.Slider(minimum=0.0, maximum=1.0, step=0.001,
+ label="Effect strength",
+ value=gfpgan_defaults['strength'],
+ visible=GFPGAN is not None)
+ with gr.Box(visible=False) as upscale_group:
- if LDSR:
- upscaleModes = ['RealESRGAN','GoBig','Latent Diffusion SR','GoLatent ']
- else:
- gr.HTML("""
+ if LDSR:
+ upscaleModes = ['RealESRGAN', 'GoBig', 'Latent Diffusion SR', 'GoLatent ']
+ else:
+ gr.HTML("""
Please download LDSR to activate more upscale features, instructions are available at the Github
""")
- upscaleModes = ['RealESRGAN','GoBig']
+ upscaleModes = ['RealESRGAN', 'GoBig']
+ with gr.Column():
+ gr.Markdown("Upscaler Selection")
+ imgproc_upscale_toggles = gr.Radio(label='', choices=upscaleModes, type="index",
+ visible=RealESRGAN is not None, value='RealESRGAN')
+ with gr.Box(visible=False) as upscalerSettings_group:
+
+ with gr.Box(visible=True) as realesrgan_group:
with gr.Column():
- gr.Markdown("Upscaler Selection")
- imgproc_upscale_toggles = gr.Radio(label = '',choices=upscaleModes, type="index",visible=RealESRGAN is not None,value='RealESRGAN')
- with gr.Box(visible=False) as upscalerSettings_group:
-
- with gr.Box(visible=True) as realesrgan_group:
+ gr.Markdown("RealESRGAN Settings")
+ imgproc_realesrgan_model_name = gr.Dropdown(label='RealESRGAN model',
+ interactive=RealESRGAN is not None,
+ choices=['RealESRGAN_x4plus',
+ 'RealESRGAN_x4plus_anime_6B',
+ 'RealESRGAN_x2plus',
+ 'RealESRGAN_x2plus_anime_6B'],
+ value='RealESRGAN_x4plus',
+ visible=RealESRGAN is not None) # TODO: Feels like I shouldnt slot it in here.
+ with gr.Box(visible=False) as ldsr_group:
+ with gr.Row(elem_id="ldsr_settings_row"):
with gr.Column():
- gr.Markdown("RealESRGAN Settings")
- imgproc_realesrgan_model_name = gr.Dropdown(label='RealESRGAN model', interactive=RealESRGAN is not None,
- choices= ['RealESRGAN_x4plus',
- 'RealESRGAN_x4plus_anime_6B','RealESRGAN_x2plus',
- 'RealESRGAN_x2plus_anime_6B'],
- value='RealESRGAN_x4plus',
- visible=RealESRGAN is not None) # TODO: Feels like I shouldnt slot it in here.
- with gr.Box(visible=False) as ldsr_group:
- with gr.Row(elem_id="ldsr_settings_row"):
- with gr.Column():
- gr.Markdown("Latent Diffusion Super Sampling Settings")
- imgproc_ldsr_steps = gr.Slider(minimum=0, maximum=500, step=10, label="LDSR Sampling Steps",
- value=100,visible=LDSR is not None)
- imgproc_ldsr_pre_downSample = gr.Dropdown(label='LDSR Pre Downsample mode (Lower resolution before processing for speed)',
- choices=["None", '1/2', '1/4'],value="None",visible=LDSR is not None)
- imgproc_ldsr_post_downSample = gr.Dropdown(label='LDSR Post Downsample mode (aka SuperSampling)',
- choices=["None", "Original Size", '1/2', '1/4'],value="None",visible=LDSR is not None)
- with gr.Box(visible=False) as gobig_group:
- with gr.Row(elem_id="proc_prompt_row"):
- with gr.Column():
- gr.Markdown("GoBig Settings")
- imgproc_prompt = gr.Textbox(label="",
- elem_id='prompt_input',
- placeholder="A corgi wearing a top hat as an oil painting.",
- lines=1,
- max_lines=1,
- value=imgproc_defaults['prompt'],
- show_label=True,
- visible=RealESRGAN is not None)
- imgproc_sampling = gr.Dropdown(label='Sampling method (k_lms is default k-diffusion sampler)',
- choices=["DDIM", 'k_dpm_2_a', 'k_dpm_2', 'k_euler_a', 'k_euler',
- 'k_heun', 'k_lms'],
- value=imgproc_defaults['sampler_name'],visible=RealESRGAN is not None)
- imgproc_steps = gr.Slider(minimum=1, maximum=250, step=1, label="Sampling Steps",
- value=imgproc_defaults['ddim_steps'],visible=RealESRGAN is not None)
- imgproc_cfg = gr.Slider(minimum=1.0, maximum=30.0, step=0.5,
- label='Classifier Free Guidance Scale (how strongly the image should follow the prompt)',
- value=imgproc_defaults['cfg_scale'],visible=RealESRGAN is not None)
- imgproc_denoising = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label='Denoising Strength',
- value=imgproc_defaults['denoising_strength'],visible=RealESRGAN is not None)
- imgproc_height = gr.Slider(minimum=64, maximum=2048, step=64, label="Height",
- value=imgproc_defaults["height"],visible=False) # not currently implemented
- imgproc_width = gr.Slider(minimum=64, maximum=2048, step=64, label="Width",
- value=imgproc_defaults["width"],visible=False) # not currently implemented
- imgproc_seed = gr.Textbox(label="Seed (blank to randomize)", lines=1, max_lines=1,
- value=imgproc_defaults["seed"],visible=RealESRGAN is not None)
- imgproc_btn.click(
- imgproc,
- [imgproc_source, imgproc_folder,imgproc_prompt,imgproc_toggles,
- imgproc_upscale_toggles,imgproc_realesrgan_model_name,imgproc_sampling, imgproc_steps, imgproc_height,
- imgproc_width, imgproc_cfg, imgproc_denoising, imgproc_seed,imgproc_gfpgan_strength,imgproc_ldsr_steps,imgproc_ldsr_pre_downSample,imgproc_ldsr_post_downSample],
- [imgproc_output])
+ gr.Markdown("Latent Diffusion Super Sampling Settings")
+ imgproc_ldsr_steps = gr.Slider(minimum=0, maximum=500, step=10,
+ label="LDSR Sampling Steps",
+ value=100, visible=LDSR is not None)
+ imgproc_ldsr_pre_downSample = gr.Dropdown(
+ label='LDSR Pre Downsample mode (Lower resolution before processing for speed)',
+ choices=["None", '1/2', '1/4'], value="None", visible=LDSR is not None)
+ imgproc_ldsr_post_downSample = gr.Dropdown(
+ label='LDSR Post Downsample mode (aka SuperSampling)',
+ choices=["None", "Original Size", '1/2', '1/4'], value="None",
+ visible=LDSR is not None)
+ with gr.Box(visible=False) as gobig_group:
+ with gr.Row(elem_id="proc_prompt_row"):
+ with gr.Column():
+ gr.Markdown("GoBig Settings")
+ imgproc_prompt = gr.Textbox(label="",
+ elem_id='prompt_input',
+ placeholder="A corgi wearing a top hat as an oil painting.",
+ lines=1,
+ max_lines=1,
+ value=imgproc_defaults['prompt'],
+ show_label=True,
+ visible=RealESRGAN is not None)
+ imgproc_sampling = gr.Dropdown(
+ label='Sampling method (k_lms is default k-diffusion sampler)',
+ choices=["DDIM", 'k_dpm_2_a', 'k_dpm_2', 'k_euler_a', 'k_euler',
+ 'k_heun', 'k_lms'],
+ value=imgproc_defaults['sampler_name'], visible=RealESRGAN is not None)
+ imgproc_steps = gr.Slider(minimum=1, maximum=250, step=1,
+ label="Sampling Steps",
+ value=imgproc_defaults['ddim_steps'],
+ visible=RealESRGAN is not None)
+ imgproc_cfg = gr.Slider(minimum=1.0, maximum=30.0, step=0.5,
+ label='Classifier Free Guidance Scale (how strongly the image should follow the prompt)',
+ value=imgproc_defaults['cfg_scale'],
+ visible=RealESRGAN is not None)
+ imgproc_denoising = gr.Slider(minimum=0.0, maximum=1.0, step=0.01,
+ label='Denoising Strength',
+ value=imgproc_defaults['denoising_strength'],
+ visible=RealESRGAN is not None)
+ imgproc_height = gr.Slider(minimum=64, maximum=2048, step=64, label="Height",
+ value=imgproc_defaults["height"],
+ visible=False) # not currently implemented
+ imgproc_width = gr.Slider(minimum=64, maximum=2048, step=64, label="Width",
+ value=imgproc_defaults["width"],
+ visible=False) # not currently implemented
+ imgproc_seed = gr.Textbox(label="Seed (blank to randomize)", lines=1,
+ max_lines=1,
+ value=imgproc_defaults["seed"],
+ visible=RealESRGAN is not None)
+ imgproc_btn.click(
+ imgproc,
+ [imgproc_source, imgproc_folder, imgproc_prompt, imgproc_toggles,
+ imgproc_upscale_toggles, imgproc_realesrgan_model_name, imgproc_sampling,
+ imgproc_steps, imgproc_height,
+ imgproc_width, imgproc_cfg, imgproc_denoising, imgproc_seed,
+ imgproc_gfpgan_strength, imgproc_ldsr_steps, imgproc_ldsr_pre_downSample,
+ imgproc_ldsr_post_downSample],
+ [imgproc_output])
- imgproc_source.change(
- uifn.get_png_nfo,
- [imgproc_source],
- [imgproc_pngnfo] )
+ imgproc_source.change(
+ uifn.get_png_nfo,
+ [imgproc_source],
+ [imgproc_pngnfo])
- output_txt2img_to_imglab.click(
- fn=uifn.copy_img_params_to_lab,
- inputs = [output_txt2img_params],
- outputs = [imgproc_prompt,imgproc_seed,imgproc_steps,imgproc_cfg,imgproc_sampling],
- )
-
- output_txt2img_to_imglab.click(
- fn=uifn.copy_img_to_lab,
- inputs = [output_txt2img_gallery],
- outputs = [imgproc_source, tabs],
- _js=call_JS("moveImageFromGallery",
- fromId="txt2img_gallery_output",
- toId="imglab_input")
- )
- if RealESRGAN is None:
- with gr.Row():
- with gr.Column():
- #seperator
- gr.HTML("""
+ output_txt2img_to_imglab.click(
+ fn=uifn.copy_img_params_to_lab,
+ inputs=[output_txt2img_params],
+ outputs=[imgproc_prompt, imgproc_seed, imgproc_steps, imgproc_cfg,
+ imgproc_sampling],
+ )
+
+ output_txt2img_to_imglab.click(
+ fn=uifn.copy_img_to_lab,
+ inputs=[output_txt2img_gallery],
+ outputs=[imgproc_source, tabs],
+ _js=call_JS("moveImageFromGallery",
+ fromId="txt2img_gallery_output",
+ toId="imglab_input")
+ )
+ if RealESRGAN is None:
+ with gr.Row():
+ with gr.Column():
+ # seperator
+ gr.HTML("""
Please download RealESRGAN to activate upscale features, instructions are available at the Github
""")
imgproc_toggles.change(fn=uifn.toggle_options_gfpgan, inputs=[imgproc_toggles], outputs=[gfpgan_group])
imgproc_toggles.change(fn=uifn.toggle_options_upscalers, inputs=[imgproc_toggles], outputs=[upscale_group])
- imgproc_toggles.change(fn=uifn.toggle_options_upscalers, inputs=[imgproc_toggles], outputs=[upscalerSettings_group])
- imgproc_upscale_toggles.change(fn=uifn.toggle_options_realesrgan, inputs=[imgproc_upscale_toggles], outputs=[realesrgan_group])
- imgproc_upscale_toggles.change(fn=uifn.toggle_options_ldsr, inputs=[imgproc_upscale_toggles], outputs=[ldsr_group])
- imgproc_upscale_toggles.change(fn=uifn.toggle_options_gobig, inputs=[imgproc_upscale_toggles], outputs=[gobig_group])
+ imgproc_toggles.change(fn=uifn.toggle_options_upscalers, inputs=[imgproc_toggles],
+ outputs=[upscalerSettings_group])
+ imgproc_upscale_toggles.change(fn=uifn.toggle_options_realesrgan, inputs=[imgproc_upscale_toggles],
+ outputs=[realesrgan_group])
+ imgproc_upscale_toggles.change(fn=uifn.toggle_options_ldsr, inputs=[imgproc_upscale_toggles],
+ outputs=[ldsr_group])
+ imgproc_upscale_toggles.change(fn=uifn.toggle_options_gobig, inputs=[imgproc_upscale_toggles],
+ outputs=[gobig_group])
"""
if GFPGAN is not None:
diff --git a/frontend/ui_functions.py b/frontend/ui_functions.py
index cebe34e..6557841 100644
--- a/frontend/ui_functions.py
+++ b/frontend/ui_functions.py
@@ -11,7 +11,7 @@ def change_image_editor_mode(choice, cropped_image, masked_image, resize_mode, w
update_image_result = update_image_mask(cropped_image, resize_mode, width, height)
return [gr.update(visible=False), update_image_result, gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=True)]
- update_image_result = update_image_mask(masked_image["image"], resize_mode, width, height)
+ update_image_result = update_image_mask(masked_image["image"] if masked_image is not None else None, resize_mode, width, height)
return [update_image_result, gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False)]
def update_image_mask(cropped_image, resize_mode, width, height):
diff --git a/webui.sh b/webui.sh
new file mode 100755
index 0000000..ea7028f
--- /dev/null
+++ b/webui.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+#
+# Starts the gui using the conda env
+#
+
+ENV_NAME="ldm"
+ENV_FILE="environment.yaml"
+ENV_UPDATED=0
+ENV_MODIFIED=$(date -r $ENV_FILE "+%s")
+ENV_MODIFED_FILE=".env_updated"
+if [[ -f $ENV_MODIFED_FILE ]]; then ENV_MODIFIED_CACHED=$(<${ENV_MODIFED_FILE}); else ENV_MODIFIED_CACHED=0; fi
+
+# Set conda path if it is not already in default environment
+custom_conda_path=
+
+# Allow setting custom path via file to allow updates of this script without undoing custom path
+if [ -f custom-conda-path.txt ]; then
+ custom_conda_path=$(cat custom-conda-path.txt)
+fi
+
+# If custom path is set above, try to setup conda environment
+if [ -f "${custom_conda_path}/etc/profile.d/conda.sh" ]; then
+ . "${custom_conda_path}/etc/profile.d/conda.sh"
+elif [ -n "${custom_conda_path}" ] && [ -f "${custom_conda_path}/bin" ]; then
+ export PATH="${custom_conda_path}/bin:$PATH"
+fi
+
+if ! command -v conda >/dev/null; then
+ echo "anaconda3/miniconda3 not found. Install from here https://docs.conda.io/en/latest/miniconda.html"
+ exit 1
+fi
+
+# Create/update conda env if needed
+if ! conda env list | grep ".*${ENV_NAME}.*" >/dev/null 2>&1; then
+ echo "Could not find conda env: ${ENV_NAME} ... creating ..."
+ conda env create -f $ENV_FILE
+ ENV_UPDATED=1
+elif [[ ! -z $CONDA_FORCE_UPDATE && $CONDA_FORCE_UPDATE == "true" ]] || (( $ENV_MODIFIED > $ENV_MODIFIED_CACHED )); then
+ echo "Updating conda env: ${ENV_NAME} ..."
+ conda env update --file $ENV_FILE --prune
+ ENV_UPDATED=1
+fi
+
+# Clear artifacts from conda after create/update
+if (( $ENV_UPDATED > 0 )); then
+ conda clean --all
+ echo -n $ENV_MODIFIED > $ENV_MODIFED_FILE
+fi
+
+# Activate conda environment
+conda activate $ENV_NAME
+conda info | grep active
+
+if [ ! -e "models/ldm/stable-diffusion-v1/model.ckpt" ]; then
+ echo "Your model file does not exist! Place it in 'models/ldm/stable-diffusion-v1' with the name 'model.ckpt'."
+ exit 1
+fi
+
+python scripts/relauncher.py
\ No newline at end of file