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/duplicatebutton_component/run.py
demo/duplicatebutton_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.DuplicateButton() 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/pending_inputs/run.py
demo/pending_inputs/run.py
import gradio as gr with gr.Blocks() as demo: gr.Markdown("# Pending Input Components") with gr.Row(): with gr.Column(): file = gr.File() btn = gr.Button("Upload") with gr.Column(): output_file = gr.File() btn.click( lambda s: (s)...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/sentiment_analysis/run.py
demo/sentiment_analysis/run.py
import gradio as gr import nltk # type: ignore from nltk.sentiment.vader import SentimentIntensityAnalyzer # type: ignore nltk.download("vader_lexicon") sid = SentimentIntensityAnalyzer() def sentiment_analysis(text): scores = sid.polarity_scores(text) del scores["compound"] return scores demo = gr.Int...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/copy_events/run.py
demo/copy_events/run.py
import gradio as gr md = "This is **bold** text." def copy_callback(copy_data: gr.CopyData): return copy_data.value with gr.Blocks() as demo: textbox = gr.Textbox(label="Copied text") with gr.Row(): markdown = gr.Markdown(value=md, header_links=True, height=400, buttons=["copy"]) chatbot ...
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_canvas_size/run.py
demo/image_editor_canvas_size/run.py
import gradio as gr with gr.Blocks() as demo: with gr.Row(): with gr.Column(): image = gr.ImageEditor(label="Default Canvas. Not fixed", elem_id="default") get_image = gr.Button("Get Default") with gr.Column(): custom_canvas = gr.ImageEditor(label="Custom Canvas,...
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_debugger/run.py
demo/audio_debugger/run.py
import gradio as gr import subprocess from gradio.media import get_audio, MEDIA_PATHS # get_audio returns the path to the audio file audio_file = get_audio("cantina.wav") with gr.Blocks() as demo: with gr.Tab("Audio"): gr.Audio(audio_file, buttons=["download"]) with gr.Tab("Interface"): gr.Int...
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_thoughts/run.py
demo/chatbot_thoughts/run.py
import gradio as gr from gradio import ChatMessage import time def simulate_thinking_chat(message: str, history: list): history.append( ChatMessage( role="assistant", content="", metadata={"title": "Thinking... ", "log": "Starting analysis"} ) ) time.slee...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/loginbutton_component/run.py
demo/loginbutton_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.LoginButton() 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/stable-diffusion/run.py
demo/stable-diffusion/run.py
import gradio as gr import torch from diffusers import StableDiffusionPipeline # type: ignore from PIL import Image import os auth_token = os.getenv("HF_TOKEN") if not auth_token: print( "ERROR: No Hugging Face access token found.\n" "Please define an environment variable 'auth_token' before runni...
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_custom_styling/run.py
demo/dataframe_custom_styling/run.py
import gradio as gr data = [ ["DeepSeek Coder", 79.3], ["Llama 3.3", 68.9], ["Qwen 2.5", 61.9], ["Gemma 2", 59.5], ["GPT 2", 18.3], ] headers = ["Model", "% Correct (LeetCode Hard)"] def get_styling(values): return [["", f"background: linear-gradient(90deg, rgba(220, 242, 220) {row[1]}%, tran...
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/run.py
demo/gpt2_xl/run.py
import gradio as gr title = "gpt2-xl" examples = [ ["The tower is 324 metres (1,063 ft) tall,"], ["The Moon's orbit around Earth has"], ["The smooth Borealis basin in the Northern Hemisphere covers 40%"], ] demo = gr.load( "huggingface/gpt2-xl", inputs=gr.Textbox(lines=5, max_lines=6, label="Inpu...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/iframe_resizer/run.py
demo/iframe_resizer/run.py
import gradio as gr import time import os from gradio import get_image def greet(): gr.Info("Warning in 1 second") time.sleep(1) gr.Warning("Error in 1 second") time.sleep(1) raise Exception("test") im = get_image("cheetah.jpg") with gr.Blocks() as demo: with gr.Tab("Accordions"): 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/render_preserve_key/run.py
demo/render_preserve_key/run.py
import gradio as gr import random with gr.Blocks() as demo: number_of_boxes = gr.Slider(1, 5, step=1, value=3, label="Number of Boxes") @gr.render(inputs=[number_of_boxes]) def create_boxes(number_of_boxes): for i in range(number_of_boxes): with gr.Row(key=f'row-{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/image_component/run.py
demo/image_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.Image() 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_essay_simple/run.py
demo/blocks_essay_simple/run.py
import gradio as gr def change_textbox(choice): if choice == "short": return gr.Textbox(lines=2, visible=True) elif choice == "long": return gr.Textbox(lines=8, visible=True, value="Lorem ipsum dolor sit amet") else: return gr.Textbox(visible=False) with gr.Blocks() as demo: ra...
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/run.py
demo/walkthrough/run.py
import gradio as gr with gr.Blocks() as demo: with gr.Walkthrough(selected=0) as walkthrough: with gr.Step("Image", id=0): image = gr.Image() btn = gr.Button("go to prompt") btn.click(lambda: gr.Walkthrough(selected=1), outputs=walkthrough) with gr.Step("Prompt",...
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_events/run.py
demo/plot_guide_filters_events/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_events/data.py
demo/plot_guide_filters_events/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/chatbot_with_tools/run.py
demo/chatbot_with_tools/run.py
import gradio as gr from gradio import ChatMessage import time def generate_response(history): history.append( ChatMessage( role="user", content="What is the weather in San Francisco right now?" ) ) yield history time.sleep(0.25) history.append( ChatMessage( ...
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_4/run.py
demo/hello_world_4/run.py
import gradio as gr def greet(name, intensity): return "Hello, " + name + "!" * int(intensity) demo = gr.Interface( fn=greet, inputs=["text", "slider"], outputs=["text"], 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/image_editor_layers/run.py
demo/image_editor_layers/run.py
import gradio as gr from pathlib import Path dir_ = Path(__file__).parent def predict(im): print(im) return im, len(im["layers"]) with gr.Blocks() as demo: with gr.Row(): im = gr.ImageEditor( type="numpy", interactive=True, ) im_preview = gr.ImageEditor( ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/slider_release/run.py
demo/slider_release/run.py
import gradio as gr def identity(x, state): state += 1 return x, state, state with gr.Blocks() as demo: slider = gr.Slider(0, 100, step=0.1) state = gr.State(value=0) with gr.Row(): number = gr.Number(label="On release") number2 = gr.Number(label="Number of events fired") slide...
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_watermark/run.py
demo/video_watermark/run.py
import gradio as gr a = gr.get_video("a.mp4") b = gr.get_video("b.mp4") w1 = gr.get_image("logo.png") w2 = gr.get_image("bus.png") def generate_video(original_video, watermark, position): return gr.Video(original_video, watermark=gr.WatermarkOptions(watermark=watermark, position=position)) 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/chatbot_editable/run.py
demo/chatbot_editable/run.py
import gradio as gr with gr.Blocks() as demo: with gr.Row(): chatbot = gr.Chatbot(value=[], editable="user") add_message_btn = gr.Button("Add Message") add_user_message_btn = gr.Button("Add User Message") with gr.Row(): concatenated_text1 = gr.Textbox(label="Concatenated Chat 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/autocomplete/run.py
demo/autocomplete/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") # load a model from https://hf.co/models as an interface, then use it as an api # you can remove the hf_token parameter if you don't care about rate limit...
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_and_download/run.py
demo/upload_and_download/run.py
from pathlib import Path import gradio as gr def upload_file(filepath): name = Path(filepath).name return [gr.UploadButton(visible=False), gr.DownloadButton(label=f"Download {name}", value=filepath, visible=True)] def download_file(): return [gr.UploadButton(visible=True), gr.DownloadButton(visible=False)...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/stock_forecast/run.py
demo/stock_forecast/run.py
import matplotlib.pyplot as plt import numpy as np import gradio as gr def plot_forecast(final_year, companies, noise, show_legend, point_style): start_year = 2020 x = np.arange(start_year, final_year + 1) year_count = x.shape[0] plt_format = ({"cross": "X", "line": "-", "circle": "o--"})[point_style]...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/interface_state/run.py
demo/interface_state/run.py
import gradio as gr def store_message(message: str, history: list[str]): # type: ignore output = { "Current messages": message, "Previous messages": history[::-1] } history.append(message) return output, history demo = gr.Interface(fn=store_message, inputs=["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/html_component/run.py
demo/html_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.HTML(value="<p style='margin-top: 1rem, margin-bottom: 1rem'>This <em>example</em> was <strong>written</strong> in <a href='https://en.wikipedia.org/wiki/HTML' _target='blank'>HTML</a> </p>") demo.launch()
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/chatbot_multimodal/run.py
demo/chatbot_multimodal/run.py
import gradio as gr import time # Chatbot demo with multimodal input (text, markdown, LaTeX, code blocks, image, audio, & video). Plus shows support for streaming text. def print_like_dislike(x: gr.LikeData): print(x.index, x.value, x.liked) def add_message(history, message): user_msg = {"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/theme_new_step_2/run.py
demo/theme_new_step_2/run.py
from __future__ import annotations from typing import Iterable import gradio as gr from gradio.themes.base import Base from gradio.themes.utils import colors, fonts, sizes import time class Seafoam(Base): def __init__( self, *, primary_hue: colors.Color | str = colors.emerald, secon...
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_sambanova/run.py
demo/llm_sambanova/run.py
# This is a simple general-purpose chatbot built on top of SambaNova API. # Before running this, make sure you have exported your SambaNova API key as an environment variable: # export SAMBANOVA_API_KEY="your-sambanova-api-key" import os import gradio as gr from openai import OpenAI api_key = os.getenv("SAMBANOVA_AP...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/white_noise_vid_not_playable/run.py
demo/white_noise_vid_not_playable/run.py
import cv2 # type: ignore import gradio as gr import numpy as np def gif_maker(): img_array = [] height, width = 50, 50 for _ in range(30): img_array.append(np.random.randint(0, 255, size=(height, width, 3)).astype(np.uint8)) output_file = "test.mp4" out = cv2.VideoWriter(output_file, cv2....
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/function_values/run.py
demo/function_values/run.py
import gradio as gr import random countries = [ "Algeria", "Argentina", "Australia", "Brazil", "Canada", "China", "Democratic Republic of the Congo", "Greenland (Denmark)", "India", "Kazakhstan", "Mexico", "Mongolia", "Peru", "Russia", "Saudi Arabia", "Su...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/theme_new_step_3/run.py
demo/theme_new_step_3/run.py
from __future__ import annotations from typing import Iterable import gradio as gr from gradio.themes.base import Base from gradio.themes.utils import colors, fonts, sizes import time class Seafoam(Base): def __init__( self, *, primary_hue: colors.Color | str = colors.emerald, secon...
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_live/run.py
demo/on_listener_live/run.py
import gradio as gr with gr.Blocks() as demo: with gr.Row(): num1 = gr.Slider(1, 10) num2 = gr.Slider(1, 10) num3 = gr.Slider(1, 10) output = gr.Number(label="Sum") @gr.on(inputs=[num1, num2, num3], outputs=output) def sum(a, b, c): return a + b + c if __name__ == "__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/plot_guide_scatter_nominal/run.py
demo/plot_guide_scatter_nominal/run.py
import gradio as gr from data import df # type: ignore with gr.Blocks() as demo: gr.ScatterPlot(df, x="ethnicity", y="height") if __name__ == "__main__": demo.launch()
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/plot_guide_scatter_nominal/data.py
demo/plot_guide_scatter_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/plot_guide_tables_stats/run.py
demo/plot_guide_tables_stats/run.py
import gradio as gr from data import df # type: ignore with gr.Blocks() as demo: with gr.Row(): gr.Label(len(df), label="Flight Count") gr.Label(f"${df['price'].min()}", label="Cheapest Flight") gr.DataFrame(df) 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_tables_stats/data.py
demo/plot_guide_tables_stats/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/stream_audio_out/run.py
demo/stream_audio_out/run.py
import gradio as gr from pydub import AudioSegment from time import sleep import os import tempfile from pathlib import Path with gr.Blocks() as demo: input_audio = gr.Audio(label="Input Audio", type="filepath", format="mp3") with gr.Row(): with gr.Column(): stream_as_file_btn = gr.Button("...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/latex/run.py
demo/latex/run.py
import gradio as gr with gr.Blocks() as demo: gr.Markdown( r""" # Hello World! $\frac{\sqrt{x + y}}{4}$ is today's lesson ## the $\sqrt{x + y}$ is first Start with $\frac{\frac{x+1}{x+2}}{x+3}$ then we get $ 2+x $ and $3$. There are three formulas to know: the first is $\gamma^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/examples_component/run.py
demo/examples_component/run.py
import gradio as gr # get_image() returns the file path to sample images included with Gradio from gradio.media import get_image def flip(i): return i.rotate(180) with gr.Blocks() as demo: with gr.Row(): with gr.Column(): img_i = gr.Image(label="Input Image", type="pil") with gr.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/uploadbutton_component/run.py
demo/uploadbutton_component/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 an Image or Video File", file_types=["image", "video"], file_count="multiple") upload_button.u...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/dialogue_mock_diarization/run.py
demo/dialogue_mock_diarization/run.py
import gradio as gr speakers = [ "Speaker 1", "Speaker 2", ] def format_speaker(speaker, text): return f"{speaker}: {text}" def mock_diarization(audio): return [ { "speaker": "Speaker 1", "text": "Hello, how are you?", }, { "speaker": "Speak...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/letter_counter/run.py
demo/letter_counter/run.py
import gradio as gr def letter_counter(word, letter): """ Count the number of occurrences of a letter in a word or text. Args: word (str): The input text to search through letter (str): The letter to search for Returns: str: A message indicating how many times the letter appea...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/highlight_pdf/run.py
demo/highlight_pdf/run.py
import gradio as gr from gradio_pdf import PDF import pymupdf # type: ignore import os from pathlib import Path current_dir = Path(os.path.abspath('')) def highlight_text_in_pdf(pdf_file: Path, highlight_text: str): page_number = 0 doc = pymupdf.open(pdf_file) for page in doc: text_instances = 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/dialogue_diarization_demo/run.py
demo/dialogue_diarization_demo/run.py
# type: ignore import gradio as gr from pyannote.audio import Pipeline import whisper diarization_pipeline = None whisper_model = None def load_models(): global diarization_pipeline, whisper_model # noqa: PLW0603 if diarization_pipeline is None: diarization_pipeline = Pipeline.from_pretrained( ...
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_decorator/run.py
demo/hello_blocks_decorator/run.py
import gradio as gr with gr.Blocks() as demo: name = gr.Textbox(label="Name") output = gr.Textbox(label="Output Box") greet_btn = gr.Button("Greet") @greet_btn.click(inputs=name, outputs=output) def greet(name): return "Hello " + name + "!" 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/downloadbutton_component/run.py
demo/downloadbutton_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.DownloadButton("📂 Click to download file", value="http://www.marketingtool.online/en/face-generator/img/faces/avatar-1151ce9f4b2043de0d2e3b7826127998.jpg") 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/unispeech-speaker-verification/run.py
demo/unispeech-speaker-verification/run.py
# type: ignore import gradio as gr import torch from torchaudio.sox_effects import apply_effects_file # type: ignore from transformers import AutoFeatureExtractor, AutoModelForAudioXVector device = torch.device("cuda" if torch.cuda.is_available() else "cpu") STYLE = """ <link rel="stylesheet" href="https://cdn.jsdel...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/gallery_component/run.py
demo/gallery_component/run.py
import gradio as gr from gradio.media import get_image, get_video with gr.Blocks() as demo: gallery_items = [ ("https://upload.wikimedia.org/wikipedia/commons/0/09/TheCheethcat.jpg", "cheetah1"), ("https://nationalzoo.si.edu/sites/default/files/animals/cheetah-003.jpg", "cheetah2"), ("https...
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_interactive/run.py
demo/plot_guide_interactive/run.py
import gradio as gr from data import df # type: ignore with gr.Blocks() as demo: with gr.Row(): ethnicity = gr.Dropdown(["all", "white", "black", "asian"], value="all") max_age = gr.Slider(18, 65, value=65) def filtered_df(ethnic, age): _df = df if ethnic == "all" else df[df["ethnicit...
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_interactive/data.py
demo/plot_guide_interactive/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_sidebar/run.py
demo/blocks_sidebar/run.py
import gradio as gr import random def generate_pet_name(animal_type, personality): cute_prefixes = ["Fluffy", "Ziggy", "Bubbles", "Pickle", "Waffle", "Mochi", "Cookie", "Pepper"] animal_suffixes = { "Cat": ["Whiskers", "Paws", "Mittens", "Purrington"], "Dog": ["Woofles", "Barkington", "Waggins"...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/unload_event_test/run.py
demo/unload_event_test/run.py
"""This demo is only meant to test the unload event. It will write to a file when the unload event is triggered. May not work as expected if multiple people are using it. """ import gradio as gr from pathlib import Path log_file = (Path(__file__).parent / "output_log.txt").resolve() def test_fn(x): with open(log_...
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_textbox_max_lines/run.py
demo/blocks_textbox_max_lines/run.py
import gradio as gr def greet(name: str, repeat: float): return "Hello " + name * int(repeat) + "!!" demo = gr.Interface( fn=greet, inputs=[gr.Textbox(lines=2, max_lines=4), gr.Number()], outputs="textarea", 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/file_explorer/run.py
demo/file_explorer/run.py
import gradio as gr from pathlib import Path current_file_path = Path(__file__).resolve() relative_path = "path/to/file" absolute_path = (current_file_path.parent / ".." / ".." / "gradio").resolve() def get_file_content(file): if file is None or Path(file).is_dir(): return None return Path(file).read_...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/agent_chatbot/run.py
demo/agent_chatbot/run.py
import gradio as gr from dataclasses import asdict from transformers import Tool, ReactCodeAgent # type: ignore from transformers.agents import stream_to_gradio, HfApiEngine # type: ignore # Import tool from Hub image_generation_tool = Tool.from_space( # type: ignore space_id="black-forest-labs/FLUX.1-schnell",...
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/run.py
demo/model3D/run.py
import gradio as gr # get_model3d() returns the file path to sample 3D models included with Gradio from gradio.media import get_model3d, MEDIA_ROOT def load_mesh(mesh_file_name): return mesh_file_name demo = gr.Interface( fn=load_mesh, inputs=gr.Model3D(label="Other name", display_mode="wireframe"), ...
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_sketchpad/run.py
demo/image_editor_sketchpad/run.py
import gradio as gr import numpy as np def percent_of_pixels_selected(image): mask = image["layers"][0] mask_bool = mask[:,:,3] > 0 return f"{round(np.sum(mask_bool) / mask_bool.size * 100, 2)}%" image_editor = gr.Sketchpad( type="numpy", ) output_image = gr.Label( label="Percent of Pixels Selecte...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/event_trigger/run.py
demo/event_trigger/run.py
# %% import gradio as gr TEST_VIDEO_A = "mp4/a.mp4" TEST_VIDEO_B = "mp4/b.mp4" TEST_IMAGE_A = "img/a.jpg" TEST_IMAGE_B = "img/b.jpg" def alert_change(component, value): print(f"Detected {component} change, {type(value)}") if type(value) == list or type(value) == str: print(value) def change_interac...
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_inputs/run.py
demo/blocks_inputs/run.py
import gradio as gr import os def combine(a, b): return a + " " + b def mirror(x): return x with gr.Blocks() as demo: txt = gr.Textbox(label="Input", lines=2) txt_2 = gr.Textbox(label="Input 2") txt_3 = gr.Textbox(value="", label="Output") btn = gr.Button(value="Submit") btn.click(combin...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/playback_position/run.py
demo/playback_position/run.py
import gradio as gr from gradio.media import get_audio, get_video # Get the directory where this script is located with gr.Blocks() as demo: with gr.Tab("Audio"): gr.Markdown("## Audio Playback Position") gr.Markdown("Click the button to see the current playback position of the audio.") au...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/save_file_no_output/run.py
demo/save_file_no_output/run.py
import random import string import gradio as gr def save_image_random_name(image): random_string = ''.join(random.choices(string.ascii_letters, k=20)) + '.png' image.save(random_string) print(f"Saved image to {random_string}!") demo = gr.Interface( fn=save_image_random_name, inputs=gr.Image(type="...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/count_generator/run.py
demo/count_generator/run.py
import gradio as gr import time def count(n): for i in range(int(n)): time.sleep(0.5) yield i def show(n): return str(list(range(int(n)))) with gr.Blocks() as demo: with gr.Column(): num = gr.Number(value=10) with gr.Row(): count_btn = gr.Button("Count") ...
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_without_queue/run.py
demo/concurrency_without_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(max_threads=41)
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/theme_new_step_1/run.py
demo/theme_new_step_1/run.py
import gradio as gr from gradio.themes.base import Base import time class Seafoam(Base): pass seafoam = Seafoam() with gr.Blocks() as demo: textbox = gr.Textbox(label="Name") slider = gr.Slider(label="Count", minimum=0, maximum=100, step=1) with gr.Row(): button = gr.Button("Submit", variant=...
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_simple/run.py
demo/chatbot_simple/run.py
import gradio as gr import random import time with gr.Blocks() as demo: chatbot = gr.Chatbot() msg = gr.Textbox() clear = gr.ClearButton([msg, chatbot]) def respond(message, chat_history): bot_message = random.choice(["How are you?", "Today is a great day", "I'm very hungry"]) chat_his...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/gallery_selections/run.py
demo/gallery_selections/run.py
import gradio as gr import numpy as np with gr.Blocks() as demo: imgs = gr.State() gallery = gr.Gallery(allow_preview=False) def deselect_images(): return gr.Gallery(selected_index=None) def generate_images(): images = [] for _ in range(9): image = np.ones((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/calculator_list_and_dict/run.py
demo/calculator_list_and_dict/run.py
import gradio as gr with gr.Blocks() as demo: a = gr.Number(label="a") b = gr.Number(label="b") with gr.Row(): add_btn = gr.Button("Add") sub_btn = gr.Button("Subtract") c = gr.Number(label="sum") def add(num1, num2): return num1 + num2 add_btn.click(add, inputs=[a, 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/llm_langchain/run.py
demo/llm_langchain/run.py
# This is a simple general-purpose chatbot built on top of LangChain and Gradio. # Before running this, make sure you have exported your OpenAI API key as an environment variable: # export OPENAI_API_KEY="your-openai-api-key" from langchain_openai import ChatOpenAI # type: ignore from langchain.schema import AIMessag...
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_2/run.py
demo/hello_world_2/run.py
import gradio as gr def greet(name, intensity): return "Hello, " + name + "!" * intensity demo = gr.Interface( fn=greet, inputs=["text", gr.Slider(value=2, minimum=1, maximum=10, step=1)], outputs=[gr.Textbox(label="greeting", lines=3)], 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/markdown_with_mermaid/run.py
demo/markdown_with_mermaid/run.py
import gradio as gr demo = gr.Blocks() with demo: gr.Markdown( """ # Project Documentation with Mermaid Diagrams This example demonstrates how to combine regular Markdown with Mermaid diagrams for better visualization. ## System Architecture Below...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/super_html/run.py
demo/super_html/run.py
import gradio as gr with gr.Blocks() as demo: gr.Markdown(""" # Simple HTML usecase This is the classic `gr.HTML` usecase where we just want to render some static HTML. """) simple_html = gr.HTML("<h1 style='color:purple;' id='simple'>Hello, World!</h1>") gr.Markdown(""" # Templated HTML ...
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_component/run.py
demo/chatbot_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.Chatbot(value=[ # type: ignore {"role": "user", "content": "Hello World"}, {"role": "assistant", "content": "Hey Gradio!"}, {"role": "user", "content": "❤️"}, {"role": "assistant", "content": "😍"}, {"role": "user", "content"...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/custom_css/run.py
demo/custom_css/run.py
import gradio as gr with gr.Blocks() as demo: with gr.Column(elem_classes="cool-col"): gr.Markdown("### Gradio Demo with Custom CSS", elem_classes="darktest") gr.Markdown( elem_classes="markdown", value="Resize the browser window to see the CSS media query in action.", ...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/sine_curve/run.py
demo/sine_curve/run.py
import math import gradio as gr import plotly.express as px # type: ignore import numpy as np plot_end = 2 * math.pi def get_plot(period=1): global plot_end x = np.arange(plot_end - 2 * math.pi, plot_end, 0.02) y = np.sin(2*math.pi*period * x) fig = px.line(x=x, y=y) plot_end += 2 * math.pi 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/rate_limit/run.py
demo/rate_limit/run.py
import gradio as gr from datetime import datetime, timedelta from collections import defaultdict import threading rate_limit_data = defaultdict(list) lock = threading.Lock() UNAUTH_RATE_LIMIT = 3 AUTH_RATE_LIMIT = 30 RATE_LIMIT_WINDOW = 60 def clean_old_entries(user_id): """Remove entries older than the rate 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/dataframe_block-ui-test/run.py
demo/dataframe_block-ui-test/run.py
import gradio as gr with gr.Blocks() as demo: count = gr.Slider(minimum=1, maximum=10, step=1, label="count") data = gr.DataFrame( headers=["A", "B"], col_count=(2, "fixed"), type="array", interactive=True # type: ignore ) btn = gr.Button(value="click") btn.click( fn=lambda cnt: [[...
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_examples/run.py
demo/test_chatinterface_examples/run.py
import gradio as gr def generate( message: str, chat_history: list[dict], ): output = "" for character in message: output += character yield output demo = gr.ChatInterface( fn=generate, examples=[ ["Hey"], ["Can you explain briefly to me what is the Python pro...
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_examples/multimodal_messages_examples_testcase.py
demo/test_chatinterface_examples/multimodal_messages_examples_testcase.py
import gradio as gr def generate( message: dict, chat_history: list[dict], ): output = "" for character in message['text']: output += character yield output demo = gr.ChatInterface( fn=generate, examples=[ [{"text": "Hey"}], [{"text": "Can you explain briefly ...
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_examples/lazy_caching_examples_testcase.py
demo/test_chatinterface_examples/lazy_caching_examples_testcase.py
import gradio as gr def generate( message: str, chat_history: list[dict], ): output = "" for character in message: output += character yield output demo = gr.ChatInterface( fn=generate, examples=[ ["Hey"], ["Can you explain briefly to me what is the Python pro...
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_examples/eager_caching_examples_testcase.py
demo/test_chatinterface_examples/eager_caching_examples_testcase.py
import gradio as gr def generate( message: str, chat_history: list[dict], ): output = "" for character in message: output += character yield output demo = gr.ChatInterface( fn=generate, examples=[ ["Hey"], ["Can you explain briefly to me what is the Python pro...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/many_tabs/run.py
demo/many_tabs/run.py
import gradio as gr import pandas as pd import numpy as np # Sample data for components sample_df = pd.DataFrame( { "Name": ["Alice", "Bob", "Charlie", "Diana", "Eve"], "Age": [25, 30, 35, 28, 32], "City": ["New York", "London", "Paris", "Tokyo", "Berlin"], "Score": [95.5, 87.2, 92....
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/login_with_huggingface/run.py
demo/login_with_huggingface/run.py
from __future__ import annotations import gradio as gr from huggingface_hub import whoami def hello(profile: gr.OAuthProfile | None) -> str: if profile is None: return "I don't know you." return f"Hello {profile.name}" def list_organizations(oauth_token: gr.OAuthToken | None) -> str: if oauth_tok...
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/run.py
demo/fake_diffusion/run.py
import gradio as gr import numpy as np import time def fake_diffusion(steps): rng = np.random.default_rng() for i in range(steps): time.sleep(1) image = rng.random(size=(600, 600, 3)) yield image image = np.ones((1000,1000,3), np.uint8) image[:] = [255, 124, 0] yield 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/skip/run.py
demo/skip/run.py
import random import gradio as gr with gr.Blocks() as demo: with gr.Row(): clear_button = gr.Button("Clear") skip_button = gr.Button("Skip") random_button = gr.Button("Random") numbers = [gr.Number(), gr.Number()] clear_button.click(lambda : (None, None), outputs=numbers) skip_...
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_essay/run.py
demo/blocks_essay/run.py
import gradio as gr countries_cities_dict = { "USA": ["New York", "Los Angeles", "Chicago"], "Canada": ["Toronto", "Montreal", "Vancouver"], "Pakistan": ["Karachi", "Lahore", "Islamabad"], } def change_textbox(choice): if choice == "short": return gr.Textbox(lines=2, visible=True), gr.Button(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/model3d_component/run.py
demo/model3d_component/run.py
import gradio as gr with gr.Blocks() as demo: gr.Model3D() 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_nested_thoughts/run.py
demo/chatinterface_nested_thoughts/run.py
import gradio as gr from gradio import ChatMessage import time sleep_time = 0.1 long_sleep_time = 1 def generate_response(message, history): start_time = time.time() responses = [ ChatMessage( content="In order to find the current weather in San Francisco, I will need to use my weather too...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/stt_or_tts/run.py
demo/stt_or_tts/run.py
import gradio as gr tts_examples = [ "I love learning machine learning", "How do you do?", ] tts_demo = gr.load( "huggingface/facebook/fastspeech2-en-ljspeech", title=None, examples=tts_examples, description="Give me something to say!", cache_examples=False ) stt_demo = gr.load( "hugg...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false
gradio-app/gradio
https://github.com/gradio-app/gradio/blob/3b56b13268ddcaf74d4e85e5dbf5a616d7843995/demo/image_mod/run.py
demo/image_mod/run.py
import gradio as gr from gradio.media import get_image def image_mod(image): return image.rotate(45) # get_image() returns file paths to sample media included with Gradio new_samples = [ [get_image("logo.png")], [get_image("tower.jpg")], ] with gr.Blocks() as demo: interface = gr.Interface( 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/llm_openai/run.py
demo/llm_openai/run.py
# This is a simple general-purpose chatbot built on top of OpenAI API. # Before running this, make sure you have exported your OpenAI API key as an environment variable: # export OPENAI_API_KEY="your-openai-api-key" from openai import OpenAI import gradio as gr client = OpenAI() def predict(message, history): h...
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_unified/run.py
demo/streaming_filter_unified/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/depth_estimation/run.py
demo/depth_estimation/run.py
# type: ignore import gradio as gr from transformers import DPTFeatureExtractor, DPTForDepthEstimation import torch import numpy as np from PIL import Image import open3d as o3d # type: ignore from pathlib import Path feature_extractor = DPTFeatureExtractor.from_pretrained("Intel/dpt-large") model = DPTForDepthEstima...
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_tool_only/run.py
demo/mcp_tool_only/run.py
import gradio as gr def slice_list(lst: list, start: int, end: int) -> list: """ A tool that slices a list given a start and end index. Args: lst: The list to slice. start: The start index. end: The end index. Returns: The sliced list. """ return lst[start:end] ...
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_component/run.py
demo/star_rating_component/run.py
import gradio as gr class StarRating(gr.HTML): def __init__(self, label, value=0, **kwargs): html_template = """ <h2>${label} rating:</h2> ${Array.from({length: 5}, (_, i) => `<img class='${i < value ? '' : 'faded'}' src='https://upload.wikimedia.org/wikipedia/commons/d/df/Award-star-gold-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/dialogue_component/run.py
demo/dialogue_component/run.py
import gradio as gr with gr.Blocks() as demo: dd = gr.Dialogue(speakers=["Speaker 1", "Speaker 2"], tags=["(laughs)", "(sighs)", "(clears throat)"], value=[ {"speaker": "Speaker 1", "text": "Hello, how are you?"}, {"speaker": "Speaker 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/custom_path/run.py
demo/custom_path/run.py
from fastapi import FastAPI import gradio as gr CUSTOM_PATH = "/gradio" app = FastAPI() @app.get("/") def read_main(): return {"message": "This is your main app"} io = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox") app = gr.mount_gradio_app(app, io, path=CUSTOM_PATH) # Run this from the term...
python
Apache-2.0
3b56b13268ddcaf74d4e85e5dbf5a616d7843995
2026-01-04T14:40:26.993006Z
false