I'm building a Gradio app.
The server-side processing may take a long time so I'd like to be able to implement a messaging paradigm to update the user-interface based on the processing status.
Something like dynamically setting a Component's value does not work (no error, just no update)
from time import sleep
import gradio as gr
import numpy as np
from gradio.components import Button, Image, Markdown, Textbox
def transform(component):
def _transform(text):
for i in range(5):
component.update(value=str(i))
sleep(1)
return np.random.randint(0, 230, (100, 100, 3))
return _transform
with gr.Blocks() as app:
inp = Textbox(label="Your message")
out = Image(label="Your transformed message")
feedback = Markdown(value="Initial")
btn = Button("See for yourself!", label="Run")
btn.click(transform(feedback), inputs=inp, outputs=out)
app.launch()
Here you can see that "Initial" is still there instead of "4".