text stringlengths 0 2k | heading1 stringlengths 3 79 | source_page_url stringclasses 189
values | source_page_title stringclasses 189
values |
|---|---|---|---|
request on the queue, if the queue has been enabled.
If False, will not put this event on the queue, even if the queue has been
enabled. If None, will use the queue setting of the gradio app.
batch: bool
default `= False`
If True, then the function should process a batch of inputs, meaning that it
sh... | Event Listeners | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
event is pending. If set to "multiple", unlimited
submissions are allowed while pending, and "always_last" (default for
`.change()` and `.key_up()` events) would allow a second submission after the
pending event is complete.
js: str | Literal[True] | None
default `= None`
Optional frontend js method t... | Event Listeners | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
be used in @gr.render(). If set, this
value identifies an event as identical across re-renders when the key is
identical.
validator: Callable | None
default `= None`
Optional validation function to run before the main function. If provided,
this function will be executed first with queue=False, and on... | Event Listeners | https://gradio.app/docs/gradio/scatterplot | Gradio - Scatterplot Docs |
Group is a layout element within Blocks which groups together children so
that they do not have any padding or margin between them.
| Description | https://gradio.app/docs/gradio/group | Gradio - Group Docs |
with gr.Group():
gr.Textbox(label="First")
gr.Textbox(label="Last")
| Example Usage | https://gradio.app/docs/gradio/group | Gradio - Group Docs |
Parameters ▼
visible: bool | Literal['hidden']
default `= True`
If False, group will be hidden.
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_classes: li... | Initialization | https://gradio.app/docs/gradio/group | Gradio - Group Docs |
Walkthrough is a layout element within Blocks that can contain multiple
"Step" Components, which can be used to create a step-by-step workflow.
| Description | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
with gr.Walkthrough(selected=1) as walkthrough:
with gr.Step("Step 1", id=1):
btn = gr.Button("go to Step 2")
btn.click(lambda: gr.Walkthrough(selected=2), outputs=walkthrough)
with gr.Step("Step 2", id=2):
txt = gr.Textbox("Welcome to Step 2")
| Example Usage | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
Parameters ▼
selected: int | None
default `= None`
The currently selected step. Must be a number corresponding to the step
number. Defaults to the first step.
visible: bool
default `= True`
If False, Walkthrough will be hidden.
elem_id: str | None
default `= None`
A... | Initialization | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
walkthrough
| Demos | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
Methods | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs | |
%20Copyright%202022%20Fonticons,%20Inc.... | change | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough 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.... | change | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
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
input component, and the function should return a single value or a tuple of
valu... | change | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
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 all
show_progress_on: Component | list[Component] | None
default `= N... | change | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
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 generators that are iterating) will be cancelled, but
functions that are currently running wil... | change | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
s 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). If fn is None,
api_visibility will automatically be set to "private".
... | change | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough 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.... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
rs ▼
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
input component, and the function should return a single value or a tuple o... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
gress 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 all
show_progress_on: Component | list[Component] | None
defaul... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
vents 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 generators that are iterating) will be cancelled, but
functions that are currently runni... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
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). If fn is None,
api_visibility will automatically be set to "private".
... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
tring that is assigned as the id of the <div> containing the
contents of the Step layout. The same string followed by "-button" is attached
to the Step button. Can be used for targeting CSS styles.
elem_classes: list[str] | str | None
default `= None`
An optional string or list of strings that are ass... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough 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/walkthrough | Gradio - Walkthrough Docs |
lable | 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 ... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
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 all
show_progress_on: Component | list[Component] | None
default `= None`
Component or lis... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
stener 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/walkthrough | Gradio - Walkthrough Docs |
blic"
(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 | N... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | change | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough 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.... | change | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
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
input component, and the function should return a single value or a tuple of
valu... | change | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
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 all
show_progress_on: Component | list[Component] | None
default `= N... | change | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
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 generators that are iterating) will be cancelled, but
functions that are currently running wil... | change | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
s 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). If fn is None,
api_visibility will automatically be set to "private".
... | change | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough 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.... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
rs ▼
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
input component, and the function should return a single value or a tuple o... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
gress 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 all
show_progress_on: Component | list[Component] | None
defaul... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
vents 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 generators that are iterating) will be cancelled, but
functions that are currently runni... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
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). If fn is None,
api_visibility will automatically be set to "private".
... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough 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/walkthrough | Gradio - Walkthrough Docs |
lable | 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 ... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
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 all
show_progress_on: Component | list[Component] | None
default `= None`
Component or lis... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
stener 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/walkthrough | Gradio - Walkthrough Docs |
blic"
(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 | N... | select | https://gradio.app/docs/gradio/walkthrough | Gradio - Walkthrough Docs |
Server is the Gradio API engine exposed on a FastAPI application (Server
mode). It inherits from FastAPI, so all standard FastAPI methods (.get(),
.post(), .add_middleware(), .include_router(), etc.) work directly on this
instance.
New methods added on top of FastAPI: api(): Decorator to register a Gradio API
endpoin... | Description | https://gradio.app/docs/gradio/server | Gradio - Server Docs |
from gradio import Server
app = Server()
@app.api(name="hello")
def hello(name: str) -> str:
return f"Hello {name}"
@app.get("/")
def root():
return {"message": "Hello World"}
app.launch()
| Example Usage | https://gradio.app/docs/gradio/server | Gradio - Server Docs |
Parameters ▼
debug: bool
default `= False`
Enable debug mode for detailed error tracebacks.
title: str
default `= "FastAPI"`
The title of the API, shown in the OpenAPI docs.
summary: str | None
default `= None`
A short summary of the API.
description... | Initialization | https://gradio.app/docs/gradio/server | Gradio - Server Docs |
ault `= None`
An async context manager for startup/shutdown lifecycle.
terms_of_service: str | None
default `= None`
URL to the terms of service.
contact: dict[str, Any] | None
default `= None`
Contact information dict for the API.
license_info: dict[str, Any] | None... | Initialization | https://gradio.app/docs/gradio/server | Gradio - Server Docs |
server_app
| Demos | https://gradio.app/docs/gradio/server | Gradio - Server Docs |
Methods | https://gradio.app/docs/gradio/server | Gradio - Server Docs | |
%20Copyright%202022%20Fonticons,%20Inc.... | api | https://gradio.app/docs/gradio/server | Gradio - Server 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.... | api | https://gradio.app/docs/gradio/server | Gradio - Server Docs |
None`
concurrency_limit: int | None | Literal['default']
default `= "default"`
concurrency_id: str | None
default `= None`
queue: bool
default `= True`
batch: bool
default `= False`
max_batch_size: int
default `= 4`
api... | api | https://gradio.app/docs/gradio/server | Gradio - Server Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | launch | https://gradio.app/docs/gradio/server | Gradio - Server 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/server | Gradio - Server Docs |
debug: bool
default `= False`
max_threads: int
default `= 40`
auth: Callable[[str, str], bool] | tuple[str, str] | list[tuple[str, str]] | None
default `= None`
auth_message: str | None
default `= None`
prevent_thread_lock: bool
default... | launch | https://gradio.app/docs/gradio/server | Gradio - Server Docs |
itoring: bool | None
default `= None`
strict_cors: bool
default `= True`
node_server_name: str | None
default `= None`
node_port: int | None
default `= None`
ssr_mode: bool | None
default `= None`
pwa: bool | None
default `= None`
... | launch | https://gradio.app/docs/gradio/server | Gradio - Server Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | api | https://gradio.app/docs/gradio/server | Gradio - Server 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.... | api | https://gradio.app/docs/gradio/server | Gradio - Server Docs |
None`
concurrency_limit: int | None | Literal['default']
default `= "default"`
concurrency_id: str | None
default `= None`
queue: bool
default `= True`
batch: bool
default `= False`
max_batch_size: int
default `= 4`
api... | api | https://gradio.app/docs/gradio/server | Gradio - Server Docs |
%20Copyright%202022%20Fonticons,%20Inc.... | launch | https://gradio.app/docs/gradio/server | Gradio - Server 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/server | Gradio - Server Docs |
debug: bool
default `= False`
max_threads: int
default `= 40`
auth: Callable[[str, str], bool] | tuple[str, str] | list[tuple[str, str]] | None
default `= None`
auth_message: str | None
default `= None`
prevent_thread_lock: bool
default... | launch | https://gradio.app/docs/gradio/server | Gradio - Server Docs |
itoring: bool | None
default `= None`
strict_cors: bool
default `= True`
node_server_name: str | None
default `= None`
node_port: int | None
default `= None`
ssr_mode: bool | None
default `= None`
pwa: bool | None
default `= None`
... | launch | https://gradio.app/docs/gradio/server | Gradio - Server Docs |
Creates an image component that can be used to upload images (as an input)
or display images (as an output).
| Description | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
**Using Image as an input component.**
How Image will pass its value to your function:
Type: `np.ndarray | PIL.Image.Image | str | None`
Passes the uploaded image as a `numpy.array`, `PIL.Image` or `str` filepath
depending on `type`.
Example Code
import gradio as gr
def pred... | Behavior | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
Parameters ▼
value: str | PIL.Image.Image | np.ndarray | Callable | None
default `= None`
A `PIL.Image`, `numpy.array`, `pathlib.Path`, or `str` filepath or URL for the
default value that Image component is going to take. If a function is
provided, the function will be called each time the app loads t... | Initialization | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
erred
from the image file type (e.g. "RGBA" for a .png image, "RGB" in most other
cases).
sources: list[Literal['upload', 'webcam', 'clipboard']] | Literal['upload', 'webcam', 'clipboard'] | None
default `= None`
List of sources for the image. "upload" creates a box where user can drop an
image file, ... | Initialization | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
o calculate `value` if `value` is a
function (has no effect otherwise). `value` is recalculated any time the
inputs change.
show_label: bool | None
default `= None`
if True, will display label.
buttons: list[Literal['download', 'share', 'fullscreen'] | Button] | None
default `= None`
... | Initialization | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
rovided, this is inferred based on whether the
component is used as an input or output.
visible: bool | Literal['hidden']
default `= True`
If False, component will be hidden. If "hidden", component will be visually
hidden and not take up space in the layout but still exist in the DOM
s... | Initialization | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
es
provided during constructor.
webcam_options: WebcamOptions | None
default `= None`
placeholder: str | None
default `= None`
Custom text for the upload area. Overrides default upload messages when
provided. Accepts new lines and `` to designate a heading.
watermark: ... | Initialization | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
Shortcuts
gradio.Image
Interface String Shortcut `"image"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
The `type` parameter controls the format of the data passed to your Python
function. Choosing the right type avoids unnecessary conversions in your code:
`type`| Your function receives| Shape / Format| Best for
---|---|---|---
`"numpy"` (default)| `numpy.ndarray`| `(height, width, 3)`, dtype `uint8`,
values 0–255|... | Understanding Image Types | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
The `gr.Image` component can process or display any image format that is
[supported by the PIL
library](https://pillow.readthedocs.io/en/stable/handbook/image-file-
formats.html), including animated GIFs. In addition, it also supports the SVG
image format.
When the `gr.Image` component is used as an input component, t... | `GIF` and `SVG` Image Formats | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
sepia_filterfake_diffusion
| Demos | https://gradio.app/docs/gradio/image | Gradio - Image 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 Image component supports the following ... | Event Listeners | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
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 | BlockContext] | None
default `= None`
List o... | Event Listeners | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
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: bool
default `= True`
If True, will place the r... | Event Listeners | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
n (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()`) would not allow any
submissions while an ev... | Event Listeners | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
nd 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 `= None`
A unique key for this event listener to be... | Event Listeners | https://gradio.app/docs/gradio/image | Gradio - Image Docs |
Helper Classes | https://gradio.app/docs/gradio/image | Gradio - Image 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/image | Gradio - Image Docs |
The gr.DownloadData class is a subclass of gr.EventData that specifically
carries information about the `.download()` event. When gr.DownloadData is
added as a type hint to an argument of an event listener method, a
gr.DownloadData object will automatically be passed as the value of that
argument. The attributes of thi... | Description | https://gradio.app/docs/gradio/downloaddata | Gradio - Downloaddata Docs |
import gradio as gr
def on_download(download_data: gr.DownloadData):
return f"Downloaded file: {download_data.file.path}"
with gr.Blocks() as demo:
files = gr.File()
textbox = gr.Textbox()
files.download(on_download, None, textbox)
demo.launch()
| Example Usage | https://gradio.app/docs/gradio/downloaddata | Gradio - Downloaddata Docs |
Parameters ▼
file: FileData
The file that was downloaded, as a FileData object.
| Attributes | https://gradio.app/docs/gradio/downloaddata | Gradio - Downloaddata Docs |
Mount a gradio.Blocks to an existing FastAPI application.
| Description | https://gradio.app/docs/gradio/mount_gradio_app | Gradio - Mount_Gradio_App Docs |
from fastapi import FastAPI
import gradio as gr
app = FastAPI()
@app.get("/")
def read_main():
return {"message": "This is your main app"}
io = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox")
app = gr.mount_gradio_app(app, io, path="/gradio")
Then run `uvicorn run:app`... | Example Usage | https://gradio.app/docs/gradio/mount_gradio_app | Gradio - Mount_Gradio_App Docs |
Parameters ▼
app: fastapi.FastAPI
The parent FastAPI application.
blocks: gradio.Blocks
The blocks object we want to mount to the parent app.
path: str
The path at which the gradio application will be mounted, e.g. "/gradio".
server_name: str
default `... | Initialization | https://gradio.app/docs/gradio/mount_gradio_app | Gradio - Mount_Gradio_App Docs |
ic request, that user is not
authorized to access the gradio app (they will see a 401 Unauthorized
response). To be used with external authentication systems like OAuth. Cannot
be used with `auth`.
root_path: str | None
default `= None`
The subpath corresponding to the public deployment of this FastAP... | Initialization | https://gradio.app/docs/gradio/mount_gradio_app | Gradio - Mount_Gradio_App Docs |
browser console log. Otherwise, errors will only be visible in
the terminal session running the Gradio app.
max_file_size: str | int | None
default `= None`
The maximum file size in bytes that can be uploaded. Can be a string of the
form "<value><unit>", where value is any positive integer and unit is... | Initialization | https://gradio.app/docs/gradio/mount_gradio_app | Gradio - Mount_Gradio_App Docs |
or will attempt to
load a theme from the Hugging Face Hub (e.g. "gradio/monochrome"). If None,
will use the Default theme.
css: str | None
default `= None`
Custom css as a code string. This css will be included in the demo webpage.
css_paths: str | Path | list[str | Path] | None
defa... | Initialization | https://gradio.app/docs/gradio/mount_gradio_app | Gradio - Mount_Gradio_App Docs |
Creates a "Sign In" button that redirects the user to sign in with Hugging
Face OAuth. Once the user is signed in, the button will act as a logout
button, and you can retrieve a signed-in user's profile by adding a parameter
of type `gr.OAuthProfile` to any Gradio function. This will only work if this
Gradio app is run... | Description | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
**Using LoginButton as an input component.**
How LoginButton will pass its value to your function:
Type: `str | None`
(Rarely used) the `str` corresponding to the button label when the button is
clicked
Example Code
import gradio as gr
def predict(
value: str | N... | Behavior | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
Parameters ▼
value: str
default `= "Sign in with Hugging Face"`
logout_value: str
default `= "Logout ({})"`
The text to display when the user is signed in. The string should contain a
placeholder for the username with a call-to-action to logout, e.g. "Logout
({})".
eve... | Initialization | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
Shortcuts
gradio.LoginButton
Interface String Shortcut `"loginbutton"`
Initialization Uses default values
| Shortcuts | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
login_with_huggingface
| Demos | https://gradio.app/docs/gradio/loginbutton | Gradio - Loginbutton Docs |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.