gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
33.97k stars 2.58k forks source link

Custom Loading UI for `gr.render` #9964

Open KeJunMao opened 16 hours ago

KeJunMao commented 16 hours ago

Is your feature request related to a problem? Please describe.
Currently, when using gr.render() for dynamic rendering, there is no support for custom loading UI. The default loading indicator does not meet specific design needs and may not align with the overall UI style, which can impact the user experience, especially in more complex applications.

Describe the solution you'd like
I would like gr.render() to support custom loading UIs. This would allow users to implement a loading indicator or animation that fits their design, instead of being limited to the default one.

Additional context
For example, it would be helpful if we could pass a custom component or loading animation as an argument when calling gr.render(), which would replace the default loading state display. This would greatly enhance flexibility for developers and improve UI consistency.

KeJunMao commented 16 hours ago

I'm using gr.Timer for loading now, is this reliable?

@gr.render(inputs=[input])
def render(input):
    desc = gr.Markdown("# loading...")
    timer = gr.Timer(0.1)

    def update_desc():
        # mock long time job
        time.sleep(5)
        return '# Success!', gr.Timer(active=False)
    timer.tick(fn=update_desc, inputs=[], outputs=[desc, timer])
abidlabs commented 2 hours ago

If I understand @KeJunMao, this is similar to: https://github.com/gradio-app/gradio/issues/3714, right?

abidlabs commented 2 hours ago

I agree btw, cc @aliabid94