text stringlengths 0 2k | heading1 stringlengths 3 79 | source_page_url stringclasses 189
values | source_page_title stringclasses 189
values |
|---|---|---|---|
running: "full" shows a
spinner which covers the output component area as well as a runtime display in
the upper right corner, "minimal" only shows the runtime display, "hidden"
shows no progress animation at all
show_progress_on: Component | list[Component] | None
default `= None`
Component or list o... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
ner is triggered. For example,
setting cancels=[click_event] will cancel the click_event, where click_event
is the return value of another components .click method. Functions that have
not yet run (or generators that are iterating) will be cancelled, but
functions that are currently running will be allowed to finish.
... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
c"
(shown in API docs and callable by clients), "private" (hidden from API docs
and not callable by the Gradio client libraries), or "undocumented" (hidden
from API docs but callable by clients and via gr.load). If fn is None,
api_visibility will automatically be set to "private".
time_limit: int | None... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%20318.... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
le | None | Literal['decorator']
default `= "decorator"`
the function to call when this event is triggered. Often a machine learning
model's prediction function. Each parameter of the function corresponds to one
input component, and the function should return a single value or a tuple of
values, with each element in ... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
running: "full" shows a
spinner which covers the output component area as well as a runtime display in
the upper right corner, "minimal" only shows the runtime display, "hidden"
shows no progress animation at all
show_progress_on: Component | list[Component] | None
default `= None`
Component or list o... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
ner is triggered. For example,
setting cancels=[click_event] will cancel the click_event, where click_event
is the return value of another components .click method. Functions that have
not yet run (or generators that are iterating) will be cancelled, but
functions that are currently running will be allowed to finish.
... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
c"
(shown in API docs and callable by clients), "private" (hidden from API docs
and not callable by the Gradio client libraries), or "undocumented" (hidden
from API docs but callable by clients and via gr.load). If fn is None,
api_visibility will automatically be set to "private".
time_limit: int | None... | select | https://gradio.app/docs/gradio/tab | Gradio - Tab Docs |
Blocks is Gradio's low-level API that allows you to create more custom web
applications and demos than Interfaces (yet still entirely in Python).
Compared to the Interface class, Blocks offers more flexibility and control
over: (1) the layout of components (2) the events that trigger the execution
of functions (3)... | Description | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
import gradio as gr
def update(name):
return f"Welcome to Gradio, {name}!"
with gr.Blocks() as demo:
gr.Markdown("Start typing below and then click **Run** to see the output.")
with gr.Row():
inp = gr.Textbox(placeholder="What is your name?")
out = gr.Textbox... | Example Usage | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
Parameters ▼
analytics_enabled: bool | None
default `= None`
Whether to allow basic telemetry. If None, will use GRADIO_ANALYTICS_ENABLED
environment variable or default to True.
mode: str
default `= "blocks"`
A human-friendly name for the kind of Blocks or Interface being created. U... | Initialization | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
blocks_helloblocks_flipperblocks_kinematics
| Demos | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
Methods | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs | |
%20Copyright%202022%20Fonticons,%20Inc.... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
-!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%203... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
3e%3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%2039... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
inline: bool | None
default `= None`
whether to display in the gradio app inline in an iframe. Defaults to True in
python notebooks; False otherwise.
inbrowser: bool
default `= False`
whether to automatically launch the gradio app in a new tab on the default
browser.
share: bo... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
default `= False`
If True, any errors in the gradio app will be displayed in an alert modal and
printed in the browser console log. They will also be displayed in the alert
modal of downstream apps that gr.load() this app.
server_name: str | None
default `= None`
to make app accessible on local net... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
t `= False`
If True, suppresses most print statements.
footer_links: list[Literal['api', 'gradio', 'settings', 'runs'] | dict[str, str]] | None
default `= None`
The links to display in the footer of the app. Accepts a list, where each
element of the list must be one of "api", "gradio", "settings", or... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
filepaths or parent directories that gradio is not allowed to
serve (i.e. users of your app are not allowed to access). Must be absolute
paths. Warning: takes precedence over `allowed_paths` and all other
directories exposed by Gradio by default. Can be set by comma separated
environment variable GRADIO_BLOCKED_PATHS.
... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
ocol: Literal['http', 'https'] | None
default `= None`
Use this to specify the protocol to use for the share links. Defaults to
"https", unless a custom share_server_address is provided, in which case it
defaults to "http". If you are using a custom share_server_address and want to
use https, you must set this to "ht... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
fault `= True`
If True, prevents external domains from making requests to a Gradio server
running on localhost. If False, allows requests to localhost that originate
from localhost but also, crucially, from "null". This parameter should
normally be True to prevent CSRF attacks but may need to be False when
embedding a... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
ustom translations, which are used to translate
strings in our components (e.g. the labels of components or Markdown strings).
This feature can only be used to translate static text in the frontend, not
values in the backend.
theme: Theme | str | None
default `= None`
A Theme object or a string repres... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%2031... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%20318.3L391.3%20319.9C381%203... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
will send status estimations to all clients whenever a job is
finished. Otherwise Queue will send status at regular intervals set by this
parameter as the number of seconds.
api_open: bool | None
default `= None`
If True, the REST routes of the backend will be open, allowing requests made
directly to... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | integrate | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%... | integrate | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
| None
default `= None`
If the wandb module is provided, will integrate with it and appear on WandB
dashboard
mlflow: ModuleType | None
default `= None`
If the mlflow module is provided, will integrate with the experiment and
appear on ML Flow dashboard
| integrate | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
ction function. Each parameter of the function corresponds to one
input component, and the function should return a single value or a tuple of
values, with each element in the tuple corresponding to one output component.
inputs: Component | BlockContext | list[Component | BlockContext] | Set[Component |... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
the runtime display, "hidden"
shows no progress animation at all
show_progress_on: Component | list[Component] | None
default `= None`
Component or list of components to show the progress animation on. If None,
will show the progress animation on all of the output components.
queue: bo... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
s .click method. Functions that have
not yet run (or generators that are iterating) will be cancelled, but
functions that are currently running will be allowed to finish.
trigger_mode: Literal['once', 'multiple', 'always_last'] | None
default `= None`
If "once" (default for all events except `.change(... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
(hidden
from API docs but callable by clients and via gr.load). If fn is None,
api_visibility will automatically be set to "private".
time_limit: int | None
default `= None`
stream_every: float
default `= 0.5`
key: int | str | tuple[int | str, ...] | None
default `= No... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4... | unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%20... | unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
ources. The function should not take any
arguments and the output is not used.
[Blocks And Event Listeners](../../guides/blocks-and-event-
listeners/)[Controlling Layout](../../guides/controlling-layout/)[State In
Blocks](../../guides/state-in-blocks/)[More Blocks
Features](../../guides/more-blocks-features/)
| unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
-!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%203... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
3e%3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%2039... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
inline: bool | None
default `= None`
whether to display in the gradio app inline in an iframe. Defaults to True in
python notebooks; False otherwise.
inbrowser: bool
default `= False`
whether to automatically launch the gradio app in a new tab on the default
browser.
share: bo... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
default `= False`
If True, any errors in the gradio app will be displayed in an alert modal and
printed in the browser console log. They will also be displayed in the alert
modal of downstream apps that gr.load() this app.
server_name: str | None
default `= None`
to make app accessible on local net... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
t `= False`
If True, suppresses most print statements.
footer_links: list[Literal['api', 'gradio', 'settings', 'runs'] | dict[str, str]] | None
default `= None`
The links to display in the footer of the app. Accepts a list, where each
element of the list must be one of "api", "gradio", "settings", or... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
filepaths or parent directories that gradio is not allowed to
serve (i.e. users of your app are not allowed to access). Must be absolute
paths. Warning: takes precedence over `allowed_paths` and all other
directories exposed by Gradio by default. Can be set by comma separated
environment variable GRADIO_BLOCKED_PATHS.
... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
ocol: Literal['http', 'https'] | None
default `= None`
Use this to specify the protocol to use for the share links. Defaults to
"https", unless a custom share_server_address is provided, in which case it
defaults to "http". If you are using a custom share_server_address and want to
use https, you must set this to "ht... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
fault `= True`
If True, prevents external domains from making requests to a Gradio server
running on localhost. If False, allows requests to localhost that originate
from localhost but also, crucially, from "null". This parameter should
normally be True to prevent CSRF attacks but may need to be False when
embedding a... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
ustom translations, which are used to translate
strings in our components (e.g. the labels of components or Markdown strings).
This feature can only be used to translate static text in the frontend, not
values in the backend.
theme: Theme | str | None
default `= None`
A Theme object or a string repres... | launch | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%2031... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%20318.3L391.3%20319.9C381%203... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
will send status estimations to all clients whenever a job is
finished. Otherwise Queue will send status at regular intervals set by this
parameter as the number of seconds.
api_open: bool | None
default `= None`
If True, the REST routes of the backend will be open, allowing requests made
directly to... | queue | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | integrate | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%... | integrate | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
| None
default `= None`
If the wandb module is provided, will integrate with it and appear on WandB
dashboard
mlflow: ModuleType | None
default `= None`
If the mlflow module is provided, will integrate with the experiment and
appear on ML Flow dashboard
| integrate | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
ction function. Each parameter of the function corresponds to one
input component, and the function should return a single value or a tuple of
values, with each element in the tuple corresponding to one output component.
inputs: Component | BlockContext | list[Component | BlockContext] | Set[Component |... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
the runtime display, "hidden"
shows no progress animation at all
show_progress_on: Component | list[Component] | None
default `= None`
Component or list of components to show the progress animation on. If None,
will show the progress animation on all of the output components.
queue: bo... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
s .click method. Functions that have
not yet run (or generators that are iterating) will be cancelled, but
functions that are currently running will be allowed to finish.
trigger_mode: Literal['once', 'multiple', 'always_last'] | None
default `= None`
If "once" (default for all events except `.change(... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
(hidden
from API docs but callable by clients and via gr.load). If fn is None,
api_visibility will automatically be set to "private".
time_limit: int | None
default `= None`
stream_every: float
default `= 0.5`
key: int | str | tuple[int | str, ...] | None
default `= No... | load | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
3c!--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4... | unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
--!%20Font%20Awesome%20Pro%206.0.0%20by%20@fontawesome%20-%20https://fontawesome.com%20License%20-%20https://fontawesome.com/license%20\(Commercial%20License\)%20Copyright%202022%20Fonticons,%20Inc.%20--%3e%3cpath%20d='M172.5%20131.1C228.1%2075.51%20320.5%2075.51%20376.1%20131.1C426.1%20181.1%20433.5%20260.8%20392.4%20... | unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
ources. The function should not take any
arguments and the output is not used.
| unload | https://gradio.app/docs/gradio/blocks | Gradio - Blocks Docs |
The render decorator allows Gradio Blocks apps to have dynamic layouts, so
that the components and event listeners in your app can change depending on
custom logic. Attaching a @gr.render decorator to a function will cause the
function to be re-run whenever the inputs are changed (or specified triggers
are activated). ... | Description | https://gradio.app/docs/gradio/render | Gradio - Render Docs |
import gradio as gr
with gr.Blocks() as demo:
textbox = gr.Textbox(label="Enter text")
@gr.render(inputs=textbox)
def show_message(text):
if not text:
gr.Markdown("Please enter some text.")
else:
gr.Markdown(f"You entered: {te... | Example Usage | https://gradio.app/docs/gradio/render | Gradio - Render Docs |
Parameters ▼
inputs: list[Component] | Component | None
default `= None`
List of gradio.components to use as inputs. If the function takes no inputs,
this should be an empty list.
triggers: list[Trigger] | Trigger | None
default `= None`
List of triggers to listen to, e.g. [btn.click... | Initialization | https://gradio.app/docs/gradio/render | Gradio - Render Docs |
Creates a video component that can be used to upload/record videos (as an
input) or display videos (as an output). For the video to be playable in the
browser it must have a compatible container and codec combination. Allowed
combinations are .mp4 with h264 codec, .ogg with theora codec, and .webm with
vp9 codec. If th... | Description | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
**Using Video as an input component.**
How Video will pass its value to your function:
Type: `str | None`
Passes the uploaded video as a `str` filepath or URL whose extension can be
modified by `format`.
Example Code
import gradio as gr
def predict(
value: str | ... | Behavior | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
Parameters ▼
value: str | Path | Callable | None
default `= None`
path or URL for the default value that Video component is going to take. Or
can be callable, in which case the function will be called whenever the app
loads to set the initial value of the component.
format: str | None
... | Initialization | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
nd
used in a `gr.Interface`, the label will be the name of the parameter this
component is assigned to.
every: Timer | float | None
default `= None`
continuously calls `value` to recalculate it if `value` is a function (has no
effect otherwise). Can provide a Timer whose tick resets `value`, or a floa... | Initialization | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
be hidden. If "hidden", component will be visually
hidden and not take up space in the layout but still exist in the DOM
elem_id: str | None
default `= None`
an optional string that is assigned as the id of this component in the HTML
DOM. Can be used for targeting CSS styles.
elem_clas... | Initialization | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
ult `= None`
whether the component should record/retain the audio track for a video. By
default, audio is excluded for webcam videos and included for uploaded videos.
autoplay: bool
default `= False`
whether to automatically play the video when the component is used as an
output. Note: browsers will ... | Initialization | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
d position on the video. Valid formats for the image are: jpeg,
png.
subtitles: str | Path | list[dict[str, Any]] | None
default `= None`
A subtitle file (srt, vtt, or json) for the video, or a list of subtitle
dictionaries in the format [{"text": str, "timestamp": [start, end]}] where
timestamps are ... | Initialization | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
Shortcuts
gradio.Video
Interface String Shortcut `"video"`
Initialization Uses default values
gradio.PlayableVideo
Interface String Shortcut `"playablevideo"`
Initialization Uses format="mp4"
| Shortcuts | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
video_identity_2
| Demos | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The Video component supports the following ... | Event Listeners | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
d when the user changes the value of the Video.
Event Parameters
Parameters ▼
fn: Callable | None | Literal['decorator']
default `= "decorator"`
the function to call when this event is triggered. Often a machine learning
model's prediction function. Each parameter of the function corresponds to one
... | Event Listeners | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
s: Literal['full', 'minimal', 'hidden']
default `= "full"`
how to show the progress animation while event is running: "full" shows a
spinner which covers the output component area as well as a runtime display in
the upper right corner, "minimal" only shows the runtime display, "hidden"
shows no progress animation at ... | Event Listeners | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
ict[str, Any] | list[dict[str, Any]] | None
default `= None`
A list of other events to cancel when this listener is triggered. For example,
setting cancels=[click_event] will cancel the click_event, where click_event
is the return value of another components .click method. Functions that have
not yet run (or generato... | Event Listeners | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
undocumented']
default `= "public"`
controls the visibility and accessibility of this endpoint. Can be "public"
(shown in API docs and callable by clients), "private" (hidden from API docs
and not callable by the Gradio client libraries), or "undocumented" (hidden
from API docs but callable by clients and via gr.load... | Event Listeners | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
Helper Classes | https://gradio.app/docs/gradio/video | Gradio - Video Docs | |
gradio.WebcamOptions(···)
Description
A dataclass for specifying options for the webcam tool in the ImageEditor
component. An instance of this class can be passed to the `webcam_options`
parameter of `gr.ImageEditor`.
Initialization
Parameters ▼
mirror: bool
default `= True`
If True, the webcam wi... | Webcam Options | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
Validates that the audio length is within the specified min and max length (in
seconds). You can use this to construct a validator that will check if the
user-provided audio is either too short or too long.
import gradio as gr
demo = gr.Interface(
lambda x: x,
inputs="video",
... | is_video_correct_length | https://gradio.app/docs/gradio/video | Gradio - Video Docs |
A base class for defining methods that all input/output components should
have.
| Description | https://gradio.app/docs/gradio/state | Gradio - State Docs |
**Using State as an input component.**
How State will pass its value to your function:
Type: `Any`
Passes a value of arbitrary type through.
Example Code
import gradio as gr
def predict(
value: Any
):
process value from the State component
... | Behavior | https://gradio.app/docs/gradio/state | Gradio - State Docs |
Parameters ▼
value: Any
default `= None`
the initial value (of arbitrary type) of the state. The provided argument is
deepcopied. If a callable is provided, the function will be called whenever
the app loads to set the initial value of the state.
render: bool
default `= True`
should ... | Initialization | https://gradio.app/docs/gradio/state | Gradio - State Docs |
Description
Event listeners allow you to respond to user interactions with the UI
components you've defined in a Gradio Blocks app. When a user interacts with
an element, such as changing a slider value or uploading an image, a function
is called.
Supported Event Listeners
The State component supports the following ... | Event Listeners | https://gradio.app/docs/gradio/state | Gradio - State Docs |
e API docs. Can be a string or None. If
set to a string, the endpoint will be exposed in the API docs with the given
name. If None (default), the name of the function will be used as the API
endpoint.
api_description: str | None | Literal[False]
default `= None`
Description of the API endpoint. Can be... | Event Listeners | https://gradio.app/docs/gradio/state | Gradio - State Docs |
. The function is then
*required* to return a tuple of lists (even if there is only 1 output
component), with each list in the tuple corresponding to one output component.
max_batch_size: int
default `= 4`
Maximum number of inputs to batch together if this is called from the queue
(only relevant if ba... | Event Listeners | https://gradio.app/docs/gradio/state | Gradio - State Docs |
for output components.
concurrency_limit: int | None | Literal['default']
default `= "default"`
If set, this is the maximum number of this event that can be running
simultaneously. Can be set to None to mean no concurrency_limit (any number of
this event can be running simultaneously). Set to "default... | Event Listeners | https://gradio.app/docs/gradio/state | Gradio - State Docs |
should return a
`gr.validate()` for each input value.
| Event Listeners | https://gradio.app/docs/gradio/state | Gradio - State Docs |
This function allows you to pass custom warning messages to the user. You
can do so simply by writing `gr.Warning('message here')` in your function, and
when that line is executed the custom message will appear in a modal on the
demo. The modal is yellow by default and has the heading: "Warning." Queue
must be enabled ... | Description | https://gradio.app/docs/gradio/warning | Gradio - Warning Docs |
import gradio as gr
def hello_world():
gr.Warning('This is a warning message.')
return "hello world"
with gr.Blocks() as demo:
md = gr.Markdown()
demo.load(hello_world, inputs=None, outputs=[md])
demo.queue().launch()
| Example Usage | https://gradio.app/docs/gradio/warning | Gradio - Warning Docs |
Parameters ▼
message: str
default `= "Warning issued."`
The warning message to be displayed to the user. Can be HTML, which will be
rendered in the modal.
duration: float | None
default `= 10`
The duration in seconds that the warning message should be displayed for. If
None or 0, the... | Initialization | https://gradio.app/docs/gradio/warning | Gradio - Warning Docs |
blocks_chained_events
[Alerts](../../guides/alerts)
| Demos | https://gradio.app/docs/gradio/warning | Gradio - Warning Docs |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.