From 2ed87c1efff3f348026081b804118aa0a814fcc2 Mon Sep 17 00:00:00 2001 From: "vahid K. nejad" Date: Tue, 2 May 2023 09:50:42 +0400 Subject: [PATCH] Remove unnecessary params and change default params --- iz_helpers/run.py | 12 +++---- iz_helpers/static_variables.py | 9 +++-- iz_helpers/ui.py | 63 ++++++++++++++++------------------ 3 files changed, 43 insertions(+), 41 deletions(-) diff --git a/iz_helpers/run.py b/iz_helpers/run.py index 7f1fb50..d783f14 100644 --- a/iz_helpers/run.py +++ b/iz_helpers/run.py @@ -179,11 +179,8 @@ def create_zoom( video_zoom_mode, video_start_frame_dupe_amount, video_last_frame_dupe_amount, - inpainting_denoising_strength, inpainting_mask_blur, inpainting_fill_mode, - inpainting_full_res, - inpainting_padding, zoom_speed, seed, outputsizeW, @@ -193,6 +190,9 @@ def create_zoom( upscale_do, upscaler_name, upscale_by, + inpainting_denoising_strength=1, + inpainting_full_res=False, + inpainting_padding=0, progress=None, ): for i in range(batchcount): @@ -302,11 +302,8 @@ def create_zoom_single( video_zoom_mode, video_start_frame_dupe_amount, video_last_frame_dupe_amount, - inpainting_denoising_strength, inpainting_mask_blur, inpainting_fill_mode, - inpainting_full_res, - inpainting_padding, zoom_speed, seed, outputsizeW, @@ -315,6 +312,9 @@ def create_zoom_single( upscale_do, upscaler_name, upscale_by, + inpainting_denoising_strength=1, + inpainting_full_res=False, + inpainting_padding=0, progress=None, ): # try: diff --git a/iz_helpers/static_variables.py b/iz_helpers/static_variables.py index 3b25463..c330cd3 100644 --- a/iz_helpers/static_variables.py +++ b/iz_helpers/static_variables.py @@ -2,7 +2,12 @@ import os from modules import scripts import modules.sd_samplers -promptTableHeaders=["Start at second [0,1,...]","Prompt"] +default_sampling_steps = 35 +default_sampler = "DDIM" +default_cfg_scale = "DDIM" +default_mask_blur = 48 +default_total_outpaints = 5 +promptTableHeaders = ["Start at second [0,1,...]", "Prompt"] default_prompt = """ { @@ -28,7 +33,7 @@ invalid_prompt = { }, "negPrompt": "Invalid prompt-json", "prePromp": "Invalid prompt", - "postPrompt": "Invalid prompt" + "postPrompt": "Invalid prompt", } available_samplers = [ diff --git a/iz_helpers/ui.py b/iz_helpers/ui.py index a880f50..8961b3f 100644 --- a/iz_helpers/ui.py +++ b/iz_helpers/ui.py @@ -3,9 +3,15 @@ from .run import create_zoom import modules.shared as shared from webui import wrap_gradio_gpu_call from modules.ui import create_output_panel + from .static_variables import ( default_prompt, available_samplers, + default_total_outpaints, + default_sampling_steps, + default_cfg_scale, + default_mask_blur, + default_sampler, ) from .helpers import putPrompts, clearPrompts from .prompt_util import readJsonPrompt @@ -37,13 +43,11 @@ def on_ui_tabs(): step=1, label="Batch Count", ) - - main_outpaint_steps = gr.Slider( - minimum=1, - maximum=100, - step=1, - value=8, + main_outpaint_steps = gr.Number( label="Total video length [s]", + value=default_total_outpaints, + precision=0, + interactive=True, ) # safe reading json prompt @@ -56,7 +60,7 @@ def on_ui_tabs(): main_prompts = gr.Dataframe( type="array", - headers= promptTableHeaders, + headers=promptTableHeaders, datatype=["number", "str"], row_count=1, col_count=(2, "fixed"), @@ -72,7 +76,7 @@ def on_ui_tabs(): value=jpr["negPrompt"], label="Negative Prompt" ) - # these button will be moved using JS unde the dataframe view as small ones + # these button will be moved using JS under the dataframe view as small ones exportPrompts_button = gr.Button( value="Export prompts", variant="secondary", @@ -132,7 +136,7 @@ def on_ui_tabs(): main_sampler = gr.Dropdown( label="Sampler", choices=available_samplers, - value="Euler a", + value=default_sampler, type="value", ) with gr.Row(): @@ -155,14 +159,14 @@ def on_ui_tabs(): minimum=0.1, maximum=15, step=0.1, - value=7, + value=default_cfg_scale, label="Guidance Scale", ) sampling_step = gr.Slider( minimum=1, - maximum=100, + maximum=150, step=1, - value=50, + value=default_sampling_steps, label="Sampling Steps for each outpaint", ) with gr.Row(): @@ -209,11 +213,11 @@ def on_ui_tabs(): ) with gr.Tab("Outpaint"): - inpainting_denoising_strength = gr.Slider( - label="Denoising Strength", minimum=0.75, maximum=1, value=1 - ) inpainting_mask_blur = gr.Slider( - label="Mask Blur", minimum=0, maximum=64, value=0 + label="Mask Blur", + minimum=0, + maximum=64, + value=default_mask_blur, ) inpainting_fill_mode = gr.Radio( label="Masked content", @@ -221,10 +225,6 @@ def on_ui_tabs(): value="latent noise", type="index", ) - inpainting_full_res = gr.Checkbox(label="Inpaint Full Resolution") - inpainting_padding = gr.Slider( - label="masked padding", minimum=0, maximum=256, value=0 - ) with gr.Tab("Post proccess"): upscale_do = gr.Checkbox(False, label="Enable Upscale") @@ -234,7 +234,6 @@ def on_ui_tabs(): choices=[x.name for x in shared.sd_upscalers], value=shared.sd_upscalers[0].name, ) - upscale_by = gr.Slider( label="Upscale by factor", minimum=1, maximum=8, value=1 ) @@ -256,7 +255,7 @@ Our best experience and trade-off is the R-ERSGAn4x upscaler. ) = create_output_panel( "infinite-zoom", shared.opts.outdir_img2img_samples ) - + generate_btn.click( fn=wrap_gradio_gpu_call(create_zoom, extra_outputs=[None, "", ""]), inputs=[ @@ -273,11 +272,8 @@ Our best experience and trade-off is the R-ERSGAn4x upscaler. video_zoom_mode, video_start_frame_dupe_amount, video_last_frame_dupe_amount, - inpainting_denoising_strength, inpainting_mask_blur, inpainting_fill_mode, - inpainting_full_res, - inpainting_padding, video_zoom_speed, seed, main_width, @@ -290,17 +286,18 @@ Our best experience and trade-off is the R-ERSGAn4x upscaler. ], outputs=[output_video, out_image, generation_info, html_info, html_log], ) - - main_prompts.change(fn=checkPrompts,inputs=[main_prompts], outputs=[generate_btn]) - + + main_prompts.change( + fn=checkPrompts, inputs=[main_prompts], outputs=[generate_btn] + ) + interrupt.click(fn=shared.state.interrupt(), inputs=[], outputs=[]) infinite_zoom_interface.queue() return [(infinite_zoom_interface, "Infinite Zoom", "iz_interface")] + def checkPrompts(p): return gr.Button.update( - interactive= - any(0 in sublist for sublist in p) - or - any('0' in sublist for sublist in p) - ) \ No newline at end of file + interactive=any(0 in sublist for sublist in p) + or any("0" in sublist for sublist in p) + )