mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-21 01:01:05 +08:00
Updates the documentation to better describe Blocks.load()
(#2413)
* updated doc * removed link change * revert changes to inner html * changelog * tweaks * formatting
This commit is contained in:
parent
da93f4f004
commit
1dd4d34933
@ -23,6 +23,7 @@ No changes to highlight.
|
||||
* Speeds up Gallery component by using temporary files instead of base64 representation in the front-end by [@proxyphi](https://github.com/proxyphi), [@pngwn](https://github.com/pngwn), and [@abidlabs](https://github.com/abidlabs) in [PR 2265](https://github.com/gradio-app/gradio/pull/2265)
|
||||
* Fixed some embedded demos in the guides by not loading the gradio web component in some guides by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2403](https://github.com/gradio-app/gradio/pull/2403)
|
||||
* When an `Image` component is set to `source="upload"`, it is now possible to drag and drop and image to replace a previously uploaded image by [@pngwn](https://github.com/pngwn) in [PR 2400](https://github.com/gradio-app/gradio/pull/2410)
|
||||
* Improve documentation of the `Blocks.load()` event by [@abidlabs](https://github.com/abidlabs) in [PR 2413](https://github.com/gradio-app/gradio/pull/2413)
|
||||
* Decreased latency in iterative-output demos by making the iteration asynchronous [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2409](https://github.com/gradio-app/gradio/pull/2409)
|
||||
|
||||
## Contributors Shoutout:
|
||||
|
@ -883,10 +883,10 @@ class Blocks(BlockContext):
|
||||
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.
|
||||
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()
|
||||
|
||||
|
||||
Instance method: adds an event for when the demo loads in the browser and returns None.
|
||||
Instance method: adds event that runs as soon as the demo loads in the browser. Example usage below.
|
||||
Parameters:
|
||||
name: Class Method - the name of the model (e.g. "gpt2"), can include the `src` as prefix (e.g. "models/gpt2")
|
||||
src: Class Method - the source of the model: `models` or `spaces` (or empty if source is provided as a prefix in `name`)
|
||||
@ -895,6 +895,15 @@ class Blocks(BlockContext):
|
||||
fn: Instance Method - Callable function
|
||||
inputs: Instance Method - input list
|
||||
outputs: Instance Method - output list
|
||||
Example:
|
||||
import gradio as gr
|
||||
import datetime
|
||||
with gr.Blocks() as demo:
|
||||
def get_time():
|
||||
return datetime.datetime.now().time()
|
||||
dt = gr.Textbox(label="Current time")
|
||||
demo.load(get_time, inputs=None, outputs=dt)
|
||||
demo.launch()
|
||||
"""
|
||||
# _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.
|
||||
if isinstance(self_or_cls, type):
|
||||
|
Loading…
Reference in New Issue
Block a user