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.5k stars 2.54k forks source link

Lite: pseudo-HTTP req/res to the Lite server is much slower than the read HTTP access #9097

Open whitphx opened 2 months ago

whitphx commented 2 months ago

Sample:

import gradio as gr

demo = gr.Interface(
    fn=lambda x: x,
    inputs=gr.Image(type="pil", streaming=True),
    outputs="image",
    live=True,
)

demo.launch()

With the same sample code above, the image frames coming back from the server is obviously delayed in Lite much more than the normal Gradio.

When the image is resized to be smaller, the streaming becomes faster. This fact and the logs in the console implies the responses sent over the pseudo-HTTP connection on Lite are not fast enough.

import gradio as gr

def fn(img):
    img.thumbnail((100, 100))
    return img

demo = gr.Interface(
    fn=fn,
    inputs=gr.Image(type="pil", streaming=True),
    outputs="image",
    live=True,
)

demo.launch()
whitphx commented 2 months ago

With rough print-debug, I found