Commit ·
8143bed
1
Parent(s): 1ada5a6
fix manual load queue
Browse files
wgp.py
CHANGED
|
@@ -756,6 +756,28 @@ def autoload_queue(state):
|
|
| 756 |
|
| 757 |
return dataframe_update, loaded_flag, state
|
| 758 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 759 |
|
| 760 |
def get_queue_table(queue):
|
| 761 |
data = []
|
|
@@ -3503,6 +3525,7 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
|
|
| 3503 |
js=trigger_zip_download_js
|
| 3504 |
)
|
| 3505 |
|
|
|
|
| 3506 |
load_queue_btn.upload(
|
| 3507 |
fn=load_queue_action,
|
| 3508 |
inputs=[load_queue_btn, state],
|
|
@@ -3511,6 +3534,28 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
|
|
| 3511 |
fn=lambda s: (gr.update(visible=bool(get_gen_info(s).get("queue",[]))), gr.Accordion(open=True)) if bool(get_gen_info(s).get("queue",[])) else (gr.update(visible=False), gr.update()),
|
| 3512 |
inputs=[state],
|
| 3513 |
outputs=[current_gen_column, queue_accordion]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3514 |
)
|
| 3515 |
|
| 3516 |
clear_queue_btn.click(
|
|
@@ -4139,28 +4184,6 @@ def create_demo():
|
|
| 4139 |
generate_about_tab()
|
| 4140 |
|
| 4141 |
should_start_flag = gr.State(False)
|
| 4142 |
-
def run_autoload_and_prepare_ui(current_state):
|
| 4143 |
-
df_update, loaded_flag, modified_state = autoload_queue(current_state)
|
| 4144 |
-
should_start_processing = loaded_flag
|
| 4145 |
-
accordion_update = gr.Accordion(open=True) if loaded_flag else gr.update()
|
| 4146 |
-
return df_update, gr.update(visible=loaded_flag), accordion_update, should_start_processing, modified_state
|
| 4147 |
-
|
| 4148 |
-
def start_processing_if_needed(should_start, current_state):
|
| 4149 |
-
if not isinstance(current_state, dict) or 'gen' not in current_state:
|
| 4150 |
-
yield "Error: Invalid state received before processing."
|
| 4151 |
-
return
|
| 4152 |
-
if should_start:
|
| 4153 |
-
yield from process_tasks(current_state)
|
| 4154 |
-
else:
|
| 4155 |
-
yield None
|
| 4156 |
-
|
| 4157 |
-
def finalize_generation_with_state(current_state):
|
| 4158 |
-
if not isinstance(current_state, dict) or 'gen' not in current_state:
|
| 4159 |
-
return gr.update(), gr.update(interactive=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False, value=""), gr.update(), current_state
|
| 4160 |
-
|
| 4161 |
-
gallery_update, abort_btn_update, gen_btn_update, add_queue_btn_update, current_gen_col_update, gen_info_update = finalize_generation(current_state)
|
| 4162 |
-
accordion_update = gr.Accordion(open=False) if len(get_gen_info(current_state).get("queue", [])) <= 1 else gr.update()
|
| 4163 |
-
return gallery_update, abort_btn_update, gen_btn_update, add_queue_btn_update, current_gen_col_update, gen_info_update, accordion_update, current_state
|
| 4164 |
|
| 4165 |
demo.load(
|
| 4166 |
fn=run_autoload_and_prepare_ui,
|
|
|
|
| 756 |
|
| 757 |
return dataframe_update, loaded_flag, state
|
| 758 |
|
| 759 |
+
def run_autoload_and_prepare_ui(current_state):
|
| 760 |
+
df_update, loaded_flag, modified_state = autoload_queue(current_state)
|
| 761 |
+
should_start_processing = loaded_flag
|
| 762 |
+
accordion_update = gr.Accordion(open=True) if loaded_flag else gr.update()
|
| 763 |
+
return df_update, gr.update(visible=loaded_flag), accordion_update, should_start_processing, modified_state
|
| 764 |
+
|
| 765 |
+
def start_processing_if_needed(should_start, current_state):
|
| 766 |
+
if not isinstance(current_state, dict) or 'gen' not in current_state:
|
| 767 |
+
yield "Error: Invalid state received before processing."
|
| 768 |
+
return
|
| 769 |
+
if should_start:
|
| 770 |
+
yield from process_tasks(current_state)
|
| 771 |
+
else:
|
| 772 |
+
yield None
|
| 773 |
+
|
| 774 |
+
def finalize_generation_with_state(current_state):
|
| 775 |
+
if not isinstance(current_state, dict) or 'gen' not in current_state:
|
| 776 |
+
return gr.update(), gr.update(interactive=True), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False, value=""), gr.update(), current_state
|
| 777 |
+
|
| 778 |
+
gallery_update, abort_btn_update, gen_btn_update, add_queue_btn_update, current_gen_col_update, gen_info_update = finalize_generation(current_state)
|
| 779 |
+
accordion_update = gr.Accordion(open=False) if len(get_gen_info(current_state).get("queue", [])) <= 1 else gr.update()
|
| 780 |
+
return gallery_update, abort_btn_update, gen_btn_update, add_queue_btn_update, current_gen_col_update, gen_info_update, accordion_update, current_state
|
| 781 |
|
| 782 |
def get_queue_table(queue):
|
| 783 |
data = []
|
|
|
|
| 3525 |
js=trigger_zip_download_js
|
| 3526 |
)
|
| 3527 |
|
| 3528 |
+
should_start_flag = gr.State(False)
|
| 3529 |
load_queue_btn.upload(
|
| 3530 |
fn=load_queue_action,
|
| 3531 |
inputs=[load_queue_btn, state],
|
|
|
|
| 3534 |
fn=lambda s: (gr.update(visible=bool(get_gen_info(s).get("queue",[]))), gr.Accordion(open=True)) if bool(get_gen_info(s).get("queue",[])) else (gr.update(visible=False), gr.update()),
|
| 3535 |
inputs=[state],
|
| 3536 |
outputs=[current_gen_column, queue_accordion]
|
| 3537 |
+
).then(
|
| 3538 |
+
fn=lambda s: (
|
| 3539 |
+
(gr.Button(visible=False), gr.Button(visible=True), gr.Column(visible=True), True)
|
| 3540 |
+
if bool(get_gen_info(s).get("queue",[]))
|
| 3541 |
+
else (gr.Button(visible=True), gr.Button(visible=False), gr.Column(visible=False), False)
|
| 3542 |
+
),
|
| 3543 |
+
inputs=[state],
|
| 3544 |
+
outputs=[generate_btn, add_to_queue_btn, current_gen_column, should_start_flag]
|
| 3545 |
+
).then(
|
| 3546 |
+
fn=start_processing_if_needed,
|
| 3547 |
+
inputs=[should_start_flag, state],
|
| 3548 |
+
outputs=[gen_status],
|
| 3549 |
+
trigger_mode="once"
|
| 3550 |
+
).then(
|
| 3551 |
+
fn=finalize_generation_with_state,
|
| 3552 |
+
inputs=[state],
|
| 3553 |
+
outputs=[output, abort_btn, generate_btn, add_to_queue_btn, current_gen_column, gen_info, queue_accordion, state],
|
| 3554 |
+
trigger_mode="always_last"
|
| 3555 |
+
).then(
|
| 3556 |
+
unload_model_if_needed,
|
| 3557 |
+
inputs= [state],
|
| 3558 |
+
outputs= []
|
| 3559 |
)
|
| 3560 |
|
| 3561 |
clear_queue_btn.click(
|
|
|
|
| 4184 |
generate_about_tab()
|
| 4185 |
|
| 4186 |
should_start_flag = gr.State(False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4187 |
|
| 4188 |
demo.load(
|
| 4189 |
fn=run_autoload_and_prepare_ui,
|