mirror of
https://github.com/Wan-Video/Wan2.1.git
synced 2025-11-05 06:29:14 +00:00
Merge branch 'dev3' of https://github.com/deepbeepmeep/Wan2GP into dev3
This commit is contained in:
commit
9e9a952022
100
wgp.py
100
wgp.py
@ -705,6 +705,15 @@ def clear_queue_action(state):
|
|||||||
if aborted_current or cleared_pending:
|
if aborted_current or cleared_pending:
|
||||||
gen["prompts_max"] = 0
|
gen["prompts_max"] = 0
|
||||||
|
|
||||||
|
if cleared_pending:
|
||||||
|
try:
|
||||||
|
if os.path.isfile(AUTOSAVE_FILENAME):
|
||||||
|
os.remove(AUTOSAVE_FILENAME)
|
||||||
|
print(f"Clear Queue: Deleted autosave file '{AUTOSAVE_FILENAME}'.")
|
||||||
|
except OSError as e:
|
||||||
|
print(f"Clear Queue: Error deleting autosave file '{AUTOSAVE_FILENAME}': {e}")
|
||||||
|
gr.Warning(f"Could not delete the autosave file '{AUTOSAVE_FILENAME}'. You may need to remove it manually.")
|
||||||
|
|
||||||
if aborted_current and cleared_pending:
|
if aborted_current and cleared_pending:
|
||||||
gr.Info("Queue cleared and current generation aborted.")
|
gr.Info("Queue cleared and current generation aborted.")
|
||||||
elif aborted_current:
|
elif aborted_current:
|
||||||
@ -722,6 +731,12 @@ def quit_application():
|
|||||||
import signal
|
import signal
|
||||||
os.kill(os.getpid(), signal.SIGINT)
|
os.kill(os.getpid(), signal.SIGINT)
|
||||||
|
|
||||||
|
def request_quit_confirmation():
|
||||||
|
return gr.update(visible=False), gr.update(visible=True)
|
||||||
|
|
||||||
|
def cancel_quit_confirmation():
|
||||||
|
return gr.update(visible=True), gr.update(visible=False)
|
||||||
|
|
||||||
def autosave_queue():
|
def autosave_queue():
|
||||||
global global_queue_ref
|
global global_queue_ref
|
||||||
if not global_queue_ref:
|
if not global_queue_ref:
|
||||||
@ -3598,6 +3613,55 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
|
|||||||
load_queue_btn = gr.UploadButton("Load Queue", file_types=[".zip"], size="sm")
|
load_queue_btn = gr.UploadButton("Load Queue", file_types=[".zip"], size="sm")
|
||||||
clear_queue_btn = gr.Button("Clear Queue", size="sm", variant="stop")
|
clear_queue_btn = gr.Button("Clear Queue", size="sm", variant="stop")
|
||||||
quit_button = gr.Button("Save and Quit", size="sm", variant="secondary")
|
quit_button = gr.Button("Save and Quit", size="sm", variant="secondary")
|
||||||
|
with gr.Row(visible=False) as quit_confirmation_row:
|
||||||
|
gr.Markdown("Quitting in 5 seconds...", elem_id="quit_timer_label")
|
||||||
|
confirm_quit_button = gr.Button("Confirm Quit Now", elem_id="comfirm_quit_btn_hidden", size="sm", variant="stop")
|
||||||
|
cancel_quit_button = gr.Button("Cancel Quit", size="sm", variant="secondary")
|
||||||
|
hidden_force_quit_trigger = gr.Button("force_quit", visible=False, elem_id="force_quit_btn_hidden")
|
||||||
|
|
||||||
|
start_quit_timer_js = """
|
||||||
|
() => {
|
||||||
|
function findAndClickGradioButton(elemId) {
|
||||||
|
const gradioApp = document.querySelector('gradio-app') || document;
|
||||||
|
const button = gradioApp.querySelector(`#${elemId}`);
|
||||||
|
if (button) {
|
||||||
|
button.click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.quitTimerId = setTimeout(() => {
|
||||||
|
}, 5000);
|
||||||
|
let countdown = 5;
|
||||||
|
const label = document.getElementById('quit_timer_label');
|
||||||
|
if (label) {
|
||||||
|
label.innerText = `Quitting in ${countdown}...`;
|
||||||
|
window.quitCountdownInterval = setInterval(() => {
|
||||||
|
countdown--;
|
||||||
|
if (countdown > 0) {
|
||||||
|
label.innerText = `Quitting in ${countdown}...`;
|
||||||
|
} else {
|
||||||
|
clearInterval(window.quitCountdownInterval);
|
||||||
|
findAndClickGradioButton('comfirm_quit_btn_hidden');
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
cancel_quit_timer_js = """
|
||||||
|
() => {
|
||||||
|
if (window.quitTimerId) {
|
||||||
|
clearTimeout(window.quitTimerId);
|
||||||
|
window.quitTimerId = null;
|
||||||
|
}
|
||||||
|
if(window.quitCountdownInterval) {
|
||||||
|
clearInterval(window.quitCountdownInterval);
|
||||||
|
window.quitCountdownInterval = null;
|
||||||
|
}
|
||||||
|
const label = document.getElementById('quit_timer_label');
|
||||||
|
if(label) { label.innerText = 'Quit cancelled.'; }
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
trigger_zip_download_js = """
|
trigger_zip_download_js = """
|
||||||
(base64String) => {
|
(base64String) => {
|
||||||
if (!base64String) {
|
if (!base64String) {
|
||||||
@ -3629,6 +3693,35 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
quit_button.click(
|
||||||
|
fn=request_quit_confirmation,
|
||||||
|
inputs=[],
|
||||||
|
outputs=[quit_button, quit_confirmation_row]
|
||||||
|
).then(
|
||||||
|
fn=None, inputs=None, outputs=None, js=start_quit_timer_js
|
||||||
|
)
|
||||||
|
|
||||||
|
confirm_quit_button.click(
|
||||||
|
fn=quit_application,
|
||||||
|
inputs=[],
|
||||||
|
outputs=[]
|
||||||
|
)
|
||||||
|
|
||||||
|
cancel_quit_button.click(
|
||||||
|
fn=cancel_quit_confirmation,
|
||||||
|
inputs=[],
|
||||||
|
outputs=[quit_button, quit_confirmation_row]
|
||||||
|
).then(
|
||||||
|
fn=None, inputs=None, outputs=None, js=cancel_quit_timer_js
|
||||||
|
)
|
||||||
|
|
||||||
|
hidden_force_quit_trigger.click(
|
||||||
|
fn=quit_application,
|
||||||
|
inputs=[],
|
||||||
|
outputs=[]
|
||||||
|
)
|
||||||
|
|
||||||
save_queue_btn.click(
|
save_queue_btn.click(
|
||||||
fn=save_queue_action,
|
fn=save_queue_action,
|
||||||
inputs=[state],
|
inputs=[state],
|
||||||
@ -3682,11 +3775,6 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
|
|||||||
inputs=None,
|
inputs=None,
|
||||||
outputs=[current_gen_column, queue_accordion]
|
outputs=[current_gen_column, queue_accordion]
|
||||||
)
|
)
|
||||||
quit_button.click(
|
|
||||||
fn=quit_application,
|
|
||||||
inputs=[],
|
|
||||||
outputs=[]
|
|
||||||
)
|
|
||||||
|
|
||||||
extra_inputs = prompt_vars + [wizard_prompt, wizard_variables_var, wizard_prompt_activated_var, video_prompt_column, image_prompt_column,
|
extra_inputs = prompt_vars + [wizard_prompt, wizard_variables_var, wizard_prompt_activated_var, video_prompt_column, image_prompt_column,
|
||||||
prompt_column_advanced, prompt_column_wizard_vars, prompt_column_wizard, lset_name, advanced_row] # show_advanced presets_column,
|
prompt_column_advanced, prompt_column_wizard_vars, prompt_column_wizard, lset_name, advanced_row] # show_advanced presets_column,
|
||||||
@ -3787,7 +3875,7 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non
|
|||||||
inputs = [state, model_choice],
|
inputs = [state, model_choice],
|
||||||
outputs=queue_df
|
outputs=queue_df
|
||||||
).then(
|
).then(
|
||||||
fn=lambda s: gr.Accordion(open=True) if len(get_gen_info(s).get("queue", [])) > 1 else gr.update(), # Expand if queue has items (len > 1 assumes placeholder)
|
fn=lambda s: gr.Accordion(open=True) if len(get_gen_info(s).get("queue", [])) > 1 else gr.update(),
|
||||||
inputs=[state],
|
inputs=[state],
|
||||||
outputs=[queue_accordion]
|
outputs=[queue_accordion]
|
||||||
).then(
|
).then(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user