Custom Components GalleryNEW
ExploreCustom Components GalleryNEW
ExploreNew to Gradio? Start here: Getting Started
See the Release History
To install Gradio from main, run the following command:
pip install https://gradio-builds.s3.amazonaws.com/4a3ee6fafe8ba9ecf1d5c103002766db14c569f4/gradio-4.31.4-py3-none-any.whl
*Note: Setting share=True
in
launch()
will not work.
gradio.State(ยทยทยท)
As input component: Passes a value of arbitrary type through.
Your function should accept one of these types:
def predict(
value: Any
)
...
As output component: Expects a value of arbitrary type, as long as it can be deepcopied.
Your function should return one of these types:
def predict(ยทยทยท) -> Any
...
return value
Parameter | Description |
---|---|
value Any default: None | the initial value (of arbitrary type) of the state. The provided argument is deepcopied. If a callable is provided, the function will be called whenever the app loads to set the initial value of the state. |
render bool default: True | has no effect, but is included for consistency with other components. |
time_to_live int | float | None default: None | The number of seconds the state should be stored for after it is created or updated. If None, the state will be stored indefinitely. Gradio automatically deletes state variables after a user closes the browser tab or refreshes the page, so this is useful for clearing state for potentially long running sessions. |
delete_callback Callable[[Any], None] | None default: None | A function that is called when the state is deleted. The function should take the state value as an argument. |