Create UIs for prototyping your machine learning model in 3 minutes

Overview

CircleCI PyPI version

Note: We just launched Hosted, where anyone can upload their interface for permanent hosting. Check it out!

Welcome to Gradio

Quickly create customizable UI components around your models. Gradio makes it easy for you to "play around" with your model in your browser by dragging-and-dropping in your own images, pasting your own text, recording your own voice, etc. and seeing what the model outputs.

Interface montage

Gradio is useful for:

  • Creating demos of your machine learning code for clients / collaborators / users

  • Getting feedback on model performance from users

  • Debugging your model interactively during development

Getting Started

You can find an interactive version of this README at https://gradio.app/getting_started.

Quick Start

To get Gradio running with a simple example, follow these three steps:

1. Install Gradio from pip.

pip install gradio

2. Run the code below as a Python script or in a Python notebook (or in a colab notebook).

import gradio as gr

def greet(name):
  return "Hello " + name + "!"

iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()

3. The interface below will appear automatically within the Python notebook, or pop in a browser on http://localhost:7860 if running from a script.

hello_world interface

The Interface

Gradio can wrap almost any Python function with an easy to use interface. That function could be anything from a simple tax calculator to a pretrained model.

The core Interface class is initialized with three parameters:

  • fn: the function to wrap
  • inputs: the input component type(s)
  • outputs: the output component type(s)

With these three arguments, we can quickly create interfaces and launch() them. But what if you want to change how the UI components look or behave?

Customizable Components

What if we wanted to customize the input text field - for example, we wanted it to be larger and have a text hint? If we use the actual input class for Textbox instead of using the string shortcut, we have access to much more customizability. To see a list of all the components we support and how you can customize them, check out the Docs

import gradio as gr

def greet(name):
  return "Hello " + name + "!"

iface = gr.Interface(
  fn=greet, 
  inputs=gr.inputs.Textbox(lines=2, placeholder="Name Here..."), 
  outputs="text")
iface.launch()

hello_world_2 interface

Multiple Inputs and Outputs

Let's say we had a much more complex function, with multiple inputs and outputs. In the example below, we have a function that takes a string, boolean, and number, and returns a string and number. Take a look how we pass a list of input and output components.

import gradio as gr

def greet(name, is_morning, temperature):
  salutation = "Good morning" if is_morning else "Good evening"
  greeting = "%s %s. It is %s degrees today" % (
    salutation, name, temperature)
  celsius = (temperature - 32) * 5 / 9
  return greeting, round(celsius, 2)

iface = gr.Interface(
  fn=greet, 
  inputs=["text", "checkbox", gr.inputs.Slider(0, 100)],
  outputs=["text", "number"])
iface.launch()

hello_world_3 interface

We simply wrap the components in a list. Furthermore, if we wanted to compare multiple functions that have the same input and return types, we can even pass a list of functions for quick comparison.

Working with Images

Let's try an image to image function. When using the Image component, your function will receive a numpy array of your specified size, with the shape (width, height, 3), where the last dimension represents the RGB values. We'll return an image as well in the form of a numpy array.

import gradio as gr
import numpy as np

def sepia(img):
  sepia_filter = np.array([[.393, .769, .189],
                           [.349, .686, .168],
                           [.272, .534, .131]])
  sepia_img = img.dot(sepia_filter.T)
  sepia_img /= sepia_img.max()                          
  return sepia_img

iface = gr.Interface(sepia, gr.inputs.Image(shape=(200, 200)), "image")
iface.launch()

sepia_filter interface

Additionally, our Image input interface comes with an 'edit' button which opens tools for cropping, flipping, rotating, drawing over, and applying filters to images. We've found that manipulating images in this way will often reveal hidden flaws in a model.

Example Data

You can provide example data that a user can easily load into the model. This can be helpful to demonstrate the types of inputs the model expects, as well as to provide a way to explore your dataset in conjunction with your model. To load example data, you provide a nested list to the examples= keyword argument of the Interface constructor. Each sublist within the outer list represents a data sample, and each element within the sublist represents an input for each input component. The format of example data for each component is specified in the Docs.

import gradio as gr
import random

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

iface = gr.Interface(calculator, 
    ["number", gr.inputs.Radio(["add", "subtract", "multiply", "divide"]), "number"],
    "number",
    examples=[
        [5, "add", 3],
        [4, "divide", 2],
        [-4, "multiply", 2.5],
        [0, "subtract", 1.2],
    ]
)

iface.launch()

calculator interface

Exploring Similar Examples with Embeddings

When you provide input to the function, you may wish to see if there are similar samples in the example dataset that could explain the behaviour of the function. For example, if an image model returns a peculiar output for a given input, you may load the training data into the examples dataset and see what training data samples are similar to the input you provided. If you enable this feature, you can click the Order by Similarity button to show the most similar samples from the example dataset.

Gradio supports exploring similar data samples through embeddings. Embeddings are a list of floats that numerically represent any input. To the embedding keyword argument of Interface, you must pass a function that takes the same inputs as the main fn argument, but instead returns an embedding that represents all the input values as a single list of floats. You can also pass the "default" string to embedding and Gradio will automatically generate embeddings for each sample in the examples dataset.

Flagging

Underneath the output interfaces, there is a button marked "Flag". When a user testing your model sees input with interesting output, such as erroneous or unexpected model behaviour, they can flag the input for review. Within the directory provided by the flagging_dir= argument to the Interface constructor, a CSV file will log the flagged inputs. If the interface involved file inputs, such as for Image and Audio interfaces, folders will be created to store those flagged inputs as well.

You can review these flagged inputs by manually exploring the flagging directory, or load them into the Gradio interface by pointing the examples= argument to the flagged CSV file.

Interpretation

Most models are black boxes such that the internal logic of the function is hidden from the end user. To encourage transparency, we've added the ability for interpretation so that users can understand what parts of the input are responsible for the output. Take a look at the simple interface below:

import gradio as gr
import re

male_words, female_words = ["he", "his", "him"], ["she", "her"]
def gender_of_sentence(sentence):
  male_count = len([word for word in sentence.split() if word.lower() in male_words])
  female_count = len([word for word in sentence.split() if word.lower() in female_words])
  total = max(male_count + female_count, 1)
  return {"male": male_count / total, "female": female_count / total}

iface = gr.Interface(
  fn=gender_of_sentence, inputs=gr.inputs.Textbox(default="She went to his house to get her keys."),
  outputs="label", interpretation="default")
iface.launch()

gender_sentence_default_interpretation interface

Notice the interpretation keyword argument. We're going to use Gradio's default interpreter here. After you submit and click Interpret, you'll see the interface automatically highlights the parts of the text that contributed to the final output orange! The parts that conflict with the output are highlight blue.

Gradio's default interpretation works with single output type interfaces, where the output is either a Label or Number. We're working on expanding the default interpreter to be much more customizable and support more interfaces.

You can also write your own interpretation function. The demo below adds custom interpretation to the previous demo. This function will take the same inputs as the main wrapped function. The output of this interpretation function will be used to highlight the input of each input interface - therefore the number of outputs here corresponds to the number of input interfaces. To see the format for interpretation for each input interface, check the Docs.

import gradio as gr
import re

male_words, female_words = ["he", "his", "him"], ["she", "her"]
def gender_of_sentence(sentence):
  male_count = len([word for word in sentence.split() if word.lower() in male_words])
  female_count = len([word for word in sentence.split() if word.lower() in female_words])
  total = max(male_count + female_count, 1)
  return {"male": male_count / total, "female": female_count / total}

def interpret_gender(sentence):
  result = gender_of_sentence(sentence)
  is_male = result["male"] > result["female"]
  interpretation = []
  for word in re.split('( )', sentence):
    score = 0
    token = word.lower()
    if (is_male and token in male_words) or (not is_male and token in female_words):
      score = 1
    elif (is_male and token in female_words) or (not is_male and token in male_words):
      score = -1
    interpretation.append((word, score))
  return interpretation

iface = gr.Interface(
  fn=gender_of_sentence, inputs=gr.inputs.Textbox(default="She went to his house to get her keys."),
  outputs="label", interpretation=interpret_gender)
iface.launch()

gender_sentence_custom_interpretation interface

Sharing Interfaces Publicly & Privacy

Interfaces can be easily shared publicly by setting share=True in the launch() method. Like this:

gr.Interface(classify_image, image, label).launch(share=True)

This generates a public, shareable link that you can send to anybody! When you send this link, the user on the other side can try out the model in their browser. Because the processing happens on your device (as long as your device stays on!), you don't have to worry about any dependencies. If you're working out of colab notebook, a share link is always automatically created. It usually looks something like this: XXXXX.gradio.app. Although the link is served through a gradio link, we are only a proxy for your local server, and do not store any data sent through the interfaces.

Keep in mind, however, that these links are publicly accessible, meaning that anyone can use your model for prediction! Therefore, make sure not to expose any sensitive information through the functions you write, or allow any critical changes to occur on your device. If you set share=False (the default), only a local link is created, which can be shared by port-forwarding with specific users.

Links expire after 6 hours. Need longer links, or private links? Contact us for Gradio Teams.

Sharing diagram

Permanent Hosting

You can share your interface publicly and permanently through Hosted, read more in our (introductury post)[https://gradio.app/introducing-hosted]. You will need to create a Gradio account. Just go to gradio.app/hosted and sign in through Github. Once you've logged in, you can specify which repositories from your Github profile you'd like to have hosted by Gradio. You must also specify the file within the repository that runs the Gradio launch() command. Once you've taken these steps, Gradio will launch your interface and provide a public link you can share. Hosted costs $7/month. Deploy one interface for free in February using the FEBRUARY promo code.

Contributing:

If you would like to contribute and your contribution is small, you can directly open a pull request (PR). If you would like to contribute a larger feature, we recommend first creating an issue with a proposed design for discussion. Please see our contributing guidelines for more info.

License:

Gradio is licensed under the Apache License 2.0

See more:

You can find many more examples (like GPT-2, model comparison, multiple inputs, and numerical interfaces) as well as more info on usage on our website: www.gradio.app

See, also, the accompanying paper: "Gradio: Hassle-Free Sharing and Testing of ML Models in the Wild", ICML HILL 2019, and please use the citation below.

@article{abid2019gradio,
title={Gradio: Hassle-Free Sharing and Testing of ML Models in the Wild},
author={Abid, Abubakar and Abdalla, Ali and Abid, Ali and Khan, Dawood and Alfozan, Abdulrahman and Zou, James},
journal={arXiv preprint arXiv:1906.02569},
year={2019}
}
Comments
  • Add Progress Bar component

    Add Progress Bar component

    Add support for progressbar component. Feel free to leave feedback on API or visual design.

    See example in demo/progress/run.py

    Snippet for tqdm-like wrapper

    def load_set(text, progress=gr.Progress()):
            imgs = [None] * 24
            for img in progress.tqdm(imgs, message="Loading from list"):
                time.sleep(0.1)
            return "done"
        load_set_btn.click(load_set, text, text2)
    

    Snippet for explicit status:

    def clean_imgs(text, progress=gr.Progress()):
            progress(0.2, message="Collecting Images")
            time.sleep(1)
            progress(0.5, message="Cleaning Images")
            time.sleep(1.5)
            progress(0.8, message="Sending Images")
            time.sleep(1.5)
            return "done"
        clean_imgs_btn.click(clean_imgs, text, text2)
    

    Recording 2022-11-30 at 18 01 51

    Closes: #340

    opened by aliabid94 59
  • Audio waveform

    Audio waveform

    Description

    Add a utility function that creates a video when supplied with audio and image files.

    https://user-images.githubusercontent.com/12725292/203449101-39a603be-fe8f-4ca5-9b24-1d06ad2db812.mov

    Test:

    def audio_waveform(audio, image):
        print(audio.name)
        return utils.audio_to_video(audio.name, image.name)
    
    
    gr.Interface(audio_waveform, inputs= [gr.Audio(type="file"), gr.Image(type="file")], outputs=gr.Video()).launch()
    

    Please include:

    • relevant motivation
    • a summary of the change
    • which issue is fixed.
    • any additional dependencies that are required for this change.

    Closes: # (issue)

    Checklist:

    • [ ] I have performed a self-review of my own code
    • [ ] I have added a short summary of my change to the CHANGELOG.md
    • [ ] My code follows the style guidelines of this project
    • [ ] I have commented my code in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [ ] I have added tests that prove my fix is effective or that my feature works
    • [ ] New and existing unit tests pass locally with my changes

    A note about the CHANGELOG

    Hello 👋 and thank you for contributing to Gradio!

    All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

    Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

    If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections. If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the GitHub web UI since that lets you upload files directly via drag-and-drop.

    opened by dawoodkhan82 43
  • Switch from SSH tunneling to FRP

    Switch from SSH tunneling to FRP

    Continuing from: https://github.com/gradio-app/gradio/pull/2396

    Remaining TODOs:

    • [x] Add back md5 encryption (@Wauplin would you be able to take a look at this?)
    • [x] Add https for the share links (@abidlabs)
    • [x] Fix the connection persistency issue that @freddyaboulton brought up below (@XciD)
    • [x] Add a better page when Gradio Interface is no longer active (@abidlabs)
    • [x] Add tests (@abidlabs)
    • [x] Expire links in 72 hours (@XciD would you be able to take a look at this?)
    • [x] Do some load testing to figure out if we need to set up horizontal scaling (@aliabid94)
    • [x] Don't hardcode IP address and port (@abidlabs)

    Also:

    • closes: #2260
    • closes: #2180
    opened by abidlabs 33
  • Sketching + Inpainting Capabilities to Gradio

    Sketching + Inpainting Capabilities to Gradio

    What use cases does the Image component need to serve?

    On the Python side, users want…

    • A standalone uploadable image (image classification, image segmentation, etc.)
    • A standalone black-and-white sketch (handwriting recognition)
    • A standalone color sketch (sketch2image)
    • An uploadable image + a binary mask (inpainting)
    • An uploadable image + a color sketch (paint2pix)

    This PR adds support for all of these (plus a few minor ones like webcam + mask/sketch). To see all of the different ways the Image component can now be used, go to: https://huggingface.co/spaces/gradio-pr-deploys/pr-2144-all-demos and click on blocks_mask or use the beta release gradio==3.4.0b to test

    The blocks_mask demo has the code snippets for all of the different modes. For example, for image upload + color sketching, you would something like:

    import gradio as gr
    
    gr.Interface(lambda x: x, gr.Image(source='upload', tool='color-sketch'), gr.Image())
    

    Fixes: #1721 Fixes: #2060 Fixes: #2124 Fixes: #2030 Fixes: #1174 Fixes: #2312 Fixes: #2224 Fixes #2295

    opened by abidlabs 31
  • Blocks components

    Blocks components

    Combine all input output and static components under components. A huge refactoring, detailed review would be great!

    Fixes: #639

    • create general structure
    • move Textbox into component.py
    opened by FarukOzderim 30
  • 🙋 Community Feedback on Blocks

    🙋 Community Feedback on Blocks

    This issue is a place for the community to try Blocks 🧱 and give feedback on its development

    What is Blocks?

    Blocks allows you to build web-based demos in a flexible way using the gradio library. Blocks is a more low-level and flexible alternative to the core Interface class. Specifically, Blocks support:

    • grouping together related demos using Tabs
    • flexible positioning of components using Columns, Rows, etc. and the ability to add explanatory Markdown or Text at any point
    • flexible data flows (e.g. any number of input and output components can be displayed on screen, and functions can define data flow between any subset of inputs and outputs)
    • flexible event triggers (e.g. button clicks, element changes, etc.)

    Here's an example Block:

    Recording 2022-02-22 at 11 54 03

    If you've used Gradio before, you'll find that Blocks still allows you to build web apps:

    • entirely in Python
    • using the standard Python interpreter, which means it will run in Jupyter notebooks, colab notebooks, or any Python IDE

    Getting Started with Blocks

    • Blocks is just released with Gradio 3.0. Check here for the announcement.
    • To use it, please install the latest release of Gradio: pip install gradio
    • TODO: Add [Blocks Introduction Guide Link]

    You can also use Blocks in Spaces! See an example here.


    Giving feedback: In the comments below, we'd love to hear from you:

    • Did Blocks allow you to build something cool? Share a screenshot or a link to a Blocks Demo!
    • Does Blocks not support your use case? Let us know too so that we can support it!
    • Did you find anything confusing or hard within the syntax or usage of Blocks? Let's improve it together!
    opened by abidlabs 29
  • Batching

    Batching

    Ignore this giant thread and go all the way to the bottom: https://github.com/gradio-app/gradio/pull/2218#issuecomment-1258823942

    ⬇️ ⬇️ ⬇️ ⬇️ ⬇️ ⬇️ ⬇️

    opened by abidlabs 27
  • Enable multi-select on gradio.Dropdown

    Enable multi-select on gradio.Dropdown

    Description

    Add option to select multiple options on gr.Dropdown

    Will be updating the colors to match other form components.

    https://user-images.githubusercontent.com/12725292/210434026-737809ed-5e6c-4b10-97ff-e489bbfe72e4.mov

    Please include:

    • relevant motivation
    • a summary of the change
    • which issue is fixed.
    • any additional dependencies that are required for this change.

    Closes: #1076

    Checklist:

    • [ ] I have performed a self-review of my own code
    • [ ] I have added a short summary of my change to the CHANGELOG.md
    • [ ] My code follows the style guidelines of this project
    • [ ] I have commented my code in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [ ] I have added tests that prove my fix is effective or that my feature works
    • [ ] New and existing unit tests pass locally with my changes

    A note about the CHANGELOG

    Hello 👋 and thank you for contributing to Gradio!

    All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

    Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

    If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections. If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the GitHub web UI since that lets you upload files directly via drag-and-drop.

    opened by dawoodkhan82 26
  • Adding a Playground Tab to the Website

    Adding a Playground Tab to the Website

    Adding a playground tab to the website, initially will just show curated demos side by side with their code.

    Currently has 12 demos (all the demos in getting started and blocks guides) but it's very easy to add more. Still need to make some styling changes.

    https://user-images.githubusercontent.com/9021060/180467578-44526ad4-d6e9-492d-a7c5-acb92840ecf5.mov

    Fixes #1638

    opened by aliabd 26
  • Add Upload Button

    Add Upload Button

    Description

    Add an upload button component. Like file upload but in button form. Main use case is for the new improved chatbot coming soon.

    Not sure about the style of the button.

    https://user-images.githubusercontent.com/12725292/199436347-e3ddff14-2ee0-4344-a477-a1a138b99c8e.mov

    import gradio as gr
    
    def test(name):
        return name.name
    
    with gr.Blocks() as demo:
        image = gr.Image(interactive=False)
        upload_button = gr.UploadButton()
        upload_button.upload(fn=test, inputs=upload_button, outputs=image)
    
    demo.launch()
    

    Please include:

    • relevant motivation
    • a summary of the change
    • which issue is fixed.
    • any additional dependencies that are required for this change.

    Closes: #2062

    Checklist:

    • [ ] I have performed a self-review of my own code
    • [ ] I have added a short summary of my change to the CHANGELOG.md
    • [ ] My code follows the style guidelines of this project
    • [ ] I have commented my code in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [ ] I have added tests that prove my fix is effective or that my feature works
    • [ ] New and existing unit tests pass locally with my changes

    A note about the CHANGELOG

    Hello 👋 and thank you for contributing to Gradio!

    All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

    Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

    If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections. If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the GitHub web UI since that lets you upload files directly via drag-and-drop.

    opened by dawoodkhan82 22
  • Allow user to send inputs as dictionary

    Allow user to send inputs as dictionary

    This is an implementation of a new API that allows users to not have to specify input and output components anymore. The way it works is, if an event listener has inputs='all', then all the IOComponents in the app are inputs to this function. The function now only receives a single input - a dictionary that maps components to their values. To change values as output, simply edit this dictionary - gradio will diff to find the edits made to the dictionary and send those back only. This fixes much of the existing ugliness with the Gradio API, and I think could eventually become the default API of event listeners.

    Example code in demo/calculator_all_inputs/run.py, snippet copied below:

    with gr.Blocks() as demo:
        a = gr.Number(label="a")
        b = gr.Number(label="b")
        add_btn = gr.Button("Add")
        c = gr.Number(label="sum")
    
        def add(data):
            data[c] = data[a] + data[b]
    
        add_btn.click(add, inputs="all")
    

    Earlier I listed the problems with our existing API, copied again below:

    1. Inputs defined in 3 different places (event listener, function header, and wherever inputs are used in function body)
    2. Each input component also needs a second name as a function arg. Sometimes this can be the same name as the variable name of the component, but this will overwrite access to the original component. If different names are used, then confusion from 2 different names.
    3. Outputs defined in 2 different places (event listener, return statement)
    4. Outputs can only be set in the return statement, so all outputs must be set simultaneously
    5. Must collect all input data from frontend at once (cannot collect conditionally)

    This API would fix 1-4.

    Drawbacks of this approach:

    • Requires frontend to send ALL component data to the backend. This could be fixed keeping a copy of the data always in the backend, and on every data submit to the frontend, we only send what has changed since the last submit.
    • We no longer know the inputs/outputs of this type of event listener beforehand. Side effects of this:
      • ‘interactive’ will have to be defined manually for components
      • Cannot automatically generate API documentation for this type of event listener
      • Will not have loading animation on outputs b/c we don’t know what they are (maybe we can animate the triggering component, e.g. the button clicked itself instead?)

    Fixes: #2471

    opened by aliabid94 22
  • Python backend to theming

    Python backend to theming

    Created python backend that will allow users to create and modify backends from python. User's can specify existing themes as:

    with gr.Blocks(theme=gr.themes.Solid) as demo:
        pass
    

    and they can modify themes, with full type hints, via:

    theme = gr.themes.Default()
    theme.color_focus_primary = "#aaaaaa"
    
    with gr.Blocks(theme=theme) as demo:
        pass
    

    Here's how it works:

    1. Themes are stored in gradio/theming/configs as jsons
    2. gradio/theming/_gen_themes.py converts these jsons into python classes. Each css variable is converted into an attribute of the class
    3. These python classes can be imported, modified, etc.
    4. When passed a Theme class, Blocks will generate the css from the attributes.
    5. This css file will be accessed via localhost:7860/theme.css

    Currently the best way I could think of implementing, lmk what you guys think.

    Example running demo/blocks_xray below: Recording 2023-01-04 at 18 29 06

    (for some reason, vscode isn't type hinting the theme attributes for me, will figure out. For now looking for feedback on general implementation_

    opened by aliabid94 1
  • Fix bug downloading files with long names

    Fix bug downloading files with long names

    Description

    If the orig_name of a file is longer than 30 characters, the UI would truncate the name of the downloaded file to the first 30 characters. This causes the file extension to be ignored which can be a problem for some demos, like 3d object files, etc.

    This is more noticeable now that we return tmp files with really long names

    This PR

    download_pr

    Main

    download_main

    Checklist:

    • [x] I have performed a self-review of my own code
    • [x] I have added a short summary of my change to the CHANGELOG.md
    • [x] My code follows the style guidelines of this project
    • [x] I have commented my code in hard-to-understand areas
    • [x] I have made corresponding changes to the documentation
    • [x] I have added tests that prove my fix is effective or that my feature works
    • [x] New and existing unit tests pass locally with my changes

    A note about the CHANGELOG

    Hello 👋 and thank you for contributing to Gradio!

    All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

    Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

    If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections. If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the GitHub web UI since that lets you upload files directly via drag-and-drop.

    opened by freddyaboulton 1
  • Move from circleci to gh actions for backend tests

    Move from circleci to gh actions for backend tests

    Description

    Remove circle ci and use github actions instead

    Checklist:

    • [ ] I have performed a self-review of my own code
    • [ ] I have added a short summary of my change to the CHANGELOG.md
    • [ ] My code follows the style guidelines of this project
    • [ ] I have commented my code in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [ ] I have added tests that prove my fix is effective or that my feature works
    • [ ] New and existing unit tests pass locally with my changes

    A note about the CHANGELOG

    Hello 👋 and thank you for contributing to Gradio!

    All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

    Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

    If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections. If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the GitHub web UI since that lets you upload files directly via drag-and-drop.

    no-changelog-update 
    opened by freddyaboulton 1
  • Fixes file upload fails for files with zero size

    Fixes file upload fails for files with zero size

    Description

    Added some error handling for when file size is zero

    Please include:

    • relevant motivation
    • a summary of the change
    • which issue is fixed.
    • any additional dependencies that are required for this change.

    Closes: #2778

    Checklist:

    • [ ] I have performed a self-review of my own code
    • [ ] I have added a short summary of my change to the CHANGELOG.md
    • [ ] My code follows the style guidelines of this project
    • [ ] I have commented my code in hard-to-understand areas
    • [ ] I have made corresponding changes to the documentation
    • [ ] I have added tests that prove my fix is effective or that my feature works
    • [ ] New and existing unit tests pass locally with my changes

    A note about the CHANGELOG

    Hello 👋 and thank you for contributing to Gradio!

    All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

    Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

    If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections. If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the GitHub web UI since that lets you upload files directly via drag-and-drop.

    opened by dawoodkhan82 3
  • Optimize images and gifs

    Optimize images and gifs

    Converts gifs to html video, and compresses some images. @pngwn I'm not 100% sure what you meant here https://github.com/gradio-app/gradio/issues/578, almost all the images in the website are pretty small. Or does optimizing mean something else? Please take a look and let me know if this is what you meant.

    Closes https://github.com/gradio-app/gradio/issues/577, closes https://github.com/gradio-app/gradio/issues/578

    opened by aliabd 2
Releases(v3.16.0)
  • v3.15.0(Dec 21, 2022)

    Version 3.15.0

    New Features:

    Gradio's newest plotting component gr.LinePlot! 📈

    With this component you can easily create time series visualizations with customizable appearance for your demos and dashboards ... all without having to know an external plotting library.

    For an example of the api see below:

    gr.LinePlot(stocks,
                x="date",
                y="price",
                color="symbol",
                color_legend_position="bottom",
                width=600, height=400, title="Stock Prices")
    

    image

    By @freddyaboulton in PR 2807

    Bug Fixes:

    • Fixed bug where the examples_per_page parameter of the Examples component was not passed to the internal Dataset component by @freddyaboultonin PR 2861
    • Fixes loading Spaces that have components with default values by @abidlabs in PR 2855
    • Fixes flagging when allow_flagging="auto" in gr.Interface() by @abidlabs in PR 2695
    • Fixed bug where passing a non-list value to gr.CheckboxGroup would crash the entire app by @freddyaboulton(https://github.com/freddyaboulton) in PR 2866

    Documentation Changes:

    • Added a Guide on using BigQuery with Gradio's DataFrame and ScatterPlot component, by @abidlabs in PR 2794

    Testing and Infrastructure Changes:

    No changes to highlight.

    Breaking Changes:

    No changes to highlight.

    Full Changelog:

    • Fixed importing gradio can cause PIL.Image.registered_extensions() to break by @aliencaocao in [PR 2846](https://github.com/gradio-app/gradio/pull/2846)
    • Fix css glitch and navigation in docs by @aliabd in PR 2856
    • Added the ability to set x_lim, y_lim and legend positions for gr.ScatterPlot by @freddyaboulton in PR 2807
    • Remove footers and min-height the correct way by @aliabd in PR 2860

    Contributors Shoutout:

    No changes to highlight.

    Source code(tar.gz)
    Source code(zip)
  • v3.14.0a1(Dec 21, 2022)

  • v3.14.0(Dec 15, 2022)

    Version 3.14.0

    New Features:

    Add Waveform Visual Support to Audio

    Adds a gr.make_waveform() function that creates a waveform video by combining an audio and an optional background image by @dawoodkhan82 and @aliabid94 in [PR 2706](https://github.com/gradio-app/gradio/pull/2706. Helpful for making audio outputs much more shareable.

    waveform screenrecording

    Allows Every Component to Accept an every Parameter

    When a component's initial value is a function, the every parameter re-runs the function every every seconds. By @abidlabs in PR 2806. Here's a code example:

    import gradio as gr
    
    with gr.Blocks() as demo:
        df = gr.DataFrame(run_query, every=60*60)
    
    demo.queue().launch() 
    

    Bug Fixes:

    • Fixed issue where too many temporary files were created, all with randomly generated filepaths. Now fewer temporary files are created and are assigned a path that is a hash based on the file contents by @abidlabs in PR 2758

    Documentation Changes:

    No changes to highlight.

    Testing and Infrastructure Changes:

    No changes to highlight.

    Breaking Changes:

    No changes to highlight.

    Full Changelog:

    No changes to highlight.

    Contributors Shoutout:

    No changes to highlight.

    Source code(tar.gz)
    Source code(zip)
  • v3.13.2(Dec 15, 2022)

    Version 3.13.2

    New Features:

    No changes to highlight.

    Bug Fixes:

    No changes to highlight.

    Documentation Changes:

    No changes to highlight.

    Testing and Infrastructure Changes:

    Breaking Changes:

    No changes to highlight.

    Full Changelog:

    No changes to highlight.

    Contributors Shoutout:

    No changes to highlight.

    Source code(tar.gz)
    Source code(zip)
  • v3.13.1b2(Dec 15, 2022)

  • v3.13.1b1(Dec 15, 2022)

  • v3.13.1b0(Dec 15, 2022)

  • v3.13.1(Dec 15, 2022)

    Version 3.13.1

    New Features:

    New Shareable Links

    Replaces tunneling logic based on ssh port-forwarding to that based on frp by @XciD and @Wauplin in PR 2509

    You don't need to do anything differently, but when you set share=True in launch(), you'll get this message and a public link that look a little bit different:

    Setting up a public link... we have recently upgraded the way public links are generated. If you encounter any problems, please downgrade to gradio version 3.13.0
    .
    Running on public URL: https://bec81a83-5b5c-471e.gradio.live
    

    These links are a more secure and scalable way to create shareable demos!

    Bug Fixes:

    • Allows gr.Dataframe() to take a pandas.DataFrame that includes numpy array and other types as its initial value, by @abidlabs in PR 2804
    • Add altair to requirements.txt by @freddyaboulton in PR 2811
    • Added aria-labels to icon buttons that are built into UI components by @emilyuhde in in PR #2791

    Documentation Changes:

    • Fixed some typos in the "Plot Component for Maps" guide by @freddyaboulton in PR 2811

    Testing and Infrastructure Changes:

    • Fixed test for IP address by @abidlabs in PR 2808

    Breaking Changes:

    No changes to highlight.

    Full Changelog:

    • Fixed typo in parameter visible in classes in templates.py by @abidlabs in PR 2805
    • Switched external service for getting IP address from https://api.ipify.org to https://checkip.amazonaws.com/ by @abidlabs in PR 2810
    Source code(tar.gz)
    Source code(zip)
  • v3.13.0b1(Dec 14, 2022)

  • v3.13.0(Dec 12, 2022)

    Version 3.13.0

    New Features:

    Scatter plot component

    It is now possible to create a scatter plot natively in Gradio!

    The gr.ScatterPlot component accepts a pandas dataframe and some optional configuration parameters and will automatically create a plot for you!

    This is the first of many native plotting components in Gradio!

    For an example of how to use gr.ScatterPlot see below:

    import gradio as gr
    from vega_datasets import data
    
    cars = data.cars()
    
    with gr.Blocks() as demo:
        gr.ScatterPlot(show_label=False,
                       value=cars,
                       x="Horsepower",
                       y="Miles_per_Gallon",
                       color="Origin",
                       tooltip="Name",
                       title="Car Data",
                       y_title="Miles per Gallon",
                       color_legend_title="Origin of Car").style(container=False)
    
    demo.launch()
    
    image

    By @freddyaboulton in PR 2764

    Support for altair plots

    The Plot component can now accept altair plots as values! Simply return an altair plot from your event listener and gradio will display it in the front-end. See the example below:

    import gradio as gr
    import altair as alt
    from vega_datasets import data
    
    cars = data.cars()
    chart = (
        alt.Chart(cars)
        .mark_point()
        .encode(
            x="Horsepower",
            y="Miles_per_Gallon",
            color="Origin",
        )
    )
    
    with gr.Blocks() as demo:
        gr.Plot(value=chart)
    demo.launch()
    
    image

    By @freddyaboulton in PR 2741

    Set the background color of a Label component

    The Label component now accepts a color argument by @freddyaboulton in PR 2736. The color argument should either be a valid css color name or hexadecimal string. You can update the color with gr.Label.update!

    This lets you create Alert and Warning boxes with the Label component. See below:

    import gradio as gr
    import random
    
    def update_color(value):
        if value < 0:
            # This is bad so use red
            return "#FF0000"
        elif 0 <= value <= 20:
            # Ok but pay attention (use orange)
            return "#ff9966"
        else:
            # Nothing to worry about
            return None
    
    def update_value():
        choice = random.choice(['good', 'bad', 'so-so'])
        color = update_color(choice)
        return gr.Label.update(value=choice, color=color)
        
        
    with gr.Blocks() as demo:
        label = gr.Label(value=-10)
        demo.load(lambda: update_value(), inputs=None, outputs=[label], every=1)
    demo.queue().launch()
    

    label_bg_color_update

    Add Brazilian Portuguese translation

    Add Brazilian Portuguese translation (pt-BR.json) by @pstwh in PR 2753:

    image

    Bug Fixes:

    • Fixed issue where image thumbnails were not showing when an example directory was provided by by @abidlabs in PR 2745
    • Fixed bug loading audio input models from the hub by @freddyaboulton in PR 2779.
    • Fixed issue where entities were not merged when highlighted text was generated from the dictionary inputs @payoto in PR 2767
    • Fixed bug where generating events did not finish running even if the websocket connection was closed by @freddyaboulton in PR 2783.

    Documentation Changes:

    No changes to highlight.

    Testing and Infrastructure Changes:

    No changes to highlight.

    Breaking Changes:

    No changes to highlight.

    Full Changelog:

    • Images in the chatbot component are now resized if they exceed a max width by @abidlabs in PR 2748
    • Missing parameters have been added to gr.Blocks().load() by @abidlabs in PR 2755
    • Deindex share URLs from search by @aliabd in PR 2772
    • Redirect old links and fix broken ones by @aliabd in PR 2774

    Contributors Shoutout:

    No changes to highlight.

    Source code(tar.gz)
    Source code(zip)
  • v3.12.0b7(Dec 10, 2022)

  • v3.12.0b6(Dec 10, 2022)

  • v3.12.0b3(Dec 10, 2022)

  • v3.12.0b2(Dec 6, 2022)

  • v3.12.0b1(Dec 1, 2022)

  • v3.12.0(Nov 29, 2022)

    3.12.0

    New Features:

    The Chatbot component now supports a subset of Markdown (including bold, italics, code, images)

    You can now pass in some Markdown to the Chatbot component and it will show up, meaning that you can pass in images as well! by @abidlabs in PR 2731

    Here's a simple example that references a local image lion.jpg that is in the same folder as the Python script:

    import gradio as gr
    
    with gr.Blocks() as demo:
        gr.Chatbot([("hi", "hello **abubakar**"), ("![](/file=lion.jpg)", "cool pic")])
        
    demo.launch()
    

    Alt text

    To see a more realistic example, see the new demo /demo/chatbot_multimodal/run.py.

    Latex support

    Added mathtext (a subset of latex) support to gr.Markdown. Added by @kashif and @aliabid94 in PR 2696.

    Example of how it can be used:

    gr.Markdown(
        r"""
        # Hello World! $\frac{\sqrt{x + y}}{4}$ is today's lesson.
        """)
    

    Update Accordion properties from the backend

    You can now update the Accordion label and open status with gr.Accordion.update by @freddyaboulton in PR 2690

    import gradio as gr
    
    with gr.Blocks() as demo:
        with gr.Accordion(label="Open for greeting", open=False) as accordion:
            gr.Textbox("Hello!")
        open_btn = gr.Button(value="Open Accordion")
        close_btn = gr.Button(value="Close Accordion")
        open_btn.click(
            lambda: gr.Accordion.update(open=True, label="Open Accordion"),
            inputs=None,
            outputs=[accordion],
        )
        close_btn.click(
            lambda: gr.Accordion.update(open=False, label="Closed Accordion"),
            inputs=None,
            outputs=[accordion],
        )
    demo.launch()
    

    update_accordion

    Bug Fixes:

    • Fixed bug where requests timeout is missing from utils.version_check() by @yujiehecs in PR 2729
    • Fixed bug where so that the File component can properly preprocess files to "binary" byte-string format by CoffeeVampir3 in PR 2727
    • Fixed bug to ensure that filenames are less than 200 characters even for non-English languages by @SkyTNT in PR 2685

    Documentation Changes:

    Testing and Infrastructure Changes:

    No changes to highlight.

    Breaking Changes:

    No changes to highlight.

    Full Changelog:

    Contributors Shoutout:

    Source code(tar.gz)
    Source code(zip)
  • v3.11.0(Nov 23, 2022)

    3.11.0

    New Features:

    Upload Button

    There is now a new component called the UploadButton which is a file upload component but in button form! You can also specify what file types it should accept in the form of a list (ex: image, video, audio, text, or generic file). Added by @dawoodkhan82 in PR 2591.

    Example of how it can be used:

    import gradio as gr
    
    def upload_file(files):
        file_paths = [file.name for file in files]
        return file_paths
    
    with gr.Blocks() as demo:
        file_output = gr.File()
        upload_button = gr.UploadButton("Click to Upload a File", file_types=["image", "video"], file_count="multiple")
        upload_button.upload(upload_file, upload_button, file_output)
    
    demo.launch()
    

    Revamped API documentation page

    New API Docs page with in-browser playground and updated aesthetics. @gary149 in PR 2652

    Revamped Login page

    Previously our login page had its own CSS, had no dark mode, and had an ugly json message on the wrong credentials. Made the page more aesthetically consistent, added dark mode support, and a nicer error message. @aliabid94 in PR 2684

    Accessing the Requests Object Directly

    You can now access the Request object directly in your Python function by @abidlabs in PR 2641. This means that you can access request headers, the client IP address, and so on. In order to use it, add a parameter to your function and set its type hint to be gr.Request. Here's a simple example:

    import gradio as gr
    
    def echo(name, request: gr.Request):
        if request:
            print("Request headers dictionary:", request.headers)
            print("IP address:", request.client.host)
        return name
    
    io = gr.Interface(echo, "textbox", "textbox").launch()
    

    Bug Fixes:

    • Fixed bug that limited files from being sent over websockets to 16MB. The new limit is now 1GB by @abidlabs in PR 2709

    Documentation Changes:

    • Updated documentation for embedding Gradio demos on Spaces as web components by @julien-c in PR 2698
    • Updated IFrames in Guides to use the host URL instead of the Space name to be consistent with the new method for embedding Spaces, by
      @julien-c in PR 2692
    • Colab buttons on every demo in the website! Just click open in colab, and run the demo there.

    https://user-images.githubusercontent.com/9021060/202878400-cb16ed47-f4dd-4cb0-b2f0-102a9ff64135.mov

    Testing and Infrastructure Changes:

    No changes to highlight.

    Breaking Changes:

    No changes to highlight.

    Full Changelog:

    • Better warnings and error messages for gr.Interface.load() by @abidlabs in PR 2694
    • Add open in colab buttons to demos in docs and /demos by @aliabd in PR 2608
    • Apply different formatting for the types in component docstrings by @aliabd in PR 2707

    Contributors Shoutout:

    No changes to highlight.

    Source code(tar.gz)
    Source code(zip)
  • v3.10.1(Nov 18, 2022)

    3.10.1

    New Features:

    No changes to highlight.

    Bug Fixes:

    Documentation Changes:

    No changes to highlight.

    Testing and Infrastructure Changes:

    No changes to highlight.

    Breaking Changes:

    No changes to highlight.

    Full Changelog:

    Contributors Shoutout:

    No changes to highlight.

    Source code(tar.gz)
    Source code(zip)
  • v3.10.0(Nov 17, 2022)

    3.10.0

    • Add support for 'password' and 'email' types to Textbox. @pngwn in PR 2653
    • gr.Textbox component will now raise an exception if type is not "text", "email", or "password" @pngwn in PR 2653. This will cause demos using the deprecated gr.Textbox(type="number") to raise an exception.

    Bug Fixes:

    • Updated the minimum FastApi used in tests to version 0.87 by @freddyaboulton in PR 2647
    • Fixed bug where interfaces with examples could not be loaded with gr.Interface.load by @freddyaboulton PR 2640
    • Fixed bug where the interactive property of a component could not be updated by @freddyaboulton in PR 2639
    • Fixed bug where some URLs were not being recognized as valid URLs and thus were not loading correctly in various components by @abidlabs in PR 2659

    Documentation Changes:

    • Fix some typos in the embedded demo names in "05_using_blocks_like_functions.md" by @freddyaboulton in PR 2656

    Testing and Infrastructure Changes:

    No changes to highlight.

    Breaking Changes:

    No changes to highlight.

    Full Changelog:

    • Add support for 'password' and 'email' types to Textbox. @pngwn in PR 2653

    Contributors Shoutout:

    No changes to highlight.

    Source code(tar.gz)
    Source code(zip)
  • v3.9.1(Nov 10, 2022)

    Version 3.9.1

    New Features:

    No changes to highlight.

    Bug Fixes:

    • Only set a min height on md and html when loading by @pngwn in PR 2623

    Documentation Changes:

    • See docs for the latest gradio commit to main as well the latest pip release:

    main-vs-pip

    • Modified the "Connecting To a Database Guide" to use pd.read_sql as opposed to low-level postgres connector by @freddyaboulton in PR 2604

    Testing and Infrastructure Changes:

    No changes to highlight.

    Breaking Changes:

    No changes to highlight.

    Full Changelog:

    • Dropdown for seeing docs as latest or main by @aliabd in PR 2544
    • Allow gr.Templates to accept parameters to override the defaults by @abidlabs in PR 2600
    • Components now throw a ValueError() if constructed with invalid parameters for type or source (for components that take those parameters) in PR 2610
    • Allow auth with using queue by @GLGDLY in PR 2611

    Contributors Shoutout:

    No changes to highlight.

    Source code(tar.gz)
    Source code(zip)
  • v3.9(Nov 3, 2022)

    Version 3.9

    New Features:

    • Gradio is now embedded directly in colab without requiring the share link by @aliabid94 in PR 2455

    Calling functions by api_name in loaded apps

    When you load an upstream app with gr.Blocks.load, you can now specify which fn to call with the api_name parameter.

    import gradio as gr
    english_translator = gr.Blocks.load(name="spaces/gradio/english-translator")
    german = english_translator("My name is Freddy", api_name='translate-to-german')
    

    The api_name parameter will take precendence over the fn_index parameter.

    Bug Fixes:

    Documentation Changes:

    • Added a Guide on how to configure the queue for maximum performance by @abidlabs in PR 2558

    Testing and Infrastructure Changes:

    No changes to highlight.

    Breaking Changes:

    No changes to highlight.

    Full Changelog:

    Contributors Shoutout:

    No changes to highlight.

    Source code(tar.gz)
    Source code(zip)
  • v3.8.2(Oct 31, 2022)

    Version 3.8.2

    Bug Fixes:

    • Ensure gradio apps embedded via spaces use the correct endpoint for predictions. @pngwn in PR 2567
    • Ensure gradio apps embedded via spaces use the correct websocket protocol. @pngwn in PR 2571

    New Features:

    Running Events Continuously

    Gradio now supports the ability to run an event continuously on a fixed schedule. To use this feature, pass every=# of seconds to the event definition. This will run the event every given number of seconds!

    This can be used to:

    • Create live visualizations that show the most up to date data
    • Refresh the state of the frontend automatically in response to changes in the backend

    Here is an example of a live plot that refreshes every half second:

    import math
    import gradio as gr
    import plotly.express as px
    import numpy as np
    
    
    plot_end = 2 * math.pi
    
    
    def get_plot(period=1):
        global plot_end
        x = np.arange(plot_end - 2 * math.pi, plot_end, 0.02)
        y = np.sin(2*math.pi*period * x)
        fig = px.line(x=x, y=y)
        plot_end += 2 * math.pi
        return fig
    
    
    with gr.Blocks() as demo:
        with gr.Row():
            with gr.Column():
                gr.Markdown("Change the value of the slider to automatically update the plot")
                period = gr.Slider(label="Period of plot", value=1, minimum=0, maximum=10, step=1)
                plot = gr.Plot(label="Plot (updates every half second)")
    
        dep = demo.load(get_plot, None, plot, every=0.5)
        period.change(get_plot, period, plot, every=0.5, cancels=[dep])
    
    demo.queue().launch()
    

    live_demo

    Bug Fixes:

    No changes to highlight.

    Documentation Changes:

    No changes to highlight.

    Testing and Infrastructure Changes:

    No changes to highlight.

    Breaking Changes:

    No changes to highlight.

    Full Changelog:

    • Allows loading private Spaces by passing an an api_key to gr.Interface.load() by @abidlabs in PR 2568

    Contributors Shoutout:

    No changes to highlight.

    Source code(tar.gz)
    Source code(zip)
  • v3.8.1dev1(Oct 31, 2022)

  • v3.8(Oct 28, 2022)

    Version 3.8

    New Features:

    • Allows event listeners to accept a single dictionary as its argument, where the keys are the components and the values are the component values. This is set by passing the input components in the event listener as a set instead of a list. @aliabid94 in PR 2550

    Bug Fixes:

    Documentation Changes:

    No changes to highlight.

    Testing and Infrastructure Changes:

    No changes to highlight.

    Breaking Changes:

    No changes to highlight.

    Full Changelog:

    Contributors Shoutout:

    No changes to highlight.

    Source code(tar.gz)
    Source code(zip)
  • v3.7(Oct 27, 2022)

    Version 3.7

    New Features:

    Batched Functions

    Gradio now supports the ability to pass batched functions. Batched functions are just functions which take in a list of inputs and return a list of predictions.

    For example, here is a batched function that takes in two lists of inputs (a list of words and a list of ints), and returns a list of trimmed words as output:

    import time
    
    def trim_words(words, lens):
        trimmed_words = []
        time.sleep(5)
        for w, l in zip(words, lens):
            trimmed_words.append(w[:l])        
        return [trimmed_words]
    

    The advantage of using batched functions is that if you enable queuing, the Gradio server can automatically batch incoming requests and process them in parallel, potentially speeding up your demo. Here's what the Gradio code looks like (notice the batch=True and max_batch_size=16 -- both of these parameters can be passed into event triggers or into the Interface class)

    import gradio as gr
    
    with gr.Blocks() as demo:
        with gr.Row():
            word = gr.Textbox(label="word", value="abc")
            leng = gr.Number(label="leng", precision=0, value=1)
            output = gr.Textbox(label="Output")
        with gr.Row():
            run = gr.Button()
    
        event = run.click(trim_words, [word, leng], output, batch=True, max_batch_size=16)
    
    demo.queue()
    demo.launch()
    

    In the example above, 16 requests could be processed in parallel (for a total inference time of 5 seconds), instead of each request being processed separately (for a total inference time of 80 seconds).

    Upload Event

    Video, Audio, Image, and File components now support a upload() event that is triggered when a user uploads a file into any of these components.

    Example usage:

    import gradio as gr
    
    with gr.Blocks() as demo:
        with gr.Row():
            input_video = gr.Video()
            output_video = gr.Video()
    
         # Clears the output video when an input video is uploaded
        input_video.upload(lambda : None, None, output_video)  
    

    Bug Fixes:

    • Fixes issue where plotly animations, interactivity, titles, legends, were not working properly. @dawoodkhan82 in PR 2486
    • Prevent requests to the /api endpoint from skipping the queue if the queue is enabled for that event by @freddyaboulton in PR 2493
    • Fixes a bug with cancels in event triggers so that it works properly if multiple Blocks are rendered by @abidlabs in PR 2530
    • Prevent invalid targets of events from crashing the whole application. @pngwn in PR 2534
    • Properly dequeue cancelled events when multiple apps are rendered by @freddyaboulton in PR 2540

    Documentation Changes:

    • Added an example interactive dashboard to the "Tabular & Plots" section of the Demos page by @freddyaboulton in PR 2508

    Testing and Infrastructure Changes:

    No changes to highlight.

    Breaking Changes:

    No changes to highlight.

    Full Changelog:

    • Fixes the error message if a user builds Gradio locally and tries to use share=True by @abidlabs in PR 2502
    • Allows the render() function to return self by @Raul9595 in PR 2514
    • Fixes issue where plotly animations, interactivity, titles, legends, were not working properly. @dawoodkhan82 in PR 2486
    • Gradio now supports batched functions by @abidlabs in PR 2218
    • Add upload event for Video, Audio, Image, and File components @dawoodkhan82 in PR 2448
    • Changes websocket path for Spaces as it is no longer necessary to have a different URL for websocket connections on Spaces by @abidlabs in PR 2528
    • Clearer error message when events are defined outside of a Blocks scope, and a warning if you try to use Series or Parallel with Blocks by @abidlabs in PR 2543
    • Adds support for audio samples that are in float64, float16, or uint16 formats by @abidlabs in PR 2545

    Contributors Shoutout:

    No changes to highlight.

    Source code(tar.gz)
    Source code(zip)
  • v3.6.0b7(Oct 28, 2022)

Owner
Gradio
Gradio's products help machine learning teams excel
Gradio
Collection of tasks for fast prototyping, baselining, finetuning and solving problems with deep learning.

Collection of tasks for fast prototyping, baselining, finetuning and solving problems with deep learning Installation

Pytorch Lightning 1.6k Jan 8, 2023
NeuPy is a Tensorflow based python library for prototyping and building neural networks

NeuPy v0.8.2 NeuPy is a python library for prototyping and building neural networks. NeuPy uses Tensorflow as a computational backend for deep learnin

Yurii Shevchuk 729 Jan 3, 2023
Myia prototyping

Myia Myia is a new differentiable programming language. It aims to support large scale high performance computations (e.g. linear algebra) and their g

Mila 456 Nov 7, 2022
A generalized framework for prototyping full-stack cooperative driving automation applications under CARLA+SUMO.

OpenCDA OpenCDA is a SIMULATION tool integrated with a prototype cooperative driving automation (CDA; see SAE J3216) pipeline as well as regular autom

UCLA Mobility Lab 726 Dec 29, 2022
An optimization and data collection toolbox for convenient and fast prototyping of computationally expensive models.

An optimization and data collection toolbox for convenient and fast prototyping of computationally expensive models. Hyperactive: is very easy to lear

Simon Blanke 422 Jan 4, 2023
Step by Step on how to create an vision recognition model using LOBE.ai, export the model and run the model in an Azure Function

Step by Step on how to create an vision recognition model using LOBE.ai, export the model and run the model in an Azure Function

El Bruno 3 Mar 30, 2022
Stroke-predictions-ml-model - Machine learning model to predict individuals chances of having a stroke

stroke-predictions-ml-model machine learning model to predict individuals chance

Alex Volchek 1 Jan 3, 2022
Machine Learning From Scratch. Bare bones NumPy implementations of machine learning models and algorithms with a focus on accessibility. Aims to cover everything from linear regression to deep learning.

Machine Learning From Scratch About Python implementations of some of the fundamental Machine Learning models and algorithms from scratch. The purpose

Erik Linder-Norén 21.8k Jan 9, 2023
Vowpal Wabbit is a machine learning system which pushes the frontier of machine learning with techniques such as online, hashing, allreduce, reductions, learning2search, active, and interactive learning.

This is the Vowpal Wabbit fast online learning code. Why Vowpal Wabbit? Vowpal Wabbit is a machine learning system which pushes the frontier of machin

Vowpal Wabbit 8.1k Jan 6, 2023
Turi Create simplifies the development of custom machine learning models.

Quick Links: Installation | Documentation | WWDC 2019 | WWDC 2018 Turi Create Check out our talks at WWDC 2019 and at WWDC 2018! Turi Create simplifie

Apple 10.9k Jan 1, 2023
Turi Create simplifies the development of custom machine learning models.

Quick Links: Installation | Documentation | WWDC 2019 | WWDC 2018 Turi Create Check out our talks at WWDC 2019 and at WWDC 2018! Turi Create simplifie

Apple 10.1k Feb 12, 2021
A Python Automated Machine Learning tool that optimizes machine learning pipelines using genetic programming.

Master status: Development status: Package information: TPOT stands for Tree-based Pipeline Optimization Tool. Consider TPOT your Data Science Assista

Epistasis Lab at UPenn 8.9k Dec 30, 2022
Scripts of Machine Learning Algorithms from Scratch. Implementations of machine learning models and algorithms using nothing but NumPy with a focus on accessibility. Aims to cover everything from basic to advance.

Algo-ScriptML Python implementations of some of the fundamental Machine Learning models and algorithms from scratch. The goal of this project is not t

Algo Phantoms 81 Nov 26, 2022
This is a Machine Learning Based Hand Detector Project, It Uses Machine Learning Models and Modules Like Mediapipe, Developed By Google!

Machine Learning Hand Detector This is a Machine Learning Based Hand Detector Project, It Uses Machine Learning Models and Modules Like Mediapipe, Dev

Popstar Idhant 3 Feb 25, 2022
In this project we investigate the performance of the SetCon model on realistic video footage. Therefore, we implemented the model in PyTorch and tested the model on two example videos.

Contrastive Learning of Object Representations Supervisor: Prof. Dr. Gemma Roig Institutions: Goethe University CVAI - Computational Vision & Artifici

Dirk Neuhäuser 6 Dec 8, 2022
Capture all information throughout your model's development in a reproducible way and tie results directly to the model code!

Rubicon Purpose Rubicon is a data science tool that captures and stores model training and execution information, like parameters and outcomes, in a r

Capital One 97 Jan 3, 2023