text stringlengths 0 2k | heading1 stringlengths 3 79 | source_page_url stringclasses 190
values | source_page_title stringclasses 190
values |
|---|---|---|---|
[](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 |
Gradio is a Python library that allows you to quickly create customizable web apps for your machine learning models and data processing pipelines. Gradio apps can be deployed on [Hugging Face Spaces](https://hf.space) for free.
In some cases though, you might want to deploy a Gradio app on your own web server. You mig... | Introduction | https://gradio.app/guides/running-gradio-on-your-web-server-with-nginx | Other Tutorials - Running Gradio On Your Web Server With Nginx Guide |
1. Start by editing the Nginx configuration file on your web server. By default, this is located at: `/etc/nginx/nginx.conf`
In the `http` block, add the following line to include server block configurations from a separate file:
```bash
include /etc/nginx/sites-enabled/*;
```
2. Create a new file in the `/etc/nginx... | Editing your Nginx configuration file | https://gradio.app/guides/running-gradio-on-your-web-server-with-nginx | Other Tutorials - Running Gradio On Your Web Server With Nginx Guide |
1. Before you launch your Gradio app, you'll need to set the `root_path` to be the same as the subpath that you specified in your nginx configuration. This is necessary for Gradio to run on any subpath besides the root of the domain.
*Note:* Instead of a subpath, you can also provide a complete URL for `root_path`... | Run your Gradio app on your web server | https://gradio.app/guides/running-gradio-on-your-web-server-with-nginx | Other Tutorials - Running Gradio On Your Web Server With Nginx Guide |
1. If you are in a tmux session, exit by typing CTRL+B (or CMD+B), followed by the "D" key.
2. Finally, restart nginx by running `sudo systemctl restart nginx`.
And that's it! If you visit `https://example.com/gradio-demo` on your browser, you should see your Gradio app running there
| Restart Nginx | https://gradio.app/guides/running-gradio-on-your-web-server-with-nginx | Other Tutorials - Running Gradio On Your Web Server With Nginx Guide |
Let’s start with a simple example of integrating a C++ program into a Gradio app. Suppose we have the following C++ program that adds two numbers:
```cpp
// add.cpp
include <iostream>
int main() {
double a, b;
std::cin >> a >> b;
std::cout << a + b << std::endl;
return 0;
}
```
This program reads two... | Using Gradio with C++ | https://gradio.app/guides/using-gradio-in-other-programming-languages | Other Tutorials - Using Gradio In Other Programming Languages Guide |
Now, let’s move to another example: calling a Rust program to apply a sepia filter to an image. The Rust code could look something like this:
```rust
// sepia.rs
extern crate image;
use image::{GenericImageView, ImageBuffer, Rgba};
fn sepia_filter(input: &str, output: &str) {
let img = image::open(input).unwrap(... | Using Gradio with Rust | https://gradio.app/guides/using-gradio-in-other-programming-languages | Other Tutorials - Using Gradio In Other Programming Languages Guide |
nput Image"),
outputs=gr.Image(label="Sepia Image")
)
demo.launch()
```
Here, when a user uploads an image and clicks submit, Gradio calls the Rust binary (`sepia`) to process the image, and returns the sepia-filtered output to Gradio.
This setup showcases how you can integrate performance-critical or specializ... | Using Gradio with Rust | https://gradio.app/guides/using-gradio-in-other-programming-languages | Other Tutorials - Using Gradio In Other Programming Languages Guide |
Integrating Gradio with R is particularly straightforward thanks to the `reticulate` package, which allows you to run Python code directly in R. Let’s walk through an example of using Gradio in R.
**Installation**
First, you need to install the `reticulate` package in R:
```r
install.packages("reticulate")
```
On... | Using Gradio with R (via `reticulate`) | https://gradio.app/guides/using-gradio-in-other-programming-languages | Other Tutorials - Using Gradio In Other Programming Languages Guide |
When you demo a machine learning model, you might want to collect data from users who try the model, particularly data points in which the model is not behaving as expected. Capturing these "hard" data points is valuable because it allows you to improve your machine learning model and make it more reliable and robust.
... | Introduction | https://gradio.app/guides/using-flagging | Other Tutorials - Using Flagging Guide |
Flagging with Gradio's `Interface` is especially easy. By default, underneath the output components, there is a button marked **Flag**. When a user testing your model sees input with interesting output, they can click the flag button to send the input and output data back to the machine where the demo is running. The s... | The **Flag** button in `gradio.Interface` | https://gradio.app/guides/using-flagging | Other Tutorials - Using Flagging Guide |
flagged data is stored.
- `flagging_callback`: this parameter takes an instance of a subclass of the `FlaggingCallback` class
- Using this parameter allows you to write custom code that gets run when the flag button is clicked
- By default, this is set to an instance of `gr.JSONLogger`
| The **Flag** button in `gradio.Interface` | https://gradio.app/guides/using-flagging | Other Tutorials - Using Flagging Guide |
Within the directory provided by the `flagging_dir` argument, a JSON file will log the flagged data.
Here's an example: The code below creates the calculator interface embedded below it:
```python
import gradio as gr
def calculator(num1, operation, num2):
if operation == "add":
return num1 + num2
el... | What happens to flagged data? | https://gradio.app/guides/using-flagging | Other Tutorials - Using Flagging Guide |
` argument of Interface. Users will have to select one of these choices when flagging, and the option will be saved as an additional column to the CSV.
If we go back to the calculator example, the following code will create the interface embedded below it.
```python
iface = gr.Interface(
calculator,
["number"... | What happens to flagged data? | https://gradio.app/guides/using-flagging | Other Tutorials - Using Flagging Guide |
What about if you are using `gradio.Blocks`? On one hand, you have even more flexibility
with Blocks -- you can write whatever Python code you want to run when a button is clicked,
and assign that using the built-in events in Blocks.
At the same time, you might want to use an existing `FlaggingCallback` to avoid writi... | Flagging with Blocks | https://gradio.app/guides/using-flagging | Other Tutorials - Using Flagging Guide |
Important Note: please make sure your users understand when the data they submit is being saved, and what you plan on doing with it. This is especially important when you use `flagging_mode=auto` (when all of the data submitted through the demo is being flagged)
That's all! Happy building :)
| Privacy | https://gradio.app/guides/using-flagging | Other Tutorials - Using Flagging 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 |
This guide explains how you can run background tasks from your gradio app.
Background tasks are operations that you'd like to perform outside the request-response
lifecycle of your app either once or on a periodic schedule.
Examples of background tasks include periodically synchronizing data to an external database or
... | Introduction | https://gradio.app/guides/running-background-tasks | Other Tutorials - Running Background Tasks Guide |
We will be creating a simple "Google-forms-style" application to gather feedback from users of the gradio library.
We will use a local sqlite database to store our data, but we will periodically synchronize the state of the database
with a [HuggingFace Dataset](https://huggingface.co/datasets) so that our user reviews ... | Overview | https://gradio.app/guides/running-background-tasks | Other Tutorials - Running Background Tasks Guide |
Our application will store the name of the reviewer, their rating of gradio on a scale of 1 to 5, as well as
any comments they want to share about the library. Let's write some code that creates a database table to
store this data. We'll also write some functions to insert a review into that table and fetch the latest ... | Step 1 - Write your database logic 💾 | https://gradio.app/guides/running-background-tasks | Other Tutorials - Running Background Tasks Guide |
Now that we have our database logic defined, we can use gradio create a dynamic web page to ask our users for feedback!
```python
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
name = gr.Textbox(label="Name", placeholder="What is your name?")
review = gr.Radio(label="How... | Step 2 - Create a gradio app ⚡ | https://gradio.app/guides/running-background-tasks | Other Tutorials - Running Background Tasks Guide |
We could call `demo.launch()` after step 2 and have a fully functioning application. However,
our data would be stored locally on our machine. If the sqlite file were accidentally deleted, we'd lose all of our reviews!
Let's back up our data to a dataset on the HuggingFace hub.
Create a dataset [here](https://huggingf... | Step 3 - Synchronize with HuggingFace Datasets 🤗 | https://gradio.app/guides/running-background-tasks | Other Tutorials - Running Background Tasks Guide |
print("updating db")
repo.push_to_hub(blocking=False, commit_message=f"Updating data at {datetime.datetime.now()}")
scheduler = BackgroundScheduler()
scheduler.add_job(func=backup_db, trigger="interval", seconds=60)
scheduler.start()
```
| Step 3 - Synchronize with HuggingFace Datasets 🤗 | https://gradio.app/guides/running-background-tasks | Other Tutorials - Running Background Tasks Guide |
You can use the HuggingFace [Spaces](https://huggingface.co/spaces) platform to deploy this application for free ✨
If you haven't used Spaces before, follow the previous guide [here](/using_hugging_face_integrations).
You will have to use the `HUB_TOKEN` environment variable as a secret in the Guides.
| Step 4 (Bonus) - Deployment to HuggingFace Spaces | https://gradio.app/guides/running-background-tasks | Other Tutorials - Running Background Tasks Guide |
Congratulations! You know how to run background tasks from your gradio app on a schedule ⏲️.
Checkout the application running on Spaces [here](https://huggingface.co/spaces/freddyaboulton/gradio-google-forms).
The complete code is [here](https://huggingface.co/spaces/freddyaboulton/gradio-google-forms/blob/main/app.py... | Conclusion | https://gradio.app/guides/running-background-tasks | Other Tutorials - Running Background Tasks Guide |
App-level parameters have been moved from `Blocks` to `launch()`
The `gr.Blocks` class constructor previously contained several parameters that applied to your entire Gradio app, specifically:
* `theme`: The theme for your Gradio app
* `css`: Custom CSS code as a string
* `css_paths`: Paths to custom CSS files
* `js`... | App-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
he "Built with Gradio" link
- `"settings"`: Shows the settings link
**Before (Gradio 5.x):**
```python
import gradio as gr
with gr.Blocks() as demo:
gr.Textbox(label="Input")
demo.launch(show_api=False)
```
**After (Gradio 6.x):**
```python
import gradio as gr
with gr.Blocks() as demo:
gr.Textbox(label... | App-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
o as gr
with gr.Blocks() as demo:
btn = gr.Button("Click me")
output = gr.Textbox()
btn.click(fn=lambda: "Hello", outputs=output, show_api=False)
demo.launch()
```
Or to completely disable the API:
```python
btn.click(fn=lambda: "Hello", outputs=output, api_name=False)
```
**After (Gradio 6.x)... | App-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
.ChatInterface` now use the name of the function you pass in as the default API endpoint name
- This makes the API more descriptive and consistent with `gr.Blocks` behavior
E.g. if your Gradio app is:
```python
import gradio as gr
def generate_text(prompt):
return f"Generated: {prompt}"
demo = gr.Interface(fn=g... | App-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
```python
chatbot = gr.Chatbot(value=[["Hello", "Hi there!"]], type="tuples")
```
**After (Gradio 6.x):**
```python
import gradio as gr
Must use messages format
chatbot = gr.Chatbot(
value=[
{"role": "user", "content": "Hello"},
{"role": "assistant", "content": "Hi there!"}
],
type="mes... | App-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
": "text", "text": "What is the capital of France?"}]},
{"role": "assistant", "content": [{"type": "text", "text": "Paris"}]}
]
```
**With files:**
When files are uploaded in the chat, they are represented as content blocks with `"type": "file"`. All content blocks (files and text) are grouped together in the sam... | App-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
Interface(
fn=predict,
inputs="text",
outputs="text",
examples=["Hello", "World"],
cache_examples=True,
cache_mode="lazy"
)
```
If you previously used `cache_examples=True` (which implied eager caching), no changes are required, as `cache_mode` defaults to `"eager"`.
| App-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
`gr.Video` no longer accepts tuple values for video and subtitles
The tuple format for returning video with subtitles has been deprecated. Instead of returning a tuple `(video_path, subtitle_path)`, you should now use the `gr.Video` component directly with the `subtitles` parameter.
**In Gradio 5.x:**
- You could ret... | Component-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
present in Gradio 5.x, explicitly set `padding=True`:
```python
html = gr.HTML("<div>Content</div>", padding=True)
```
`gr.Dataframe` `row_count` and `col_count` parameters restructured
The `row_count` and `col_count` parameters in `gr.Dataframe` have been restructured to provide more flexibility and clarity. The t... | Component-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
r.Dataframe(row_count=5, row_limits=None, column_count=3, column_limits=None)
```
Or with min/max constraints:
```python
Rows between 3 and 10, columns between 2 and 5
df = gr.Dataframe(row_count=5, row_limits=(3, 10), column_count=3, column_limits=(2, 5))
```
**Migration examples:**
- `row_count=(5, "fixed")` → `r... | Component-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
e`:
```python
import gradio as gr
chatbot = gr.Chatbot(allow_tags=False)
```
**Note:** You can also specify a list of specific tags to allow:
```python
chatbot = gr.Chatbot(allow_tags=["thinking", "tool_call"])
```
This will only preserve `<thinking>` and `<tool_call>` tags while removing all other custom tags.
... | Component-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
fore (Gradio 5.x):**
```python
audio = gr.Audio(min_length=1, max_length=10)
```
**After (Gradio 6.x):**
```python
audio = gr.Audio()
audio.upload(
fn=process_audio,
validator=lambda audio: gr.validators.is_audio_correct_length(audio, min_length=1, max_length=10),
inputs=audio
)
```
**`show_download_butt... | Component-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
``python
image = gr.Image(buttons=["download", "share", "fullscreen"])
```
`gr.Video` removed parameters
**`mirror_webcam`** - This parameter has been removed. Use `webcam_options` with `gr.WebcamOptions` instead.
**Before (Gradio 5.x):**
```python
video = gr.Video(mirror_webcam=True)
```
**After (Gradio 6.x):**
``... | Component-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
`gr.LogoutButton`** - This component has been removed. Use `gr.LoginButton` instead, which handles both login and logout processes.
**Before (Gradio 5.x):**
```python
logout_btn = gr.LogoutButton()
```
**After (Gradio 6.x):**
```python
login_btn = gr.LoginButton()
```
Native plot components removed parameters
The f... | Component-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
buttons=["copy"])
```
`gr.Markdown` removed parameters
**`show_copy_button`** - This parameter has been removed. Use the `buttons` parameter instead.
**Before (Gradio 5.x):**
```python
markdown = gr.Markdown(show_copy_button=True)
```
**After (Gradio 6.x):**
```python
markdown = gr.Markdown(buttons=["copy"])
```
`... | Component-level Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
`gradio sketch` command removed
The `gradio sketch` command-line tool has been deprecated and completely removed in Gradio 6. This tool was used to create Gradio apps through a visual interface.
**In Gradio 5.x:**
- You could run `gradio sketch` to launch an interactive GUI for building Gradio apps
- The tool would g... | CLI Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
`hf_token` parameter renamed to `token` in `Client`
The `hf_token` parameter in the `Client` class has been renamed to `token` for consistency and simplicity.
**Before (Gradio 5.x):**
```python
from gradio_client import Client
client = Client("abidlabs/my-private-space", hf_token="hf_...")
```
**After (Gradio 6.x)... | Python Client Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
"username/space-name")
result = client.predict("/predict", inputs)
except AppError as e:
Explicitly catch AppError
print(f"App error: {e}")
except ValueError as e:
This will no longer catch AppError
print(f"Value error: {e}")
```
| Python Client Changes | https://gradio.app/guides/gradio-6-migration-guide | Other Tutorials - Gradio 6 Migration Guide Guide |
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 |
Data visualization is a crucial aspect of data analysis and machine learning. The Gradio `DataFrame` component is a popular way to display tabular data within a web application.
But what if you want to stylize the table of data? What if you want to add background colors, partially highlight cells, or change the displ... | Introduction | https://gradio.app/guides/styling-the-gradio-dataframe | Other Tutorials - Styling The Gradio Dataframe Guide |
The Gradio `DataFrame` component now supports values of the type `Styler` from the `pandas` class. This allows us to reuse the rich existing API and documentation of the `Styler` class instead of inventing a new style format on our own. Here's a complete example of how it looks:
```python
import pandas as pd
import g... | The Pandas `Styler` | https://gradio.app/guides/styling-the-gradio-dataframe | Other Tutorials - Styling The Gradio Dataframe Guide |
, 32, 23]
})
Applying style to highlight the maximum value in each row
styler = df.style.highlight_max(color = 'lightgreen', axis = 0)
```
Now, we simply pass this object into the Gradio `DataFrame` and we can visualize our colorful table of data in 4 lines of python:
```python
import gradio as gr
with gr.Blocks()... | The Pandas `Styler` | https://gradio.app/guides/styling-the-gradio-dataframe | Other Tutorials - Styling The Gradio Dataframe Guide |
on of numbers displayed. Here's how you can do this:
```python
import pandas as pd
import gradio as gr
Creating a sample dataframe with floating numbers
df = pd.DataFrame({
"A" : [14.12345, 4.23456, 5.34567, 4.45678, 1.56789],
"B" : [5.67891, 2.78912, 54.89123, 3.91234, 2.12345],
... other columns
})
... | The Pandas `Styler` | https://gradio.app/guides/styling-the-gradio-dataframe | Other Tutorials - Styling The Gradio Dataframe Guide |
So far, we've been restricting ourselves to styling that is supported by the Pandas `Styler` class. But what if you want to create custom styles like partially highlighting cells based on their values:
. If the `DataFrame` component is interactive, then the styling information is ignored and instead the raw table values are shown instead.
The `DataFrame` component ... | Note about Interactivity | https://gradio.app/guides/styling-the-gradio-dataframe | Other Tutorials - Styling The Gradio Dataframe Guide |
This is just a taste of what's possible using the `gradio.DataFrame` component with the `Styler` class from `pandas`. Try it out and let us know what you think! | Conclusion 🎉 | https://gradio.app/guides/styling-the-gradio-dataframe | Other Tutorials - Styling The Gradio Dataframe 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 for Codex, Cursor, OpenCode, and other assistants that use the shared `.agents/skills` directory:
```bash
gradio skills add
```
This downloads the G... | 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 --global
```
Or using the short flag:
```bash
gradio skills add ... | 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
```
This connects to the Space, extracts i... | 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 --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 |
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 |
Blocks``` class, we can see that it is calling the ```attach_load_events``` function which is used for setting event triggers to components. So we have to use the ```with``` syntax to trigger the ```__exit__``` function.
Of course, we can call ```attach_load_events``` without using the ```with``` syntax, but the funct... | Implementation | https://gradio.app/guides/wrapping-layouts | Other Tutorials - Wrapping Layouts Guide |
In this guide, we saw
- How we can wrap the layouts
- How components are rendered
- How we can structure our application with wrapped layout classes
Because the classes used in this guide are used for demonstration purposes, they may still not be totally optimized or modular. But that would make the guide much longer... | Conclusion | https://gradio.app/guides/wrapping-layouts | Other Tutorials - Wrapping Layouts 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 |
In this Guide, we'll walk you through:
- Introduction of ONNX, ONNX model zoo, Gradio, and Hugging Face Spaces
- How to setup a Gradio demo for EfficientNet-Lite4
- How to contribute your own Gradio demos for the ONNX organization on Hugging Face
Here's an [example](https://onnx-efficientnet-lite4.hf.space/) of an ON... | Introduction | https://gradio.app/guides/Gradio-and-ONNX-on-Hugging-Face | Other Tutorials - Gradio And Onnx On Hugging Face Guide |
Open Neural Network Exchange ([ONNX](https://onnx.ai/)) is an open standard format for representing machine learning models. ONNX is supported by a community of partners who have implemented it in many frameworks and tools. For example, if you have trained a model in TensorFlow or PyTorch, you can convert it to ONNX ea... | What is the ONNX Model Zoo? | https://gradio.app/guides/Gradio-and-ONNX-on-Hugging-Face | Other Tutorials - Gradio And Onnx On Hugging Face Guide |
Gradio
Gradio lets users demo their machine learning models as a web app all in python code. Gradio wraps a python function into a user interface and the demos can be launched inside jupyter notebooks, colab notebooks, as well as embedded in your own website and hosted on Hugging Face Spaces for free.
Get started [he... | What are Hugging Face Spaces & Gradio? | https://gradio.app/guides/Gradio-and-ONNX-on-Hugging-Face | Other Tutorials - Gradio And Onnx On Hugging Face Guide |
There are a lot of Jupyter notebooks in the ONNX Model Zoo for users to test models. Previously, users needed to download the models themselves and run those notebooks locally for testing. With Hugging Face, the testing process can be much simpler and more user-friendly. Users can easily try certain ONNX Model Zoo mode... | How did Hugging Face help the ONNX Model Zoo? | https://gradio.app/guides/Gradio-and-ONNX-on-Hugging-Face | Other Tutorials - Gradio And Onnx On Hugging Face Guide |
ONNX Runtime is a cross-platform inference and training machine-learning accelerator. It makes live Gradio demos with ONNX Model Zoo model on Hugging Face possible.
ONNX Runtime inference can enable faster customer experiences and lower costs, supporting models from deep learning frameworks such as PyTorch and TensorF... | What is the role of ONNX Runtime? | https://gradio.app/guides/Gradio-and-ONNX-on-Hugging-Face | Other Tutorials - Gradio And Onnx On Hugging Face Guide |
EfficientNet-Lite 4 is the largest variant and most accurate of the set of EfficientNet-Lite models. It is an integer-only quantized model that produces the highest accuracy of all of the EfficientNet models. It achieves 80.4% ImageNet top-1 accuracy, while still running in real-time (e.g. 30ms/image) on a Pixel 4 CPU.... | Setting up a Gradio Demo for EfficientNet-Lite4 | https://gradio.app/guides/Gradio-and-ONNX-on-Hugging-Face | Other Tutorials - Gradio And Onnx On Hugging Face Guide |
the image with a proportional scale
def resize_with_aspectratio(img, out_height, out_width, scale=87.5, inter_pol=cv2.INTER_LINEAR):
height, width, _ = img.shape
new_height = int(100. * out_height / scale)
new_width = int(100. * out_width / scale)
if height > width:
w = new_width
h = int... | Setting up a Gradio Demo for EfficientNet-Lite4 | https://gradio.app/guides/Gradio-and-ONNX-on-Hugging-Face | Other Tutorials - Gradio And Onnx On Hugging Face Guide |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.