From 4f7e88c0431b2929f542fc3f2d4cf33eb7de6ce0 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Wed, 12 Apr 2023 10:30:12 -0300 Subject: [PATCH] Simplify send_pictures --- extensions/send_pictures/script.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/extensions/send_pictures/script.py b/extensions/send_pictures/script.py index 91d40e4c..b21423e4 100644 --- a/extensions/send_pictures/script.py +++ b/extensions/send_pictures/script.py @@ -39,11 +39,9 @@ def generate_chat_picture(picture, name1, name2): def ui(): picture_select = gr.Image(label='Send a picture', type='pil') - # Prepare the hijack with custom inputs - picture_select.upload(lambda picture, name1, name2: input_hijack.update({"state": True, "value": generate_chat_picture(picture, name1, name2)}), [picture_select, shared.gradio['name1'], shared.gradio['name2']], None) - - # Call the generation function + # Prepare the input hijack, update the interface values, call the generation function, and clear the picture picture_select.upload( + lambda picture, name1, name2: input_hijack.update({"state": True, "value": generate_chat_picture(picture, name1, name2)}), [picture_select, shared.gradio['name1'], shared.gradio['name2']], None).then( gather_interface_values, [shared.gradio[k] for k in shared.input_elements], shared.gradio['interface_state']).then( chat.cai_chatbot_wrapper, shared.input_params, shared.gradio['display'], show_progress=shared.args.no_stream).then( lambda: None, None, picture_select, show_progress=False)