Spaces:
Sleeping
Sleeping
|
Download tutorial.md from balthou/interactive-pipe-tutorial: direct link, hf CLI and curl.
- Browser
- Download file 1.66 kB
-
https://huggingface.co/spaces/balthou/interactive-pipe-tutorial/resolve/74f19b4e4b4b9af2bd4d76a359d58aed486e460e/tutorial.md
- Command line
-
hf download hf://spaces/balthou/interactive-pipe-tutorial@74f19b4e4b4b9af2bd4d76a359d58aed486e460e/tutorial.md
-
curl -L -o tutorial.md https://huggingface.co/spaces/balthou/interactive-pipe-tutorial/resolve/74f19b4e4b4b9af2bd4d76a359d58aed486e460e/tutorial.md
1.66 kB
Tutorial
Keep separation between "production code" (library / not interactive) & interactivity
- π‘ One of the strength of interactive pipe is to avoid adding hundreds of lines of code dedicated to GUI (graphical user interfaces).
- With interactive pipe, you have the choice to keep this design choice. Each processing block can be defined as a regular function, without even importing the
interactivedecorator. In a separate file, you'll add sliders.
Several ways to decorate building blocks
1.Decorate afterward π = Recommended approach
- β Less elegant to read (
add_interactivitymay be in a different file) - β The decorated function can't be re-used somewhere else.
- β Possibility to add conditions (
debugflag)
def gen_color(frequency=0, isotropy=0.):
...
def add_interactivity(debug=True):
interactive(
frequency=(80, [1, 100]),
isotropy=(0.8, [0.1, 1.]) if debug else 0.8
)(gen_color)
2.Decorate using @
@interactive(
frequency=(80, [1, 100]),
isotropy=(0.8, [0.1, 1.])
)
def gen_color(frequency=0, isotropy=0.):
...
- β Easy to read
- β The decorated function can't be re-used somewhere else.
- β No possibility to add condition to hide/show slider. To hide the slider, you need to comment!
3. Shorter code using @
@interactive()
def gen_color(
frequency=(80, [1, 100]),
isotropy=(0.8, [0.1, 1.])
):
- β Shortest code
- β The decorated function can't be re-used somewhere else

