From b7a0cb318a17bf87463485ba43bd8519225bf11d Mon Sep 17 00:00:00 2001 From: GeorgLegato Date: Sun, 30 Apr 2023 22:39:31 +0200 Subject: [PATCH 1/3] added check --- iz_helpers/ui.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/iz_helpers/ui.py b/iz_helpers/ui.py index 51ce9d2..f6db773 100644 --- a/iz_helpers/ui.py +++ b/iz_helpers/ui.py @@ -256,7 +256,7 @@ Our best experience and trade-off is the R-ERSGAn4x upscaler. "infinite-zoom", shared.opts.outdir_img2img_samples ) generate_btn.click( - fn=wrap_gradio_gpu_call(create_zoom, extra_outputs=[None, "", ""]), + fn=wrap_gradio_gpu_call(check_create_zoom, extra_outputs=[None, "", ""]), inputs=[ main_common_prompt_pre, main_prompts, @@ -291,3 +291,67 @@ Our best experience and trade-off is the R-ERSGAn4x upscaler. interrupt.click(fn=lambda: shared.state.interrupt(), inputs=[], outputs=[]) infinite_zoom_interface.queue() return [(infinite_zoom_interface, "Infinite Zoom", "iz_interface")] + + + +def check_create_zoom( + main_common_prompt_pre, + main_prompts, + main_common_prompt_suf, + main_negative_prompt, + main_outpaint_steps, + main_guidance_scale, + sampling_step, + init_image, + exit_image, + video_frame_rate, + 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, + main_height, + batchcount_slider, + main_sampler, + upscale_do, + upscaler_name, + upscale_by, +): + keys = main_prompts.keys() + if 0 not in keys: + raise gr.Error("Ensure your prompt table has a step 9 (zero) prompt") + + return create_zoom( main_common_prompt_pre, + main_prompts, + main_common_prompt_suf, + main_negative_prompt, + main_outpaint_steps, + main_guidance_scale, + sampling_step, + init_image, + exit_image, + video_frame_rate, + 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, + main_height, + batchcount_slider, + main_sampler, + upscale_do, + upscaler_name, + upscale_by, + ) \ No newline at end of file From 443b3256f5cff5d5653a4b96c4c6cfa91749c71b Mon Sep 17 00:00:00 2001 From: GeorgLegato Date: Mon, 1 May 2023 01:07:57 +0200 Subject: [PATCH 2/3] fix json complete. do not accept headers --- iz_helpers/prompt_util.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/iz_helpers/prompt_util.py b/iz_helpers/prompt_util.py index 95519a8..b42d81e 100644 --- a/iz_helpers/prompt_util.py +++ b/iz_helpers/prompt_util.py @@ -9,18 +9,19 @@ from .static_variables import ( def completeOptionals(j): if isinstance(j, dict): + # Remove header information, user dont pimp our ui if "prompts" in j: - if "headers" not in j["prompts"]: - j["prompts"]["headers"] = ["outpaint steps","prompt"] + if "headers" in j["prompts"]: + del j["prompts"]["headers"] if "negPrompt" not in j: - j["prompts"]["negPrompt"]="" + j["negPrompt"]="" if "prePrompt" not in j: - j["prompts"]["prePrompt"]="" + j["prePrompt"]="" if "postPrompt" not in j: - j["prompts"]["postPrompt"]="" + j["postPrompt"]="" return j @@ -32,8 +33,7 @@ def validatePromptJson_throws(data): validate(instance=data, schema=schema) except Exception: - raise "Your prompts are not schema valid." - #fixJson(data) + raise Exception("Your prompts are not schema valid.") return completeOptionals(data) From 700b1c9560ac30ae1ab1909154d57c0b6d41713b Mon Sep 17 00:00:00 2001 From: GeorgLegato Date: Mon, 1 May 2023 01:29:11 +0200 Subject: [PATCH 3/3] changed wording to help users understand concept very easily. disabling generate button on invalid table --- iz_helpers/ui.py | 80 ++++++------------------------- javascript/infinite-zoom-hints.js | 7 ++- 2 files changed, 17 insertions(+), 70 deletions(-) diff --git a/iz_helpers/ui.py b/iz_helpers/ui.py index f6db773..f9d52e7 100644 --- a/iz_helpers/ui.py +++ b/iz_helpers/ui.py @@ -42,7 +42,7 @@ def on_ui_tabs(): maximum=100, step=1, value=8, - label="Total Outpaint Steps", + label="Total video length [s]", ) # safe reading json prompt @@ -55,7 +55,7 @@ def on_ui_tabs(): main_prompts = gr.Dataframe( type="array", - headers=["outpaint step", "prompt"], + headers=["Start at second [0,1,...]", "Prompt"], datatype=["number", "str"], row_count=1, col_count=(2, "fixed"), @@ -255,8 +255,9 @@ 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(check_create_zoom, extra_outputs=[None, "", ""]), + fn=wrap_gradio_gpu_call(create_zoom, extra_outputs=[None, "", ""]), inputs=[ main_common_prompt_pre, main_prompts, @@ -288,70 +289,17 @@ Our best experience and trade-off is the R-ERSGAn4x upscaler. ], outputs=[output_video, out_image, generation_info, html_info, html_log], ) - interrupt.click(fn=lambda: shared.state.interrupt(), inputs=[], outputs=[]) + + 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 check_create_zoom( - main_common_prompt_pre, - main_prompts, - main_common_prompt_suf, - main_negative_prompt, - main_outpaint_steps, - main_guidance_scale, - sampling_step, - init_image, - exit_image, - video_frame_rate, - 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, - main_height, - batchcount_slider, - main_sampler, - upscale_do, - upscaler_name, - upscale_by, -): - keys = main_prompts.keys() - if 0 not in keys: - raise gr.Error("Ensure your prompt table has a step 9 (zero) prompt") - - return create_zoom( main_common_prompt_pre, - main_prompts, - main_common_prompt_suf, - main_negative_prompt, - main_outpaint_steps, - main_guidance_scale, - sampling_step, - init_image, - exit_image, - video_frame_rate, - 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, - main_height, - batchcount_slider, - main_sampler, - upscale_do, - upscaler_name, - upscale_by, +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 diff --git a/javascript/infinite-zoom-hints.js b/javascript/infinite-zoom-hints.js index ef7be89..e046f65 100644 --- a/javascript/infinite-zoom-hints.js +++ b/javascript/infinite-zoom-hints.js @@ -2,7 +2,7 @@ infzoom_titles = { "Batch Count":"How many separate videos to create", - "Total Outpaint Steps":"The more it is, the longer your videos will be. Each step generates frame for 1 second at your FPS, while cycling through your array of prompts", + "Total video length [s]":"For each seconds frame (FPS) will be generated. Define prompts at which time they should start wihtin this duration.", "Common Prompt Prefix":"Prompt inserted before each step", "Common Prompt Suffix":"Prompt inserted after each step", "Negative Prompt":"What your model shall avoid", @@ -12,9 +12,8 @@ infzoom_titles = { "Custom initial image":"An image at the end resp. begin of your movie, depending or ZoomIn or Out", "Custom exit image":"An image at the end resp. begin of your movie, depending or ZoomIn or Out", "Zoom Speed":"Varies additional frames per second", - - - + "Start at second [0,1,...]": "At which time the prompt has to be occure. We need at least one prompt starting at time 0", + "Generate video": "Start rendering. If it´s disabled the prompt table is invalid, check we have a start prompt at time 0" }