-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
After interrogation is started, can't abort - Batch interrogate #76
Comments
well yeah, that happens. |
I guess the interrogate button could change in Cancel a bit similar to txt2img or img2img. |
It would be great. |
The button to change into Cancel after a press. The press of this button should function according a toggled state (e.g. a static interrogator bool) The loop to break |
I think maybe it would be easier to implement and maintain with two buttons. Maybe like this, two buttons, refer to https://www.gradio.app/docs/button#initialization, we can use This is demo: import time
from threading import Event
import gradio as gr
############################################
cancel_event = Event()
SHOW_INTERROGATE = [
gr.update(visible = True),
gr.update(visible = False),
]
SHOW_CANCEL = SHOW_INTERROGATE[::-1]
############################################
def fake_interrogate():
cancel_event.clear() # reset cancel event
yield SHOW_CANCEL
# fake interrogate
for i in range(10):
if cancel_event.isSet(): # check if cancel event is set
print("canceled")
break
time.sleep(1)
print(i)
yield SHOW_INTERROGATE
def fake_cancel():
cancel_event.set() # set cancel event to stop the interrogation
return SHOW_INTERROGATE
############################################
with gr.Blocks() as demo:
with gr.Row():
interrogate = gr.Button(value="interrogate")
cancel = gr.Button(value="cancel", visible=False)
interrogate.click(
fn = fake_interrogate,
outputs=[interrogate, cancel],
)
cancel.click(
fn = fake_cancel,
outputs=[interrogate, cancel],
)
# queue is required to yield, and `concurrency_count` must be > 1 (in A1111 seems 64)
demo.queue(concurrency_count=2).launch(debug=True) |
Thanks for your input, you are right, It is difficult to return and change the label before interrogation. Maybe it can be done by queuing th interrogation, then returning, but then the double button may be easier. |
It might also be possible to use a state variable, let the button just handle the label change and change the state of the state variable. Then the state variable, on change should trigger either the batch interrogation or the cancel action, dependent on its (inverted) state. Another approach could be to use the elem_id and change the button label in javascript, rather than relying on gradio. |
After it is started, can't abort Batch interrogate. I started a folder with 100 images and then realized it was the wrong folder, I had to close SD because I didn't find how to stop the process.
The text was updated successfully, but these errors were encountered: