github gradio-app/gradio v3.6

latest releases: gradio@4.44.0, @gradio/core@0.0.4, @gradio/audio@0.13.5...
23 months ago

Version 3.6

New Features:

Cancelling Running Events

Running events can be cancelled when other events are triggered! To test this feature, pass the cancels parameter to the event listener.
For this feature to work, the queue must be enabled.

cancel_on_change_rl

Code:

import time
import gradio as gr

def fake_diffusion(steps):
    for i in range(steps):
        time.sleep(1)
        yield str(i)

def long_prediction(*args, **kwargs):
    time.sleep(10)
    return 42


with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            n = gr.Slider(1, 10, value=9, step=1, label="Number Steps")
            run = gr.Button()
            output = gr.Textbox(label="Iterative Output")
            stop = gr.Button(value="Stop Iterating")
        with gr.Column():
            prediction = gr.Number(label="Expensive Calculation")
            run_pred = gr.Button(value="Run Expensive Calculation")
        with gr.Column():
            cancel_on_change = gr.Textbox(label="Cancel Iteration and Expensive Calculation on Change")

    click_event = run.click(fake_diffusion, n, output)
    stop.click(fn=None, inputs=None, outputs=None, cancels=[click_event])
    pred_event = run_pred.click(fn=long_prediction, inputs=None, outputs=prediction)

    cancel_on_change.change(None, None, None, cancels=[click_event, pred_event])


demo.queue(concurrency_count=1, max_size=20).launch()

For interfaces, a stop button will be added automatically if the function uses a yield statement.

import gradio as gr
import time

def iteration(steps):
    for i in range(steps):
       time.sleep(0.5)
       yield i

gr.Interface(iteration,
             inputs=gr.Slider(minimum=1, maximum=10, step=1, value=5),
             outputs=gr.Number()).queue().launch()

stop_interface_rl

Bug Fixes:

  • Add loading status tracker UI to HTML and Markdown components. @pngwn in PR 2474
  • Fixed videos being mirrored in the front-end if source is not webcam by @freddyaboulton in PR 2475
  • Add clear button for timeseries component @dawoodkhan82 in PR 2487
  • Removes special characters from temporary filenames so that the files can be served by components @abidlabs in PR 2480
  • Fixed infinite reload loop when mounting gradio as a sub application by @freddyaboulton in PR 2477

Documentation Changes:

  • Adds a demo to show how a sound alert can be played upon completion of a prediction by @abidlabs in PR 2478

Testing and Infrastructure Changes:

No changes to highlight.

Breaking Changes:

No changes to highlight.

Full Changelog:

Contributors Shoutout:

No changes to highlight.

Don't miss a new gradio release

NewReleases is sending notifications on new releases.