MCPcopy Create free account
hub / github.com/DenOfEquity/ersatzForge / create_ui

Function create_ui

modules/ui_postprocessing.py:7–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5
6def create_ui():
7 dummy_component = gr.Textbox(visible=False)
8 tab_index = gr.State(value=0)
9
10 with ResizeHandleRow(equal_height=False, variant="compact"):
11 with gr.Column(variant="compact"):
12 with gr.Tabs(elem_id="mode_extras"):
13 with gr.TabItem("Single Image", id="single_image", elem_id="extras_single_tab") as tab_single:
14 extras_image = gr.Image(label="Source", interactive=True, type="pil", elem_id="extras_image", image_mode="RGBA", height="60vh")
15
16 with gr.TabItem("Batch Process", id="batch_process", elem_id="extras_batch_process_tab") as tab_batch:
17 image_batch = gr.Files(label="Batch Process", interactive=True, elem_id="extras_image_batch")
18
19 with gr.TabItem("Batch from Directory", id="batch_from_directory", elem_id="extras_batch_directory_tab") as tab_batch_dir:
20 extras_batch_input_dir = gr.Textbox(label="Input directory", **shared.hide_dirs, placeholder="A directory on the same machine where the server is running.", elem_id="extras_batch_input_dir")
21 extras_batch_output_dir = gr.Textbox(label="Output directory", **shared.hide_dirs, placeholder="Leave blank to save images to the default path.", elem_id="extras_batch_output_dir")
22 show_extras_results = gr.Checkbox(label="Show result images", value=True, elem_id="extras_show_extras_results")
23
24 with gr.TabItem("Video", id="video", elem_id="extras_video") as tab_video:
25 gr.Markdown("## combine frames to video")
26 with gr.Row():
27 input_frames = gr.Textbox(label="Input frames", placeholder="A directory of images on the same machine where the server is running.", max_lines=1)
28 clear_combine = ToolButton("\U0001f5d1\ufe0f", elem_id="extras_video_clear_combine", tooltip="Clear 'combine' settings")
29 with gr.Row():
30 output_video = gr.Textbox(label="Output video filename", placeholder="Blank: default name", max_lines=1)
31 output_fps = gr.Number(label="Output fps", value=0, minimum=0, scale=0)
32 interpolate = gr.Number(label="Interpolation", value=1, minimum=1, step=1, scale=0)
33 gr.Markdown("### if *Input video file* is provided, it will be used for **audio** and, if *Output fps* is zero, for **fps**.")
34 gr.Markdown("## split video to frames")
35 with gr.Row():
36 input_video = gr.Textbox(label="Input video file", placeholder="A video on the same machine where the server is running.", max_lines=1)
37 with gr.Row():
38 output_frames = gr.Textbox(label="Output directory", placeholder="Blank: directory of input.", max_lines=1)
39 clear_split = ToolButton("\U0001f5d1\ufe0f", elem_id="extras_video_clear_split", tooltip="Clear 'split' settings")
40 gr.Markdown("---")
41 gr.Markdown("### further post-processing is ignored - switch to 'Batch from Directory'")
42
43 def clearI():
44 return "", ""
45 def clearO():
46 return "", 0, "", 1
47
48 clear_split.click(fn=clearI, inputs=None, outputs=[input_video, output_frames], show_progress="hidden")
49 clear_combine.click(fn=clearO, inputs=None, outputs=[input_frames, output_fps, output_video, interpolate], show_progress="hidden")
50
51
52 script_inputs = scripts.scripts_postproc.setup_ui()
53
54 toprow = ui_toprow.Toprow(id_part="extras")
55 output_panel = ui_common.create_output_panel("extras", shared.opts.outdir_extras_samples, toprow)
56 submit = toprow.submit
57
58 tab_single.select(fn=lambda: 0, inputs=None, outputs=[tab_index])
59 tab_batch.select(fn=lambda: 1, inputs=None, outputs=[tab_index])
60 tab_batch_dir.select(fn=lambda: 2, inputs=None, outputs=[tab_index])
61 tab_video.select(fn=lambda: 3, inputs=None, outputs=[tab_index])
62
63 submit_click_inputs = [
64 dummy_component,

Callers

nothing calls this directly

Calls 3

ResizeHandleRowClass · 0.90
ToolButtonClass · 0.90
setup_uiMethod · 0.45

Tested by

no test coverage detected