repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/scatter_plot/run.py | demo/scatter_plot/run.py | import gradio as gr
from vega_datasets import data
cars = data.cars()
iris = data.iris()
# # Or generate your own fake data
# import pandas as pd
# import random
# cars_data = {
# "Name": ["car name " + f" {int(i/10)}" for i in range(400)],
# "Miles_per_Gallon": [random.randint(10, 30) for _ in range(400)],... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/hidden_change/run.py | demo/hidden_change/run.py | import gradio as gr
import time
import random
def screen_data(data, n):
entry = data.get(f"{n}", {})
ts = entry.get("timestamp", "unknown time")
msg = entry.get("message", "unknown message")
return f"At {ts}, JS says: “{msg}”"
def increment_counter(counter):
return counter + 1
def update_hidde... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/image_segmentation/run.py | demo/image_segmentation/run.py | import gradio as gr
import numpy as np
import random
with gr.Blocks() as demo:
section_labels = [
"apple",
"banana",
"carrot",
"donut",
"eggplant",
"fish",
"grapes",
"hamburger",
"ice cream",
"juice",
]
with gr.Row():
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/change_vs_input/run.py | demo/change_vs_input/run.py | import gradio as gr
from gradio.media import get_image, get_audio, get_video, MEDIA_PATHS
with gr.Blocks() as demo:
set_button = gr.Button("Set Values")
counter = gr.Number(label="Change counter")
with gr.Row():
gr.Markdown("# Enter Here")
gr.Markdown("# ON:INPUT/UPLOAD")
gr.Markdo... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/sound_alert/run.py | demo/sound_alert/run.py | import time
import gradio as gr
js_function = "() => {new Audio('file=beep.mp3').play();}"
def task(x):
time.sleep(2)
return "Hello, " + x
with gr.Blocks() as demo:
name = gr.Textbox(label="name")
greeting = gr.Textbox(label="greeting")
name.blur(task, name, greeting)
greeting.change(None, []... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/lineplot_component/run.py | demo/lineplot_component/run.py | import gradio as gr
from vega_datasets import data
with gr.Blocks() as demo:
gr.LinePlot(
data.stocks(),
x="date",
y="price",
color="symbol",
title="Stock Prices",
tooltip=["date", "price", "symbol"],
height=300,
container=False,
)
if __name__ ==... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/llm_llamaindex/run.py | demo/llm_llamaindex/run.py | # This is a simple RAG chatbot built on top of Llama Index and Gradio. It allows you to upload any text or PDF files and ask questions about them!
# Before running this, make sure you have exported your OpenAI API key as an environment variable:
# export OPENAI_API_KEY="your-openai-api-key"
from llama_index.core impor... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/dropdown_component/run.py | demo/dropdown_component/run.py | import gradio as gr
with gr.Blocks() as demo:
gr.Dropdown(choices=["First Choice", "Second Choice", "Third Choice"])
demo.launch()
| python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/blocks_neural_instrument_coding/run.py | demo/blocks_neural_instrument_coding/run.py | # A Blocks implementation of https://erlj.notion.site/Neural-Instrument-Cloning-from-very-few-samples-2cf41d8b630842ee8c7eb55036a1bfd6
import datetime
import os
import random
import gradio as gr
from gradio.components import Markdown as m
def get_time():
now = datetime.datetime.now()
return now.strftime("%m/... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/barplot_component/run.py | demo/barplot_component/run.py | import gradio as gr
import pandas as pd
simple = pd.DataFrame(
{
"item": ["A", "B", "C", "D", "E", "F", "G", "H", "I"],
"inventory": [28, 55, 43, 91, 81, 53, 19, 87, 52],
}
)
with gr.Blocks() as demo:
gr.BarPlot(
value=simple,
x="item",
y="inventory",
title=... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/render_queue_false/run.py | demo/render_queue_false/run.py | import gradio as gr
with gr.Blocks() as demo:
input_text = gr.Textbox(label="Input Text")
@gr.render(inputs=input_text, queue=False)
def show_split(text):
if len(text) == 0:
gr.Markdown("## No Input Provided")
else:
for letter in text:
with gr.Row():... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/highlightedtext_component/run.py | demo/highlightedtext_component/run.py | import gradio as gr
with gr.Blocks() as demo:
gr.HighlightedText(
value=[("This is highlighted", "highlight"), ("This is not", None), ("This is also highlighted", "highlight")],
color_map={"highlight": "yellow"},
combine_adjacent=True,
)
demo.launch()
| python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/image_editor_webcam/run.py | demo/image_editor_webcam/run.py | import gradio as gr
def predict(im):
return im["composite"]
with gr.Blocks() as demo:
with gr.Row():
im = gr.ImageEditor(
canvas_size=(1024, 1024),
fixed_canvas=True,
webcam_options=gr.WebcamOptions(
constraints={"video": {"width": 1024, "height": ... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/rows_and_columns/run.py | demo/rows_and_columns/run.py | import gradio as gr
with gr.Blocks() as demo:
with gr.Row():
text1 = gr.Textbox(label="t1")
slider2 = gr.Textbox(label="s2")
drop3 = gr.Dropdown(["a", "b", "c"], label="d3")
with gr.Row():
with gr.Column(scale=1, min_width=300):
text1 = gr.Textbox(label="prompt 1")
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/bar_plot/run.py | demo/bar_plot/run.py | import gradio as gr
import pandas as pd
import random
simple = pd.DataFrame(
{
"a": ["A", "B", "C", "D", "E", "F", "G", "H", "I"],
"b": [28, 55, 43, 91, 81, 53, 19, 87, 52],
}
)
fake_barley = pd.DataFrame(
{
"site": [
random.choice(
[
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/webcam_constraints/run.py | demo/webcam_constraints/run.py | import gradio as gr
import cv2 # type: ignore
def get_video_shape(video):
cap = cv2.VideoCapture(video)
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
cap.release()
return {"width": width, "height": height}
def image_mod(image):
width, height =... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/hello_world/run.py | demo/hello_world/run.py | import gradio as gr
def greet(name):
return "Hello " + name + "!"
demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox", api_name="predict")
if __name__ == "__main__":
demo.launch()
| python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/chatbot_streaming/run.py | demo/chatbot_streaming/run.py | import gradio as gr
import random
import time
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
msg = gr.Textbox()
clear = gr.Button("Clear")
def user(user_message, history: list):
return "", history + [{"role": "user", "content": user_message}]
def bot(history: list):
bot_message ... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/dropdown_custom_value/run.py | demo/dropdown_custom_value/run.py | import gradio
with gradio.Blocks() as demo:
dropdown = gradio.Dropdown(
choices=[("hello", "goodbye"), ("abc", "123")],
allow_custom_value=True,
label="Dropdown",
)
text = gradio.Textbox(label="Output")
dropdown.change(lambda x: x, inputs=dropdown, outputs=text)
if __name__ == ... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/mcp_image_app/run.py | demo/mcp_image_app/run.py | import gradio as gr
import tempfile
from PIL import Image
import numpy as np
@gr.mcp.tool(
_meta={
"openai/outputTemplate": "ui://widget/app.html",
"openai/resultCanProduceWidget": True,
"openai/widgetAccessible": True,
}
)
def power_law_image(input_path: str, gamma: float = 0.5) -> s... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/paramviewer_component/run.py | demo/paramviewer_component/run.py | import gradio as gr
with gr.Blocks() as demo:
gr.Markdown("The `round()` function in Python takes two parameters")
gr.ParamViewer(
{ # type: ignore
"number": {
"type": "int | float",
"description": "The number to round",
"default": None
},
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/rt-detr-object-detection/run.py | demo/rt-detr-object-detection/run.py | # type: ignore
import spaces
import gradio as gr
import cv2 # type: ignore
from PIL import Image
import torch
import time
import numpy as np
import uuid
from transformers import RTDetrForObjectDetection, RTDetrImageProcessor # type: ignore
from draw_boxes import draw_bounding_boxes
image_processor = RTDetrImagePro... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/rt-detr-object-detection/draw_boxes.py | demo/rt-detr-object-detection/draw_boxes.py | from PIL import ImageDraw, ImageFont # type: ignore
import colorsys
def get_color(label):
# Simple hash function to generate consistent colors for each label
hash_value = hash(label)
hue = (hash_value % 100) / 100.0
saturation = 0.7
value = 0.9
rgb = colorsys.hsv_to_rgb(hue, saturation, value... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/tab_render_children/run.py | demo/tab_render_children/run.py | import gradio as gr
with gr.Blocks() as demo:
gr.Markdown("## Tab render_children parameter")
with gr.Tabs():
with gr.Tab("Tab 1") as tab1:
gr.Markdown("This tab is visible by default")
with gr.Tab("Tab 2", render_children=True) as tab2:
tb = gr.Textbox(label="Will be re... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/theme_extended_step_1/run.py | demo/theme_extended_step_1/run.py | import gradio as gr
import time
with gr.Blocks() as demo:
textbox = gr.Textbox(label="Name")
slider = gr.Slider(label="Count", minimum=0, maximum=100, step=1)
with gr.Row():
button = gr.Button("Submit", variant="primary")
clear = gr.Button("Clear")
output = gr.Textbox(label="Output")
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/tax_calculator/run.py | demo/tax_calculator/run.py | import gradio as gr
def tax_calculator(income, marital_status, assets):
tax_brackets = [(10, 0), (25, 8), (60, 12), (120, 20), (250, 30)]
total_deductible = sum(cost for cost, deductible in zip(assets["Cost"], assets["Deductible"]) if deductible)
taxable_income = income - total_deductible
total_tax = ... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/on_listener_decorator/run.py | demo/on_listener_decorator/run.py | import gradio as gr
with gr.Blocks() as demo:
name = gr.Textbox(label="Name")
output = gr.Textbox(label="Output Box")
greet_btn = gr.Button("Greet")
@gr.on(triggers=[name.submit, greet_btn.click], inputs=name, outputs=output)
def greet(name):
return "Hello " + name + "!"
if __name__ == "_... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/theme_extended_step_4/run.py | demo/theme_extended_step_4/run.py | import gradio as gr
import time
theme = gr.themes.Default(primary_hue="blue").set(
loader_color="#FF0000",
slider_color="#FF0000",
)
with gr.Blocks() as demo:
textbox = gr.Textbox(label="Name")
slider = gr.Slider(label="Count", minimum=0, maximum=100, step=1)
with gr.Row():
button = gr.But... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/stream_video_out/run.py | demo/stream_video_out/run.py | import gradio as gr
import cv2 # type: ignore
import os
from pathlib import Path
import atexit
current_dir = Path(__file__).resolve().parent
def delete_files():
for p in Path(current_dir).glob("*.ts"):
p.unlink()
for p in Path(current_dir).glob("*.mp4"):
p.unlink()
atexit.register(delete_f... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/request_ip_headers/run.py | demo/request_ip_headers/run.py | import gradio as gr
def predict(text, request: gr.Request):
headers = request.headers
host = request.client.host
user_agent = request.headers["user-agent"]
return {
"ip": host,
"user_agent": user_agent,
"headers": headers,
}
gr.Interface(predict, "text", "json", api_name="p... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/blocks_js_load/run.py | demo/blocks_js_load/run.py | import gradio as gr
def welcome(name):
return f"Welcome to Gradio, {name}!"
js = """
function createGradioAnimation() {
var container = document.createElement('div');
container.id = 'gradio-animation';
container.style.fontSize = '2em';
container.style.fontWeight = 'bold';
container.style.textA... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/image_component_events/run.py | demo/image_component_events/run.py | import gradio as gr
def test_select_is_defined(n, evt: gr.SelectData):
assert isinstance(evt.index, list)
assert isinstance(evt.index[0], int)
return n + 1
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
input_img = gr.Image(type="filepath", label="Input Image", sources=... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/question-answering/run.py | demo/question-answering/run.py | import gradio as gr
from transformers import pipeline
model_name = "deepset/roberta-base-squad2"
nlp = pipeline("question-answering", model=model_name, tokenizer=model_name)
context = "The Amazon rainforest, also known in English as Amazonia or the Amazon Jungle, is a moist broadleaf forest that covers most of the ... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/render_merge/run.py | demo/render_merge/run.py | import gradio as gr
import time
with gr.Blocks() as demo:
text_count = gr.Slider(1, 5, value=1, step=1, label="Textbox Count")
@gr.render(inputs=text_count)
def render_count(count):
boxes = []
for i in range(count):
box = gr.Textbox(label=f"Box {i}")
boxes.append(bo... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/image_mod_default_image/run.py | demo/image_mod_default_image/run.py | import gradio as gr
from gradio.media import get_image
def image_mod(image):
return image.rotate(45)
# get_image() returns file paths to sample media included with Gradio
cheetah = get_image("cheetah1.jpg")
demo = gr.Interface(image_mod, gr.Image(type="pil", value=cheetah), "image",
api_name=... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/file_component/run.py | demo/file_component/run.py | import gradio as gr
with gr.Blocks() as demo:
gr.File()
demo.launch()
| python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/chatinterface_echo_multimodal/run.py | demo/chatinterface_echo_multimodal/run.py | import gradio as gr
def echo_multimodal(message, history):
response = []
response.append("You wrote: '" + message["text"] + "' and uploaded:")
if message.get("files"):
for file in message["files"]:
response.append(gr.File(value=file))
return response
demo = gr.ChatInterface(
ec... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/dataframe_datatype/run.py | demo/dataframe_datatype/run.py | import gradio as gr
import pandas as pd
import numpy as np
def make_dataframe(n_periods):
rng = np.random.default_rng()
return pd.DataFrame({"date_1": pd.date_range("2021-01-01", periods=n_periods),
"date_2": pd.date_range("2022-02-15", periods=n_periods).strftime('%B %d, %Y, %r'),
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/kitchen_sink_random/run.py | demo/kitchen_sink_random/run.py | import gradio as gr
from datetime import datetime
import random
import string
import pandas as pd
# get_audio(), get_video(), get_image(), get_model3d(), get_file() return file paths to sample media included with Gradio
from gradio.media import get_audio, get_video, get_image, get_model3d, get_file
from constants imp... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/kitchen_sink_random/constants.py | demo/kitchen_sink_random/constants.py | import numpy as np
import matplotlib.pyplot as plt
import random
from gradio.media import get_model3d
def random_plot():
start_year = 2020
x = np.arange(start_year, start_year + random.randint(0, 10))
year_count = x.shape[0]
plt_format = "-"
fig = plt.figure()
ax = fig.add_subplot(111)
seri... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/kitchen_sink_random/__init__.py | demo/kitchen_sink_random/__init__.py | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false | |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/validator_simple/run.py | demo/validator_simple/run.py | import gradio as gr
def validate_input(age, location):
return [
gr.validate(not age or age > 3, "Age must be at least 3"),
gr.validate("london" not in location.lower(), "Location must not be in London"),
]
def process_text(age, location):
return f"Processed: {age} -- {location.upper()}"
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/blocks_hello/run.py | demo/blocks_hello/run.py | import gradio as gr
def welcome(name):
return f"Welcome to Gradio, {name}!"
with gr.Blocks() as 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(welcome, inp, out)
if _... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/theme_soft/run.py | demo/theme_soft/run.py | import gradio as gr
import time
with gr.Blocks() as demo:
textbox = gr.Textbox(label="Name")
slider = gr.Slider(label="Count", minimum=0, maximum=100, step=1)
with gr.Row():
button = gr.Button("Submit", variant="primary")
clear = gr.Button("Clear")
output = gr.Textbox(label="Output")
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/image_classifier/run.py | demo/image_classifier/run.py | import requests
import tensorflow as tf # type: ignore
import gradio as gr
# get_image() returns the file path to sample images included with Gradio
from gradio.media import get_image
inception_net = tf.keras.applications.MobileNetV2() # load the model
# Download human-readable labels for ImageNet.
response = requ... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/chatinterface_system_prompt/run.py | demo/chatinterface_system_prompt/run.py | import gradio as gr
import time
def echo(message, history, system_prompt, tokens):
response = f"System prompt: {system_prompt}\n Message: {message}."
for i in range(min(len(response), int(tokens))):
time.sleep(0.05)
yield response[: i + 1]
demo = gr.ChatInterface(
echo,
additional_inpu... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/audio_component_events/run.py | demo/audio_component_events/run.py | import gradio as gr
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
input_audio = gr.Audio(type="filepath", label="Input Audio", sources=["upload", "microphone"])
with gr.Column():
output_audio = gr.Audio(label="Output Audio", sources=["upload", "microphone"])
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/same-person-or-different/run.py | demo/same-person-or-different/run.py | # type: ignore
import gradio as gr
import torch
from torchaudio.sox_effects import apply_effects_file # type: ignore
from transformers import AutoFeatureExtractor, AutoModelForAudioXVector
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
OUTPUT_OK = (
"""
<div class="container">
<... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/image_classifier_2/run.py | demo/image_classifier_2/run.py | import requests
import torch
from PIL import Image
from torchvision import transforms # type: ignore
import gradio as gr
model = torch.hub.load("pytorch/vision:v0.6.0", "resnet18", pretrained=True).eval()
# Download human-readable labels for ImageNet.
response = requests.get("https://git.io/JJkYN")
labels = respons... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/chatbot_core_components_simple/run.py | demo/chatbot_core_components_simple/run.py | import gradio as gr
import random
# Chatbot demo with multimodal input (text, markdown, LaTeX, code blocks, image, audio, & video). Plus shows support for streaming text.
color_map = {
"harmful": "crimson",
"neutral": "gray",
"beneficial": "green",
}
def html_src(harm_level):
return f"""
<div style="... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/longest_word/run.py | demo/longest_word/run.py | import gradio as gr
def longest_word(text):
words = text.split(" ")
lengths = [len(word) for word in words]
return max(lengths)
ex = "The quick brown fox jumped over the lazy dog."
demo = gr.Interface(
longest_word, "textbox", "label", examples=[[ex]],
api_name="predict",
)
if __name__ == "__mai... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/gradio_pdf_demo/run.py | demo/gradio_pdf_demo/run.py | import gradio as gr
from gradio_pdf import PDF
from pathlib import Path
current_dir = Path(__file__).parent
demo = gr.Interface(lambda x: x,
PDF(),
gr.File(),
examples=[[str(current_dir / "contract.pdf")]],
api_name="predict")
if __name_... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/theme_extended_step_3/run.py | demo/theme_extended_step_3/run.py | import gradio as gr
import time
with gr.Blocks() as demo:
textbox = gr.Textbox(label="Name")
slider = gr.Slider(label="Count", minimum=0, maximum=100, step=1)
with gr.Row():
button = gr.Button("Submit", variant="primary")
clear = gr.Button("Clear")
output = gr.Textbox(label="Output")
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/chatinterface_artifacts/run.py | demo/chatinterface_artifacts/run.py | import gradio as gr
python_code = """
def fib(n):
if n <= 0:
return 0
elif n == 1:
return 1
else:
return fib(n-1) + fib(n-2)
"""
js_code = """
function fib(n) {
if (n <= 0) return 0;
if (n === 1) return 1;
return fib(n - 1) + fib(n - 2);
}
"""
def chat(message, history... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/number_component/run.py | demo/number_component/run.py | import gradio as gr
with gr.Blocks() as demo:
gr.Number()
demo.launch()
| python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/video_subtitle/run.py | demo/video_subtitle/run.py | import gradio as gr
from gradio.media import get_video, get_file
def video_demo(video, subtitle=None):
if subtitle is None:
return video
return gr.Video(label="Out", value=video, subtitles=subtitle.name)
demo = gr.Interface(
fn=video_demo,
inputs=[
gr.Video(label="In", interactive=True... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/hangman/run.py | demo/hangman/run.py | import gradio as gr
secret_word = "gradio"
with gr.Blocks() as demo:
used_letters_var = gr.State([])
with gr.Row() as row:
with gr.Column():
input_letter = gr.Textbox(label="Enter letter")
btn = gr.Button("Guess Letter")
with gr.Column():
hangman = gr.Textbo... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/bar_plot_demo/run.py | demo/bar_plot_demo/run.py | import pandas as pd
from random import randint, random
import gradio as gr
temp_sensor_data = pd.DataFrame(
{
"time": pd.date_range("2021-01-01", end="2021-01-05", periods=200),
"temperature": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
"humidity": [randint(50 + 10... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/tictactoe/run.py | demo/tictactoe/run.py | import gradio as gr
with gr.Blocks() as demo:
turn = gr.Textbox("X", interactive=False, label="Turn")
board = gr.Dataframe(value=[["", "", ""]] * 3, interactive=False, type="array")
def place(board: list[list[int]], turn, evt: gr.SelectData): # type: ignore
if evt.value:
return board,... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/zip_files/run.py | demo/zip_files/run.py | from zipfile import ZipFile
import gradio as gr
def zip_files(files):
with ZipFile("tmp.zip", "w") as zip_obj:
for file in files:
zip_obj.write(file.name, file.name.split("/")[-1])
return "tmp.zip"
demo = gr.Interface(
zip_files,
gr.File(file_count="multiple", file_types=["text", ... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/browser_state_component/run.py | demo/browser_state_component/run.py | import gradio as gr
with gr.Blocks() as demo:
gr.BrowserState()
demo.launch()
| python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/on_listener_basic/run.py | demo/on_listener_basic/run.py | import gradio as gr
with gr.Blocks() as demo:
name = gr.Textbox(label="Name")
output = gr.Textbox(label="Output Box")
greet_btn = gr.Button("Greet")
trigger = gr.Textbox(label="Trigger Box")
def greet(name, evt_data: gr.EventData):
return "Hello " + name + "!", evt_data.target.__class__.__... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/visibility_test/run.py | demo/visibility_test/run.py | import gradio as gr
def toggle_visibility(choice, input_text):
"""Toggle visibility based on choice and return current input value."""
updates = {}
if choice == "Visible":
updates["textbox"] = gr.update(visible=True)
updates["button"] = gr.update(visible=True)
elif choice == "Hidden (... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/llm_hf_transformers/run.py | demo/llm_hf_transformers/run.py | # type: ignore
from transformers import AutoModelForCausalLM, AutoTokenizer
import gradio as gr
checkpoint = "HuggingFaceTB/SmolLM2-135M-Instruct"
device = "cpu" # "cuda" or "cpu"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
def predict(mes... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/plot_guide_aggregate_temporal/run.py | demo/plot_guide_aggregate_temporal/run.py | import gradio as gr
from data import df # type: ignore
with gr.Blocks() as demo:
plot = gr.BarPlot(df, x="time", y="price", x_bin="10m")
bins = gr.Radio(["10m", "30m", "1h"], label="Bin Size")
bins.change(lambda bins: gr.BarPlot(x_bin=bins), bins, plot)
if __name__ == "__main__":
demo.launch() | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/plot_guide_aggregate_temporal/data.py | demo/plot_guide_aggregate_temporal/data.py | import pandas as pd
import numpy as np
import random
from datetime import datetime, timedelta
now = datetime.now()
df = pd.DataFrame({
'time': [now - timedelta(minutes=5*i) for i in range(25)],
'price': np.random.randint(100, 1000, 25),
'origin': [random.choice(["DFW", "DAL", "HOU"]) for _ in range(25)],
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/upload_file_limit_test/run.py | demo/upload_file_limit_test/run.py | import gradio as gr
with gr.Blocks() as demo:
gr.Markdown("""
# ⬆️📁 max_file_size test
The demo has a max file size of 15kb. The error modal should pop up when a file larger than that is uploaded.
""")
with gr.Row():
with gr.Column():
gr.Image(label="Image", interacti... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/unified_demo_text_generation/run.py | demo/unified_demo_text_generation/run.py | import gradio as gr
from transformers import pipeline
generator = pipeline('text-generation', model = 'gpt2')
def generate_text(text_prompt):
response = generator(text_prompt, max_length = 30, num_return_sequences=5)
return response[0]['generated_text'] # type: ignore
textbox = gr.Textbox()
demo = gr.Interface... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/gallery_component_events/run.py | demo/gallery_component_events/run.py | import gradio as gr
with gr.Blocks() as demo:
files = [
"https://gradio-builds.s3.amazonaws.com/assets/cheetah-003.jpg",
"https://gradio-static-files.s3.amazonaws.com/world.mp4",
"https://gradio-builds.s3.amazonaws.com/assets/TheCheethcat.jpg",
]
with gr.Row():
with gr.Colum... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/sort_records/run.py | demo/sort_records/run.py | import gradio as gr
def sort_records(records):
return records.sort("Quantity")
demo = gr.Interface(
sort_records,
gr.Dataframe(
headers=["Item", "Quantity"],
datatype=["str", "number"], # type: ignore
row_count=3,
column_count=2,
column_limits=(2, 2),
type=... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/image_editor_many/run.py | demo/image_editor_many/run.py | import gradio as gr
with gr.Blocks() as demo:
with gr.Tab("Default ImageEditor"):
im = gr.ImageEditor(value="./cheetah.jpg", interactive=True, fixed_canvas=True)
with gr.Tab("Brush Options"):
with gr.Row():
with gr.Column():
image_editor = gr.ImageEditor(
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/blocks_form/run.py | demo/blocks_form/run.py | import gradio as gr
with gr.Blocks() as demo:
name_box = gr.Textbox(label="Name")
age_box = gr.Number(label="Age", minimum=0, maximum=100)
symptoms_box = gr.CheckboxGroup(["Cough", "Fever", "Runny Nose"])
submit_btn = gr.Button("Submit")
with gr.Column(visible=False) as output_col:
diagnos... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/text_analysis/run.py | demo/text_analysis/run.py | import gradio as gr
import os
os.system('python -m spacy download en_core_web_sm')
import spacy # type: ignore
from spacy import displacy # type: ignore
nlp = spacy.load("en_core_web_sm")
def text_analysis(text):
doc = nlp(text)
html = displacy.render(doc, style="dep", page=True)
html = (
"<div ... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/reverse_audio_2/run.py | demo/reverse_audio_2/run.py | import gradio as gr
import numpy as np
def reverse_audio(audio):
sr, data = audio
return (sr, np.flipud(data))
demo = gr.Interface(fn=reverse_audio,
inputs="microphone",
outputs="audio", api_name="predict")
if __name__ == "__main__":
demo.launch()
| python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/html_autoscroll/run.py | demo/html_autoscroll/run.py | import gradio as gr
import time
def longer(val):
for i in range(10):
val = val + f"<p>This is paragraph {i+1}.</p>"
time.sleep(0.2)
yield val
with gr.Blocks() as demo:
h = gr.HTML(value="<p>This is a paragraph 0.</p>", max_height=200, autoscroll=True)
demo.load(longer, h, h)
demo.... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/chicago-bikeshare-dashboard/run.py | demo/chicago-bikeshare-dashboard/run.py | import os
import gradio as gr
import pandas as pd
DB_USER = os.getenv("DB_USER")
DB_PASSWORD = os.getenv("DB_PASSWORD")
DB_HOST = os.getenv("DB_HOST")
PORT = 8080
DB_NAME = "bikeshare"
connection_string = (
f"postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}?port={PORT}&dbname={DB_NAME}"
)
def get_count_ride_type()... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/video_identity_2/run.py | demo/video_identity_2/run.py | import gradio as gr
def video_identity(video):
return video
demo = gr.Interface(video_identity,
gr.Video(),
"playable_video",
api_name="predict"
)
if __name__ == "__main__":
demo.launch()
| python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/generate_english_german/run.py | demo/generate_english_german/run.py | import gradio as gr
from transformers import pipeline
english_translator = gr.load(name="spaces/gradio/english_translator")
english_generator = pipeline("text-generation", model="distilgpt2")
def generate_text(text):
english_text = english_generator(text)[0]["generated_text"] # type: ignore
german_text = en... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/image_editor_story/run.py | demo/image_editor_story/run.py | import gradio as gr
from pathlib import Path
import subprocess
def predict(im):
path = str(Path(__file__).parent / "output-image.png")
with open(path, "wb") as f:
f.write(Path(im["composite"]).read_bytes())
print("Writing to ", path)
return path
with gr.Blocks() as demo:
with gr.Row():
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/plot_guide_series_quantitative/run.py | demo/plot_guide_series_quantitative/run.py | import gradio as gr
from data import df # type: ignore
with gr.Blocks() as demo:
gr.ScatterPlot(df, x="weight", y="height", color="age")
if __name__ == "__main__":
demo.launch() | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/plot_guide_series_quantitative/data.py | demo/plot_guide_series_quantitative/data.py | import pandas as pd
import numpy as np
import random
df = pd.DataFrame({
'height': np.random.randint(50, 70, 25),
'weight': np.random.randint(120, 320, 25),
'age': np.random.randint(18, 65, 25),
'ethnicity': [random.choice(["white", "black", "asian"]) for _ in range(25)]
})
| python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/sepia_filter/run.py | demo/sepia_filter/run.py | import numpy as np
import gradio as gr
def sepia(input_img):
sepia_filter = np.array([
[0.393, 0.769, 0.189],
[0.349, 0.686, 0.168],
[0.272, 0.534, 0.131]
])
sepia_img = input_img.dot(sepia_filter.T)
sepia_img /= sepia_img.max()
return sepia_img
demo = gr.Interface(sepia, g... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/navbar_query_params/run.py | demo/navbar_query_params/run.py | """This is a demo of a custom navbar that preserves query parameters from one page to the next."""
import gradio as gr
def update_navbar_with_query(choice):
"""Updates navbar links to preserve query parameters"""
if choice:
return [("Main Page", f"?option={choice}"), ("Page 2", f"second?option={choice... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/load_space/run.py | demo/load_space/run.py | import gradio as gr
demo = gr.load("gradio/test-gr-load", src="spaces")
if __name__ == "__main__":
demo.launch()
| python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/validator_test/run.py | demo/validator_test/run.py | import gradio as gr
def validate_input(age, location):
is_age_valid = True
is_location_valid = True
if not age or age < 3:
is_age_valid = False
if "london" in location.lower():
is_location_valid = False
return [
gr.validate(is_age_valid, "Age must be at least 3"),
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/stream_asr/run.py | demo/stream_asr/run.py | import gradio as gr
from transformers import pipeline
import numpy as np
transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")
def transcribe(stream, new_chunk):
sr, y = new_chunk
# Convert to mono if stereo
if y.ndim > 1:
y = y.mean(axis=1)
y = y... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/datetimes/run.py | demo/datetimes/run.py | import gradio as gr
with gr.Blocks() as demo:
date1 = gr.DateTime(include_time=True, label="Date and Time", type="datetime", elem_id="date1")
date2 = gr.DateTime(include_time=False, label="Date Only", type="string", elem_id="date2")
date3 = gr.DateTime(elem_id="date3", timezone="Europe/Paris")
with gr... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/dataframe_streaming/run.py | demo/dataframe_streaming/run.py | import gradio as gr
import pandas as pd
import time
def update_dataframe(df):
df.iloc[:, :] = 1
yield df, 1
time.sleep(0.1)
df.iloc[:, :] = 2
yield df, 2
def sum_values(df):
return pd.to_numeric(df.values.flatten(), errors='coerce').sum() # type: ignore
initial_df = pd.DataFrame(0, index=rang... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/star_rating_simple/run.py | demo/star_rating_simple/run.py | import gradio as gr
with gr.Blocks() as demo:
three_star_rating = gr.HTML("""
<h2>Star Rating:</h2>
<img src='https://upload.wikimedia.org/wikipedia/commons/d/df/Award-star-gold-3d.svg'>
<img src='https://upload.wikimedia.org/wikipedia/commons/d/df/Award-star-gold-3d.svg'>
<img src=... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/plot_guide_scatter/run.py | demo/plot_guide_scatter/run.py | import gradio as gr
from data import df # type: ignore
with gr.Blocks() as demo:
gr.ScatterPlot(df, x="weight", y="height")
if __name__ == "__main__":
demo.launch() | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/plot_guide_scatter/data.py | demo/plot_guide_scatter/data.py | import pandas as pd
import numpy as np
import random
df = pd.DataFrame({
'height': np.random.randint(50, 70, 25),
'weight': np.random.randint(120, 320, 25),
'age': np.random.randint(18, 65, 25),
'ethnicity': [random.choice(["white", "black", "asian"]) for _ in range(25)]
})
| python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/reversible_flow/run.py | demo/reversible_flow/run.py | import gradio as gr
def increase(num):
return num + 1
with gr.Blocks() as demo:
a = gr.Number(label="a")
b = gr.Number(label="b")
atob = gr.Button("a > b")
btoa = gr.Button("b > a")
atob.click(increase, a, b)
btoa.click(increase, b, a)
if __name__ == "__main__":
demo.launch()
| python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/state_change/run.py | demo/state_change/run.py | import gradio as gr
with gr.Blocks() as demo:
with gr.Row():
state_a = gr.State(0)
btn_a = gr.Button("Increment A")
value_a = gr.Number(label="Number A")
btn_a.click(lambda x: x + 1, state_a, state_a)
state_a.change(lambda x: x, state_a, value_a)
with gr.Row():
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/variable_outputs/run.py | demo/variable_outputs/run.py | import gradio as gr
max_textboxes = 10
def variable_outputs(k):
k = int(k)
return [gr.Textbox(visible=True)]*k + [gr.Textbox(visible=False)]*(max_textboxes-k)
with gr.Blocks() as demo:
s = gr.Slider(1, max_textboxes, value=max_textboxes, step=1, label="How many textboxes to show:")
textboxes = []
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/progress_simple/run.py | demo/progress_simple/run.py | import gradio as gr
import time
def slowly_reverse(word, progress=gr.Progress()):
progress(0, desc="Starting")
time.sleep(1)
progress(0.05)
new_string = ""
for letter in progress.tqdm(word, desc="Reversing"):
time.sleep(0.25)
new_string = letter + new_string # type: ignore
retu... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/chatbot_dialogpt/run.py | demo/chatbot_dialogpt/run.py | # type: ignore
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium")
model = AutoModelForCausalLM.from_pretrained("microsoft/DialoGPT-medium")
def user(message, history):
return "", history + [[message, ... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/titanic_survival/run.py | demo/titanic_survival/run.py | import pandas as pd
from sklearn.ensemble import RandomForestClassifier # type: ignore
from sklearn.model_selection import train_test_split # type: ignore
import gradio as gr
# get_file() returns the file path to sample data files included with Gradio
from gradio.media import get_file
data = pd.read_csv(get_file("t... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/chatbot_consecutive/run.py | demo/chatbot_consecutive/run.py | import gradio as gr
import random
import time
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
msg = gr.Textbox()
clear = gr.Button("Clear")
def user(user_message, history):
return "", history + [{"role": "user", "content": user_message}]
def bot(history):
bot_message = random.cho... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/chatbot_nested_thoughts/run.py | demo/chatbot_nested_thoughts/run.py | import gradio as gr
from gradio import ChatMessage
import time
sleep_time = 0.1
long_sleep_time = 1
def generate_response(history):
history.append(
ChatMessage(
role="user", content="What is the weather in San Francisco right now?"
)
)
yield history
time.sleep(sleep_time)
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/blocks_chained_events/run.py | demo/blocks_chained_events/run.py | import gradio as gr
def failure():
raise gr.Error("This should fail!")
def exception():
raise ValueError("Something went wrong")
def success():
return True
def warning_fn():
gr.Warning("This is a warning!")
def info_fn():
gr.Info("This is some info")
with gr.Blocks() as demo:
gr.Markdown("... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.