gradio/CHANGELOG.md
Paulo A 728f3a960c
Add pt-br.json (#2753)
* Add pt-br.json

* Fix json name, changelog

* Format file

* Fix json name

* Fix CHANGELOG.md

* Rename pt-br.json to pt-BR.json

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update i18n.test.ts

Co-authored-by: freddyaboulton <alfonsoboulton@gmail.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
2022-12-08 19:18:02 -08:00

95 KiB

Upcoming Release

New Features:

Support for altair plots

The Plot component can now accept altair plots as values! Simply return an altair plot from your event listener and gradio will display it in the front-end. See the example below:

import gradio as gr
import altair as alt
from vega_datasets import data

cars = data.cars()
chart = (
    alt.Chart(cars)
    .mark_point()
    .encode(
        x="Horsepower",
        y="Miles_per_Gallon",
        color="Origin",
    )
)

with gr.Blocks() as demo:
    gr.Plot(value=chart)
demo.launch()
image

By @freddyaboulton in PR 2741

Set the background color of a Label component

The Label component now accepts a color argument by @freddyaboulton in PR 2736. The color argument should either be a valid css color name or hexadecimal string. You can update the color with gr.Label.update!

This lets you create Alert and Warning boxes with the Label component. See below:

import gradio as gr
import random

def update_color(value):
    if value < 0:
        # This is bad so use red
        return "#FF0000"
    elif 0 <= value <= 20:
        # Ok but pay attention (use orange)
        return "#ff9966"
    else:
        # Nothing to worry about
        return None

def update_value():
    choice = random.choice(['good', 'bad', 'so-so'])
    color = update_color(choice)
    return gr.Label.update(value=choice, color=color)
    
    
with gr.Blocks() as demo:
    label = gr.Label(value=-10)
    demo.load(lambda: update_value(), inputs=None, outputs=[label], every=1)
demo.queue().launch()

label_bg_color_update

Add Brazilian Portuguese translation

Add Brazilian Portuguese translation (pt-BR.json) by @pstwh in PR 2753:

image

Bug Fixes:

  • Fixed issue where image thumbnails were not showing when an example directory was provided by by @abidlabs in PR 2745

Documentation Changes:

No changes to highlight.

Testing and Infrastructure Changes:

No changes to highlight.

Breaking Changes:

No changes to highlight.

Full Changelog:

  • Images in the chatbot component are now resized if they exceed a max width by @abidlabs in PR 2748
  • Images in the chatbot component are now resized if they exceed a max width by @abidlabs in PR 2748
  • Missing parameters have been added to gr.Blocks().load() by @abidlabs in PR 2755

Contributors Shoutout:

No changes to highlight.

Version 3.12.0

New Features:

The Chatbot component now supports a subset of Markdown (including bold, italics, code, images)

You can now pass in some Markdown to the Chatbot component and it will show up, meaning that you can pass in images as well! by @abidlabs in PR 2731

Here's a simple example that references a local image lion.jpg that is in the same folder as the Python script:

import gradio as gr

with gr.Blocks() as demo:
    gr.Chatbot([("hi", "hello **abubakar**"), ("![](/file=lion.jpg)", "cool pic")])
    
demo.launch()

Alt text

To see a more realistic example, see the new demo /demo/chatbot_multimodal/run.py.

Latex support

Added mathtext (a subset of latex) support to gr.Markdown. Added by @kashif and @aliabid94 in PR 2696.

Example of how it can be used:

gr.Markdown(
    r"""
    # Hello World! $\frac{\sqrt{x + y}}{4}$ is today's lesson.
    """)

Update Accordion properties from the backend

You can now update the Accordion label and open status with gr.Accordion.update by @freddyaboulton in PR 2690

import gradio as gr

with gr.Blocks() as demo:
    with gr.Accordion(label="Open for greeting", open=False) as accordion:
        gr.Textbox("Hello!")
    open_btn = gr.Button(value="Open Accordion")
    close_btn = gr.Button(value="Close Accordion")
    open_btn.click(
        lambda: gr.Accordion.update(open=True, label="Open Accordion"),
        inputs=None,
        outputs=[accordion],
    )
    close_btn.click(
        lambda: gr.Accordion.update(open=False, label="Closed Accordion"),
        inputs=None,
        outputs=[accordion],
    )
demo.launch()

update_accordion

Bug Fixes:

  • Fixed bug where requests timeout is missing from utils.version_check() by @yujiehecs in PR 2729
  • Fixed bug where so that the File component can properly preprocess files to "binary" byte-string format by CoffeeVampir3 in PR 2727
  • Fixed bug to ensure that filenames are less than 200 characters even for non-English languages by @SkyTNT in PR 2685

Documentation Changes:

Testing and Infrastructure Changes:

No changes to highlight.

Breaking Changes:

No changes to highlight.

Full Changelog:

Contributors Shoutout:

Version 3.11.0

New Features:

Upload Button

There is now a new component called the UploadButton which is a file upload component but in button form! You can also specify what file types it should accept in the form of a list (ex: image, video, audio, text, or generic file). Added by @dawoodkhan82 in PR 2591.

Example of how it can be used:

import gradio as gr

def upload_file(files):
    file_paths = [file.name for file in files]
    return file_paths

with gr.Blocks() as demo:
    file_output = gr.File()
    upload_button = gr.UploadButton("Click to Upload a File", file_types=["image", "video"], file_count="multiple")
    upload_button.upload(upload_file, upload_button, file_output)

demo.launch()

Revamped API documentation page

New API Docs page with in-browser playground and updated aesthetics. @gary149 in PR 2652

Revamped Login page

Previously our login page had its own CSS, had no dark mode, and had an ugly json message on the wrong credentials. Made the page more aesthetically consistent, added dark mode support, and a nicer error message. @aliabid94 in PR 2684

Accessing the Requests Object Directly

You can now access the Request object directly in your Python function by @abidlabs in PR 2641. This means that you can access request headers, the client IP address, and so on. In order to use it, add a parameter to your function and set its type hint to be gr.Request. Here's a simple example:

import gradio as gr

def echo(name, request: gr.Request):
    if request:
        print("Request headers dictionary:", request.headers)
        print("IP address:", request.client.host)
    return name

io = gr.Interface(echo, "textbox", "textbox").launch()

Bug Fixes:

  • Fixed bug that limited files from being sent over websockets to 16MB. The new limit is now 1GB by @abidlabs in PR 2709

Documentation Changes:

  • Updated documentation for embedding Gradio demos on Spaces as web components by @julien-c in PR 2698
  • Updated IFrames in Guides to use the host URL instead of the Space name to be consistent with the new method for embedding Spaces, by
    @julien-c in PR 2692
  • Colab buttons on every demo in the website! Just click open in colab, and run the demo there.

https://user-images.githubusercontent.com/9021060/202878400-cb16ed47-f4dd-4cb0-b2f0-102a9ff64135.mov

Testing and Infrastructure Changes:

No changes to highlight.

Breaking Changes:

No changes to highlight.

Full Changelog:

  • Better warnings and error messages for gr.Interface.load() by @abidlabs in PR 2694
  • Add open in colab buttons to demos in docs and /demos by @aliabd in PR 2608
  • Apply different formatting for the types in component docstrings by @aliabd in PR 2707

Contributors Shoutout:

No changes to highlight.

Version 3.10.1

New Features:

No changes to highlight.

Bug Fixes:

Documentation Changes:

No changes to highlight.

Testing and Infrastructure Changes:

No changes to highlight.

Breaking Changes:

No changes to highlight.

Full Changelog:

Contributors Shoutout:

No changes to highlight.

Version 3.10.0

  • Add support for 'password' and 'email' types to Textbox. @pngwn in PR 2653
  • gr.Textbox component will now raise an exception if type is not "text", "email", or "password" @pngwn in PR 2653. This will cause demos using the deprecated gr.Textbox(type="number") to raise an exception.

Bug Fixes:

  • Updated the minimum FastApi used in tests to version 0.87 by @freddyaboulton in PR 2647
  • Fixed bug where interfaces with examples could not be loaded with gr.Interface.load by @freddyaboulton PR 2640
  • Fixed bug where the interactive property of a component could not be updated by @freddyaboulton in PR 2639
  • Fixed bug where some URLs were not being recognized as valid URLs and thus were not loading correctly in various components by @abidlabs in PR 2659

Documentation Changes:

  • Fix some typos in the embedded demo names in "05_using_blocks_like_functions.md" by @freddyaboulton in PR 2656

Testing and Infrastructure Changes:

No changes to highlight.

Breaking Changes:

No changes to highlight.

Full Changelog:

  • Add support for 'password' and 'email' types to Textbox. @pngwn in PR 2653

Contributors Shoutout:

No changes to highlight.

Version 3.9.1

New Features:

No changes to highlight.

Bug Fixes:

  • Only set a min height on md and html when loading by @pngwn in PR 2623

Documentation Changes:

  • See docs for the latest gradio commit to main as well the latest pip release:

main-vs-pip

  • Modified the "Connecting To a Database Guide" to use pd.read_sql as opposed to low-level postgres connector by @freddyaboulton in PR 2604

Testing and Infrastructure Changes:

No changes to highlight.

Breaking Changes:

No changes to highlight.

Full Changelog:

  • Dropdown for seeing docs as latest or main by @aliabd in PR 2544
  • Allow gr.Templates to accept parameters to override the defaults by @abidlabs in PR 2600
  • Components now throw a ValueError() if constructed with invalid parameters for type or source (for components that take those parameters) in PR 2610
  • Allow auth with using queue by @GLGDLY in PR 2611

Contributors Shoutout:

No changes to highlight.

Version 3.9

New Features:

  • Gradio is now embedded directly in colab without requiring the share link by @aliabid94 in PR 2455

Calling functions by api_name in loaded apps

When you load an upstream app with gr.Blocks.load, you can now specify which fn to call with the api_name parameter.

import gradio as gr
english_translator = gr.Blocks.load(name="spaces/gradio/english-translator")
german = english_translator("My name is Freddy", api_name='translate-to-german')

The api_name parameter will take precendence over the fn_index parameter.

Bug Fixes:

Documentation Changes:

  • Added a Guide on how to configure the queue for maximum performance by @abidlabs in PR 2558

Testing and Infrastructure Changes:

No changes to highlight.

Breaking Changes:

No changes to highlight.

Full Changelog:

Contributors Shoutout:

No changes to highlight.

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.

Version 3.8

New Features:

  • Allows event listeners to accept a single dictionary as its argument, where the keys are the components and the values are the component values. This is set by passing the input components in the event listener as a set instead of a list. @aliabid94 in PR 2550

Bug Fixes:

Documentation Changes:

No changes to highlight.

Testing and Infrastructure Changes:

No changes to highlight.

Breaking Changes:

No changes to highlight.

Full Changelog:

Contributors Shoutout:

No changes to highlight.

Version 3.7

New Features:

Batched Functions

Gradio now supports the ability to pass batched functions. Batched functions are just functions which take in a list of inputs and return a list of predictions.

For example, here is a batched function that takes in two lists of inputs (a list of words and a list of ints), and returns a list of trimmed words as output:

import time

def trim_words(words, lens):
    trimmed_words = []
    time.sleep(5)
    for w, l in zip(words, lens):
        trimmed_words.append(w[:l])        
    return [trimmed_words]

The advantage of using batched functions is that if you enable queuing, the Gradio server can automatically batch incoming requests and process them in parallel, potentially speeding up your demo. Here's what the Gradio code looks like (notice the batch=True and max_batch_size=16 -- both of these parameters can be passed into event triggers or into the Interface class)

import gradio as gr

with gr.Blocks() as demo:
    with gr.Row():
        word = gr.Textbox(label="word", value="abc")
        leng = gr.Number(label="leng", precision=0, value=1)
        output = gr.Textbox(label="Output")
    with gr.Row():
        run = gr.Button()

    event = run.click(trim_words, [word, leng], output, batch=True, max_batch_size=16)

demo.queue()
demo.launch()

In the example above, 16 requests could be processed in parallel (for a total inference time of 5 seconds), instead of each request being processed separately (for a total inference time of 80 seconds).

Upload Event

Video, Audio, Image, and File components now support a upload() event that is triggered when a user uploads a file into any of these components.

Example usage:

import gradio as gr

with gr.Blocks() as demo:
    with gr.Row():
        input_video = gr.Video()
        output_video = gr.Video()

     # Clears the output video when an input video is uploaded
    input_video.upload(lambda : None, None, output_video)  

Bug Fixes:

  • Fixes issue where plotly animations, interactivity, titles, legends, were not working properly. @dawoodkhan82 in PR 2486
  • Prevent requests to the /api endpoint from skipping the queue if the queue is enabled for that event by @freddyaboulton in PR 2493
  • Fixes a bug with cancels in event triggers so that it works properly if multiple Blocks are rendered by @abidlabs in PR 2530
  • Prevent invalid targets of events from crashing the whole application. @pngwn in PR 2534
  • Properly dequeue cancelled events when multiple apps are rendered by @freddyaboulton in PR 2540

Documentation Changes:

  • Added an example interactive dashboard to the "Tabular & Plots" section of the Demos page by @freddyaboulton in PR 2508

Testing and Infrastructure Changes:

No changes to highlight.

Breaking Changes:

No changes to highlight.

Full Changelog:

  • Fixes the error message if a user builds Gradio locally and tries to use share=True by @abidlabs in PR 2502
  • Allows the render() function to return self by @Raul9595 in PR 2514
  • Fixes issue where plotly animations, interactivity, titles, legends, were not working properly. @dawoodkhan82 in PR 2486
  • Gradio now supports batched functions by @abidlabs in PR 2218
  • Add upload event for Video, Audio, Image, and File components @dawoodkhan82 in PR 2448
  • Changes websocket path for Spaces as it is no longer necessary to have a different URL for websocket connections on Spaces by @abidlabs in PR 2528
  • Clearer error message when events are defined outside of a Blocks scope, and a warning if you try to use Series or Parallel with Blocks by @abidlabs in PR 2543
  • Adds support for audio samples that are in float64, float16, or uint16 formats by @abidlabs in PR 2545

Contributors Shoutout:

No changes to highlight.

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.

Version 3.5

Bug Fixes:

  • Ensure that Gradio does not take control of the HTML page title when embedding a gradio app as a web component, this behaviour flipped by adding control_page_title="true" to the webcomponent. @pngwn in PR 2400

  • Decreased latency in iterative-output demos by making the iteration asynchronous @freddyaboulton in PR 2409

  • Fixed queue getting stuck under very high load by @freddyaboulton in PR 2374

  • Ensure that components always behave as if interactive=True were set when the following conditions are true:

    • no default value is provided,
    • they are not set as the input or output of an event,
    • interactive kwarg is not set.

    @pngwn in PR 2459

New Features:

  • When an Image component is set to source="upload", it is now possible to drag and drop and image to replace a previously uploaded image by @pngwn in PR 1711
  • The gr.Dataset component now accepts HTML and Markdown components by @abidlabs in PR 2437

Documentation Changes:

Testing and Infrastructure Changes:

No changes to highlight.

Breaking Changes:

  • The Carousel component is officially deprecated. Since gradio 3.0, code containing the Carousel component would throw warnings. As of the next release, the Carousel component will raise an exception.

Full Changelog:

Contributors Shoutout:

No changes to highlight.

Version 3.4.1

New Features:

1. See Past and Upcoming Changes in the Release History 👀

You can now see gradio's release history directly on the website, and also keep track of upcoming changes. Just go here.

release-history

Bug Fixes:

  1. Fix typo in guide image path by @freddyaboulton in PR 2357
  2. Raise error if Blocks has duplicate component with same IDs by @abidlabs in PR 2359
  3. Catch the permission exception on the audio component by @Ian-GL in PR 2330
  4. Fix image_classifier_interface_load demo by @freddyaboulton in PR 2365
  5. Fix combining adjacent components without gaps by introducing gr.Row(variant="compact") by @aliabid94 in PR 2291 This comes with deprecation of the following arguments for Component.style: round, margin, border.
  6. Fix audio streaming, which was previously choppy in PR 2351. Big thanks to @yannickfunk for the proposed solution.
  7. Fix bug where new typeable slider doesn't respect the minimum and maximum values @dawoodkhan82 in PR 2380

Documentation Changes:

  1. New Guide: Connecting to a Database 🗄️

    A new guide by @freddyaboulton that explains how you can use Gradio to connect your app to a database. Read more here.

  2. New Guide: Running Background Tasks 🥷

    A new guide by @freddyaboulton that explains how you can run background tasks from your gradio app. Read more here.

  3. Small fixes to docs for Image component by @abidlabs in PR 2372

Testing and Infrastructure Changes:

No changes to highlight.

Breaking Changes:

No changes to highlight.

Full Changelog:

Contributors Shoutout:

No changes to highlight.

Version 3.4

New Features:

You can now pass captions to images in the Gallery component. To do so you need to pass a {List} of (image, {str} caption) tuples. This is optional and the component also accepts just a list of the images.

Here's an example:

import gradio as gr

images_with_captions = [
    ("https://images.unsplash.com/photo-1551969014-7d2c4cddf0b6", "Cheetah by David Groves"),
    ("https://images.unsplash.com/photo-1546182990-dffeafbe841d", "Lion by Francesco"), 
    ("https://images.unsplash.com/photo-1561731216-c3a4d99437d5", "Tiger by Mike Marrah")
    ]

with gr.Blocks() as demo:
    gr.Gallery(value=images_with_captions)

demo.launch()
gallery_captions

2. Type Values into the Slider 🔢

You can now type values directly on the Slider component! Here's what it looks like:

type-slider

3. Better Sketching and Inpainting 🎨

We've made a lot of changes to our Image component so that it can support better sketching and inpainting.

Now supports:

  • A standalone black-and-white sketch
import gradio as gr
demo = gr.Interface(lambda x: x, gr.Sketchpad(), gr.Image())
demo.launch()

bw

  • A standalone color sketch
import gradio as gr
demo = gr.Interface(lambda x: x, gr.Paint(), gr.Image())
demo.launch()

color-sketch

  • An uploadable image with black-and-white or color sketching
import gradio as gr
demo = gr.Interface(lambda x: x, gr.Image(source='upload', tool='color-sketch'), gr.Image()) # for black and white, tool = 'sketch'
demo.launch()

sketch-new

  • Webcam with black-and-white or color sketching
import gradio as gr
demo = gr.Interface(lambda x: x, gr.Image(source='webcam', tool='color-sketch'), gr.Image()) # for black and white, tool = 'sketch'
demo.launch()

webcam-sketch

As well as other fixes

Bug Fixes:

  1. Fix bug where max concurrency count is not respected in queue by @freddyaboulton in PR 2286
  2. fix : queue could be blocked by @SkyTNT in PR 2288
  3. Supports gr.update() in example caching by @abidlabs in PR 2309
  4. Clipboard fix for iframes by @abidlabs in PR 2321
  5. Fix: Dataframe column headers are reset when you add a new column by @dawoodkhan82 in PR 2318
  6. Added support for URLs for Video, Audio, and Image by @abidlabs in PR 2256
  7. Add documentation about how to create and use the Gradio FastAPI app by @abidlabs in PR 2263

Documentation Changes:

  1. Adding a Playground Tab to the Website by @aliabd in PR 1860
  2. Gradio for Tabular Data Science Workflows Guide by @merveenoyan in PR 2199
  3. Promotes postprocess and preprocess to documented parameters by @abidlabs in PR 2293
  4. Update 2)key_features.md by @voidxd in PR 2326
  5. Add docs to blocks context postprocessing function by @Ian-GL in PR 2332

Testing and Infrastructure Changes

  1. Website fixes and refactoring by @aliabd in PR 2280
  2. Don't deploy to spaces on release by @freddyaboulton in PR 2313

Full Changelog:

Contributors Shoutout:

Version 3.3

New Features:

1. Iterative Outputs

You can now create an iterative output simply by having your function return a generator!

Here's (part of) an example that was used to generate the interface below it. See full code.

def predict(steps, seed):
    generator = torch.manual_seed(seed)
    for i in range(1,steps):
        yield pipeline(generator=generator, num_inference_steps=i)["sample"][0]

example

2. Accordion Layout 🆕

This version of Gradio introduces a new layout component to Blocks: the Accordion. Wrap your elements in a neat, expandable layout that allows users to toggle them as needed.

Usage: (Read the docs)

with gr.Accordion("open up"):
# components here 

accordion

3. Skops Integration 📈

Our new integration with skops allows you to load tabular classification and regression models directly from the hub.

Here's a classification example showing how quick it is to set up an interface for a model.

import gradio as gr
gr.Interface.load("models/scikit-learn/tabular-playground").launch()

187936493-5c90c01d-a6dd-400f-aa42-833a096156a1

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:

Contributors Shoutout:

Version 3.2

New Features:

1. Improvements to Queuing 🥇

We've implemented a brand new queuing system based on web sockets instead of HTTP long polling. Among other things, this allows us to manage queue sizes better on Hugging Face Spaces. There are also additional queue-related parameters you can add:

  • Now supports concurrent workers (parallelization)
demo = gr.Interface(...)
demo.queue(concurrency_count=3)
demo.launch()
  • Configure a maximum queue size
demo = gr.Interface(...)
demo.queue(max_size=100)
demo.launch()
  • If a user closes their tab / browser, they leave the queue, which means the demo will run faster for everyone else

2. Fixes to Examples

  • Dataframe examples will render properly, and look much clearer in the UI: (thanks to PR #2125)

Screen Shot 2022-08-30 at 8 29 58 PM

  • Image and Video thumbnails are cropped to look neater and more uniform: (thanks to PR #2109)

Screen Shot 2022-08-30 at 8 32 15 PM

  • Other fixes in PR #2131 and #2064 make it easier to design and use Examples

3. Component Fixes 🧱

  • Specify the width and height of an image in its style tag (thanks to PR #2133)
components.Image().style(height=260, width=300)
  • Automatic conversion of videos so they are playable in the browser (thanks to PR #2003). Gradio will check if a video's format is playable in the browser and, if it isn't, will automatically convert it to a format that is (mp4).
  • Pass in a json filepath to the Label component (thanks to PR #2083)
  • Randomize the default value of a Slider (thanks to PR #1935)

slider-random

  • Improvements to State in PR #2100

4. Ability to Randomize Input Sliders and Reload Data whenever the Page Loads

  • In some cases, you want to be able to show a different set of input data to every user as they load the page app. For example, you might want to randomize the value of a "seed" Slider input. Or you might want to show a Textbox with the current date. We now supporting passing functions as the default value in input components. When you pass in a function, it gets re-evaluated every time someone loads the demo, allowing you to reload / change data for different users.

Here's an example loading the current date time into an input Textbox:

import gradio as gr
import datetime

with gr.Blocks() as demo:
    gr.Textbox(datetime.datetime.now)
    
demo.launch()

Note that we don't evaluate the function -- datetime.datetime.now() -- we pass in the function itself to get this behavior -- datetime.datetime.now

Because randomizing the initial value of Slider is a common use case, we've added a randomize keyword argument you can use to randomize its initial value:

import gradio as gr
demo = gr.Interface(lambda x:x, gr.Slider(0, 10, randomize=True), "number")
demo.launch()

5. New Guide 🖊️

Full Changelog:

Contributors Shoutout:

Version 3.1

New Features:

1. Embedding Demos on Any Website 💻

With PR #1444, Gradio is now distributed as a web component. This means demos can be natively embedded on websites. You'll just need to add two lines: one to load the gradio javascript, and one to link to the demos backend.

Here's a simple example that embeds the demo from a Hugging Face space:

<script type="module" src="https://gradio.s3-us-west-2.amazonaws.com/3.0.18/gradio.js"></script>
<gradio-app space="abidlabs/pytorch-image-classifier"></gradio-app>

But you can also embed demos that are running anywhere, you just need to link the demo to src instead of space. In fact, all the demos on the gradio website are embedded this way:

Screen Shot 2022-07-14 at 2 41 44 PM

Read more in the Embedding Gradio Demos guide.

2. Reload Mode 👨‍💻

Reload mode helps developers create gradio demos faster by automatically reloading the demo whenever the code changes. It can support development on Python IDEs (VS Code, PyCharm, etc), the terminal, as well as Jupyter notebooks.

If your demo code is in a script named app.py, instead of running python app.py you can now run gradio app.py and that will launch the demo in reload mode:

Launching in reload mode on: http://127.0.0.1:7860 (Press CTRL+C to quit)
Watching...
WARNING: The --reload flag should not be used in production on Windows.

If you're working from a Jupyter or Colab Notebook, use these magic commands instead: %load_ext gradio when you import gradio, and %%blocks in the top of the cell with the demo code. Here's an example that shows how much faster the development becomes:

Blocks

3. Inpainting Support on gr.Image() 🎨

We updated the Image component to add support for inpainting demos. It works by adding tool="sketch" as a parameter, that passes both an image and a sketchable mask to your prediction function.

Here's an example from the LAMA space:

FXApVlFVsAALSD-

4. Markdown and HTML support in Dataframes 🔢

We upgraded the Dataframe component in PR #1684 to support rendering Markdown and HTML inside the cells.

This means you can build Dataframes that look like the following:

image (8)

5. gr.Examples() for Blocks 🧱

We've added the gr.Examples component helper to allow you to add examples to any Blocks demo. This class is a wrapper over the gr.Dataset component.

Screen Shot 2022-07-14 at 2 23 50 PM

gr.Examples takes two required parameters:

  • examples which takes in a nested list
  • inputs which takes in a component or list of components

You can read more in the Examples docs or the Adding Examples to your Demos guide.

6. Fixes to Audio Streaming

With PR [#1828](PR 1828),,) we now hide the status loading animation, as well as remove the echo in streaming. Check out the stream_audio demo for more or read through our Real Time Speech Recognition guide.

Screen Shot 2022-07-19 at 6 02 35 PM

Full Changelog:

Contributors Shoutout:

Version 3.0

🔥 Gradio 3.0 is the biggest update to the library, ever.

New Features:

1. Blocks 🧱

Blocks is a new, low-level API that allows you to have full control over the data flows and layout of your application. It allows you to build very complex, multi-step applications. For example, you might want to:

  • Group together related demos as multiple tabs in one web app
  • Change the layout of your demo instead of just having all of the inputs on the left and outputs on the right
  • Have multi-step interfaces, in which the output of one model becomes the input to the next model, or have more flexible data flows in general
  • Change a component's properties (for example, the choices in a Dropdown) or its visibility based on user input

Here's a simple example that creates the demo below it:

import gradio as gr

def update(name):
    return f"Welcome to Gradio, {name}!"

demo = gr.Blocks()

with demo:
    gr.Markdown(
    """
    # Hello World!
    Start typing below to see the output.
    """)
    inp = gr.Textbox(placeholder="What is your name?")
    out = gr.Textbox()

    inp.change(fn=update, 
               inputs=inp, 
               outputs=out)

demo.launch()

hello-blocks

Read our Introduction to Blocks guide for more, and join the 🎈 Gradio Blocks Party!

2. Our Revamped Design 🎨

We've upgraded our design across the entire library: from components, and layouts all the way to dark mode.

kitchen_sink

3. A New Website 💻

We've upgraded gradio.app to make it cleaner, faster and easier to use. Our docs now come with components and demos embedded directly on the page. So you can quickly get up to speed with what you're looking for.

website

4. New Components: Model3D, Dataset, and More..

We've introduced a lot of new components in 3.0, including Model3D, Dataset, Markdown, Button and Gallery. You can find all the components and play around with them here.

Model3d

Full Changelog:

Contributors Shoutout: