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/datetime_component/run.py | demo/datetime_component/run.py | import gradio as gr
with gr.Blocks() as demo:
gr.DateTime()
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/calculator_live/run.py | demo/calculator_live/run.py | import gradio as gr
def calculator(num1, operation, num2):
if operation == "add":
return num1 + num2
elif operation == "subtract":
return num1 - num2
elif operation == "multiply":
return num1 * num2
elif operation == "divide":
return num1 / num2
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/blocks_xray/run.py | demo/blocks_xray/run.py | import gradio as gr
disease_values = [0.25, 0.5, 0.75]
def xray_model(diseases, img):
return [{disease: disease_values[idx] for idx,disease in enumerate(diseases)}]
def ct_model(diseases, img):
return [{disease: 0.1 for disease in diseases}]
with gr.Blocks(fill_width=True) as demo:
gr.Markdown(
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/tabs_visibility/run.py | demo/tabs_visibility/run.py | import gradio as gr
with gr.Blocks() as demo:
with gr.Tab("abc"):
gr.Textbox(label="abc")
with gr.Tab("def", visible=False) as t:
gr.Textbox(label="def")
with gr.Tab("ghi"):
gr.Textbox(label="ghi")
with gr.Tab("jkl", visible=False) as t2:
gr.Textbox(label="jkl")
with... | 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_deep_link/run.py | demo/chatinterface_deep_link/run.py | import time
import gradio as gr
def slow_echo(message, history):
for i in range(len(message["text"])):
time.sleep(0.05)
yield "You typed: " + message["text"][: i + 1]
chat = gr.ChatInterface(
slow_echo,
flagging_mode="manual",
flagging_options=["Like", "Spam", "Inappropriate", "Other"]... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/code/run.py | demo/code/run.py | import gradio as gr
import os
from time import sleep
css_file = os.path.join(os.path.dirname(__file__), "file.css")
def set_lang(language):
print(language)
return gr.Code(language=language)
def set_lang_from_path():
sleep(1)
return gr.Code(open(css_file).read(), language="css")
def code(language, co... | 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_save_history/run.py | demo/chatinterface_save_history/run.py | import gradio as gr
def echo_multimodal(message, history):
response = "You wrote: '" + message["text"] + "' and uploaded: " + str(len(message["files"])) + " files"
return response
demo = gr.ChatInterface(
echo_multimodal,
multimodal=True,
textbox=gr.MultimodalTextbox(file_count="multiple"),
sa... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/test_chatinterface_multimodal_examples/run.py | demo/test_chatinterface_multimodal_examples/run.py | import gradio as gr
image = gr.get_image("avatar.png")
audio = gr.get_audio("cantina.wav")
def echo(message, history):
return f"You wrote: {message['text']} and uploaded {len(message['files'])} files."
demo = gr.ChatInterface(
fn=echo,
examples=[{"text": "hello"}, {"text": "hola", "files": [image]}, {"te... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/test_chatinterface_multimodal_examples/cached_testcase.py | demo/test_chatinterface_multimodal_examples/cached_testcase.py | import gradio as gr
image = gr.get_image("avatar.png")
audio = gr.get_audio("cantina.wav")
def echo(message, history):
return f"You wrote: {message['text']} and uploaded {len(message['files'])} files."
demo = gr.ChatInterface(
fn=echo,
examples=[{"text": "hello"}, {"text": "hola", "files": [image]}, {"te... | 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_component/run.py | demo/plot_component/run.py | import gradio as gr
import matplotlib.pyplot as plt
import numpy as np
Fs = 8000
f = 5
sample = 8000
x = np.arange(sample)
y = np.sin(2 * np.pi * f * x / Fs)
plt.plot(x, y)
with gr.Blocks() as demo:
gr.Plot(value=plt)
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/gpt2_xl_unified/run.py | demo/gpt2_xl_unified/run.py | import gradio as gr
component = gr.Textbox(lines=5, label="Text")
api = gr.load("huggingface/gpt2-xl")
demo = gr.Interface(
fn=lambda x: x[:-50] + api(x[-50:]),
inputs=component,
outputs=component,
title="gpt2-xl",
)
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/mcp_letter_counter_app/run.py | demo/mcp_letter_counter_app/run.py | import gradio as gr
@gr.mcp.tool(
_meta={
"openai/outputTemplate": "ui://widget/app.html",
"openai/resultCanProduceWidget": True,
"openai/widgetAccessible": True,
}
)
def letter_counter(word: str, letter: str) -> int:
"""
Count the number of letters in a word or phrase.
Pa... | 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_random_slider/run.py | demo/blocks_random_slider/run.py |
import gradio as gr
def func(slider_1, slider_2):
return slider_1 * 5 + slider_2
with gr.Blocks() as demo:
slider = gr.Slider(minimum=-10.2, maximum=15, label="Random Slider (Static)", randomize=True)
slider_1 = gr.Slider(minimum=100, maximum=200, label="Random Slider (Input 1)", randomize=True)
slid... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/main_note/run.py | demo/main_note/run.py | from math import log2, pow
import numpy as np
from scipy.fftpack import fft
import gradio as gr
from gradio.media import get_audio
A4 = 440
C0 = A4 * pow(2, -4.75)
name = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
def get_pitch(freq):
h = round(12 * log2(freq / C0))
n = h % 12
ret... | 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/run.py | demo/webcam/run.py |
import gradio as gr
def snap(image, video):
return [image, video]
demo = gr.Interface(
snap,
[gr.Image(sources=["webcam"]), gr.Video(sources=["webcam"])],
["image", "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/draggable_dashboard/run.py | demo/draggable_dashboard/run.py | import gradio as gr
import numpy as np
import pandas as pd
with gr.Blocks() as demo:
gr.Markdown("# Draggable Dashboard Demo")
gr.Markdown("Drag the charts around to reorder them!")
x = np.linspace(0, 10, 100)
data = pd.DataFrame({
'x': x,
'y1': np.random.normal(100, 20, 100) + 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/image_watermark/run.py | demo/image_watermark/run.py | import gradio as gr
import os
from gradio.media import get_image
# get_image() returns file paths to sample media included with Gradio
base_a = get_image("groot.jpeg")
base_b = os.path.join(os.path.dirname(__file__), "files/bird.bmp")
watermark_a = get_image("hf-logo_transpng.png")
watermark_b = os.path.join(os.path.... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/annotatedimage_component/run.py | demo/annotatedimage_component/run.py | import gradio as gr
import numpy as np
import requests
from io import BytesIO
from PIL import Image
base_image = "https://gradio-docs-json.s3.us-west-2.amazonaws.com/base.png"
building_image = requests.get("https://gradio-docs-json.s3.us-west-2.amazonaws.com/buildings.png")
building_image = np.asarray(Image.open(Byt... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/color_picker/run.py | demo/color_picker/run.py | import gradio as gr
import numpy as np
from PIL import Image, ImageColor
def change_color(icon, color):
"""
Function that given an icon in .png format changes its color
Args:
icon: Icon whose color needs to be changed.
color: Chosen color with which to edit the input icon.
Returns:
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/scatter_plot_demo/run.py | demo/scatter_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/asr/run.py | demo/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(audio):
sr, y = audio
# Convert to mono if stereo
if y.ndim > 1:
y = y.mean(axis=1)
y = y.astype(np.float... | 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_nominal/run.py | demo/plot_guide_aggregate_nominal/run.py | import gradio as gr
from data import df # type: ignore
with gr.Blocks() as demo:
gr.BarPlot(df, x="ethnicity", y="height", y_aggregate="mean")
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_nominal/data.py | demo/plot_guide_aggregate_nominal/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/image_editor/run.py | demo/image_editor/run.py | import gradio as gr
import time
def sleep(im):
time.sleep(5)
return [im["background"], im["layers"][0], im["layers"][1], im["composite"]]
def predict(im):
return im["composite"]
with gr.Blocks() as demo:
with gr.Row():
im = gr.ImageEditor(
type="numpy",
)
im_pre... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/diffusers_with_batching/run.py | demo/diffusers_with_batching/run.py | import torch
from diffusers import DiffusionPipeline # type: ignore
import gradio as gr
generator = DiffusionPipeline.from_pretrained("CompVis/ldm-text2im-large-256")
# move to GPU if available
if torch.cuda.is_available():
generator = generator.to("cuda")
def generate(prompts):
images = generator(list(prompts... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/sales_projections/run.py | demo/sales_projections/run.py | import matplotlib.pyplot as plt
import numpy as np
import gradio as gr
def sales_projections(employee_data):
sales_data = employee_data.iloc[:, 1:4].astype("int").to_numpy()
regression_values = np.apply_along_axis(
lambda row: np.array(np.poly1d(np.polyfit([0, 1, 2], row, 2))), 0, sales_data
)
... | 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_tab/run.py | demo/dataframe_tab/run.py | import gradio as gr
with gr.Blocks() as demo:
with gr.Tab():
gr.HTML("<p>hi</p>")
with gr.Tab():
gr.Dataframe(
value=[[i + 1] for i in range(10)],
)
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/zip_to_json/run.py | demo/zip_to_json/run.py | from zipfile import ZipFile
import gradio as gr
def zip_to_json(file_obj):
files = []
with ZipFile(file_obj.name) as zfile:
for zinfo in zfile.infolist():
files.append(
{
"name": zinfo.filename,
"file_size": zinfo.file_size,
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/textbox_custom_buttons/run.py | demo/textbox_custom_buttons/run.py | import gradio as gr
def export_data(text):
print("Exporting data:", text)
return "Data exported to server!"
def refresh_data():
import random
return f"Refreshed content: {random.randint(1000, 9999)}"
with gr.Blocks() as demo:
gr.Markdown("""
# Textbox with Custom Buttons Demo
This de... | 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_reasoning_tags/run.py | demo/chatbot_reasoning_tags/run.py | import gradio as gr
def respond(message, history):
response = """<thinking>
Let me analyze this problem step by step.
First, I need to understand what the user is asking.
Then I can formulate a proper response.
</thinking>
Based on your question, here's my answer: This is the main response content that should be ... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/sub_block_render/run.py | demo/sub_block_render/run.py | import gradio as gr
import os
from pathlib import Path
from PIL import Image
root = Path(os.path.dirname(__file__))
def infer(
text,
guidance_scale,
):
img = (
Image.open(root / "cheetah.jpg")
if text == "Cheetah"
else Image.open(root / "frog.jpg")
)
img = img.resize((224... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/component_props/run.py | demo/component_props/run.py | import gradio as gr
from gradio.media import get_image
with gr.Blocks() as demo:
a = gr.Number(value=5, minimum=0, maximum=10, label="Input A", info="Enter a number between 0 and 10")
output_a = gr.JSON(label="Output", elem_id="output")
with gr.Row():
show_value_btn = gr.Button("Show 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/gif_maker/run.py | demo/gif_maker/run.py | import gradio as gr
import os
import tempfile
from PIL import Image
def gif_maker(img_files):
img_array = []
for filename, _ in img_files:
pil_img = Image.open(filename)
if pil_img.mode in ('RGBA', 'LA', 'P'):
pil_img = pil_img.convert('RGB')
img_array.append(pil_img)
... | 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_split/run.py | demo/render_split/run.py | import gradio as gr
with gr.Blocks() as demo:
input_text = gr.Textbox(label="input")
mode = gr.Radio(["textbox", "button"], value="textbox")
@gr.render(inputs=[input_text, mode], triggers=[input_text.submit])
def show_split(text, mode):
if len(text) == 0:
gr.Markdown("## No Input 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/musical_instrument_identification/run.py | demo/musical_instrument_identification/run.py | import gradio as gr
import torch
import torchaudio # type: ignore
from timeit import default_timer as timer
from data_setups import audio_preprocess, resample # type: ignore
import gdown # type: ignore
url = 'https://drive.google.com/uc?id=1X5CR18u0I-ZOi_8P0cNptCe5JGk9Ro0C'
output = 'piano.wav'
gdown.download(url, ... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/musical_instrument_identification/data_setups.py | demo/musical_instrument_identification/data_setups.py | # Make function to find classes in target directory
import os
import librosa # type: ignore
import torch
import numpy as np
from torchaudio.transforms import Resample # type: ignore
SAMPLE_RATE = 44100
AUDIO_LEN = 2.90
# Parameters to control the MelSpec generation
N_MELS = 128
F_MIN = 20
F_MAX = 16000
N_FFT = 1024... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/automatic-speech-recognition/run.py | demo/automatic-speech-recognition/run.py | import gradio as gr
import os
# save your HF API token from https:/hf.co/settings/tokens as an env variable to avoid rate limiting
hf_token = os.getenv("hf_token")
# automatically load the interface from a HF model
# you can remove the hf_token parameter if you don't care about rate limiting.
demo = gr.load(
"hug... | 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_button/run.py | demo/upload_button/run.py | 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_fil... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/deep_link/run.py | demo/deep_link/run.py | import gradio as gr
import random
def random_response(message, history):
return random.choice(["Hi!", "Hello!", "Greetings!"])
with gr.Blocks() as demo:
gr.ChatInterface(
random_response,
title="Greeting Bot",
description="Ask anything and receive a nice greeting!",
api_name="c... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/browserstate/run.py | demo/browserstate/run.py | import random
import string
import gradio as gr
import time
with gr.Blocks() as demo:
gr.Markdown("Your Username and Password will get saved in the browser's local storage. "
"If you refresh the page, the values will be retained.")
username = gr.Textbox(label="Username")
password = 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/simple_state/run.py | demo/simple_state/run.py | import gradio as gr
with gr.Blocks() as demo:
cart = gr.State([])
items_to_add = gr.CheckboxGroup(["Cereal", "Milk", "Orange Juice", "Water"])
def add_items(new_items, previous_cart):
cart = previous_cart + new_items
return cart
gr.Button("Add Items").click(add_items, [items_to_add, c... | 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_simple/run.py | demo/render_merge_simple/run.py | import gradio as gr
with gr.Blocks() as demo:
text_count = gr.State(1)
add_btn = gr.Button("Add Box")
add_btn.click(lambda x: x + 1, text_count, text_count)
@gr.render(inputs=text_count)
def render_count(count):
boxes = []
for i in range(count):
box = gr.Textbox(key=i, ... | 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/run.py | demo/progress/run.py | import gradio as gr
import random
import time
import tqdm
from datasets import load_dataset # type: ignore
import shutil
from uuid import uuid4
with gr.Blocks() as demo:
with gr.Row():
text = gr.Textbox()
textb = gr.Textbox()
with gr.Row():
load_set_btn = gr.Button("Load Set")
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/calculator/run.py | demo/calculator/run.py | import gradio as gr
def calculator(num1, operation, num2):
if operation == "add":
return num1 + num2
elif operation == "subtract":
return num1 - num2
elif operation == "multiply":
return num1 * num2
elif operation == "divide":
if num2 == 0:
raise gr.Error("Ca... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/imageslider/run.py | demo/imageslider/run.py | import gradio as gr
from PIL import ImageFilter
def img_to_slider(im):
if not im:
return im
return (im, im.filter(filter=ImageFilter.GaussianBlur(radius=10)))
def slider_to_self(im):
if not im or not im[0]:
return im
return (im[0], im[0].filter(filter=ImageFilter.GaussianBlur(radius=... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/live_with_vars/run.py | demo/live_with_vars/run.py | import gradio as gr
demo = gr.Interface(
lambda x, y: (x + y if y is not None else x, x + y if y is not None else x),
["textbox", "state"],
["textbox", "state"], live=True, 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/blocks_speech_text_sentiment/run.py | demo/blocks_speech_text_sentiment/run.py | from transformers import pipeline
import gradio as gr
asr = pipeline("automatic-speech-recognition", "facebook/wav2vec2-base-960h")
classifier = pipeline("text-classification")
def speech_to_text(speech):
text = asr(speech)["text"] # type: ignore
return text
def text_to_sentiment(text):
return classifi... | 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_joined/run.py | demo/blocks_joined/run.py | from time import sleep
import gradio as gr
from gradio.media import get_image
# get_image() returns file paths to sample media included with Gradio
cheetah = get_image("cheetah1.jpg")
def img(text):
sleep(3)
return [
cheetah,
cheetah,
cheetah,
cheetah,
cheetah,
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/walkthrough_many/run.py | demo/walkthrough_many/run.py | import gradio as gr
def process_step(step_num):
return f"You are on step {step_num}"
with gr.Blocks() as demo:
gr.Markdown("# Stepper - Many Steps")
with gr.Walkthrough(selected=0) as walkthrough:
with gr.Step("Introduction", id=0):
gr.Markdown("This is the introduction step.")
... | 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_templates/run.py | demo/star_rating_templates/run.py | import gradio as gr
with gr.Blocks() as demo:
star_rating = gr.HTML(
value=3,
html_template="""
<h2>Star Rating:</h2>
${Array.from({length: 5}, (_, i) => `<img class='${i < value ? '' : 'faded'}' src='https://upload.wikimedia.org/wikipedia/commons/d/df/Award-star-gold-3d.svg'>`).joi... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/queue_full_e2e_test/run.py | demo/queue_full_e2e_test/run.py | import gradio as gr
import time
import random
n_calls = 0
def get_random_number():
global n_calls
if n_calls == 1:
n_calls += 1
raise gr.Error("This is a gradio error")
n_calls += 1
time.sleep(5)
return random.randrange(1, 10)
with gr.Blocks() as demo:
with gr.Row():
w... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/i18n/run.py | demo/i18n/run.py | import gradio as gr
# create an i18n instance with translations for different languages
i18n = gr.I18n(
en={"greeting": "Hello, welcome to my app!", "name_label": "Your Name", "submit_button": "Greet", "john_doe": "John English", "result_label": "Result"},
es={"greeting": "¡Hola, bienvenido a mi aplicación!", ... | 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_hyperbolic/run.py | demo/llm_hyperbolic/run.py | # This is a simple general-purpose chatbot built on top of Hyperbolic API.
# Before running this, make sure you have exported your Hyperbolic API key as an environment variable:
# export HYPERBOLIC_API_KEY="your-hyperbolic-api-key"
import os
import gradio as gr
from openai import OpenAI
api_key = os.getenv("HYPERBOL... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/dia_dialogue_demo/run.py | demo/dia_dialogue_demo/run.py | import gradio as gr
import httpx
tags = [
"(laughs)",
"(clears throat)",
"(sighs)",
"(gasps)",
"(coughs)",
"(singing)",
"(sings)",
"(mumbles)",
"(beep)",
"(groans)",
"(sniffs)",
"(claps)",
"(screams)",
"(inhales)",
"(exhales)",
"(applause)",
"(burps)... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/todo_list/run.py | demo/todo_list/run.py | import gradio as gr
with gr.Blocks() as demo:
tasks = gr.State([])
new_task = gr.Textbox(label="Task Name", autofocus=True, max_lines=1)
def add_task(tasks, new_task_name):
return tasks + [{"name": new_task_name, "complete": False}], ""
new_task.submit(add_task, [tasks, new_task], [tasks, ne... | 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_blocks/run.py | demo/hello_blocks/run.py | import gradio as gr
def greet(name):
return "Hello " + name + "!"
with gr.Blocks() as demo:
name = gr.Textbox(label="Name")
output = gr.Textbox(label="Output Box")
greet_btn = gr.Button("Greet")
greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")
if __name__ == "__main__":
... | 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_zoom/run.py | demo/plot_guide_zoom/run.py | import gradio as gr
from data import df # type: ignore
with gr.Blocks() as demo:
plt = gr.LinePlot(df, x="weight", y="height")
def select_region(selection: gr.SelectData):
min_w, max_w = selection.index
return gr.LinePlot(x_lim=(min_w, max_w)) # type: ignore
plt.select(select_region, Non... | 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_zoom/data.py | demo/plot_guide_zoom/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/blocks_page_load/run.py | demo/blocks_page_load/run.py | import gradio as gr
def print_message(n):
return "Welcome! This page has loaded for " + n
with gr.Blocks() as demo:
t = gr.Textbox("Frank", label="Name")
t2 = gr.Textbox(label="Output")
demo.load(print_message, t, t2)
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/line_plot/run.py | demo/line_plot/run.py | import gradio as gr
from vega_datasets import data
stocks = data.stocks()
gapminder = data.gapminder()
gapminder = gapminder.loc[
gapminder.country.isin(["Argentina", "Australia", "Afghanistan"])
]
climate = data.climate()
seattle_weather = data.seattle_weather()
## Or generate your own fake data, here's an examp... | 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_streaming_echo/run.py | demo/chatinterface_streaming_echo/run.py | import time
import gradio as gr
def slow_echo(message, history):
for i in range(len(message)):
time.sleep(0.05)
yield "You typed: " + message[: i + 1]
demo = gr.ChatInterface(
slow_echo,
flagging_mode="manual",
flagging_options=["Like", "Spam", "Inappropriate", "Other"],
save_histo... | 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_login/run.py | demo/hello_login/run.py | import gradio as gr
import argparse
import sys
parser = argparse.ArgumentParser()
parser.add_argument("--name", type=str, default="User")
args, unknown = parser.parse_known_args()
print(sys.argv)
with gr.Blocks() as demo:
gr.Markdown(f"# Greetings {args.name}!")
inp = gr.Textbox()
out = gr.Textbox()
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/spectogram/run.py | demo/spectogram/run.py | import matplotlib.pyplot as plt
import numpy as np
from scipy import signal
import gradio as gr
def spectrogram(audio):
sr, data = audio
if len(data.shape) == 2:
data = np.mean(data, axis=0)
frequencies, times, spectrogram_data = signal.spectrogram(
data, sr, window="hamming"
)
plt... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/checkboxgroup_component/run.py | demo/checkboxgroup_component/run.py | import gradio as gr
with gr.Blocks() as demo:
gr.CheckboxGroup(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/radio_component/run.py | demo/radio_component/run.py | import gradio as gr
with gr.Blocks() as demo:
gr.Radio(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/image_classifier_interface_load/run.py | demo/image_classifier_interface_load/run.py | import gradio as gr
import pathlib
current_dir = pathlib.Path(__file__).parent
images = [str(current_dir / "cheetah1.jpeg"), str(current_dir / "cheetah1.jpg"), str(current_dir / "lion.jpg")]
img_classifier = gr.load(
"models/google/vit-base-patch16-224", examples=images, cache_examples=False
)
def func(img, tex... | 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_component/run.py | demo/dataframe_component/run.py | import gradio as gr
with gr.Blocks() as demo:
gr.Dataframe(interactive=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_remote_url/run.py | demo/image_remote_url/run.py | import gradio as gr
def fn(im):
return im, "https://picsum.photos/400/300"
demo = gr.Interface(
fn=fn,
inputs=gr.Image("https://picsum.photos/300/200", label="InputImage"),
outputs=[gr.Image(label="Loopback"), gr.Image(label="RemoteImage")],
examples=[
["https://picsum.photos/640/480"]
... | 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_button_component_events/run.py | demo/upload_button_component_events/run.py | import gradio as gr
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
upload_btn = gr.UploadButton(label="Upload Single File", file_count="single")
with gr.Column():
output_file_1 = gr.File(label="Upload Single File Output", file_count="single")
num_loa... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/timeseries-forecasting-with-prophet/run.py | demo/timeseries-forecasting-with-prophet/run.py | import gradio as gr
import pypistats # type: ignore
from datetime import date
from dateutil.relativedelta import relativedelta
import pandas as pd
from prophet import Prophet # type: ignore
pd.options.plotting.backend = "plotly"
def get_forecast(lib, time):
data = pypistats.overall(lib, total=True, format="pand... | 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_tests/run.py | demo/render_tests/run.py | from datetime import datetime
import time
import gradio as gr
def update_log():
return datetime.now().timestamp()
def get_target(evt: gr.EventData):
return evt.target
def get_select_index(evt: gr.SelectData):
return evt.index
with gr.Blocks() as demo:
gr.Textbox(value=update_log, every=0.5, label="... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/matrix_transpose/run.py | demo/matrix_transpose/run.py | import numpy as np
import gradio as gr
def transpose(matrix):
return matrix.T
demo = gr.Interface(
transpose,
gr.Dataframe(type="numpy", datatype="number", row_count=5, column_count=3, buttons=["fullscreen"]),
"numpy",
examples=[
[np.zeros((30, 30)).tolist()],
[np.ones((2, 2)).tol... | 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_customization/run.py | demo/navbar_customization/run.py | import gradio as gr
with gr.Blocks(title="Navbar Demo") as demo:
navbar = gr.Navbar(value=[("About Me", "https://x.com/abidlabs")], visible=True, main_page_name="Dashboard")
gr.Markdown("# Dashboard Page")
hide_btn = gr.Button("Hide Navbar")
hide_btn.click(fn=lambda : gr.Navbar(visible=False), outputs=... | 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_events/run.py | demo/image_editor_events/run.py | import gradio as gr
import numpy as np
def predict(im):
return im["composite"]
def verify_clear(im):
print(im)
return int(not np.any(im["composite"])), im["composite"]
with gr.Blocks() as demo:
with gr.Group():
with gr.Row():
im = gr.ImageEditor(
type="numpy",
... | 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_inpainting/run.py | demo/image_editor_inpainting/run.py | import gradio as gr
import numpy as np
def average_inpainting_colors(image):
mask = image["layers"][0]
img = image["background"]
mask_bool = mask[:,:,3] > 0
if not np.any(mask_bool):
return img
selected_pixels = img[mask_bool]
avg_color = np.mean(selected_pixels, axis=0)
result = im... | 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_plug/run.py | demo/blocks_plug/run.py | import gradio as gr
def change_tab():
return gr.Tabs(selected=2)
identity_demo, input_demo, output_demo = gr.Blocks(), gr.Blocks(), gr.Blocks()
with identity_demo:
gr.Interface(lambda x: x, "text", "text")
with input_demo:
t = gr.Textbox(label="Enter your text here")
with gr.Row():
btn = 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/score_tracker/run.py | demo/score_tracker/run.py | import gradio as gr
scores = []
def track_score(score):
scores.append(score)
top_scores = sorted(scores, reverse=True)[:3]
return top_scores
demo = gr.Interface(
track_score,
gr.Number(label="Score"),
gr.JSON(label="Top Scores"),
api_name="predict"
)
if __name__ == "__main__":
demo.la... | 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_chatinterface/run.py | demo/validator_chatinterface/run.py | import gradio as gr
import time
def validate_input(x):
print("VALIDATE", x)
return gr.validate(x != "error", "Can't be error")
def do_chat(message, history):
for i in range(len(message)):
time.sleep(0.05)
yield "You typed: " + message[: i + 1]
demo = gr.ChatInterface(fn=do_chat, valida... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/button_component/run.py | demo/button_component/run.py | import gradio as gr
icon = "https://cdn.icon-icons.com/icons2/2620/PNG/512/among_us_player_red_icon_156942.png"
with gr.Blocks() as demo:
with gr.Row():
gr.Button(variant="primary")
gr.Button(variant="secondary")
gr.Button(variant="stop")
with gr.Row():
gr.Button(variant="primary", size="... | 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_tools/run.py | demo/mcp_tools/run.py | import numpy as np
import gradio as gr
from pathlib import Path
import os
from PIL import Image
def prime_factors(n: str):
"""
Compute the prime factorization of a positive integer.
Args:
n (str): The integer to factorize. Must be greater than 1.
"""
n_int = int(n)
if n_int <= 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/state_component/run.py | demo/state_component/run.py | import gradio as gr
with gr.Blocks() as demo:
gr.State()
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/reverse_audio/run.py | demo/reverse_audio/run.py |
import numpy as np
import gradio as gr
def reverse_audio(audio):
sr, data = audio
return (sr, np.flipud(data))
input_audio = gr.Audio(
sources=["microphone"],
waveform_options=gr.WaveformOptions(
waveform_color="#01C6FF",
waveform_progress_color="#0066B4",
skip_length=2,
... | 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_datetimerange/run.py | demo/plot_guide_datetimerange/run.py | import gradio as gr
from gradio_datetimerange import DateTimeRange # type: ignore
from data import df # type: ignore
with gr.Blocks() as demo:
daterange = DateTimeRange(["now - 24h", "now"])
plot1 = gr.LinePlot(df, x="time", y="price")
plot2 = gr.LinePlot(df, x="time", y="price", color="origin")
date... | 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_datetimerange/data.py | demo/plot_guide_datetimerange/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/rapid_generation/run.py | demo/rapid_generation/run.py | import gradio as gr
with gr.Blocks() as demo:
chatbot = gr.Chatbot(elem_id="chatbot")
with gr.Row():
num1 = gr.Number(label="a")
num2 = gr.Number(label="b")
with gr.Row():
num3 = gr.Number(label="c")
num4 = gr.Number(label="d")
btn = gr.Button("Start")
def add_use... | 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_3/run.py | demo/hello_world_3/run.py | import gradio as gr
def greet(name, is_morning, temperature):
salutation = "Good morning" if is_morning else "Good evening"
greeting = f"{salutation} {name}. It is {temperature} degrees today"
celsius = (temperature - 32) * 5 / 9
return greeting, round(celsius, 2)
demo = gr.Interface(
fn=greet,
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/markdown_component/run.py | demo/markdown_component/run.py | import gradio as gr
with gr.Blocks() as demo:
gr.Markdown(
value="This _example_ was **written** in [Markdown](https://en.wikipedia.org/wiki/Markdown)\n <a onclick='stoof' href='https://en.wikipedia.org/wiki/Markdown'>Markdown</a>"
)
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/streaming_simple/run.py | demo/streaming_simple/run.py | import gradio as gr
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
input_img = gr.Image(label="Input", sources="webcam")
with gr.Column():
output_img = gr.Image(label="Output")
input_img.stream(lambda s: s, input_img, output_img, time_limit=15, stream_eve... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/filter_records/run.py | demo/filter_records/run.py | import gradio as gr
def filter_records(records, gender):
return records[records["gender"] == gender]
demo = gr.Interface(
filter_records,
[
gr.Dataframe(
headers=["name", "age", "gender"],
datatype=["str", "number", "str"], # type: ignore
row_count=5,
... | 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_visibility/run.py | demo/render_visibility/run.py | import gradio as gr
def greet(name):
return "Hello " + name + "!"
with gr.Blocks() as demo:
with gr.Tabs():
with gr.TabItem("Tab 1"):
t = gr.Textbox("Some value", label="Name", visible=False, interactive=True)
with gr.Row():
show_btn = gr.Button("Show")
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/multipage/run.py | demo/multipage/run.py | import gradio as gr
import random
import time
with gr.Blocks() as demo:
name = gr.Textbox(label="Name")
output = gr.Textbox(label="Output Box")
greet_btn = gr.Button("Greet")
@gr.on([greet_btn.click, name.submit], inputs=name, outputs=output)
def greet(name):
return "Hello " + 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/clear_components/run.py | demo/clear_components/run.py | import gradio as gr
from datetime import datetime
import os
import random
import string
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# get_audio(), get_video() return file paths to sample media included with Gradio
from gradio.media import get_audio, get_video, MEDIA_ROOT
def random_plot():
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/clear_components/__init__.py | demo/clear_components/__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/tabbed_interface_lite/run.py | demo/tabbed_interface_lite/run.py | import gradio as gr
hello_world = gr.Interface(lambda name: "Hello " + name, "text", "text", api_name="predict")
bye_world = gr.Interface(lambda name: "Bye " + name, "text", "text", api_name="predict")
chat = gr.ChatInterface(lambda *args: "Hello " + args[0], api_name="chat")
demo = gr.TabbedInterface([hello_world, b... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/live_dashboard/run.py | demo/live_dashboard/run.py | import math
import pandas as pd
import gradio as gr
import datetime
import numpy as np
def get_time():
return datetime.datetime.now()
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)
update ... | 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_explorer_component_events/run.py | demo/file_explorer_component_events/run.py | import gradio as gr
from pathlib import Path
base_root = Path(__file__).parent.resolve()
with gr.Blocks() as demo:
with gr.Row():
dd = gr.Dropdown(label="Select File Explorer Root",
value=str(base_root / "dir1"),
choices=[str(base_root / "dir1"),
... | python | Apache-2.0 | 3b56b13268ddcaf74d4e85e5dbf5a616d7843995 | 2026-01-04T14:40:26.993006Z | false |
gradio-app/gradio | https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/markdown_example/run.py | demo/markdown_example/run.py | import gradio as gr
# sample md stolen from https://dillinger.io/
md = """# Dillinger
## _The Last Markdown Editor, Ever_
This is some `inline code`, it is good.
[](https://travis-ci.org/joemccann/dillinger)
Dillinger is a cloud-enabled, 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/progress_component/run.py | demo/progress_component/run.py | import gradio as gr
import time
def load_set(progress=gr.Progress()):
imgs = [None] * 24
for img in progress.tqdm(imgs, desc="Loading..."):
time.sleep(0.1)
return "Loaded"
with gr.Blocks() as demo:
load = gr.Button("Load")
label = gr.Label(label="Loader")
load.click(load_set, outputs=l... | 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_key_up/run.py | demo/dropdown_key_up/run.py | import gradio as gr
def test(value, key_up_data: gr.KeyUpData):
return {
"component value": value,
"input value": key_up_data.input_value,
"key": key_up_data.key
}
with gr.Blocks() as demo:
d = gr.Dropdown(["abc", "def"], allow_custom_value=True)
t = gr.JSON()
d.key_up(test... | 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_component/run.py | demo/video_component/run.py | import gradio as gr
# get_video() returns the file path to sample videos included with Gradio
from gradio.media import get_video
demo = gr.Interface(
fn=lambda x: x,
inputs=gr.Video(),
outputs=gr.Video(),
examples=[
[get_video("world.mp4")],
[get_video("a.mp4")],
[get_video("b.m... | 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.