Here's what's new in gradio v3.2
:
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)
- Image and Video thumbnails are cropped to look neater and more uniform: (thanks to PR #2109)
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)
- 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 aTextbox
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 change log below:
What's Changed
- Reset components to original state by setting value to None by @freddyaboulton in #2044
- Cleaning up the way data is processed for components by @abidlabs in #1967
- version 3.1.8b by @abidlabs in #2063
- Wandb guide by @AK391 in #1898
- Add a flagging callback to save json files to a hugging face dataset by @chrisemezue in #1821
- Add data science demos to landing page by @freddyaboulton in #2067
- Hide time series + xgboost demos by default by @freddyaboulton in #2079
- Encourage people to keep trying when queue full by @apolinario in #2076
- Updated our analytics on creation of Blocks/Interface by @abidlabs in #2082
Label
component now accepts file paths to.json
files by @abidlabs in #2083- Fix issues related to demos in Spaces by @abidlabs in #2086
- Fix TimeSeries examples not properly displayed in UI by @dawoodkhan82 in #2064
- Fix infinite requests when doing tab item select by @freddyaboulton in #2070
- Accept deprecated
file
route as well by @abidlabs in #2099 - Allow frontend method execution on Block.load event by @codedealer in #2108
- Improvements to
State
by @abidlabs in #2100 - Catch IndexError, KeyError in video_is_playable by @freddyaboulton in #2113
- Fix: Download button does not respect the filepath returned by the function by @dawoodkhan82 in #2073
- Refactoring Layout: Adding column widths, forms, and more. by @aliabid94 in #2097
- Update CONTRIBUTING.md by @abidlabs in #2118
- 2092 df ex by @pngwn in #2125
- feat(samples table/gallery): Crop thumbs to square by @ronvoluted in #2109
- Some enhancements to
gr.Examples
by @abidlabs in #2131 - Image size fix by @aliabid94 in #2133
New Contributors
- @chrisemezue made their first contribution in #1821
- @apolinario made their first contribution in #2076
- @codedealer made their first contribution in #2108
Full Changelog: v3.1.7...v3.2