github gradio-app/gradio v3.8.2

latest releases: @gradio/uploadbutton@0.6.13, @gradio/video@0.9.1, @gradio/upload@0.11.4...
20 months ago

Version 3.8.2

Bug Fixes:

  • Ensure gradio apps embedded via spaces use the correct endpoint for predictions. @pngwn in PR 2567
  • Ensure gradio apps embedded via spaces use the correct websocket protocol. @pngwn in PR 2571

New Features:

Running Events Continuously

Gradio now supports the ability to run an event continuously on a fixed schedule. To use this feature,
pass every=# of seconds to the event definition. This will run the event every given number of seconds!

This can be used to:

  • Create live visualizations that show the most up to date data
  • Refresh the state of the frontend automatically in response to changes in the backend

Here is an example of a live plot that refreshes every half second:

import math
import gradio as gr
import plotly.express as px
import numpy as np


plot_end = 2 * math.pi


def get_plot(period=1):
    global plot_end
    x = np.arange(plot_end - 2 * math.pi, plot_end, 0.02)
    y = np.sin(2*math.pi*period * x)
    fig = px.line(x=x, y=y)
    plot_end += 2 * math.pi
    return fig


with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            gr.Markdown("Change the value of the slider to automatically update the plot")
            period = gr.Slider(label="Period of plot", value=1, minimum=0, maximum=10, step=1)
            plot = gr.Plot(label="Plot (updates every half second)")

    dep = demo.load(get_plot, None, plot, every=0.5)
    period.change(get_plot, period, plot, every=0.5, cancels=[dep])

demo.queue().launch()

live_demo

Bug Fixes:

No changes to highlight.

Documentation Changes:

No changes to highlight.

Testing and Infrastructure Changes:

No changes to highlight.

Breaking Changes:

No changes to highlight.

Full Changelog:

  • Allows loading private Spaces by passing an an api_key to gr.Interface.load()
    by @abidlabs in PR 2568

Contributors Shoutout:

No changes to highlight.

Don't miss a new gradio release

NewReleases is sending notifications on new releases.