MCPcopy
hub / github.com/TheLastBen/fast-stable-diffusion / load

Method load

Dreambooth/blocks.py:1066–1124  ·  view source on GitHub ↗

For reverse compatibility reasons, this is both a class method and an instance method, the two of which, confusingly, do two completely different things. Class method: loads a demo from a Hugging Face Spaces repo and creates it locally and returns a block instance. Equival

(
        self_or_cls,
        fn: Optional[Callable] = None,
        inputs: Optional[List[Component]] = None,
        outputs: Optional[List[Component]] = None,
        *,
        name: Optional[str] = None,
        src: Optional[str] = None,
        api_key: Optional[str] = None,
        alias: Optional[str] = None,
        _js: Optional[str] = None,
        every: None | int = None,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

1064
1065 @class_or_instancemethod
1066 def load(
1067 self_or_cls,
1068 fn: Optional[Callable] = None,
1069 inputs: Optional[List[Component]] = None,
1070 outputs: Optional[List[Component]] = None,
1071 *,
1072 name: Optional[str] = None,
1073 src: Optional[str] = None,
1074 api_key: Optional[str] = None,
1075 alias: Optional[str] = None,
1076 _js: Optional[str] = None,
1077 every: None | int = None,
1078 **kwargs,
1079 ) -> Blocks | Dict[str, Any] | None:
1080 """
1081 For reverse compatibility reasons, this is both a class method and an instance
1082 method, the two of which, confusingly, do two completely different things.
1083
1084
1085 Class method: loads a demo from a Hugging Face Spaces repo and creates it locally and returns a block instance. Equivalent to gradio.Interface.load()
1086
1087
1088 Instance method: adds event that runs as soon as the demo loads in the browser. Example usage below.
1089 Parameters:
1090 name: Class Method - the 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")
1091 src: Class Method - the source of the model: `models` or `spaces` (or leave empty if source is provided as a prefix in `name`)
1092 api_key: Class Method - optional access token for loading private Hugging Face Hub models or spaces. Find your token here: https://huggingface.co/settings/tokens
1093 alias: Class Method - optional string used as the name of the loaded model instead of the default name (only applies if loading a Space running Gradio 2.x)
1094 fn: Instance Method - Callable function
1095 inputs: Instance Method - input list
1096 outputs: Instance Method - output list
1097 every: Instance Method - Run this event 'every' number of seconds. Interpreted in seconds. Queue must be enabled.
1098 Example:
1099 import gradio as gr
1100 import datetime
1101 with gr.Blocks() as demo:
1102 def get_time():
1103 return datetime.datetime.now().time()
1104 dt = gr.Textbox(label="Current time")
1105 demo.load(get_time, inputs=None, outputs=dt)
1106 demo.launch()
1107 """
1108 # _js: Optional frontend js method to run before running 'fn'. Input arguments for js method are values of 'inputs' and 'outputs', return should be a list of values for output components.
1109 if isinstance(self_or_cls, type):
1110 if name is None:
1111 raise ValueError(
1112 "Blocks.load() requires passing parameters as keyword arguments"
1113 )
1114 return external.load_blocks_from_repo(name, src, api_key, alias, **kwargs)
1115 else:
1116 return self_or_cls.set_event_trigger(
1117 event_name="load",
1118 fn=fn,
1119 inputs=inputs,
1120 outputs=outputs,
1121 js=_js,
1122 no_target=True,
1123 every=every,

Calls 1

set_event_triggerMethod · 0.45

Tested by

no test coverage detected