Gradio Spaces
Last updated
Last updated
Gradio provides an easy and intuitive interface for running a model from a list of inputs and displaying the outputs in formats such as images, audio, 3D objects, and more. Gradio now even has a for creating data visualizations with Matplotlib, Bokeh, and Plotly! For more details, take a look at the guide from the Gradio team.
Selecting Gradio as the SDK when will initialize your Space with the latest version of Gradio by setting the sdk
property to gradio
in your README.md
file’s YAML block. If you’d like to change the Gradio version, you can edit the sdk_version
property.
Visit the to learn all about its features and check out the for some handy tutorials to help you get started!
In the following sections, you’ll learn the basics of creating a Space, configuring it, and deploying your code to it. We’ll create a Hot Dog Classifier Space with Gradio that’ll be used to demo the model, which can detect whether a given picture contains a hot dog 🌭
You can find a completed version of this hosted at .
We’ll start by and choosing Gradio as our SDK. BOINC AI Spaces are Git repositories, meaning that you can work on your Space incrementally (and collaboratively) by pushing commits. Take a look at the guide to learn about how you can create and edit files before continuing.
For the Hot Dog Classifier we’ll be using a BOINC AI to use the model, so we need to start by installing a few dependencies. This can be done by creating a requirements.txt file in our repository, and adding the following dependencies to it:
Copied
The Spaces runtime will handle installing the dependencies!
To create the Gradio app, make a new file in the repository called app.py, and add the following code:
Copied
This Python script uses a BOINC AI to load the model, which is used by the Gradio interface. The Gradio app will expect you to upload an image, which it’ll then classify as hot dog or not hot dog. Once you’ve saved the code to the app.py file, visit the App tab to see your app in action!
You can embed a Gradio Space on other webpages by using either Web Components or the HTML <iframe>
tag. Check out or the for more details.