- Helpers
- load
New to Gradio? Start here: Getting Started
See the Release History
load
gradio.load(···)Description
Constructs a demo from a Hugging Face repo. Can accept model repos (if src is "models") or Space repos (if src is "spaces"). The input and output components are automatically loaded from the repo. Note that if a Space is loaded, certain high-level attributes of the Blocks (e.g. custom css, js, and head attributes) will not be loaded.
Example Usage
import gradio as gr
demo = gr.load("gradio/question-answering", src="spaces")
demo.launch()Initialization
Parameters
name: str
name: strthe name of the model (e.g. "gpt2" or "facebook/bart-base") or space (e.g. "flax-community/spanish-gpt2"), can include the `src` as prefix (e.g. "models/facebook/bart-base")
src: str | None
src: str | Nonedefault
= Nonethe source of the model: `models` or `spaces` (or leave empty if source is provided as a prefix in `name`)
hf_token: str | Literal[False] | None
hf_token: str | Literal[False] | Nonedefault
= Noneoptional access token for loading private Hugging Face Hub models or spaces. Will default to the locally saved token if not provided. Pass `token=False` if you don't want to send your token to the server. Find your token here: https://huggingface.co/settings/tokens. Warning: only provide a token if you are loading a trusted private Space as it can be read by the Space you are loading.