text stringlengths 0 2k | heading1 stringlengths 3 79 | source_page_url stringclasses 188
values | source_page_title stringclasses 188
values |
|---|---|---|---|
Gradio features a built-in theming engine that lets you customize the look and feel of your app. You can choose from a variety of themes, or create your own. To do so, pass the `theme=` kwarg to the `launch()` method of `Blocks` or `Interface`. For example:
```python
with gr.Blocks() as demo:
... your code here
de... | Introduction | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
the `"ocean"` theme has a blue-green primary color and gray secondary color. The theme also uses horizontal gradients, especially for buttons and some form elements.
Each of these themes set values for hundreds of CSS variables. You can use prebuilt themes as a starting point for your own custom themes, or you can c... | Introduction | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
The easiest way to build a theme is using the Theme Builder. To launch the Theme Builder locally, run the following code:
```python
import gradio as gr
gr.themes.builder()
```
$demo_theme_builder
You can use the Theme Builder running on Spaces above, though it runs much faster when you launch it locally via `gr.the... | Using the Theme Builder | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
Although each theme has hundreds of CSS variables, the values for most these variables are drawn from 8 core variables which can be set through the constructor of each prebuilt theme. Modifying these 8 arguments allows you to quickly change the look and feel of your app.
Core Colors
The first 3 constructor arguments ... | Extending Themes via the Constructor | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
ld`
- `teal`
- `cyan`
- `sky`
- `blue`
- `indigo`
- `violet`
- `purple`
- `fuchsia`
- `pink`
- `rose`
You could also create your own custom `Color` objects and pass them in.
Core Sizing
The next 3 constructor arguments set the sizing of the theme and are `gradio.themes.Size` objects. Internally, these Size objects h... | Extending Themes via the Constructor | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
these arguments to specify fallbacks. If you provide a string, it will be loaded as a system font. If you provide a `gradio.themes.GoogleFont`, the font will be loaded from Google Fonts.
- `font`: This sets the primary font of the theme. In the default theme, this is set to `gradio.themes.GoogleFont("IBM Plex Sans")`.... | Extending Themes via the Constructor | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
You can also modify the values of CSS variables after the theme has been loaded. To do so, use the `.set()` method of the theme object to get access to the CSS variables. For example:
```python
theme = gr.themes.Default(primary_hue="blue").set(
loader_color="FF0000",
slider_color="FF0000",
)
with gr.Blocks() ... | Extending Themes via `.set()` | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
cing a set of core variables and referencing each other. This allows us to only have to modify a few variables to change the look and feel of the entire theme, while also getting finer control of individual elements that we may want to modify.
Referencing Core Variables
To reference one of the core constructor variab... | Extending Themes via `.set()` | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
ll` variable in the `button_primary_background_fill_hover` and `button_primary_border` variables, using a `*` prefix.
```python
theme = gr.themes.Default().set(
button_primary_background_fill="FF0000",
button_primary_background_fill_hover="*button_primary_background_fill",
button_primary_border="*button_pr... | Extending Themes via `.set()` | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
For a full list of all available CSS variables, see the [CSS Variables Reference](/main/guides/css-variables-reference).
| CSS Variables Reference | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
Let's say you want to create a theme from scratch! We'll go through it step by step - you can also see the source of prebuilt themes in the gradio source repo for reference - [here's the source](https://github.com/gradio-app/gradio/blob/main/gradio/themes/monochrome.py) for the Monochrome theme.
Our new theme class wi... | Creating a Full Theme | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
ght"
frameborder="0"
></iframe>
</div>
Look how fun our theme looks now! With just a few variable changes, our theme looks completely different.
You may find it helpful to explore the [source code of the other prebuilt themes](https://github.com/gradio-app/gradio/blob/main/gradio/themes) to see how they modified the... | Creating a Full Theme | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
Once you have created a theme, you can upload it to the HuggingFace Hub to let others view it, use it, and build off of it!
Uploading a Theme
There are two ways to upload a theme, via the theme class instance or the command line. We will cover both of them with the previously created `seafoam` theme.
- Via the class... | Sharing Themes | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
verview).
For example, the theme preview for the calm seafoam theme is here: [calm seafoam preview](https://huggingface.co/spaces/shivalikasingh/calm_seafoam).
<div class="wrapper">
<iframe
src="https://shivalikasingh-calm-seafoam.hf.space/?__theme=light"
frameborder="0"
></iframe>
</div>
Discovering Themes
The [... | Sharing Themes | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
hey'll see a warning:
```
UserWarning: This theme was created for Gradio 5.0.0, but you are using Gradio 5.1.0. Some styles may not work as expected.
```
This helps prevent unexpected styling issues when themes rely on CSS variables that may have changed between Gradio versions. Patch version differences (e.g. 5.0.0 ... | Sharing Themes | https://gradio.app/guides/theming-guide | Other Tutorials - Theming Guide Guide |
By default, every Gradio demo includes a built-in queuing system that scales to thousands of requests. When a user of your app submits a request (i.e. submits an input to your function), Gradio adds the request to the queue, and requests are processed in order, generally speaking (this is not exactly true, as discussed... | Overview of Gradio's Queueing System | https://gradio.app/guides/setting-up-a-demo-for-maximum-performance | Other Tutorials - Setting Up A Demo For Maximum Performance Guide |
-single-worker** model by default. This means that each worker thread is only assigned a single function from among all of the functions that could be part of your Gradio app. This ensures that you do not see, for example, out-of-memory errors, due to multiple workers calling a machine learning model at the same time. ... | Overview of Gradio's Queueing System | https://gradio.app/guides/setting-up-a-demo-for-maximum-performance | Other Tutorials - Setting Up A Demo For Maximum Performance Guide |
sts are processed in parallel, each request will consume memory to store the data and weights for processing. This means that you might get out-of-memory errors if you increase the `default_concurrency_limit` too high. You may also start to get diminishing returns if the `default_concurrency_limit` is too high because ... | Overview of Gradio's Queueing System | https://gradio.app/guides/setting-up-a-demo-for-maximum-performance | Other Tutorials - Setting Up A Demo For Maximum Performance Guide |
is [guide](https://fastapi.tiangolo.com/async/) is a good primer on the concept.
The `max_size` parameter in `queue()`
A more blunt way to reduce the wait times is simply to prevent too many people from joining the queue in the first place. You can set the maximum number of requests that the queue processes using th... | Overview of Gradio's Queueing System | https://gradio.app/guides/setting-up-a-demo-for-maximum-performance | Other Tutorials - Setting Up A Demo For Maximum Performance Guide |
e passed into `gr.Interface()` or to an event in Blocks such as `.click()`.
While setting a batch is conceptually similar to having workers process requests in parallel, it is often _faster_ than setting `default_concurrency_limit` for deep learning models. The downside is that you might need to adapt your function a ... | Overview of Gradio's Queueing System | https://gradio.app/guides/setting-up-a-demo-for-maximum-performance | Other Tutorials - Setting Up A Demo For Maximum Performance Guide |
If you have done everything above, and your demo is still not fast enough, you can upgrade the hardware that your model is running on. Changing the model from running on CPUs to running on GPUs will usually provide a 10x-50x increase in inference time for deep learning models.
It is particularly straightforward to upg... | Upgrading your Hardware (GPUs, TPUs, etc.) | https://gradio.app/guides/setting-up-a-demo-for-maximum-performance | Other Tutorials - Setting Up A Demo For Maximum Performance Guide |
Congratulations! You know how to set up a Gradio demo for maximum performance. Good luck on your next viral demo!
| Conclusion | https://gradio.app/guides/setting-up-a-demo-for-maximum-performance | Other Tutorials - Setting Up A Demo For Maximum Performance Guide |
Building a dashboard from a public Google Sheet is very easy, thanks to the [`pandas` library](https://pandas.pydata.org/):
1\. Get the URL of the Google Sheets that you want to use. To do this, simply go to the Google Sheets, click on the "Share" button in the top-right corner, and then click on the "Get shareable li... | Public Google Sheets | https://gradio.app/guides/creating-a-realtime-dashboard-from-google-sheets | Other Tutorials - Creating A Realtime Dashboard From Google Sheets Guide |
For private Google Sheets, the process requires a little more work, but not that much! The key difference is that now, you must authenticate yourself to authorize access to the private Google Sheets.
Authentication
To authenticate yourself, obtain credentials from Google Cloud. Here's [how to set up google cloud cred... | Private Google Sheets | https://gradio.app/guides/creating-a-realtime-dashboard-from-google-sheets | Other Tutorials - Creating A Realtime Dashboard From Google Sheets Guide |
google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/email_id"
}
```
Querying
Once you have the credentials `.json` file, you can use the following steps to query your Google Sheet:
1\. Cl... | Private Google Sheets | https://gradio.app/guides/creating-a-realtime-dashboard-from-google-sheets | Other Tutorials - Creating A Realtime Dashboard From Google Sheets Guide |
. To do this, we just pass the function into the respective components, and set the `every` parameter based on how frequently (in seconds) we would like the component to refresh. Here's the Gradio code:
```python
import gradio as gr
with gr.Blocks() as demo:
gr.Markdown("📈 Real-Time Line Plot")
with gr.Row()... | Private Google Sheets | https://gradio.app/guides/creating-a-realtime-dashboard-from-google-sheets | Other Tutorials - Creating A Realtime Dashboard From Google Sheets Guide |
And that's all there is to it! With just a few lines of code, you can use `gradio` and other libraries to read data from a public or private Google Sheet and then display and plot the data in a real-time dashboard.
| Conclusion | https://gradio.app/guides/creating-a-realtime-dashboard-from-google-sheets | Other Tutorials - Creating A Realtime Dashboard From Google Sheets Guide |
**[OpenAPI](https://www.openapis.org/)** is a widely adopted standard for describing RESTful APIs in a machine-readable format, typically as a JSON file.
You can create a Gradio UI from an OpenAPI Spec **in 1 line of Python**, instantly generating an interactive web interface for any API, making it accessible for de... | Introduction | https://gradio.app/guides/from-openapi-spec | Other Tutorials - From Openapi Spec Guide |
Gradio now provides a convenient function, `gr.load_openapi`, that can automatically generate a Gradio app from an OpenAPI v3 specification. This function parses the spec, creates UI components for each endpoint and parameter, and lets you interact with the API directly from your browser.
Here's a minimal example:
``... | How it works | https://gradio.app/guides/from-openapi-spec | Other Tutorials - From Openapi Spec Guide |
Once your Gradio app is running, you can share the URL with others so they can try out the API through a friendly web interface—no code required. For even more power, you can launch the app as an MCP (Model Control Protocol) server using [Gradio's MCP integration](https://www.gradio.app/guides/building-mcp-server-with-... | Next steps | https://gradio.app/guides/from-openapi-spec | Other Tutorials - From Openapi Spec Guide |
In this Guide, we'll walk you through:
- Introduction of Gradio, and Hugging Face Spaces, and Wandb
- How to setup a Gradio demo using the Wandb integration for JoJoGAN
- How to contribute your own Gradio demos after tracking your experiments on wandb to the Wandb organization on Hugging Face
| Introduction | https://gradio.app/guides/Gradio-and-Wandb-Integration | Other Tutorials - Gradio And Wandb Integration Guide |
Weights and Biases (W&B) allows data scientists and machine learning scientists to track their machine learning experiments at every stage, from training to production. Any metric can be aggregated over samples and shown in panels in a customizable and searchable dashboard, like below:
<img alt="Screen Shot 2022-08-01... | What is Wandb? | https://gradio.app/guides/Gradio-and-Wandb-Integration | Other Tutorials - Gradio And Wandb Integration Guide |
Gradio
Gradio lets users demo their machine learning models as a web app, all in a few lines of Python. Gradio wraps any Python function (such as a machine learning model's inference function) into a user interface and the demos can be launched inside jupyter notebooks, colab notebooks, as well as embedded in your own... | What are Hugging Face Spaces & Gradio? | https://gradio.app/guides/Gradio-and-Wandb-Integration | Other Tutorials - Gradio And Wandb Integration Guide |
Now, let's walk you through how to do this on your own. We'll make the assumption that you're new to W&B and Gradio for the purposes of this tutorial.
Let's get started!
1. Create a W&B account
Follow [these quick instructions](https://app.wandb.ai/login) to create your free account if you don’t have one already.... | Setting up a Gradio Demo for JoJoGAN | https://gradio.app/guides/Gradio-and-Wandb-Integration | Other Tutorials - Gradio And Wandb Integration Guide |
: storage)
discriminator.load_state_dict(ckpt["d"], strict=False)
reset generator
del generator
generator = deepcopy(original_generator)
g_optim = optim.Adam(generator.parameters(), lr=2e-3, betas=(0, 0.99))
Which layers to swap for generating a family of plausible real images -> fake image
if p... | Setting up a Gradio Demo for JoJoGAN | https://gradio.app/guides/Gradio-and-Wandb-Integration | Other Tutorials - Gradio And Wandb Integration Guide |
ave, Download, and Load Model
Here's how to save and download your model.
```python
from PIL import Image
import torch
torch.backends.cudnn.benchmark = True
from torchvision import transforms, utils
from util import *
import math
import random
import numpy as np
from torch import nn,... | Setting up a Gradio Demo for JoJoGAN | https://gradio.app/guides/Gradio-and-Wandb-Integration | Other Tutorials - Gradio And Wandb Integration Guide |
.5, 0.5)),
]
)
def inference(img):
img.save('out.jpg')
aligned_face = align_face('out.jpg')
my_w = e4e_projection(aligned_face, "out.pt", device).unsqueeze(0)
with torch.no_grad():
my_sample = generator(my_w, input_is_latent=True)
npimage = my_sampl... | Setting up a Gradio Demo for JoJoGAN | https://gradio.app/guides/Gradio-and-Wandb-Integration | Other Tutorials - Gradio And Wandb Integration Guide |
``python
import gradio as gr
def wandb_report(url):
iframe = f'<iframe src={url} style="border:none;height:1024px;width:100%">'
return gr.HTML(iframe)
with gr.Blocks() as demo:
report_url = 'https://wandb.ai/_scott/pytorch-sweeps-demo/reports/loss-22-10-07-16-00-17---VmlldzoyNzU2Nz... | Setting up a Gradio Demo for JoJoGAN | https://gradio.app/guides/Gradio-and-Wandb-Integration | Other Tutorials - Gradio And Wandb Integration Guide |
We hope you enjoyed this brief demo of embedding a Gradio demo to a W&B report! Thanks for making it to the end. To recap:
- Only one single reference image is needed for fine-tuning JoJoGAN which usually takes about 1 minute on a GPU in colab. After training, style can be applied to any input image. Read more in the ... | Conclusion | https://gradio.app/guides/Gradio-and-Wandb-Integration | Other Tutorials - Gradio And Wandb Integration Guide |
- Create an account on Hugging Face [here](https://huggingface.co/join).
- Add Gradio Demo under your username, see this [course](https://huggingface.co/course/chapter9/4?fw=pt) for setting up Gradio Demo on Hugging Face.
- Request to join wandb organization [here](https://huggingface.co/wandb).
- Once approved transfe... | How to contribute Gradio demos on HF spaces on the Wandb organization | https://gradio.app/guides/Gradio-and-Wandb-Integration | Other Tutorials - Gradio And Wandb Integration Guide |
The Hugging Face Hub is a central platform that has hundreds of thousands of [models](https://huggingface.co/models), [datasets](https://huggingface.co/datasets) and [demos](https://huggingface.co/spaces) (also known as Spaces).
Gradio has multiple features that make it extremely easy to leverage existing models and ... | Introduction | https://gradio.app/guides/using-hugging-face-integrations | Other Tutorials - Using Hugging Face Integrations Guide |
Hugging Face has a service called [Serverless Inference Endpoints](https://huggingface.co/docs/api-inference/index), which allows you to send HTTP requests to models on the Hub. The API includes a generous free tier, and you can switch to [dedicated Inference Endpoints](https://huggingface.co/inference-endpoints/dedica... | Demos with the Hugging Face Inference Endpoints | https://gradio.app/guides/using-hugging-face-integrations | Other Tutorials - Using Hugging Face Integrations Guide |
[Hugging Face Spaces](https://hf.co/spaces) allows anyone to host their Gradio demos freely, and uploading your Gradio demos take a couple of minutes. You can head to [hf.co/new-space](https://huggingface.co/new-space), select the Gradio SDK, create an `app.py` file, and voila! You have a demo you can share with anyone... | Hosting your Gradio demos on Spaces | https://gradio.app/guides/using-hugging-face-integrations | Other Tutorials - Using Hugging Face Integrations Guide |
You can also use and remix existing Gradio demos on Hugging Face Spaces. For example, you could take two existing Gradio demos on Spaces and put them as separate tabs and create a new demo. You can run this new demo locally, or upload it to Spaces, allowing endless possibilities to remix and create new demos!
Here's a... | Loading demos from Spaces | https://gradio.app/guides/using-hugging-face-integrations | Other Tutorials - Using Hugging Face Integrations Guide |
Hugging Face's popular `transformers` library has a very easy-to-use abstraction, [`pipeline()`](https://huggingface.co/docs/transformers/v4.16.2/en/main_classes/pipelinestransformers.pipeline) that handles most of the complex code to offer a simple API for common tasks. By specifying the task and an (optional) model, ... | Demos with the `Pipeline` in `transformers` | https://gradio.app/guides/using-hugging-face-integrations | Other Tutorials - Using Hugging Face Integrations Guide |
That's it! Let's recap the various ways Gradio and Hugging Face work together:
1. You can build a demo around Inference Endpoints without having to load the model, by using `gr.load()`.
2. You host your Gradio demo on Hugging Face Spaces, either using the GUI or entirely in Python.
3. You can load demos from Hugging F... | Recap | https://gradio.app/guides/using-hugging-face-integrations | Other Tutorials - Using Hugging Face Integrations Guide |
3D models are becoming more popular in machine learning and make for some of the most fun demos to experiment with. Using `gradio`, you can easily build a demo of your 3D image model and share it with anyone. The Gradio 3D Model component accepts 3 file types including: _.obj_, _.glb_, & _.gltf_.
This guide will show ... | Introduction | https://gradio.app/guides/how-to-use-3D-model-component | Other Tutorials - How To Use 3D Model Component Guide |
Let's take a look at how to create the minimal interface above. The prediction function in this case will just return the original 3D model mesh, but you can change this function to run inference on your machine learning model. We'll take a look at more complex examples below.
```python
import gradio as gr
import os
... | Taking a Look at the Code | https://gradio.app/guides/how-to-use-3D-model-component | Other Tutorials - How To Use 3D Model Component Guide |
Below is a demo that uses the DPT model to predict the depth of an image and then uses 3D Point Cloud to create a 3D object. Take a look at the [app.py](https://huggingface.co/spaces/gradio/dpt-depth-estimation-3d-obj/blob/main/app.py) file for a peek into the code and the model prediction function.
<gradio-app space="... | Exploring a more complex Model3D Demo: | https://gradio.app/guides/how-to-use-3D-model-component | Other Tutorials - How To Use 3D Model Component Guide |
A virtual environment in Python is a self-contained directory that holds a Python installation for a particular version of Python, along with a number of additional packages. This environment is isolated from the main Python installation and other virtual environments. Each environment can have its own independent set ... | Virtual Environments | https://gradio.app/guides/installing-gradio-in-a-virtual-environment | Other Tutorials - Installing Gradio In A Virtual Environment Guide |
To install Gradio on a Windows system in a virtual environment, follow these steps:
1. **Install Python**: Ensure you have Python 3.10 or higher installed. You can download it from [python.org](https://www.python.org/). You can verify the installation by running `python --version` or `python3 --version` in Command Pro... | Installing Gradio on Windows | https://gradio.app/guides/installing-gradio-in-a-virtual-environment | Other Tutorials - Installing Gradio In A Virtual Environment Guide |
The installation steps on MacOS and Linux are similar to Windows but with some differences in commands.
1. **Install Python**:
Python usually comes pre-installed on MacOS and most Linux distributions. You can verify the installation by running `python --version` in the terminal (note that depending on how Python is... | Installing Gradio on MacOS/Linux | https://gradio.app/guides/installing-gradio-in-a-virtual-environment | Other Tutorials - Installing Gradio In A Virtual Environment Guide |
Image classification is a central task in computer vision. Building better classifiers to classify what object is present in a picture is an active area of research, as it has applications stretching from facial recognition to manufacturing quality control.
State-of-the-art image classifiers are based on the _transfor... | Introduction | https://gradio.app/guides/image-classification-with-vision-transformers | Other Tutorials - Image Classification With Vision Transformers Guide |
First, we will need an image classification model. For this tutorial, we will use a model from the [Hugging Face Model Hub](https://huggingface.co/models?pipeline_tag=image-classification). The Hub contains thousands of models covering dozens of different machine learning tasks.
Expand the Tasks category on the left s... | Step 1 — Choosing a Vision Image Classification Model | https://gradio.app/guides/image-classification-with-vision-transformers | Other Tutorials - Image Classification With Vision Transformers Guide |
When using a model from the Hugging Face Hub, we do not need to define the input or output components for the demo. Similarly, we do not need to be concerned with the details of preprocessing or postprocessing.
All of these are automatically inferred from the model tags.
Besides the import statement, it only takes a s... | Step 2 — Loading the Vision Transformer Model with Gradio | https://gradio.app/guides/image-classification-with-vision-transformers | Other Tutorials - Image Classification With Vision Transformers Guide |
Tabular data science is the most widely used domain of machine learning, with problems ranging from customer segmentation to churn prediction. Throughout various stages of the tabular data science workflow, communicating your work to stakeholders or clients can be cumbersome; which prevents data scientists from focusin... | Introduction | https://gradio.app/guides/using-gradio-for-tabular-workflows | Other Tutorials - Using Gradio For Tabular Workflows Guide |
We will take a look at how we can create a simple UI that predicts failures based on product information.
```python
import gradio as gr
import pandas as pd
import joblib
import datasets
inputs = [gr.Dataframe(row_count = (2, "dynamic"), col_count=(4,"dynamic"), label="Input Data", interactive=1)]
outputs = [gr.Data... | Let's Create a Simple Interface! | https://gradio.app/guides/using-gradio-for-tabular-workflows | Other Tutorials - Using Gradio For Tabular Workflows Guide |
app space="gradio/tabular-playground"></gradio-app>
```python
import gradio as gr
import pandas as pd
import datasets
import seaborn as sns
import matplotlib.pyplot as plt
df = datasets.load_dataset("merve/supersoaker-failures")
df = df["train"].to_pandas()
df.dropna(axis=0, inplace=True)
def plot(df):
plt.scatter... | Let's Create a Simple Interface! | https://gradio.app/guides/using-gradio-for-tabular-workflows | Other Tutorials - Using Gradio For Tabular Workflows Guide |
`skops` is a library built on top of `huggingface_hub` and `sklearn`. With the recent `gradio` integration of `skops`, you can build tabular data interfaces with one line of code!
```python
import gradio as gr
title and description are optional
title = "Supersoaker Defective Product Prediction"
description = "This mo... | Easily load tabular data interfaces with one line of code using skops | https://gradio.app/guides/using-gradio-for-tabular-workflows | Other Tutorials - Using Gradio For Tabular Workflows Guide |
To use Gradio with BigQuery, you will need to obtain your BigQuery credentials and use them with the [BigQuery Python client](https://pypi.org/project/google-cloud-bigquery/). If you already have BigQuery credentials (as a `.json` file), you can skip this section. If not, you can do this for free in just a couple of mi... | Setting up your BigQuery Credentials | https://gradio.app/guides/creating-a-dashboard-from-bigquery-data | Other Tutorials - Creating A Dashboard From Bigquery Data Guide |
Once you have the credentials, you will need to use the BigQuery Python client to authenticate using your credentials. To do this, you will need to install the BigQuery Python client by running the following command in the terminal:
```bash
pip install google-cloud-bigquery[pandas]
```
You'll notice that we've instal... | Using the BigQuery Client | https://gradio.app/guides/creating-a-dashboard-from-bigquery-data | Other Tutorials - Creating A Dashboard From Bigquery Data Guide |
Once you have a function to query the data, you can use the `gr.DataFrame` component from the Gradio library to display the results in a tabular format. This is a useful way to inspect the data and make sure that it has been queried correctly.
Here is an example of how to use the `gr.DataFrame` component to display th... | Building the Real-Time Dashboard | https://gradio.app/guides/creating-a-dashboard-from-bigquery-data | Other Tutorials - Creating A Dashboard From Bigquery Data Guide |
First of all, we need some data to visualize. Following this [excellent guide](https://supabase.com/blog/loading-data-supabase-python), we'll create fake commerce data and put it in Supabase.
1\. Start by creating a new project in Supabase. Once you're logged in, click the "New Project" button
2\. Give your project a... | Create a table in Supabase | https://gradio.app/guides/creating-a-dashboard-from-supabase-data | Other Tutorials - Creating A Dashboard From Supabase Data Guide |
The next step is to write data to a Supabase dataset. We will use the Supabase Python library to do this.
6\. Install `supabase` by running the following command in your terminal:
```bash
pip install supabase
```
7\. Get your project URL and API key. Click the Settings (gear icon) on the left pane and click 'API'. T... | Write data to Supabase | https://gradio.app/guides/creating-a-dashboard-from-supabase-data | Other Tutorials - Creating A Dashboard From Supabase Data Guide |
Finally, we will read the data from the Supabase dataset using the same `supabase` Python library and create a realtime dashboard using `gradio`.
Note: We repeat certain steps in this section (like creating the Supabase client) in case you did not go through the previous sections. As described in Step 7, you will need... | Visualize the Data in a Real-Time Gradio Dashboard | https://gradio.app/guides/creating-a-dashboard-from-supabase-data | Other Tutorials - Creating A Dashboard From Supabase Data Guide |
That's it! In this tutorial, you learned how to write data to a Supabase dataset, and then read that data and plot the results as bar plots. If you update the data in the Supabase database, you'll notice that the Gradio dashboard will update within a minute.
Try adding more plots and visualizations to this example (or... | Conclusion | https://gradio.app/guides/creating-a-dashboard-from-supabase-data | Other Tutorials - Creating A Dashboard From Supabase Data Guide |
Make sure you have Gradio installed along with a recent version of `huggingface_hub`:
```bash
pip install --upgrade gradio huggingface_hub
```
> `huggingface_hub >= 1.4.0` is required for the skills command.
| Prerequisites | https://gradio.app/guides/Gradio-skills-for-ai-coding-assistants | Other Tutorials - Gradio Skills For Ai Coding Assistants Guide |
The general Gradio skill gives your assistant comprehensive knowledge of the Gradio API — components, event listeners, layout patterns, and working examples.
To install, pass the flag for your assistant:
```bash
gradio skills add --cursor or --claude, --codex, --opencode
```
This downloads two files (`SKILL.md` an... | Installing the General Gradio Skill | https://gradio.app/guides/Gradio-skills-for-ai-coding-assistants | Other Tutorials - Gradio Skills For Ai Coding Assistants Guide |
By default, skills are installed **locally** in your current project directory. This means the assistant only has Gradio knowledge when working in that project.
To install **globally** (user-level, available in all projects):
```bash
gradio skills add --claude --global
```
Or using the short flag:
```bash
gradio sk... | Project-Level vs. Global Installation | https://gradio.app/guides/Gradio-skills-for-ai-coding-assistants | Other Tutorials - Gradio Skills For Ai Coding Assistants Guide |
One of the most powerful features is generating a skill for any public HuggingFace Space. This gives your assistant full knowledge of that Space's API — endpoints, parameters, return types, and ready-to-use code snippets.
```bash
gradio skills add abidlabs/english-translator --claude
```
This connects to the Space, e... | Generating a Skill for a Specific HuggingFace Space | https://gradio.app/guides/Gradio-skills-for-ai-coding-assistants | Other Tutorials - Gradio Skills For Ai Coding Assistants Guide |
If a skill is already installed, the command will exit with an error. To overwrite it:
```bash
gradio skills add --claude --force
```
| Overwriting Existing Skills | https://gradio.app/guides/Gradio-skills-for-ai-coding-assistants | Other Tutorials - Gradio Skills For Ai Coding Assistants Guide |
General Gradio Skill
| File | Contents |
|------|----------|
| `SKILL.md` | Core API reference — component signatures, event listeners, layout patterns, ChatInterface, and links to detailed guides |
| `examples.md` | Complete working Gradio apps covering common patterns (forms, chatbots, streaming, image processing, e... | What Gets Installed | https://gradio.app/guides/Gradio-skills-for-ai-coding-assistants | Other Tutorials - Gradio Skills For Ai Coding Assistants Guide |
Here's a typical workflow using skills with Claude Code:
1. **Install the skill** in your project:
```bash
cd my-project
gradio skills add --claude
```
2. **Start Claude Code** and ask it to build a Gradio app:
```
> Build me a Gradio app with an image input that applies a sepia filter
and disp... | Example Workflow | https://gradio.app/guides/Gradio-skills-for-ai-coding-assistants | Other Tutorials - Gradio Skills For Ai Coding Assistants Guide |
When you are building a Gradio demo, particularly out of Blocks, you may find it cumbersome to keep re-running your code to test your changes.
To make it faster and more convenient to write your code, we've made it easier to "reload" your Gradio apps instantly when you are developing in a **Python IDE** (like VS Code,... | Why Hot Reloading? | https://gradio.app/guides/developing-faster-with-reload-mode | Other Tutorials - Developing Faster With Reload Mode Guide |
If you are building Gradio Blocks using a Python IDE, your file of code (let's name it `run.py`) might look something like this:
```python
import gradio as gr
with gr.Blocks() as demo:
gr.Markdown("Greetings from Gradio!")
inp = gr.Textbox(placeholder="What is your name?")
out = gr.Textbox()
inp.chan... | Python IDE Reload 🔥 | https://gradio.app/guides/developing-faster-with-reload-mode | Other Tutorials - Developing Faster With Reload Mode Guide |
emo as the 2nd parameter in your code. So if your `run.py` file looked like this:
```python
import gradio as gr
with gr.Blocks() as my_demo:
gr.Markdown("Greetings from Gradio!")
inp = gr.Textbox(placeholder="What is your name?")
out = gr.Textbox()
inp.change(fn=lambda x: f"Welcome, {x}!",
... | Python IDE Reload 🔥 | https://gradio.app/guides/developing-faster-with-reload-mode | Other Tutorials - Developing Faster With Reload Mode Guide |
By default, reload mode will re-run your entire script for every change you make.
But there are some cases where this is not desirable.
For example, loading a machine learning model should probably only happen once to save time. There are also some Python libraries that use C or Rust extensions that throw errors when t... | Controlling the Reload 🎛️ | https://gradio.app/guides/developing-faster-with-reload-mode | Other Tutorials - Developing Faster With Reload Mode Guide |
You can also enable Gradio's **Vibe Mode**, which, which provides an in-browser chat that can be used to write or edit your Gradio app using natural language. To enable this, simply run use the `--vibe` flag with Gradio, e.g. `gradio --vibe app.py`.
Vibe Mode lets you describe commands using natural language and have ... | Vibe Mode | https://gradio.app/guides/developing-faster-with-reload-mode | Other Tutorials - Developing Faster With Reload Mode Guide |
What about if you use Jupyter Notebooks (or Colab Notebooks, etc.) to develop code? We got something for you too!
We've developed a **magic command** that will create and run a Blocks demo for you. To use this, load the gradio extension at the top of your notebook:
`%load_ext gradio`
Then, in the cell that you are d... | Jupyter Notebook Magic 🔮 | https://gradio.app/guides/developing-faster-with-reload-mode | Other Tutorials - Developing Faster With Reload Mode Guide |
Now that you know how to develop quickly using Gradio, start building your own!
If you are looking for inspiration, try exploring demos other people have built with Gradio, [browse public Hugging Face Spaces](http://hf.space/) 🤗
| Next Steps | https://gradio.app/guides/developing-faster-with-reload-mode | Other Tutorials - Developing Faster With Reload Mode Guide |
In this guide we will demonstrate some of the ways you can use Gradio with Comet. We will cover the basics of using Comet with Gradio and show you some of the ways that you can leverage Gradio's advanced features such as [Embedding with iFrames](https://www.gradio.app/guides/sharing-your-app/embedding-with-iframes) and... | Introduction | https://gradio.app/guides/Gradio-and-Comet | Other Tutorials - Gradio And Comet Guide |
[Comet](https://www.comet.com?utm_source=gradio&utm_medium=referral&utm_campaign=gradio-integration&utm_content=gradio-docs) is an MLOps Platform that is designed to help Data Scientists and Teams build better models faster! Comet provides tooling to Track, Explain, Manage, and Monitor your models in a single place! It... | What is Comet? | https://gradio.app/guides/Gradio-and-Comet | Other Tutorials - Gradio And Comet Guide |
First, install the dependencies needed to run these examples
```shell
pip install comet_ml torch torchvision transformers gradio shap requests Pillow
```
Next, you will need to [sign up for a Comet Account](https://www.comet.com/signup?utm_source=gradio&utm_medium=referral&utm_campaign=gradio-integration&utm_content=... | Setup | https://gradio.app/guides/Gradio-and-Comet | Other Tutorials - Gradio And Comet Guide |
[](https://colab.research.google.com/github/comet-ml/comet-examples/blob/master/integrations/model-evaluation/gradio/notebooks/Gradio_and_Comet.ipynb)
In this example, we will go over how to log your Gradio Applications to Comet and interact wit... | 1. Logging Gradio UI's to your Comet Experiments | https://gradio.app/guides/Gradio-and-Comet | Other Tutorials - Gradio And Comet Guide |
r-images.githubusercontent.com/7529846/214328034-09369d4d-8b94-4c4a-aa3c-25e3ed8394c4.mp4"></source>
</video>
Add the Gradio Panel to your Experiment to interact with your application.
<video width="560" height="315" controls>
<source src="https://user-images.githubusercontent.com/7529846/214328194-95987f83-c180-... | 1. Logging Gradio UI's to your Comet Experiments | https://gradio.app/guides/Gradio-and-Comet | Other Tutorials - Gradio And Comet Guide |
<iframe width="560" height="315" src="https://www.youtube.com/embed/KZnpH7msPq0?start=9" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
If you are permanently hosting your Gradio applicat... | 2. Embedding Gradio Applications directly into your Comet Projects | https://gradio.app/guides/Gradio-and-Comet | Other Tutorials - Gradio And Comet Guide |
<iframe width="560" height="315" src="https://www.youtube.com/embed/KZnpH7msPq0?start=107" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
You can also embed Gradio Applications that are h... | 3. Embedding Hugging Face Spaces directly into your Comet Projects | https://gradio.app/guides/Gradio-and-Comet | Other Tutorials - Gradio And Comet Guide |
<iframe width="560" height="315" src="https://www.youtube.com/embed/KZnpH7msPq0?start=176" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
[
workspace = api.get_default_workspace()
project_name = comet_ml.config.get_config()["comet.project_name"]
experiment = comet_ml.API... | 4. Logging Model Inferences to Comet | https://gradio.app/guides/Gradio-and-Comet | Other Tutorials - Gradio And Comet Guide |
887c-065aca14dd30.mp4"></source>
</video>
| 4. Logging Model Inferences to Comet | https://gradio.app/guides/Gradio-and-Comet | Other Tutorials - Gradio And Comet Guide |
We hope you found this guide useful and that it provides some inspiration to help you build awesome model evaluation workflows with Comet and Gradio.
| Conclusion | https://gradio.app/guides/Gradio-and-Comet | Other Tutorials - Gradio And Comet Guide |
- Create an account on Hugging Face [here](https://huggingface.co/join).
- Add Gradio Demo under your username, see this [course](https://huggingface.co/course/chapter9/4?fw=pt) for setting up Gradio Demo on Hugging Face.
- Request to join the Comet organization [here](https://huggingface.co/Comet).
| How to contribute Gradio demos on HF spaces on the Comet organization | https://gradio.app/guides/Gradio-and-Comet | Other Tutorials - Gradio And Comet Guide |
- [Comet Documentation](https://www.comet.com/docs/v2/?utm_source=gradio&utm_medium=referral&utm_campaign=gradio-integration&utm_content=gradio-docs)
| Additional Resources | https://gradio.app/guides/Gradio-and-Comet | Other Tutorials - Gradio And Comet Guide |
Let's go through a simple example to understand how to containerize a Gradio app using Docker.
Step 1: Create Your Gradio App
First, we need a simple Gradio app. Let's create a Python file named `app.py` with the following content:
```python
import gradio as gr
def greet(name):
return f"Hello {name}!"
iface = ... | How to Dockerize a Gradio App | https://gradio.app/guides/deploying-gradio-with-docker | Other Tutorials - Deploying Gradio With Docker Guide |
When running Gradio applications in Docker, there are a few important things to keep in mind:
Running the Gradio app on `"0.0.0.0"` and exposing port 7860
In the Docker environment, setting `GRADIO_SERVER_NAME="0.0.0.0"` as an environment variable (or directly in your Gradio app's `launch()` function) is crucial for ... | Important Considerations | https://gradio.app/guides/deploying-gradio-with-docker | Other Tutorials - Deploying Gradio With Docker Guide |
Gradio features [blocks](https://www.gradio.app/docs/blocks) to easily layout applications. To use this feature, you need to stack or nest layout components and create a hierarchy with them. This isn't difficult to implement and maintain for small projects, but after the project gets more complex, this component hierar... | Introduction | https://gradio.app/guides/wrapping-layouts | Other Tutorials - Wrapping Layouts Guide |
We are going to follow the implementation from this Huggingface Space example:
<gradio-app
space="gradio/wrapping-layouts">
</gradio-app>
| Example | https://gradio.app/guides/wrapping-layouts | Other Tutorials - Wrapping Layouts Guide |
The wrapping utility has two important classes. The first one is the ```LayoutBase``` class and the other one is the ```Application``` class.
We are going to look at the ```render``` and ```attach_event``` functions of them for brevity. You can look at the full implementation from [the example code](https://huggingfac... | Implementation | https://gradio.app/guides/wrapping-layouts | Other Tutorials - Wrapping Layouts Guide |
at this means is by calling the components' render functions under the ```with``` syntax, we are actually simulating the default implementation.
So now let's consider two nested ```with```s to see how the outer one works. For this, let's expand our example with the ```Tab``` component:
```python
with Tab():
with ... | Implementation | https://gradio.app/guides/wrapping-layouts | Other Tutorials - Wrapping Layouts Guide |
ct``` variable in the ```Application``` class's ```attach_event``` function.
Application Class
1. Render Function
```python
other Application implementations
def _render(self):
with self.app:
for child in self.children:
child.render()
self.app.render()
```
From ... | Implementation | https://gradio.app/guides/wrapping-layouts | Other Tutorials - Wrapping Layouts Guide |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.