NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #1673 most downloaded on PyPI
Python library for easily interacting with trained machine learning models
Last release 2 days ago
02 Oct 2026
Ships on a steady schedule
a new release about every 2 weeks
Nearly every release is documented
notes for 58 of the last 60 stable releases
11 versions withdrawn
withdrawn after publishing
8 years old
679 releases · first in 2019
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.
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 shou
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()
New API Docs page with in-browser playground and updated aesthetics. @gary149 in PR 2652
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
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()
https://user-images.githubusercontent.com/9021060/202878400-cb16ed47-f4dd-4cb0-b2f0-102a9ff64135.mov
No changes to highlight.
No changes to highlight.
gr.Interface.load() by @abidlabs in PR 2694No changes to highlight.
Passes kwargs into gr.Interface.load() by @abidlabs in PR 2669
No changes to highlight.
No changes to highlight.
No changes to highlight.
No changes to highlight.
No changes to highlight.
This will cause demos using the deprecated gr.Textbox(type="number") to raise an exception.
'password' and 'email' types to Textbox. @pngwn in PR 2653gr.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.gr.Interface.load by @freddyaboulton PR 2640interactive property of a component could not be updated by @freddyaboulton in PR 2639No changes to highlight.
No changes to highlight.
No changes to highlight.
Only set a min height on md and html when loading by @pngwn in PR 2623
No changes to highlight.
pd.read_sql as opposed to low-level postgres connector by @freddyaboulton in PR 2604No changes to highlight.
No changes to highlight.
gr.Templates to accept parameters to override the defaults by @abidlabs in PR 2600ValueError() if constructed with invalid parameters for type or source (for components that take those parameters) in PR 2610No changes to highlight.
Gradio is now embedded directly in colab without requiring the share link by @aliabid94 in PR 2455
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 precedence over the fn_index parameter.
gr.Blocks.load() now correctly loads example files from Spaces @abidlabs in PR 2594No changes to highlight.
No changes to highlight.
api_name to Blocks.__call__ by @freddyaboulton in PR 2593No changes to highlight.
Ensure gradio apps embedded via spaces use the correct endpoint for predictions. @pngwn in PR 2567
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:
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()
No changes to highlight.
queue and auth when working with reload mode by by @freddyaboulton in PR 3089No changes to highlight.
No changes to highlight.
api_key to gr.Interface.load()
by @abidlabs in PR 2568No changes to highlight.
Nothing published for this version
Nothing published for this version
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
No changes to highlight.
No changes to highlight.
No changes to highlight.
every keyword to event listeners that runs events on a fixed schedule by @freddyaboulton in PR 2512No changes to highlight.
Nothing published for this version
Nothing published for this version
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
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).
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)
/api endpoint from skipping the queue if the queue is enabled for that event by @freddyaboulton in PR 2493cancels in event triggers so that it works properly if multiple
Blocks are rendered by @abidlabs in PR 2530No changes to highlight.
No changes to highlight.
share=True by @abidlabs in PR 2502upload event for Video, Audio, Image, and File components @dawoodkhan82 in PR 2448Series or Parallel with Blocks by @abidlabs in PR 2543float64, float16, or uint16 formats by @abidlabs in PR 2545No changes to highlight.
Running events can be cancelled when other events are triggered! To test this feature, pass the cancels parameter to the event listener. For this feat
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.
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()
No changes to highlight.
No changes to highlight.
No changes to highlight.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
The Carousel component is officially deprecated. Since gradio 3.0, code containing the Carousel component would throw warnings. As of the next release…
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:
interactive kwarg is not set.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 1711gr.Dataset component now accepts HTML and Markdown components by @abidlabs in PR 2437No changes to highlight.
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.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 2400Blocks.load() event by @abidlabs in PR 2413gr.Plot() component @dawoodkhan82 in PR 2402Textbox and Number components @dawoodkhan82 in PR 2448No changes to highlight.
…by @aliabid94 in PR 2291 This comes with deprecation of the following arguments for Component.style: round, margin, border.
You can now see gradio's release history directly on the website, and also keep track of upcoming changes. Just go here.
gr.Row(variant="compact") by @aliabid94 in PR 2291 This comes with deprecation of the following arguments for Component.style: round, margin, border.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.
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.
Small fixes to docs for Image component by @abidlabs in PR 2372
No changes to highlight.
No changes to highlight.
analytics dependency by @abidlabs in PR 2347Image component by @abidlabs in PR 2372gr.update() dictionary even if post-processing is disabled @abidlabs in PR 2385No changes to highlight.
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 an
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()
<img src="https://user-images.githubusercontent.com/9021060/192399521-7360b1a9-7ce0-443e-8e94-863a230a7dbe.gif" alt="gallery_captions" width="1000"/>
You can now type values directly on the Slider component! Here's what it looks like:
We've made a lot of changes to our Image component so that it can support better sketching and inpainting.
Now supports:
import gradio as gr
demo = gr.Interface(lambda x: x, gr.Sketchpad(), gr.Image())
demo.launch()
import gradio as gr
demo = gr.Interface(lambda x: x, gr.Paint(), gr.Image())
demo.launch()
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()
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()
As well as other fixes
gr.update() in example caching by @abidlabs in PR 2309postprocess and preprocess to documented parameters by @abidlabs in PR 2293postprocess and preprocess to documented parameters by @abidlabs in PR 2293gr.update() in example caching by @abidlabs in PR 2309Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
You can now create an iterative output simply by having your function return a generator!
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]
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
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()
No changes to highlight.
No changes to highlight.
No changes to highlight.
No changes to highlight.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Accept deprecated file route as well by @abidlabs in PR 2099
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:
demo = gr.Interface(...)
demo.queue(concurrency_count=3)
demo.launch()
demo = gr.Interface(...)
demo.queue(max_size=100)
demo.launch()
components.Image().style(height=260, width=300)
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()
Label component now accepts file paths to .json files by @abidlabs in PR 2083file route as well by @abidlabs in PR 2099State by @abidlabs in PR 2100gr.Examples by @abidlabs in PR 2131Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →