github gradio-app/gradio v3.1.0
v3.1

latest releases: gradio@5.0.0-beta.4, @gradio/dataframe@0.11.0-beta.4, @self/app@1.41.0-beta.3...
2 years ago

Here's what's new in gradio v3.1:

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, 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 change log below:

What's Changed

New Contributors

Full Changelog: v3.0.26...v3.1

Don't miss a new gradio release

NewReleases is sending notifications on new releases.