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/blocks_multiple_event_triggers/run.py
demo/blocks_multiple_event_triggers/run.py
import gradio as gr import pypistats # type: ignore from datetime import date from dateutil.relativedelta import relativedelta import pandas as pd def get_plot(lib, time): data = pypistats.overall(lib, total=True, format="pandas") data = data.groupby("category").get_group("with_mirrors").sort_values("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/streaming_filter/run.py
demo/streaming_filter/run.py
import gradio as gr import numpy as np import cv2 # type: ignore def transform_cv2(frame, transform): if transform == "cartoon": # prepare color img_color = cv2.pyrDown(cv2.pyrDown(frame)) for _ in range(6): img_color = cv2.bilateralFilter(img_color, 9, 9, 7) img_color...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/cancel_events/run.py
demo/cancel_events/run.py
import time import gradio as gr import atexit import pathlib log_file = pathlib.Path(__file__).parent / "cancel_events_output_log.txt" def fake_diffusion(steps): log_file.write_text("") for i in range(steps): print(f"Current step: {i}") with log_file.open("a") as f: f.write(f"Curr...
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_props/run.py
demo/star_rating_props/run.py
import gradio as gr with gr.Blocks() as demo: star_rating = gr.HTML( 7, size=40, max_stars=10, html_template=""" <h2>Star Rating:</h2> ${Array.from({length: max_stars}, (_, i) => `<img class='${i < value ? '' : 'faded'}' src='https://upload.wikimedia.org/wikipedia/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/text_generation/run.py
demo/text_generation/run.py
import gradio as gr from transformers import pipeline generator = pipeline('text-generation', model='gpt2') def generate(text): result = generator(text, max_length=30, num_return_sequences=1) return result[0]["generated_text"] # type: ignore examples = [ ["The Moon's orbit around Earth has"], ["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/neon-tts-plugin-coqui/run.py
demo/neon-tts-plugin-coqui/run.py
import tempfile import gradio as gr from neon_tts_plugin_coqui import CoquiTTS # type: ignore LANGUAGES = list(CoquiTTS.langs.keys()) coquiTTS = CoquiTTS() def tts(text: str, language: str): with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp: coquiTTS.get_tts(text, fp, speaker = {"langua...
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_mixer/run.py
demo/audio_mixer/run.py
import gradio as gr with gr.Blocks() as demo: track_count = gr.State(1) add_track_btn = gr.Button("Add Track") add_track_btn.click(lambda count: count + 1, track_count, track_count) @gr.render(inputs=track_count) def render_tracks(count): audios = [] volumes = [] with gr.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/calculator_blocks_cached/run.py
demo/calculator_blocks_cached/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 with gr.Blocks() as 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/timer/run.py
demo/timer/run.py
import gradio as gr import random import time with gr.Blocks() as demo: timer = gr.Timer(1) timestamp = gr.Number(label="Time") timer.tick(lambda: round(time.time()), outputs=timestamp) gr.Number(lambda: round(time.time()), label="Time 2", every=1) with gr.Row(): timestamp_3 = gr.Number() start_btn ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/concurrency_with_queue/run.py
demo/concurrency_with_queue/run.py
import gradio as gr import time def say_hello(name): time.sleep(5) return f"Hello {name}!" with gr.Blocks() as demo: inp = gr.Textbox() outp = gr.Textbox() button = gr.Button() button.click(say_hello, inp, outp) 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/audio_component/run.py
demo/audio_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.Audio() 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_progress/run.py
demo/mcp_progress/run.py
import gradio as gr import time def slow_text_reverser(text: str, progress=gr.Progress()): for i in range(len(text)): progress(i / len(text), desc="Reversing text") time.sleep(0.3) return text[::-1] demo = gr.Interface(slow_text_reverser, gr.Textbox("Hello, world!"), gr.Textbox(), 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/clearbutton_component/run.py
demo/clearbutton_component/run.py
import gradio as gr with gr.Blocks() as demo: textbox = gr.Textbox(value="This is some text") gr.ClearButton(textbox) 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/dataset/run.py
demo/dataset/run.py
import gradio as gr import numpy as np # get_image(), get_video(), get_audio(), get_file(), get_model3d() return file paths to sample media included with Gradio from gradio.media import get_image, get_video, get_audio, get_file, get_model3d txt = "the quick brown fox" num = 10 img = get_image("cheetah1.jpg") vid = ge...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/diff_texts/run.py
demo/diff_texts/run.py
from difflib import Differ import gradio as gr def diff_texts(text1, text2): d = Differ() return [ (token[2:], token[0] if token[0] != " " else None) for token in d.compare(text1, text2) ] demo = gr.Interface( diff_texts, [ gr.Textbox( label="Text 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/load_model_with_token/run.py
demo/load_model_with_token/run.py
import gradio as gr # This demo requires a Hugging Face PRO token. demo = gr.load("meta-llama/Meta-Llama-3-8B-Instruct", src="models", accept_token=True) 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/file_explorer_component/run.py
demo/file_explorer_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.FileExplorer() 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/native_plots/run.py
demo/native_plots/run.py
import gradio as gr from scatter_plot_demo import scatter_plots # type: ignore from line_plot_demo import line_plots # type: ignore from bar_plot_demo import bar_plots # type: ignore with gr.Blocks() as demo: with gr.Tabs(): with gr.TabItem("Line Plot"): line_plots.render() 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/native_plots/bar_plot_demo.py
demo/native_plots/bar_plot_demo.py
import gradio as gr from data import temp_sensor_data, food_rating_data # type: ignore with gr.Blocks() as bar_plots: with gr.Row(): start = gr.DateTime("2021-01-01 00:00:00", label="Start") end = gr.DateTime("2021-01-05 00:00:00", label="End") apply_btn = gr.Button("Apply", scale=0) 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/native_plots/scatter_plot_demo.py
demo/native_plots/scatter_plot_demo.py
import gradio as gr from data import temp_sensor_data, food_rating_data # type: ignore with gr.Blocks() as scatter_plots: with gr.Row(): start = gr.DateTime("2021-01-01 00:00:00", label="Start") end = gr.DateTime("2021-01-05 00:00:00", label="End") apply_btn = gr.Button("Apply", scale=0) ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/native_plots/data.py
demo/native_plots/data.py
import pandas as pd from random import randint, random 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 * (i % 2), 65 + 15 *...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/native_plots/line_plot_demo.py
demo/native_plots/line_plot_demo.py
import gradio as gr from data import temp_sensor_data, food_rating_data # type: ignore with gr.Blocks() as line_plots: with gr.Row(): start = gr.DateTime("2021-01-01 00:00:00", label="Start") end = gr.DateTime("2021-01-05 00:00:00", label="End") apply_btn = gr.Button("Apply", scale=0) ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/json_component/run.py
demo/json_component/run.py
import gradio as gr import numpy as np with gr.Blocks() as demo: inp = gr.JSON( label="InputJSON", value={ "Key 1": "Value 1", "Key 2": {"Key 3": "Value 2", "Key 4": "Value 3"}, "Key 5": ["Item 1", "Item 2", "Item 3"], "Key 6": 123, "Key 7...
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_blocks/run.py
demo/calculator_blocks/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 with gr.Blocks() as 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/fake_gan_2/run.py
demo/fake_gan_2/run.py
# This demo needs to be run from the repo folder. # python demo/fake_gan/run.py import time import gradio as gr # get_image() returns file paths (randomly if None) to sample media included with Gradio from gradio.media import get_image def fake_gan(desc): if desc == "NSFW": raise gr.Error("NSFW - banned 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/scatterplot_component/run.py
demo/scatterplot_component/run.py
import gradio as gr from vega_datasets import data cars = data.cars() with gr.Blocks() as demo: gr.ScatterPlot( value=cars, x="Horsepower", y="Miles_per_Gallon", color="Origin", tooltip=["Name"], title="Car Data", y_title="Miles per Gallon", containe...
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_group/run.py
demo/blocks_group/run.py
import gradio as gr def greet(name): return "Hello " + name + "!" with gr.Blocks() as demo: gr.Markdown("### This is a couple of elements without any gr.Group. Form elements naturally group together anyway.") gr.Textbox("A") gr.Number(3) gr.Button() gr.Image() gr.Slider() 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/video_component_events/run.py
demo/video_component_events/run.py
import gradio as gr with gr.Blocks() as demo: with gr.Row(): with gr.Column(): input_video = gr.Video(label="Input Video") with gr.Column(): output_video = gr.Video(label="Output Video") with gr.Column(): num_change = gr.Number(label="# Change Events", va...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/translation/run.py
demo/translation/run.py
# type: ignore import gradio as gr from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline import torch # this model was loaded from https://hf.co/models model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-600M") tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distil...
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_nominal/run.py
demo/plot_guide_series_nominal/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="ethnicity") 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_nominal/data.py
demo/plot_guide_series_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/blocks_update/run.py
demo/blocks_update/run.py
import gradio as gr with gr.Blocks() as demo: gr.Markdown( """ # Animal Generator Once you select a species, the detail panel should be visible. """ ) species = gr.Radio(label="Animal Class", choices=["Mammal", "Fish", "Bird"]) animal = gr.Dropdown(label="Animal", choices=[]) ...
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_flipper/run.py
demo/blocks_flipper/run.py
import numpy as np import gradio as gr def flip_text(x): return x[::-1] def flip_image(x): return np.fliplr(x) with gr.Blocks() as demo: gr.Markdown("Flip text or image files using this demo.") with gr.Tab("Flip Text"): text_input = gr.Textbox() text_output = gr.Textbox() 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/on_listener_test/run.py
demo/on_listener_test/run.py
import gradio as gr with gr.Blocks() as demo: name = gr.Textbox(label="Name") output = gr.Textbox(label="Output") greet_btn = gr.Button("Greet") trigger = gr.Textbox(label="Trigger 1") trigger2 = gr.Textbox(label="Trigger 2") def greet(name, evt_data: gr.EventData): return "Hello " + 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/validator_interface/run.py
demo/validator_interface/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/chatinterface_options/run.py
demo/chatinterface_options/run.py
import gradio as gr import random example_code = """ Here's an example Python lambda function: lambda x: x + {} Is this correct? """ def chat(message, history): if message == "Yes, that's correct.": return "Great!" else: return gr.ChatMessage( content=example_code.format(random.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/blocks_outputs/run.py
demo/blocks_outputs/run.py
import gradio as gr def make_markdown(): return [ [ "# hello again", "Hello my name is frank, I am liking the small turtle you have there. It would be a shame if it went missing.", '<img src="https://images.unsplash.com/photo-1574613362884-f79513a5128c?fit=crop&w=500&q=8...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/no_input/run.py
demo/no_input/run.py
import gradio as gr import random sentence_list = [ "Good morning!", "Prayers are with you, have a safe day!", "I love you!" ] def random_sentence(): return sentence_list[random.randint(0, 2)] demo = gr.Interface(fn=random_sentence, inputs=None, outputs="text") 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/animeganv2/run.py
demo/animeganv2/run.py
import gradio as gr import torch model2 = torch.hub.load( "AK391/animegan2-pytorch:main", "generator", pretrained=True, progress=False ) model1 = torch.hub.load("AK391/animegan2-pytorch:main", "generator", pretrained="face_paint_512_v1") face2paint = torch.hub.load( 'AK391/animegan2-pytorch: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/bokeh_plot/run.py
demo/bokeh_plot/run.py
# type: ignore import gradio as gr import xyzservices.providers as xyz from bokeh.models import ColumnDataSource, Whisker from bokeh.plotting import figure from bokeh.sampledata.autompg2 import autompg2 as df from bokeh.sampledata.penguins import data from bokeh.transform import factor_cmap, jitter, factor_mark def ge...
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/run.py
demo/chatbot_core_components/run.py
# type: ignore import gradio as gr import os import plotly.express as px # type: ignore import random # Chatbot demo with multimodal input (text, markdown, LaTeX, code blocks, image, audio, video, & model3d). Plus shows support for streaming text. txt = """ Absolutely! The mycorrhizal network, often referred to as 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/test_chatinterface_streaming_echo/run.py
demo/test_chatinterface_streaming_echo/run.py
import gradio as gr runs = 0 def reset_runs(): global runs runs = 0 def slow_echo(message, history): global runs # i didn't want to add state or anything to this demo runs = runs + 1 for i in range(len(message)): yield f"Run {runs} - You typed: " + message[: i + 1] chat = gr.ChatInterfa...
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_streaming_echo/multimodal_messages_testcase.py
demo/test_chatinterface_streaming_echo/multimodal_messages_testcase.py
import gradio as gr runs = 0 def reset_runs(): global runs runs = 0 def slow_echo(message, history): global runs # i didn't want to add state or anything to this demo runs = runs + 1 for i in range(len(message['text'])): yield f"Run {runs} - You typed: " + message['text'][: i + 1] chat ...
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_streaming_echo/multimodal_group_messages_testcase.py
demo/test_chatinterface_streaming_echo/multimodal_group_messages_testcase.py
import gradio as gr runs = 0 def reset_runs(): global runs runs = 0 def slow_echo(message, history): global runs # i didn't want to add state or anything to this demo runs = runs + 1 for i in range(len(message['text'])): yield f"Run {runs} - You typed: " + message['text'][: i + 1] 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/test_chatinterface_streaming_echo/multimodal_non_stream_testcase.py
demo/test_chatinterface_streaming_echo/multimodal_non_stream_testcase.py
import gradio as gr runs = 0 def reset_runs(): global runs runs = 0 def slow_echo(message, history): global runs # i didn't want to add state or anything to this demo runs = runs + 1 return f"Run {runs} - You typed: " + message['text'] chat = gr.ChatInterface(slow_echo, multimodal=True, api_nam...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/imageeditor_component/run.py
demo/imageeditor_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.ImageEditor() 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_selection/run.py
demo/plot_guide_selection/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") selection_total = gr.Number(label="Total Weight of Selection") def select_region(selection: gr.SelectData): min_w, max_w = selection.index return df[(df["weight"]...
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_selection/data.py
demo/plot_guide_selection/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/color_generator/run.py
demo/color_generator/run.py
import gradio as gr import cv2 # type: ignore import numpy as np import random # Convert decimal color to hexadecimal color def RGB_to_Hex(rgb): color = "#" for i in rgb: num = int(i) color += str(hex(num))[-2:].replace("x", "0").upper() return color # Randomly generate light or dark colo...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/magic_8_ball/run.py
demo/magic_8_ball/run.py
import io from threading import Thread import random import os import numpy as np import spaces # type: ignore import gradio as gr import torch from parler_tts import ParlerTTSForConditionalGeneration # type: ignore from pydub import AudioSegment from transformers import AutoTokenizer, AutoFeatureExtractor, set_see...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/magic_8_ball/streamer.py
demo/magic_8_ball/streamer.py
from queue import Queue from transformers.generation.streamers import BaseStreamer from typing import Optional from parler_tts import ParlerTTSForConditionalGeneration # type: ignore import numpy as np import math import torch class ParlerTTSStreamer(BaseStreamer): def __init__( self, model: Parl...
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_datetime/run.py
demo/plot_guide_datetime/run.py
import gradio as gr from data import df # type: ignore with gr.Blocks() as demo: with gr.Row(): start = gr.DateTime("now - 24h") end = gr.DateTime("now") apply_btn = gr.Button("Apply") plot = gr.LinePlot(df, x="time", y="price") apply_btn.click(lambda start, end: gr.BarPlot(x_lim=...
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_datetime/data.py
demo/plot_guide_datetime/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/checkbox_component/run.py
demo/checkbox_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.Checkbox() 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_gpt/run.py
demo/blocks_gpt/run.py
import gradio as gr api = gr.load("huggingface/gpt2-xl") def complete_with_gpt(text): # Use the last 50 characters of the text as context return text[:-50] + api(text[-50:]) with gr.Blocks() as demo: textbox = gr.Textbox(placeholder="Type here and press enter...", lines=4) btn = gr.Button("Generate")...
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_temporal/run.py
demo/plot_guide_temporal/run.py
import gradio as gr 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"]) 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/dashboard/run.py
demo/dashboard/run.py
import gradio as gr import pandas as pd import plotly.express as px # type: ignore from helpers import retrieve_pip_installs, retrieve_stars, retrieve_issues # type: ignore LIBRARIES = ["accelerate", "datasets", "diffusers", "evaluate", "gradio", "hub_docs", "huggingface_hub", "optimum", "pytorch_image_...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/dashboard/helpers.py
demo/dashboard/helpers.py
# type: ignore import collections from datetime import datetime from datasets import DatasetDict, load_dataset import numpy as np datasets = { "stars": load_dataset("open-source-metrics/stars").sort('dates'), "issues": load_dataset("open-source-metrics/issues").sort('dates'), "pip": load_dataset("open-sou...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/label_component/run.py
demo/label_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.Label(value={"First Label": 0.7, "Second Label": 0.2, "Third Label": 0.1}) 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/tabs/run.py
demo/tabs/run.py
import gradio as gr with gr.Blocks() as demo: with gr.Tabs(): with gr.Tab("Set 1"): with gr.Tabs(selected="a3") as tabs_1: tabset_1 = [] textset_1 = [] for i in range(10): with gr.Tab(f"Tab {i+1}", id=f"a{i+1}") as tab: ...
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_scroll/run.py
demo/blocks_scroll/run.py
import gradio as gr demo = gr.Blocks() with demo: inp = gr.Textbox(placeholder="Enter text.") scroll_btn = gr.Button("Scroll") no_scroll_btn = gr.Button("No Scroll") big_block = gr.HTML(""" <div style='height: 800px; width: 100px; background-color: pink;'></div> """) 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/outbreak_forecast/run.py
demo/outbreak_forecast/run.py
import gradio as gr from math import sqrt import numpy as np import pandas as pd def outbreak(plot_type, r, month, countries, social_distancing): months = ["January", "February", "March", "April", "May"] m = months.index(month) start_day = 30 * m final_day = 30 * (m + 1) x = np.arange(start_day, fi...
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_simple/run.py
demo/render_split_simple/run.py
import gradio as gr with gr.Blocks() as demo: input_text = gr.Textbox(label="input") @gr.render(inputs=input_text) def show_split(text): if len(text) == 0: gr.Markdown("## No Input Provided") else: for letter in text: gr.Textbox(letter) 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/dataframe_events/run.py
demo/dataframe_events/run.py
import gradio as gr import pandas as pd import numpy as np def update_dataframe(): regular_df = pd.DataFrame( np.random.randint(1, 10, size=(5, 5)), columns=pd.Index([str(i) for i in range(5)]), ) wide_df = pd.DataFrame( [ [5, 22, 91, 17, 73, 38, 84, 46, 65, 10, 155, 12...
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_subtitle/run.py
demo/audio_subtitle/run.py
import gradio as gr from gradio.media import get_audio, get_file, MEDIA_PATHS a = get_audio("cate_blanch.mp3") b = get_audio("cate_blanch_2.mp3") s1 = get_file("s1.srt") s2 = get_file("s2.vtt") def add_subtitles_to_audio(audio, subtitles=None): if subtitles is None: return audio if subtitles is not ...
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_flashcards/run.py
demo/blocks_flashcards/run.py
import random import gradio as gr with gr.Blocks() as demo: gr.Markdown( "Load the flashcards in the table below, then use the Practice tab to practice." ) with gr.Tabs() as tabs: with gr.Tab("Word Bank"): flashcards_table = gr.Dataframe(headers=["front", "back"], type="array"...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/ner_pipeline/run.py
demo/ner_pipeline/run.py
from transformers import pipeline import gradio as gr ner_pipeline = pipeline("ner") # type: ignore examples = [ "Does Chicago have any stores and does Joe live here?", ] def ner(text): output = ner_pipeline(text) return {"text": text, "entities": output} demo = gr.Interface(ner, gr.Textb...
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_thoughts/run.py
demo/chatinterface_thoughts/run.py
import gradio as gr from gradio import ChatMessage import time sleep_time = 0.5 def simulate_thinking_chat(message, history): start_time = time.time() response = ChatMessage( content="", metadata={"title": "_Thinking_ step-by-step", "id": 0, "status": "pending"} ) yield response 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/model3d_component_events/run.py
demo/model3d_component_events/run.py
import gradio as gr with gr.Blocks() as demo: with gr.Row(): with gr.Column(): input_3d = gr.Model3D(label="Input Model3D") with gr.Column(): output_3d = gr.Model3D(label="Output Model3D") with gr.Column(): num_change = gr.Number(label="# Change Events", ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/input_output/run.py
demo/input_output/run.py
import gradio as gr def image_mod(text): return text[::-1] demo = gr.Blocks() with demo: text = gr.Textbox(label="Input-Output") btn = gr.Button("Run") btn.click(image_mod, text, text) 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/chatinterface_prefill/run.py
demo/chatinterface_prefill/run.py
import gradio as gr import random def prefill_chatbot(choice): if choice == "Greeting": return [ {"role": "user", "content": "Hi there!"}, {"role": "assistant", "content": "Hello! How can I assist you today?"} ] elif choice == "Complaint": return [ {"...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/map_airbnb/run.py
demo/map_airbnb/run.py
# type: ignore import gradio as gr import plotly.graph_objects as go from datasets import load_dataset dataset = load_dataset("gradio/NYC-Airbnb-Open-Data", split="train") df = dataset.to_pandas() def filter_map(min_price, max_price, boroughs): filtered_df = df[(df['neighbourhood_group'].isin(boroughs)) & ...
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_cleanup/run.py
demo/state_cleanup/run.py
from __future__ import annotations import gradio as gr import numpy as np from PIL import Image from pathlib import Path import secrets import shutil current_dir = Path(__file__).parent def generate_random_img(history: list[Image.Image], request: gr.Request): """Generate a random red, green, blue, orange, yellor ...
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_claude/run.py
demo/llm_claude/run.py
# This is a simple 20 questions-style game built on top of the Anthropic API. # Before running this, make sure you have exported your Anthropic API key as an environment variable: # export ANTHROPIC_API_KEY="your-anthropic-api-key" import anthropic # type: ignore import gradio as gr client = anthropic.Anthropic() d...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/xgboost-income-prediction-with-explainability/run.py
demo/xgboost-income-prediction-with-explainability/run.py
# type: ignore import gradio as gr import random import matplotlib.pyplot as plt import pandas as pd import shap import xgboost as xgb from datasets import load_dataset dataset = load_dataset("scikit-learn/adult-census-income") X_train = dataset["train"].to_pandas() _ = X_train.pop("fnlwgt") _ = X_train.pop("race") 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/plot_guide_aggregate_quantitative/run.py
demo/plot_guide_aggregate_quantitative/run.py
import gradio as gr from data import df # type: ignore with gr.Blocks() as demo: gr.BarPlot(df, x="weight", y="height", x_bin=10, y_aggregate="sum") 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_quantitative/data.py
demo/plot_guide_aggregate_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/invisible_textbox/run.py
demo/invisible_textbox/run.py
import gradio as gr with gr.Blocks() as demo: with gr.Tabs(): with gr.Tab("Invisible Textbox Demo"): textbox = gr.Textbox(visible=False, interactive=True, elem_id="test-textbox") make_visible_btn = gr.Button("Show") hide = gr.Button("Hide") def 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/plot_guide_zoom_sync/run.py
demo/plot_guide_zoom_sync/run.py
import gradio as gr from data import df # type: ignore with gr.Blocks() as demo: plt1 = gr.LinePlot(df, x="weight", y="height") plt2 = gr.BarPlot(df, x="weight", y="age", x_bin=10) plots = [plt1, plt2] def select_region(selection: gr.SelectData): min_w, max_w = selection.index return ...
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_sync/data.py
demo/plot_guide_zoom_sync/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_layout/run.py
demo/blocks_layout/run.py
import gradio as gr demo = gr.Blocks() with demo: with gr.Row(): gr.Image(interactive=True, scale=2) gr.Image() with gr.Row(): gr.Textbox(label="Text") gr.Number(label="Count", scale=2) gr.Radio(choices=["One", "Two"]) with gr.Row(): gr.Button("500", scale=0...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/interface_with_additional_inputs/run.py
demo/interface_with_additional_inputs/run.py
import gradio as gr def generate_fake_image(prompt, seed, initial_image=None): return f"Used seed: {seed}", "https://dummyimage.com/300/09f.png" demo = gr.Interface( generate_fake_image, inputs=["textbox"], outputs=["textbox", "image"], additional_inputs=[ gr.Slider(0, 1000), "imag...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/sentence_builder/run.py
demo/sentence_builder/run.py
import gradio as gr def sentence_builder(quantity, animal, countries, place, activity_list, morning): return f"""The {quantity} {animal}s from {" and ".join(countries)} went to the {place} where they {" and ".join(activity_list)} until the {"morning" if morning else "night"}""" demo = gr.Interface( sentence_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/line_plot_demo/run.py
demo/line_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/chatbot_feedback/run.py
demo/chatbot_feedback/run.py
import gradio as gr def test_liked_loading(): test_history = [ {"role": "user", "content": "test user message"}, {"role": "assistant", "content": "test assistant message"} ] # Set feedback_value to ["Like"] for the assistant message return gr.update(value=test_history, feedback_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/chatbot_examples/run.py
demo/chatbot_examples/run.py
import gradio as gr import os # Multimodal Chatbot demo that shows support for examples (example messages shown within the chatbot). def print_like_dislike(x: gr.LikeData): print(x.index, x.value, x.liked) def add_message(history, message): for x in message["files"]: history.append({"role": "user", "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/stream_audio/run.py
demo/stream_audio/run.py
import gradio as gr import numpy as np def add_to_stream(audio, instream): if audio is None: return gr.Audio(), instream if instream is None: ret = audio else: ret = (audio[0], np.concatenate((instream[1], audio[1]))) return ret, ret with gr.Blocks() as demo: inp = gr.Audio...
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_component/run.py
demo/code_component/run.py
import gradio as gr demo = gr.Interface( lambda x: x, gr.Code(language="python"), gr.Code(language="python"), examples=[[("/Users/freddy/sources/gradio/demo/code_component/run.py",)], ["print('Hello, World!')"], [("/Users/freddy/sources/gradio/demo/code/run.py", )]] ) 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/fake_diffusion_with_gif/run.py
demo/fake_diffusion_with_gif/run.py
import gradio as gr import numpy as np import time import os from PIL import Image import requests from io import BytesIO def create_gif(images): pil_images = [] for image in images: if isinstance(image, str): response = requests.get(image) image = Image.open(BytesIO(response.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/yolov10_webcam_stream/run.py
demo/yolov10_webcam_stream/run.py
import gradio as gr import cv2 # type: ignore from huggingface_hub import hf_hub_download from gradio_webrtc import WebRTC # type: ignore from twilio.rest import Client # type: ignore import os from inference import YOLOv10 # type: ignore model_file = hf_hub_download( repo_id="onnx-community/yolov10n", filenam...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/yolov10_webcam_stream/inference.py
demo/yolov10_webcam_stream/inference.py
import time import cv2 # type: ignore import numpy as np import onnxruntime # type: ignore from utils import draw_detections # type: ignore class YOLOv10: def __init__(self, path): # Initialize model self.initialize_model(path) def __call__(self, image): return self.detect_objects...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/yolov10_webcam_stream/utils.py
demo/yolov10_webcam_stream/utils.py
import numpy as np import cv2 # type: ignore class_names = [ "person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light", "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "hor...
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_events/run.py
demo/star_rating_events/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'>`).jo...
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_methods/run.py
demo/blocks_js_methods/run.py
import gradio as gr blocks = gr.Blocks() with blocks as demo: subject = gr.Textbox(placeholder="subject") verb = gr.Radio(["ate", "loved", "hated"]) object = gr.Textbox(placeholder="object") with gr.Row(): btn = gr.Button("Create sentence.") reverse_btn = gr.Button("Reverse sentence."...
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_retry_undo_like/run.py
demo/chatbot_retry_undo_like/run.py
from huggingface_hub import InferenceClient import gradio as gr client = InferenceClient() def respond( prompt: str, history, ): if not history: history = [{"role": "system", "content": "You are a friendly chatbot"}] history.append({"role": "user", "content": prompt}) yield history 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/english_translator/run.py
demo/english_translator/run.py
import gradio as gr from transformers import pipeline pipe = pipeline("translation", model="t5-base") def translate(text): return pipe(text)[0]["translation_text"] # type: ignore with gr.Blocks() as demo: with gr.Row(): with gr.Column(): english = gr.Textbox(label="English 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/plot_guide_filters/run.py
demo/plot_guide_filters/run.py
import gradio as gr from data import df # type: ignore with gr.Blocks() as demo: with gr.Row(): origin = gr.Dropdown(["All", "DFW", "DAL", "HOU"], value="All", label="Origin") destination = gr.Dropdown(["All", "JFK", "LGA", "EWR"], value="All", label="Destination") max_price = gr.Slider(0,...
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_filters/data.py
demo/plot_guide_filters/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/show_progress_on/run.py
demo/show_progress_on/run.py
# This demo needs to be run from the repo folder. # python demo/fake_gan/run.py import time import gradio as gr from gradio.media import get_image def fake_gan(): time.sleep(5) images = [ (get_image("cheetah.jpg"), f"label {i}") for i in range(3) ] return images, "Done" with gr.Blocks(...
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_heavy_concurrently/run.py
demo/render_heavy_concurrently/run.py
import gradio as gr import random with gr.Blocks() as demo: with gr.Row(): @gr.render() def render(): for _ in range(500): gr.Textbox(str(random.randint(0, 100))) gr.Button("DONE 1") @gr.render() def render2(): for _ in range(50...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false