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.28k stars 2.51k forks source link

Lite: image and gallery output widgets make spurious GET requests if image is larger than some size #7036

Open fcole opened 9 months ago

fcole commented 9 months ago

Describe the bug

For interface functions that have an output image or gallery, there seems to be some threshold of image size that changes the behavior and introduces a bug in gradio-lite. If the image is too large, spurious GET requests will be issued that look like:

GET https://www.gradio.app/file=/tmp/gradio/0915498aa2aeabbf1780f517e0941334dae69ed5/image.png 404 (Not Found)

Oddly, the image is eventually displayed correctly, it just takes an extra second and a broken image icon appearing temporarily.

The bug can be reproduced in the playground (https://www.gradio.app/playground).

Have you searched existing issues? 🔎

Reproduction

import gradio as gr
import numpy as np

def get_an_image(name):
  return np.random.rand(3,512,512,3) # This line causes the bug
  # return np.random.rand(3,100,100,3) # This line does not cause the bug

demo = gr.Interface(fn=get_an_image, inputs="textbox", outputs="gallery")

if __name__ == "__main__":
  demo.launch()

Screenshot

image

Logs

No response

System Info

Running the gradio playground.

Severity

I can work around it

abidlabs commented 1 day ago

Hi, apologies for the late follow up. We haven't had a chance to look into this issue, but the Gradio codebase has changed quite significantly since this issue was created, particularly with the release of Gradio 5. Could you let us know if this is still an issue in the latest version of Gradio (pip install --upgrade gradio)? Thanks!