mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
continuing on video tab
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
+10
-4
@@ -38,7 +38,7 @@ def run_video(*args):
|
||||
if selected and 'Hunyuan' in selected.name:
|
||||
return hunyuan.generate(*args)
|
||||
shared.log.error(f'Video model not found: args={args}')
|
||||
return [], '', '', f'Video model not found: engine={engine} model={model}'
|
||||
return [], None, '', '', f'Video model not found: engine={engine} model={model}'
|
||||
|
||||
|
||||
def create_ui():
|
||||
@@ -85,8 +85,14 @@ def create_ui():
|
||||
video_type, video_duration, video_loop, video_pad, video_interpolate = ui_sections.create_video_inputs(tab='video')
|
||||
override_settings = ui_common.create_override_inputs('video')
|
||||
|
||||
# output panel with gallery
|
||||
gallery, gen_info, html_info, _html_info_formatted, html_log = ui_common.create_output_panel("video", prompt=prompt, preview=False, transfer=False, scale=2)
|
||||
# output panel with gallery and video tabs
|
||||
with gr.Column(elem_id='video-output-column', scale=3) as _column_output:
|
||||
with gr.Tabs(elem_classes=['video-output-tabs'], elem_id='video-output-tabs'):
|
||||
with gr.Tab('Frames', id='out-gallery'):
|
||||
gallery, gen_info, html_info, _html_info_formatted, html_log = ui_common.create_output_panel("video", prompt=prompt, preview=False, transfer=False, scale=2)
|
||||
with gr.Tab('Video', id='out-video'):
|
||||
video = gr.Video(label="Output", show_label=False, elem_id='control_output_video', elem_classes=['control-image'])
|
||||
|
||||
# connect reuse seed button
|
||||
ui_common.connect_reuse_seed(seed, reuse_seed, gen_info, is_subseed=False)
|
||||
random_seed.click(fn=lambda: -1, show_progress=False, inputs=[], outputs=[seed])
|
||||
@@ -132,7 +138,7 @@ def create_ui():
|
||||
fn=call_queue.wrap_gradio_gpu_call(run_video, extra_outputs=[None, '', ''], name='Video'),
|
||||
_js="submit_video",
|
||||
inputs=video_args,
|
||||
outputs=[gallery, gen_info, html_info, html_log],
|
||||
outputs=[gallery, video, gen_info, html_info, html_log],
|
||||
show_progress=False,
|
||||
)
|
||||
prompt.submit(**video_dict)
|
||||
|
||||
@@ -166,14 +166,14 @@ def generate(*args, **kwargs):
|
||||
task_id, ui_state, engine, model, prompt, negative, styles, width, height, frames, steps, sampler_index, sampler_shift, seed, guidance_scale, guidance_true, init_image, vae_type, vae_tile_frames, save_frames, video_type, video_duration, video_loop, video_pad, video_interpolate, override_settings = args
|
||||
if engine is None or model is None or engine == 'None' or model == 'None':
|
||||
shared.log.error('Video: model not selected')
|
||||
return [], '', '', 'Video model not selected'
|
||||
return [], None, '', '', 'Video model not selected'
|
||||
if not shared.sd_loaded or 'Hunyuan' not in shared.sd_model.__class__.__name__:
|
||||
found = [model.name for model in models.get(engine, [])]
|
||||
selected = [m for m in models[engine] if m.name == model][0] if len(found) > 0 else None
|
||||
load(selected)
|
||||
if not shared.sd_loaded or 'Hunyuan' not in shared.sd_model.__class__.__name__:
|
||||
shared.log.error('Video: model not loaded')
|
||||
return [], '', '', 'Video model not loaded'
|
||||
return [], None, '', '', 'Video model not loaded'
|
||||
debug(f'Video generate: task={task_id} args={args} kwargs={kwargs}')
|
||||
|
||||
p = processing.StableDiffusionProcessingVideo(
|
||||
@@ -201,7 +201,7 @@ def generate(*args, **kwargs):
|
||||
if 'I2V' in model:
|
||||
if init_image is None:
|
||||
shared.log.error('Video: init image not set')
|
||||
return [], '', '', 'Error: init image not set'
|
||||
return [], None, '', '', 'Error: init image not set'
|
||||
p.task_args['image'] = init_image
|
||||
|
||||
shared.sd_model = sd_models.apply_balanced_offload(shared.sd_model)
|
||||
@@ -251,10 +251,12 @@ def generate(*args, **kwargs):
|
||||
|
||||
p.close()
|
||||
if processed is None or len(processed.images) == 0:
|
||||
return [], '', '', 'Error: processing failed'
|
||||
return [], None, '', '', 'Error: processing failed'
|
||||
shared.log.info(f'Video: frames={len(processed.images)} time={t1-t0:.2f}')
|
||||
if video_type != 'None':
|
||||
images.save_video(p, filename=None, images=processed.images, video_type=video_type, duration=video_duration, loop=video_loop, pad=video_pad, interpolate=video_interpolate)
|
||||
video_file = images.save_video(p, filename=None, images=processed.images, video_type=video_type, duration=video_duration, loop=video_loop, pad=video_pad, interpolate=video_interpolate)
|
||||
else:
|
||||
video_file = None
|
||||
|
||||
generation_info_js = processed.js() if processed is not None else ''
|
||||
return processed.images, generation_info_js, processed.info, ui_common.plaintext_to_html(processed.comments)
|
||||
return processed.images, video_file, generation_info_js, processed.info, ui_common.plaintext_to_html(processed.comments)
|
||||
|
||||
Reference in New Issue
Block a user