improve wrap_gradio_call

Signed-off-by: vladmandic <mandic00@live.com>
This commit is contained in:
vladmandic
2026-01-20 18:56:49 +01:00
parent a7b69cd805
commit 84ad7bf20b
4 changed files with 14 additions and 7 deletions
+6 -6
View File
@@ -37,7 +37,6 @@ def wrap_gradio_gpu_call(func, extra_outputs=None, name=None):
id_task = None
with get_lock():
progress.start_task(id_task)
res = [None, '', '', '']
try:
res = func(*args, **kwargs)
progress.record_results(id_task, res)
@@ -45,7 +44,8 @@ def wrap_gradio_gpu_call(func, extra_outputs=None, name=None):
shared.log.error(f"Exception: {e}")
shared.log.error(f"Arguments: args={str(args)[:10240]} kwargs={str(kwargs)[:10240]}")
errors.display(e, 'gradio call')
res[-1] = f"<div class='error'>{html.escape(str(e))}</div>"
res = extra_outputs or []
res.append(f"<div class='error'>{html.escape(str(e))}</div>")
finally:
progress.finish_task(id_task)
return res
@@ -70,7 +70,8 @@ def wrap_gradio_call(func, extra_outputs=None, add_stats=False, name=None):
if res is None:
msg = "No result returned from function"
shared.log.warning(msg)
res = [None, '', '', f"<div class='error'>{html.escape(msg)}</div>"]
res = extra_outputs_array or []
res.append(f"<div class='error'>{html.escape(msg)}</div>")
else:
res = list(res)
if shared.cmd_opts.profile:
@@ -78,9 +79,8 @@ def wrap_gradio_call(func, extra_outputs=None, add_stats=False, name=None):
errors.profile(pr, 'Wrap')
except Exception as e:
errors.display(e, 'gradio call')
if extra_outputs_array is None:
extra_outputs_array = [None, '']
res = extra_outputs_array + [f"<div class='error'>{html.escape(type(e).__name__+': '+str(e))}</div>"]
res = extra_outputs_array or []
res.append(f"<div class='error'>{html.escape(type(e).__name__+': '+str(e))}</div>")
shared.state.end(jobid)
if not add_stats:
return tuple(res)
+1
View File
@@ -11,6 +11,7 @@ debug = shared.log.trace if os.environ.get('SD_VIDEO_DEBUG', None) is not None e
def generate(*args, **kwargs):
task_id, ui_state, engine, model, prompt, negative, styles, width, height, frames, steps, sampler_index, sampler_shift, dynamic_shift, seed, guidance_scale, guidance_true, init_image, init_strength, last_image, vae_type, vae_tile_frames, mp4_fps, mp4_interpolate, mp4_codec, mp4_ext, mp4_opt, mp4_video, mp4_frames, mp4_sf, vlm_enhance, vlm_model, vlm_system_prompt, override_settings = args
if engine is None or model is None or engine == 'None' or model == 'None':
return video_utils.queue_err('model not selected')
# videojob = shared.state.begin('Video')
+1 -1
View File
@@ -190,7 +190,7 @@ def create_ui(prompt, negative, styles, overrides, init_image, init_strength, la
]
video_dict = dict(
fn=call_queue.wrap_gradio_gpu_call(video_run.generate, extra_outputs=[None, '', ''], name='Video'),
fn=call_queue.wrap_gradio_gpu_call(video_run.generate, extra_outputs=[gr.update(), gr.update(), gr.update(), gr.update()], name='Video'),
_js="submit_video",
inputs=state_inputs + video_inputs,
outputs=video_outputs,