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:
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:
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:
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:
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.
gr.Examples takes two required parameters:
examples
which takes in a nested listinputs
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.
Full change log below:
What's Changed
- File component: list multiple files and allow for download #1446 by @dawoodkhan82 in #1681
- Add ColorPicker to docs by @freddyaboulton in #1768
- Mock out requests in TestRequest unit tests by @freddyaboulton in #1794
- Add requirements.txt and test_files to source dist by @freddyaboulton in #1817
- refactor: f-string for tunneling.py by @nhankiet in #1819
- Miscellaneous formatting improvements to website by @aliabd in #1754
integrate()
method moved toBlocks
by @abidlabs in #1776- Add python-3.7 tests by @freddyaboulton in #1818
- Copy test dir in website dockers by @aliabd in #1827
- Add info to docs on how to set default values for components by @freddyaboulton in #1788
- Embedding Components on Docs by @aliabd in #1726
- Remove usage of deprecated gr.inputs and gr.outputs from website by @freddyaboulton in #1796
- Some cleanups to the docs page by @abidlabs in #1822
New Contributors
Full Changelog: v3.0.26...v3.1