Constructor
Parameters
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.
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.
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.
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.
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.
If “lazy”, examples are cached after their first use. If “eager”, all examples are cached at app launch.
If examples are provided, how many to display per page.
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.
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.
Whether the interface should automatically rerun if any of the inputs change.
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.
A description for the interface; if provided, appears above the input and output components and beneath the title. Accepts Markdown and HTML content.
An expanded article explaining the interface; if provided, appears below the input and output components. Accepts Markdown and HTML content.
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.
If provided, allows user to select from the list of options when flagging.
Path to the directory where flagged data is stored.
Either None or an instance of a subclass of FlaggingCallback which will be called when a sample is flagged.
Whether to allow basic telemetry. If None, will use GRADIO_ANALYTICS_ENABLED environment variable if defined, or default to True.
If True, then the function should process a batch of inputs.
The maximum number of inputs to batch together if this is called from the queue.
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).
Defines how the prediction endpoint appears in the API docs. Can be a string or None.
Description of the API endpoint. Can be a string, None, or False.
If True, then will show a ‘Duplicate Spaces’ button on Hugging Face Spaces.
If set, this is the maximum number of this event that can be running simultaneously.
A single Gradio component, or list of Gradio components. These components will be rendered in an accordion below the main input components.
The button to use for submitting inputs.
The button to use for stopping the interface.
The button to use for clearing the inputs.
A tuple corresponding [frequency, age] both expressed in number of seconds.
How to show the progress animation while event is running.
Whether to horizontally expand to fill container fully.
The time limit for the stream to run. Default is 30 seconds.
The latency (in seconds) at which stream chunks are sent to the backend.
A string or gr.DeepLinkButton object that creates a unique URL you can use to share your app.
A function that takes in the inputs and can optionally return a gr.validate() object for each input.
Class Methods
from_pipeline
The pipeline object to use.
A Gradio Interface object from the given Pipeline.