Exemplo n.º 1
0
 def load(cls, name, src=None, api_key=None, alias=None, **kwargs):
     """
     Loads a model and Interface from an external source repo
     Parameters: 
     name (str): the name of the model (e.g. "gpt2"), can include the `src` as prefix (e.g. "huggingface/gpt2")
     src (str): the source of the model: `huggingface` or `gradio` (or empty if source is provided as a prefix in `name`)
     api_key (str): optional api key for use with Hugging Face Model Hub
     alias (str): optional, used as the name of the loaded model instead of the default name
     Returns:
     (Interface): an Interface object for the given model
     """
     interface_info = load_interface(name, src, api_key, alias)
     interface_info.update(kwargs)
     return cls(**interface_info)
Exemplo n.º 2
0
 def load(cls, name, src=None, api_key=None, alias=None, **kwargs):
     """
     Class method to construct an Interface from an external source repository, such as huggingface.
     Parameters: 
     name (str): the name of the model (e.g. "gpt2"), can include the `src` as prefix (e.g. "huggingface/gpt2")
     src (str): the source of the model: `huggingface` or `gradio` (or empty if source is provided as a prefix in `name`)
     api_key (str): optional api key for use with Hugging Face Model Hub
     alias (str): optional, used as the name of the loaded model instead of the default name
     Returns:
     (gradio.Interface): a Gradio Interface object for the given model
     """
     interface_info = load_interface(name, src, api_key, alias)
     # create a dictionary of kwargs without overwriting the original interface_info dict because it is mutable
     # and that can cause some issues since the internal prediction function may rely on the original interface_info dict
     kwargs = dict(interface_info, **kwargs)
     return cls(**kwargs)
Exemplo n.º 3
0
 def load(
     cls,
     name: str,
     src: Optional[str] = None,
     api_key: Optional[str] = None,
     alias: Optional[str] = None,
     **kwargs,
 ) -> Interface:
     """
     Class method to construct an Interface from an external source repository, such as huggingface.
     Parameters:
     name (str): the name of the model (e.g. "gpt2"), can include the `src` as prefix (e.g. "huggingface/gpt2")
     src (str): the source of the model: `huggingface` or `gradio` (or empty if source is provided as a prefix in `name`)
     api_key (str): optional api key for use with Hugging Face Model Hub
     alias (str): optional, used as the name of the loaded model instead of the default name
     Returns:
     (gradio.Interface): a Gradio Interface object for the given model
     """
     interface_info = load_interface(name, src, api_key, alias)
     kwargs = dict(interface_info, **kwargs)
     interface = cls(**kwargs)
     interface.api_mode = True  # So interface doesn't run pre/postprocess.
     return interface