Constructor
Parameters
Callable
required
The function to wrap an interface around. 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 the tuple corresponding to one output component.
str | Component | Sequence[str | Component] | None
required
A single Gradio component, or list of Gradio components. Components can either be passed as instantiated objects, or referred to by their string shortcuts. The number of input components should match the number of parameters in fn. If set to None, then only the output components will be displayed.
str | Component | Sequence[str | Component] | None
required
A single Gradio component, or list of Gradio components. Components can either be passed as instantiated objects, or referred to by their string shortcuts. The number of output components should match the number of values returned by fn. If set to None, then only the input components will be displayed.
list[Any] | list[list[Any]] | str | None
default:"None"
Sample inputs for the function; if provided, appear below the UI components and can be clicked to populate the interface. 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.
bool | None
default:"None"
If True, caches examples in the server for fast runtime in examples. If “lazy”, then examples are cached (for all users of the app) after their first use. Note that examples are cached separately from Gradio’s queue() so certain features will not be displayed in Gradio’s UI for cached examples.
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"
If examples are provided, how many to display per page.
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, and these labels will be used in the UI instead of rendering the example values.
int | Literal[False]
default:"0"
If an integer is provided, the example at that index in the examples list will be preloaded when the Gradio app is first loaded. If False, no example will be preloaded.
bool
default:"False"
Whether the interface should automatically rerun if any of the inputs change.
str | I18nData | None
default:"None"
A title for the interface; if provided, appears above the input and output components in large font. Also used as the tab title when opened in a browser window.
str | None
default:"None"
A description for the interface; if provided, appears above the input and output components and beneath the title. Accepts Markdown and HTML content.
str | None
default:"None"
An expanded article explaining the interface; if provided, appears below the input and output components. Accepts Markdown and HTML content.
Literal['never', 'auto', 'manual'] | None
default:"None"
One of “never”, “auto”, or “manual”. If “never” or “auto”, users will not see a button to flag an input and output. If “manual”, users will see a button to flag. If “auto”, every input the user submits will be automatically flagged.
list[str] | list[tuple[str, str]] | None
default:"None"
If provided, allows user to select from the list of options when flagging.
str
default:"'.gradio/flagged'"
Path to the directory where flagged data is stored.
FlaggingCallback | None
default:"None"
Either None or an instance of a subclass of FlaggingCallback which will be called when a sample is flagged.
bool | None
default:"None"
Whether to allow basic telemetry. If None, will use GRADIO_ANALYTICS_ENABLED environment variable if defined, or default to True.
bool
default:"False"
If True, then the function should process a batch of inputs.
int
default:"4"
The maximum number of inputs to batch together if this is called from the queue.
Literal['public', 'private', 'undocumented']
default:"'public'"
Controls the visibility of the prediction endpoint. Can be “public” (shown in API docs and callable), “private” (hidden from API docs and not callable), or “undocumented” (hidden from API docs but callable).
str | None
default:"None"
Defines how the prediction endpoint appears in the API docs. Can be a string or None.
str | None | Literal[False]
default:"None"
Description of the API endpoint. Can be a string, None, or False.
bool
default:"False"
If True, then will show a ‘Duplicate Spaces’ button on Hugging Face Spaces.
int | None | Literal['default']
default:"'default'"
If set, this is the maximum number of this event that can be running simultaneously.
str | Component | Sequence[str | Component] | None
default:"None"
A single Gradio component, or list of Gradio components. These components will be rendered in an accordion below the main input components.
str | Button
default:"'Submit'"
The button to use for submitting inputs.
str | Button
default:"'Stop'"
The button to use for stopping the interface.
str | Button | None
default:"'Clear'"
The button to use for clearing the inputs.
tuple[int, int] | None
default:"None"
A tuple corresponding [frequency, age] both expressed in number of seconds.
Literal['full', 'minimal', 'hidden']
default:"'full'"
How to show the progress animation while event is running.
bool
default:"False"
Whether to horizontally expand to fill container fully.
int | None
default:"30"
The time limit for the stream to run. Default is 30 seconds.
float
default:"0.5"
The latency (in seconds) at which stream chunks are sent to the backend.
str | DeepLinkButton | bool | None
default:"None"
A string or gr.DeepLinkButton object that creates a unique URL you can use to share your app.
Callable | None
default:"None"
A function that takes in the inputs and can optionally return a gr.validate() object for each input.
Class Methods
from_pipeline
Pipeline | DiffusionPipeline
required
The pipeline object to use.
Interface
A Gradio Interface object from the given Pipeline.