Interfaces for your ML Models
Gradio allows you to quickly create customizable UI components around your TensorFlow or PyTorch models, or even arbitrary Python functions. Mix and match components to support any combination of inputs and outputs. Our core library is free and open-source!
Below are a few demos. Check the Getting Started for full code examples.
import gradio as gr def recognize_digit(img): # ... implement digit recognition model on input array # ... return dictionary of labels and confidences gr.Interface(fn=recognize_digit, inputs="sketchpad", outputs="label").launch()
import gradio as gr def answer_question(paragraph, question): # ... implement Q&A model # ... return answer to question gr.Interface(fn=answer_question, inputs=["textbox", "text"], outputs="text").launch()
import gradio as gr def face_segmentation(img): # ... implement face segmentation model on input 200x200 numpy array # ... return segmentation mask as numpy array webcam = gr.in.Webcam(shape=(200, 200)) gr.Interface(fn=face_segmentation, inputs=webcam, outputs="image").launch()
import gradio as gr, matplotlib.pyplot as plt def outbreak_forecast(r, month, countries, social_distancing): # ... run model to forecast outbreak and generate plots # ... return plt r = gr.in.Slider(1, 5) month = gr.in.Dropdown(["May", "June", "July"]) countries = gr.in.CheckboxGroup(["USA", "Canada", "Mexico", "UK"]) gr.Interface(fn=outbreak_forecast, inputs=[r, month, countries, "checkbox"], outputs="plot").launch()
Fast, easy setup
Gradio can be installed directly through pip. Creating a Gradio interface only requires adding a couple lines of code to your project. You can choose from a variety of interface types to interface your function.
More on Getting Started >>
Present and share
Gradio can be embedded in Python notebooks or presented as a webpage. A Gradio interface can automatically generate a public link you can share with colleagues that lets them interact with the model on your computer remotely from their own devices.
More on Sharing >>
Want to integrate Gradio in a large team? We can help with Gradio for Teams. Get in touch.
Running into any issues? Open an issue at our github repo.