Merge pull request #12 from GeorgLegato/main
fix issue #11, 'infinite-zoom' settings added to webui setting including 'select size' and 'output folder'pull/16/head
commit
6e5a4da82a
|
|
@ -7,6 +7,7 @@ sys.path.extend(basedir + "/extensions/infinite-zoom-automatic1111-webui/")
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
import math
|
||||||
|
|
||||||
from iz_helpers import shrink_and_paste_on_blank, write_video
|
from iz_helpers import shrink_and_paste_on_blank, write_video
|
||||||
from webui import wrap_gradio_gpu_call
|
from webui import wrap_gradio_gpu_call
|
||||||
|
|
@ -20,7 +21,6 @@ from modules.processing import (
|
||||||
|
|
||||||
from modules.ui import create_output_panel, plaintext_to_html
|
from modules.ui import create_output_panel, plaintext_to_html
|
||||||
|
|
||||||
output_path = basedir + "/extensions/infinite-zoom-automatic1111-webui/out"
|
|
||||||
default_prompt = "A psychedelic jungle with trees that have glowing, fractal-like patterns, Simon stalenhag poster 1920s style, street level view, hyper futuristic, 8k resolution, hyper realistic"
|
default_prompt = "A psychedelic jungle with trees that have glowing, fractal-like patterns, Simon stalenhag poster 1920s style, street level view, hyper futuristic, 8k resolution, hyper realistic"
|
||||||
default_negative_prompt = "frames, borderline, text, character, duplicate, error, out of frame, watermark, low quality, ugly, deformed, blur"
|
default_negative_prompt = "frames, borderline, text, character, duplicate, error, out of frame, watermark, low quality, ugly, deformed, blur"
|
||||||
|
|
||||||
|
|
@ -106,6 +106,7 @@ def create_zoom(
|
||||||
inpainting_full_res,
|
inpainting_full_res,
|
||||||
inpainting_padding,
|
inpainting_padding,
|
||||||
zoom_speed,
|
zoom_speed,
|
||||||
|
outputsize
|
||||||
):
|
):
|
||||||
prompts = {}
|
prompts = {}
|
||||||
for x in prompts_array:
|
for x in prompts_array:
|
||||||
|
|
@ -117,8 +118,9 @@ def create_zoom(
|
||||||
pass
|
pass
|
||||||
assert len(prompts_array) > 0, "prompts is empty"
|
assert len(prompts_array) > 0, "prompts is empty"
|
||||||
|
|
||||||
width = 512
|
width = outputsize
|
||||||
height = 512
|
height = outputsize
|
||||||
|
|
||||||
current_image = Image.new(mode="RGBA", size=(height, width))
|
current_image = Image.new(mode="RGBA", size=(height, width))
|
||||||
mask_image = np.array(current_image)[:, :, 3]
|
mask_image = np.array(current_image)[:, :, 3]
|
||||||
mask_image = Image.fromarray(255 - mask_image).convert("RGB")
|
mask_image = Image.fromarray(255 - mask_image).convert("RGB")
|
||||||
|
|
@ -139,7 +141,8 @@ def create_zoom(
|
||||||
height,
|
height,
|
||||||
)
|
)
|
||||||
current_image = processed.images[0]
|
current_image = processed.images[0]
|
||||||
mask_width = 128
|
|
||||||
|
mask_width = math.trunc(width/4) # was initially 512px => 128px
|
||||||
num_interpol_frames = round(video_frame_rate * zoom_speed)
|
num_interpol_frames = round(video_frame_rate * zoom_speed)
|
||||||
|
|
||||||
all_frames = []
|
all_frames = []
|
||||||
|
|
@ -216,7 +219,8 @@ def create_zoom(
|
||||||
all_frames.append(current_image)
|
all_frames.append(current_image)
|
||||||
|
|
||||||
video_file_name = "infinite_zoom_" + str(int(time.time())) + ".mp4"
|
video_file_name = "infinite_zoom_" + str(int(time.time())) + ".mp4"
|
||||||
save_path = os.path.join(output_path, "videos")
|
output_path = shared.opts.data.get("infzoom_outpath",shared.opts.data.get("outdir_img2img_samples"))
|
||||||
|
save_path = os.path.join(output_path, shared.opts.data.get("infzoom_outSUBpath","infinite-zooms"))
|
||||||
if not os.path.exists(save_path):
|
if not os.path.exists(save_path):
|
||||||
os.makedirs(save_path)
|
os.makedirs(save_path)
|
||||||
out = os.path.join(save_path, video_file_name)
|
out = os.path.join(save_path, video_file_name)
|
||||||
|
|
@ -251,7 +255,9 @@ def on_ui_tabs():
|
||||||
interrupt = gr.Button(value="Interrupt", elem_id="interrupt_training")
|
interrupt = gr.Button(value="Interrupt", elem_id="interrupt_training")
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
with gr.Column(scale=1, variant="panel"):
|
with gr.Column(scale=1, variant="panel"):
|
||||||
|
|
||||||
with gr.Tab("Main"):
|
with gr.Tab("Main"):
|
||||||
|
outsize_slider = gr.Slider(minimum=512, maximum=2048,value=shared.opts.data.get("infzoom_outsize",512),step=8,label="Output size (square)")
|
||||||
outpaint_prompts = gr.Dataframe(
|
outpaint_prompts = gr.Dataframe(
|
||||||
type="array",
|
type="array",
|
||||||
headers=["outpaint steps", "prompt"],
|
headers=["outpaint steps", "prompt"],
|
||||||
|
|
@ -374,6 +380,7 @@ def on_ui_tabs():
|
||||||
inpainting_full_res,
|
inpainting_full_res,
|
||||||
inpainting_padding,
|
inpainting_padding,
|
||||||
zoom_speed_slider,
|
zoom_speed_slider,
|
||||||
|
outsize_slider
|
||||||
],
|
],
|
||||||
outputs=[output_video, out_image, generation_info, html_info, html_log],
|
outputs=[output_video, out_image, generation_info, html_info, html_log],
|
||||||
)
|
)
|
||||||
|
|
@ -384,5 +391,18 @@ def on_ui_tabs():
|
||||||
)
|
)
|
||||||
return [(infinite_zoom_interface, "Infinite Zoom", "iz_interface")]
|
return [(infinite_zoom_interface, "Infinite Zoom", "iz_interface")]
|
||||||
|
|
||||||
|
def on_ui_settings():
|
||||||
|
section = ('infinite-zoom', "Infinite Zoom")
|
||||||
|
|
||||||
|
shared.opts.add_option("infzoom_outpath", shared.OptionInfo(
|
||||||
|
"", "Path where to store your infinite video. Let empty to use img2img-output", gr.Textbox, {"interactive": True}, section=section))
|
||||||
|
|
||||||
|
shared.opts.add_option("infzoom_outSUBpath", shared.OptionInfo(
|
||||||
|
"infinite-zooms", "Which subfolder name to be created in the outpath. Default is 'infinite-zooms'", gr.Textbox, {"interactive": True}, section=section))
|
||||||
|
|
||||||
|
shared.opts.add_option("infzoom_outsize", shared.OptionInfo(
|
||||||
|
512, "Default size for X and Y of your video", gr.Slider, {"minimum": 512, "maximum": 2048, "step": 8}, section=section))
|
||||||
|
|
||||||
|
|
||||||
script_callbacks.on_ui_tabs(on_ui_tabs)
|
script_callbacks.on_ui_tabs(on_ui_tabs)
|
||||||
|
script_callbacks.on_ui_settings(on_ui_settings)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue