Custom Components GalleryNEW

Explore

New to Gradio? Start here: Getting Started

See the Release History

To install Gradio from main, run the following command:

pip install https://gradio-builds.s3.amazonaws.com/98c1cbcd0e3b66a8d2463820d3ce157efe0a032d/gradio-4.31.4-py3-none-any.whl

*Note: Setting share=True in launch() will not work.

Progress

gradio.Progress(···)

Description

The Progress class provides a custom progress tracker that is used in a function signature. To attach a Progress tracker to a function, simply add a parameter right after the input parameters that has a default value set to a gradio.Progress() instance. The Progress tracker can then be updated in the function by calling the Progress object or using the tqdm method on an Iterable. The Progress tracker is currently only available with queue().

Example Usage

import gradio as gr
import time
def my_function(x, progress=gr.Progress()):
    progress(0, desc="Starting...")
    time.sleep(1)
    for i in progress.tqdm(range(100)):
        time.sleep(0.1)
    return x
gr.Interface(my_function, gr.Textbox(), gr.Textbox()).queue().launch()

Initialization

Parameter Description
track_tqdm

bool

default: False

If True, the Progress object will track any tqdm.tqdm iterations with the tqdm library in the function.

Methods

__call__

gradio.Progress.__call__(progress, ···)

Description

Updates progress tracker with progress and message text.

Agruments

Parameter Description
progress

float | tuple[int, int | None] | None

required

If float, should be between 0 and 1 representing completion. If Tuple, first number represents steps completed, and second value represents total steps or None if unknown. If None, hides progress bar.

desc

str | None

default: None

description to display.

total

int | None

default: None

estimated total number of steps.

unit

str

default: "steps"

unit of iterations.

tqdm

gradio.Progress.tqdm(iterable, ···)

Description

Attaches progress tracker to iterable, like tqdm.

Agruments

Parameter Description
iterable

Iterable | None

required

iterable to attach progress tracker to.

desc

str | None

default: None

description to display.

total

int | None

default: None

estimated total number of steps.

unit

str

default: "steps"

unit of iterations.