Examples
Parameters
list[Any] | list[list[Any]] | str
required
Example inputs that can be clicked to populate specific components. Should be nested list, in which the outer list consists of samples and each inner list consists of an input corresponding to each input component. A string path to a directory of examples can also be provided.
Component | Sequence[Component]
required
The component or list of components corresponding to the examples.
Component | Sequence[Component] | None
default:"None"
Optionally, provide the component or list of components corresponding to the output of the examples. Required if cache_examples is not False.
Callable | None
default:"None"
Optionally, provide the function to run to generate the outputs corresponding to the examples. Required if cache_examples is not False.
bool | None
default:"None"
If True, caches examples in the server for fast runtime in examples. If “lazy”, then examples are cached after their first use.
Literal['eager', 'lazy'] | None
default:"None"
If “lazy”, examples are cached after their first use. If “eager”, all examples are cached at app launch.
int
default:"10"
How many examples to show per page.
str | I18nData | None
default:"'Examples'"
The label to use for the examples component.
str | None
default:"None"
An optional string that is assigned as the id of this component in the HTML DOM.
bool
default:"False"
If cache_examples is False, clicking on an example does not run the function when an example is clicked. Set this to True to run the function when an example is clicked.
bool
default:"True"
If True, preprocesses the example input before running the prediction function and caching the output.
bool
default:"True"
If True, postprocesses the example output after running the prediction function and before caching.
list[str] | None
default:"None"
A list of labels for each example. If provided, the length of this list should be the same as the number of examples.
bool | Literal['hidden']
default:"True"
If False, the examples component will be hidden in the UI.
int | Literal[False]
default:"0"
If an integer is provided, the example at that index will be preloaded when the Gradio app is first loaded.
Example
Progress
gr.Progress() instance.
Parameters
bool
default:"False"
If True, the Progress object will track any tqdm.tqdm iterations with the tqdm library in the function.
Methods
call
float | tuple[int, int | None] | None
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.
str | None
default:"None"
Description to display.
int | float | None
default:"None"
Estimated total number of steps.
str
default:"'steps'"
Unit of iterations.
tqdm
Iterable | None
Iterable to attach progress tracker to.
str | None
default:"None"
Description to display.
int | float | None
default:"None"
Estimated total number of steps.
str
default:"'steps'"
Unit of iterations.
Example
update
gr.update(...) with any arbitrary parameters to update.
Parameters
str | None
default:"None"
Use this to update the id of the component in the HTML DOM.
list[str] | str | None
default:"None"
Use this to update the classes of the component in the HTML DOM.
bool | Literal['hidden'] | None
default:"None"
Use this to update the visibility of the component.
Any
Any other keyword arguments to update the component’s properties.
Example
skip
Example
validate
Parameters
bool
required
Whether the value is valid.
str
required
The validation message to display.