diff --git a/iz_helpers/helpers.py b/iz_helpers/helpers.py index c119212..5756470 100644 --- a/iz_helpers/helpers.py +++ b/iz_helpers/helpers.py @@ -122,4 +122,5 @@ def clearPrompts(): return [ gr.DataFrame.update(value=[[0, "Infinite Zoom. Start over"]]), gr.Textbox.update(""), + gr.Textbox.update("") ] diff --git a/iz_helpers/promptschema.json b/iz_helpers/promptschema.json index b7fcfd4..281855f 100644 --- a/iz_helpers/promptschema.json +++ b/iz_helpers/promptschema.json @@ -1,49 +1,60 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "properties": { - "prompts": { - "type": "object", - "properties": { - "data": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "1.1", + "type": "object", + "properties": { + "prompts": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { "type": "array", - "items": { - "type": "array", - "items": [ - { - "oneOf": [ - { - "type": "integer", - "minimum": 0 - }, - { - "type": "string" - } - ] - }, - { - "type": "string" - } - ], - "minItems": 0, - "maxItems": 999, - "uniqueItems": false - }, - "minItems": 0 + "items": [ + { + "oneOf": [ + { + "type": "integer", + "minimum": 0 + }, + { + "type": "string" + } + ] + }, + { + "type": "string" + } + ], + "minItems": 0, + "maxItems": 999, + "uniqueItems": false }, - "headers": { - "type": "array", - "items": { - "type": "string" - }, - "minItems": 2 - } + "minItems": 0 }, - "required": ["data", "headers"] + "headers": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 3 + } }, - "negPrompt": { - "type": "string" - } + "required": [ + "data", + "headers" + ] }, - "required": ["prompts", "negPrompt"] - } \ No newline at end of file + "negPrompt": { + "type": "string" + }, + "commonPrompt": { + "type": "string" + } + }, + "required": [ + "prompts", + "negPrompt", + "commonPrompt" + ] +} \ No newline at end of file diff --git a/iz_helpers/run.py b/iz_helpers/run.py index 3a8d97e..0a9789a 100644 --- a/iz_helpers/run.py +++ b/iz_helpers/run.py @@ -16,6 +16,7 @@ from .video import write_video def create_zoom( + common_prompt, prompts_array, negative_prompt, num_outpainting_steps, @@ -46,6 +47,7 @@ def create_zoom( for i in range(batchcount): print(f"Batch {i+1}/{batchcount}") result = create_zoom_single( + common_prompt, prompts_array, negative_prompt, num_outpainting_steps, @@ -76,6 +78,7 @@ def create_zoom( def create_zoom_single( + common_prompt, prompts_array, negative_prompt, num_outpainting_steps, @@ -139,8 +142,9 @@ def create_zoom_single( "infzoom_txt2img_model", progress, "Loading Model for txt2img: " ) + pr = prompts[min(k for k in prompts.keys() if k >= 0)] processed, newseed = renderTxt2Img( - prompts[min(k for k in prompts.keys() if k >= 0)], + f"{common_prompt}\n{pr}" if common_prompt else pr, negative_prompt, sampler, num_inference_steps, @@ -203,8 +207,9 @@ def create_zoom_single( ) print("using Custom Exit Image") else: + pr = prompts[max(k for k in prompts.keys() if k <= i)] processed, newseed = renderImg2Img( - prompts[max(k for k in prompts.keys() if k <= i)], + f"{common_prompt}\n{pr}" if common_prompt else pr, negative_prompt, sampler, num_inference_steps, diff --git a/iz_helpers/static_variables.py b/iz_helpers/static_variables.py index ac25cb1..efa83dd 100644 --- a/iz_helpers/static_variables.py +++ b/iz_helpers/static_variables.py @@ -5,20 +5,18 @@ import modules.sd_samplers default_prompt = """ { "prompts":{ - "headers":["outpaint steps","prompt"], + "headers":["outpaint steps","prompt","img"], "data":[ - [0,"Huge spectacular Waterfall in a dense tropical forest,epic perspective,(vegetation overgrowth:1.3)(intricate, ornamentation:1.1),(baroque:1.1), fantasy, (realistic:1) digital painting , (magical,mystical:1.2) , (wide angle shot:1.4), (landscape composed:1.2)(medieval:1.1), divine,cinematic,(tropical forest:1.4),(river:1.3)mythology,india, volumetric lighting, Hindu ,epic, Alex Horley Wenjun Lin greg rutkowski Ruan Jia (Wayne Barlowe:1.2) "] + [0,"Huge spectacular Waterfall in a dense tropical forest,epic perspective,(vegetation overgrowth:1.3)(intricate, ornamentation:1.1),(baroque:1.1), fantasy, (realistic:1) digital painting , (magical,mystical:1.2) , (wide angle shot:1.4), (landscape composed:1.2)(medieval:1.1), divine,cinematic,(tropical forest:1.4),(river:1.3)mythology,india, volumetric lighting, Hindu ,epic"] ] }, - "negPrompt":"frames, borderline, text, character, duplicate, error, out of frame, watermark, low quality, ugly, deformed, blur bad-artist" + "negPrompt":"frames, border, edges, borderline, text, character, duplicate, error, out of frame, watermark, low quality, ugly, deformed, blur bad-artist", + "commonPrompt":"style by Alex Horley Wenjun Lin greg rutkowski Ruan Jia (Wayne Barlowe:1.2), " } """ -available_samplers = [ - s.name for s in modules.sd_samplers.samplers if "UniPc" not in s.name -] empty_prompt = ( - '{"prompts":{"data":[],"headers":["outpaint steps","prompt"]},"negPrompt":""}' + '{"prompts":{"data":[],"headers":["outpaint steps","prompt"]},"negPrompt":"", commonPrompt:""}' ) invalid_prompt = { @@ -27,7 +25,13 @@ invalid_prompt = { "headers": ["outpaint steps", "prompt"], }, "negPrompt": "Invalid prompt-json", + "commonPrompt": "Invalid prompt" } + +available_samplers = [ + s.name for s in modules.sd_samplers.samplers if "UniPc" not in s.name +] + current_script_dir = scripts.basedir().split(os.sep)[ -2: ] # contains install and our extension foldername diff --git a/iz_helpers/ui.py b/iz_helpers/ui.py index 9729631..4fc3ab5 100644 --- a/iz_helpers/ui.py +++ b/iz_helpers/ui.py @@ -49,6 +49,10 @@ def on_ui_tabs(): except Exception: jpr = invalid_prompt + main_common_prompt = gr.Textbox( + value=jpr["commonPrompt"], label="Common Prompt" + ) + main_prompts = gr.Dataframe( type="array", headers=["outpaint step", "prompt"], @@ -79,7 +83,7 @@ def on_ui_tabs(): exportPrompts_button.click( None, _js="exportPrompts", - inputs=[main_prompts, main_negative_prompt], + inputs=[main_common_prompt, main_prompts, main_negative_prompt], outputs=None, ) importPrompts_button.upload( @@ -97,7 +101,7 @@ def on_ui_tabs(): clearPrompts_button.click( fn=clearPrompts, inputs=[], - outputs=[main_prompts, main_negative_prompt], + outputs=[main_prompts, main_negative_prompt, main_common_prompt], ) with gr.Row(): seed = gr.Number( @@ -237,6 +241,7 @@ Our best experience and trade-off is the R-ERSGAn4x upscaler. generate_btn.click( fn=wrap_gradio_gpu_call(create_zoom, extra_outputs=[None, "", ""]), inputs=[ + main_common_prompt, main_prompts, main_negative_prompt, main_outpaint_steps, diff --git a/javascript/infinite-zoom.js b/javascript/infinite-zoom.js index 8f7d546..0a41d0c 100644 --- a/javascript/infinite-zoom.js +++ b/javascript/infinite-zoom.js @@ -1,7 +1,7 @@ // Function to download data to a file -function exportPrompts(p, np, filename = "infinite-zoom-prompts.json") { +function exportPrompts(cp,p, np, filename = "infinite-zoom-prompts.json") { - let J = { prompts: p, negPrompt: np } + let J = { prompts: p, negPrompt: np, commonPrompt: cp } var file = new Blob([JSON.stringify(J)], { type: "text/csv" }); if (window.navigator.msSaveOrOpenBlob) // IE10+