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
30.69k stars 2.28k forks source link

Connection errored out #8393

Closed pg56714 closed 1 month ago

pg56714 commented 1 month ago

Describe the bug

After clicking on the examples, click again to directly display the results without needing to click 'submit'.

I tried the same approach and found that others using Gradio on HuggingFace also have this issue where results are produced without needing to click submit. Three cases have been attached to the Google folder linked below.

According to this question, Connection errored out will appear when pressing submit to execute.

This issue does not occur locally.

huggingface discuss

Have you searched existing issues? 🔎

Reproduction

my huggingface space

Screenshot

Three Cases

Logs

No response

System Info

The latest version(2024/05/28) 4.31.5

Severity

Blocking usage of gradio

freddyaboulton commented 1 month ago

Hi @pg56714 - I think the problem is that clicking the examples updates the input image but you have a change event on the input image that clears the outputs.

https://huggingface.co/spaces/pg56714/Segment-Anything-Arena/blob/main/app.py#L202

I think you need to use .clear event, not a change event.

Will close as this is behaving as expected.

pg56714 commented 1 month ago

After further inspection, the issue was that gr.Examples was bound to fn, causing automatic execution when clicking on examples. It was resolved after removing that binding. Thank you.