Skip to content

Commit

Permalink
update element ids
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Mandic <[email protected]>
  • Loading branch information
vladmandic committed Jan 16, 2025
1 parent 6b225d0 commit 27e087e
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 42 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- send-to image transfer
- sana vae tiling
- increase gallery timeouts
- update ui element ids

## Update for 2025-01-15

Expand Down
2 changes: 1 addition & 1 deletion extensions-builtin/sdnext-modernui
2 changes: 1 addition & 1 deletion javascript/aspectRatioOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function dimensionChange(e, is_width, is_height) {
if (tabIndex === 0) targetElement = gradioApp().querySelector('#img2img_image div[data-testid=image] img'); // img2img
else if (tabIndex === 1) targetElement = gradioApp().querySelector('#img2img_sketch div[data-testid=image] img'); // Sketch
else if (tabIndex === 2) targetElement = gradioApp().querySelector('#img2maskimg div[data-testid=image] img'); // Inpaint
else if (tabIndex === 3) targetElement = gradioApp().querySelector('#inpaint_sketch div[data-testid=image] img'); // Inpaint sketch
else if (tabIndex === 3) targetElement = gradioApp().querySelector('#composite div[data-testid=image] img'); // Inpaint sketch

if (targetElement) {
let arPreviewRect = gradioApp().querySelector('#imageARPreview');
Expand Down
6 changes: 0 additions & 6 deletions javascript/sdnext.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { margin-left
.gradio-image { min-height: fit-content; }
.gradio-image img { object-fit: contain; }
*/
/*
.gradio-image { min-height: 200px !important; }
.image-container { height: unset !important; }
.control-image { height: unset !important; }
#img2img_sketch, #img2maskimg, #inpaint_sketch { overflow: overlay !important; resize: auto; background: var(--panel-background-fill); z-index: 5; }
*/

/* color elements */
.gradio-dropdown, .block.gradio-slider, .block.gradio-checkbox, .block.gradio-textbox, .block.gradio-radio, .block.gradio-checkboxgroup, .block.gradio-number, .block.gradio-colorpicker { border-width: 0 !important; box-shadow: none !important;}
Expand Down
4 changes: 2 additions & 2 deletions modules/generation_parameters_copypaste.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ def create_buttons(tabs_list):
return buttons


def bind_buttons(buttons, send_image, send_generate_info):
def bind_buttons(buttons, image_component, send_generate_info):
"""old function for backwards compatibility; do not use this, use register_paste_params_button"""
for tabname, button in buttons.items():
source_text_component = send_generate_info if isinstance(send_generate_info, gr.components.Component) else None
source_tabname = send_generate_info if isinstance(send_generate_info, str) else None
bindings = ParamBinding(paste_button=button, tabname=tabname, source_text_component=source_text_component, source_image_component=send_image, source_tabname=source_tabname)
bindings = ParamBinding(paste_button=button, tabname=tabname, source_text_component=source_text_component, source_image_component=image_component, source_tabname=source_tabname)
register_paste_params_button(bindings)


Expand Down
2 changes: 1 addition & 1 deletion modules/ui_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def create_ui(_blocks: gr.Blocks=None):
video_skip_frames = gr.Slider(minimum=0, maximum=100, step=1, label='Skip input frames', value=0, elem_id="control_video_skip_frames")
with gr.Row():
from modules.ui_sections import create_video_inputs
video_type, video_duration, video_loop, video_pad, video_interpolate = create_video_inputs()
video_type, video_duration, video_loop, video_pad, video_interpolate = create_video_inputs(tab='control')

enable_hr, hr_sampler_index, hr_denoising_strength, hr_resize_mode, hr_resize_context, hr_upscaler, hr_force, hr_second_pass_steps, hr_scale, hr_resize_x, hr_resize_y, refiner_steps, refiner_start, refiner_prompt, refiner_negative = ui_sections.create_hires_inputs('control')
detailer_enabled, detailer_prompt, detailer_negative, detailer_steps, detailer_strength = shared.yolo.ui('control')
Expand Down
12 changes: 6 additions & 6 deletions modules/ui_sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def create_seed_inputs(tab, reuse_visible=True):
return seed, reuse_seed, subseed, reuse_subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w


def create_video_inputs():
def create_video_inputs(tab:str):
def video_type_change(video_type):
return [
gr.update(visible=video_type != 'None'),
Expand All @@ -141,12 +141,12 @@ def video_type_change(video_type):
]
with gr.Column():
video_codecs = ['None', 'GIF', 'PNG', 'MP4/MP4V', 'MP4/AVC1', 'MP4/JVT3', 'MKV/H264', 'AVI/DIVX', 'AVI/RGBA', 'MJPEG/MJPG', 'MPG/MPG1', 'AVR/AVR1']
video_type = gr.Dropdown(label='Video type', choices=video_codecs, value='None')
video_type = gr.Dropdown(label='Video type', choices=video_codecs, value='None', elem_id=f"{tab}_video_type")
with gr.Column():
video_duration = gr.Slider(label='Duration', minimum=0.25, maximum=300, step=0.25, value=2, visible=False)
video_loop = gr.Checkbox(label='Loop', value=True, visible=False, elem_id="control_video_loop")
video_pad = gr.Slider(label='Pad frames', minimum=0, maximum=24, step=1, value=1, visible=False)
video_interpolate = gr.Slider(label='Interpolate frames', minimum=0, maximum=24, step=1, value=0, visible=False)
video_duration = gr.Slider(label='Duration', minimum=0.25, maximum=300, step=0.25, value=2, visible=False, elem_id=f"{tab}_video_duration")
video_loop = gr.Checkbox(label='Loop', value=True, visible=False, elem_id=f"{tab}_video_loop")
video_pad = gr.Slider(label='Pad frames', minimum=0, maximum=24, step=1, value=1, visible=False, elem_id=f"{tab}_video_pad")
video_interpolate = gr.Slider(label='Interpolate frames', minimum=0, maximum=24, step=1, value=0, visible=False, elem_id=f"{tab}_video_interpolate")
video_type.change(fn=video_type_change, inputs=[video_type], outputs=[video_duration, video_loop, video_pad, video_interpolate])
return video_type, video_duration, video_loop, video_pad, video_interpolate

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"url": "git+https://github.com/vladmandic/automatic.git"
},
"scripts": {
"venv": "source venv/bin/activate",
"start": "python launch.py --debug",
"ruff": "ruff check",
"venv": ". venv/bin/activate",
"start": "npm run venv; python launch.py --debug",
"ruff": ". venv/bin/activate && ruff check",
"eslint": "eslint javascript/ extensions-builtin/sdnext-modernui/javascript/",
"pylint": "pylint *.py modules/ extensions-builtin/",
"lint": "npm run eslint; npm run ruff; npm run pylint",
"pylint": ". venv/bin/activate && pylint *.py modules/ extensions-builtin/ | grep -v '^*'",
"lint": "npm run eslint && npm run ruff && npm run pylint",
"test": "cli/test.sh"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions scripts/allegrovideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def show(self, is_img2img):
return not is_img2img if shared.native else False

# return signature is array of gradio components
def ui(self, _is_img2img):
def ui(self, is_img2img):
with gr.Row():
gr.HTML('<a href="https://huggingface.co/rhymes-ai/Allegro">&nbsp Allegro Video</a><br>')
with gr.Row():
Expand All @@ -46,7 +46,7 @@ def ui(self, _is_img2img):
override_scheduler = gr.Checkbox(label='Override scheduler', value=True)
with gr.Row():
from modules.ui_sections import create_video_inputs
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs()
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs(tab='img2img' if is_img2img else 'txt2img')
return [num_frames, override_scheduler, video_type, duration, gif_loop, mp4_pad, mp4_interpolate]

def run(self, p: processing.StableDiffusionProcessing, num_frames, override_scheduler, video_type, duration, gif_loop, mp4_pad, mp4_interpolate): # pylint: disable=arguments-differ, unused-argument
Expand Down
4 changes: 2 additions & 2 deletions scripts/animatediff.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def show(self, is_img2img):
return not is_img2img


def ui(self, _is_img2img):
def ui(self, is_img2img):
with gr.Row():
gr.HTML("<span>&nbsp AnimateDiff</span><br>")
with gr.Row():
Expand All @@ -221,7 +221,7 @@ def ui(self, _is_img2img):
fi_temporal = gr.Slider(label='Temporal frequency', minimum=0.0, maximum=1.0, step=0.05, value=0.25)
with gr.Row():
from modules.ui_sections import create_video_inputs
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs()
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs(tab='img2img' if is_img2img else 'txt2img')
return [adapter_index, frames, lora_index, strength, latent_mode, video_type, duration, gif_loop, mp4_pad, mp4_interpolate, override_scheduler, fi_method, fi_iters, fi_order, fi_spatial, fi_temporal]

def run(self, p: processing.StableDiffusionProcessing, adapter_index, frames, lora_index, strength, latent_mode, video_type, duration, gif_loop, mp4_pad, mp4_interpolate, override_scheduler, fi_method, fi_iters, fi_order, fi_spatial, fi_temporal): # pylint: disable=arguments-differ, unused-argument
Expand Down
4 changes: 2 additions & 2 deletions scripts/cogvideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def show(self, is_img2img):
return shared.native


def ui(self, _is_img2img):
def ui(self, is_img2img):
with gr.Row():
gr.HTML("<span>&nbsp CogVideoX</span><br>")
with gr.Row():
Expand All @@ -46,7 +46,7 @@ def ui(self, _is_img2img):
video = gr.Video(value=None, label='Video', source='upload', width=256, height=256)
with gr.Row():
from modules.ui_sections import create_video_inputs
video_type, duration, loop, pad, interpolate = create_video_inputs()
video_type, duration, loop, pad, interpolate = create_video_inputs(tab='img2img' if is_img2img else 'txt2img')
return [model, sampler, frames, guidance, offload, override, video_type, duration, loop, pad, interpolate, image, video]

def load(self, model):
Expand Down
4 changes: 2 additions & 2 deletions scripts/hunyuanvideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def show(self, is_img2img):
return not is_img2img if shared.native else False

# return signature is array of gradio components
def ui(self, _is_img2img):
def ui(self, is_img2img):
with gr.Row():
gr.HTML('<a href="https://huggingface.co/tencent/HunyuanVideo">&nbsp Hunyuan Video</a><br>')
with gr.Row():
Expand All @@ -72,7 +72,7 @@ def ui(self, _is_img2img):
template = gr.TextArea(label='Prompt processor', lines=3, value=default_template)
with gr.Row():
from modules.ui_sections import create_video_inputs
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs()
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs(tab='img2img' if is_img2img else 'txt2img')
return [num_frames, tile_frames, override_scheduler, template, video_type, duration, gif_loop, mp4_pad, mp4_interpolate]

def run(self, p: processing.StableDiffusionProcessing, num_frames, tile_frames, override_scheduler, template, video_type, duration, gif_loop, mp4_pad, mp4_interpolate): # pylint: disable=arguments-differ, unused-argument
Expand Down
4 changes: 2 additions & 2 deletions scripts/image2video.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def show(self, is_img2img):
# return False

# return signature is array of gradio components
def ui(self, _is_img2img):
def ui(self, is_img2img):
def model_change(model_name):
model = next(m for m in MODELS if m['name'] == model_name)
return gr.update(value=model['info']), gr.update(visible=model_name == 'PIA'), gr.update(visible=model_name == 'VGen')
Expand All @@ -47,7 +47,7 @@ def model_change(model_name):
vg_fps = gr.Slider(label='Change rate', minimum=0.1, maximum=1.0, step=0.1, value=0.5)
with gr.Row():
from modules.ui_sections import create_video_inputs
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs()
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs(tab='img2img' if is_img2img else 'txt2img')
model_name.change(fn=model_change, inputs=[model_name], outputs=[model_info, fi_accordion, vgen_accordion])
return [model_name, num_frames, video_type, duration, gif_loop, mp4_pad, mp4_interpolate, fi_method, fi_iters, fi_order, fi_spatial, fi_temporal, vg_chunks, vg_fps]

Expand Down
4 changes: 2 additions & 2 deletions scripts/ltxvideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def show(self, is_img2img):
return shared.native

# return signature is array of gradio components
def ui(self, _is_img2img):
def ui(self, is_img2img):
def model_change(model):
return gr.update(visible=model == 'custom')

Expand All @@ -84,7 +84,7 @@ def model_change(model):
model_custom = gr.Textbox(value='', label='Path to model file', visible=False)
with gr.Row():
from modules.ui_sections import create_video_inputs
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs()
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs(tab='img2img' if is_img2img else 'txt2img')
model.change(fn=model_change, inputs=[model], outputs=[model_custom])
return [model, model_custom, decode, sampler, num_frames, video_type, duration, gif_loop, mp4_pad, mp4_interpolate, teacache_enable, teacache_threshold]

Expand Down
4 changes: 2 additions & 2 deletions scripts/mochivideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ def show(self, is_img2img):
return not is_img2img if shared.native else False

# return signature is array of gradio components
def ui(self, _is_img2img):
def ui(self, is_img2img):
with gr.Row():
gr.HTML('<a href="https://huggingface.co/genmo/mochi-1-preview">&nbsp Mochi.1 Video</a><br>')
with gr.Row():
num_frames = gr.Slider(label='Frames', minimum=9, maximum=257, step=1, value=45)
with gr.Row():
from modules.ui_sections import create_video_inputs
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs()
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs(tab='img2img' if is_img2img else 'txt2img')
return [num_frames, video_type, duration, gif_loop, mp4_pad, mp4_interpolate]

def run(self, p: processing.StableDiffusionProcessing, num_frames, video_type, duration, gif_loop, mp4_pad, mp4_interpolate): # pylint: disable=arguments-differ, unused-argument
Expand Down
4 changes: 2 additions & 2 deletions scripts/stablevideodiffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def show(self, is_img2img):
return is_img2img if shared.native else False

# return signature is array of gradio components
def ui(self, _is_img2img):
def ui(self, is_img2img):
with gr.Row():
gr.HTML('<a href="https://huggingface.co/stabilityai/stable-video-diffusion-img2vid">&nbsp Stable Video Diffusion</a><br>')
with gr.Row():
Expand All @@ -39,7 +39,7 @@ def ui(self, _is_img2img):
override_resolution = gr.Checkbox(label='Override resolution', value=True)
with gr.Row():
from modules.ui_sections import create_video_inputs
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs()
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs(tab='img2img' if is_img2img else 'txt2img')
return [model, num_frames, override_resolution, min_guidance_scale, max_guidance_scale, decode_chunk_size, motion_bucket_id, noise_aug_strength, video_type, duration, gif_loop, mp4_pad, mp4_interpolate]

def run(self, p: processing.StableDiffusionProcessing, model, num_frames, override_resolution, min_guidance_scale, max_guidance_scale, decode_chunk_size, motion_bucket_id, noise_aug_strength, video_type, duration, gif_loop, mp4_pad, mp4_interpolate): # pylint: disable=arguments-differ, unused-argument
Expand Down
4 changes: 2 additions & 2 deletions scripts/text2video.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def show(self, is_img2img):
return not is_img2img if shared.native else False

# return signature is array of gradio components
def ui(self, _is_img2img):
def ui(self, is_img2img):

def model_info_change(model_name):
if model_name == 'None':
Expand All @@ -50,7 +50,7 @@ def model_info_change(model_name):
num_frames = gr.Slider(label='Frames', minimum=1, maximum=50, step=1, value=0)
with gr.Row():
from modules.ui_sections import create_video_inputs
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs()
video_type, duration, gif_loop, mp4_pad, mp4_interpolate = create_video_inputs(tab='img2img' if is_img2img else 'txt2img')
return [model_name, use_default, num_frames, video_type, duration, gif_loop, mp4_pad, mp4_interpolate]

def run(self, p: processing.StableDiffusionProcessing, model_name, use_default, num_frames, video_type, duration, gif_loop, mp4_pad, mp4_interpolate): # pylint: disable=arguments-differ, unused-argument
Expand Down
2 changes: 1 addition & 1 deletion scripts/xyz_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def ui(self, is_img2img):
create_video = gr.Checkbox(label='Create video', value=False, elem_id=self.elem_id("xyz_create_video"), container=False)

with gr.Row(visible=False) as ui_video:
video_type, video_duration, video_loop, video_pad, video_interpolate = create_video_inputs()
video_type, video_duration, video_loop, video_pad, video_interpolate = create_video_inputs(tab='img2img' if is_img2img else 'txt2img')
create_video.change(fn=lambda x: gr.update(visible=x), inputs=[create_video], outputs=[ui_video])

with gr.Row():
Expand Down
2 changes: 1 addition & 1 deletion scripts/xyz_grid_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def ui(self, is_img2img):
create_video = gr.Checkbox(label='Create video', value=False, elem_id=self.elem_id("xyz_create_video"), container=False)

with gr.Row(visible=False) as ui_video:
video_type, video_duration, video_loop, video_pad, video_interpolate = create_video_inputs()
video_type, video_duration, video_loop, video_pad, video_interpolate = create_video_inputs(tab='img2img' if is_img2img else 'txt2img')
create_video.change(fn=lambda x: gr.update(visible=x), inputs=[create_video], outputs=[ui_video])

with gr.Row():
Expand Down

0 comments on commit 27e087e

Please sign in to comment.