Spaces:
Sleeping
Sleeping
add headless animation
Browse files- animation.gif +3 -0
- tutorial.md +38 -2
animation.gif
ADDED
|
Git LFS Details
|
tutorial.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
|
| 2 |
-
# β― [
|
| 3 |
|
| 4 |

|
| 5 |
|
|
@@ -8,6 +8,35 @@
|
|
| 8 |
|
| 9 |
**Note** : The same tutorial is also available on [Google Colab](https://colab.research.google.com/github/livalgo/interactive-pipe-examples/blob/main/interactive_pipe_tutorial.ipynb) to learn about the Jupyter notebook backend.
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
# Advice
|
| 12 |
|
| 13 |
|
|
@@ -20,7 +49,7 @@
|
|
| 20 |
|
| 21 |
#### 1.Decorate afterward π *= Recommended approach*
|
| 22 |
- β Less elegant to read (`add_interactivity` may be in a different file)
|
| 23 |
-
- β The decorated function can
|
| 24 |
- β Possibility to add conditions (`debug` flag)
|
| 25 |
|
| 26 |
```python
|
|
@@ -68,6 +97,13 @@ def gen_color(
|
|
| 68 |
## Pipeline visualization
|
| 69 |
|
| 70 |
Internally, `interactive_pipe` builds an execution graph of the pipeline.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
| pipeline's execution graph |
|
| 72 |
| :--:|
|
| 73 |
|  |
|
|
|
|
| 1 |
|
| 2 |
+
# β― [interactive pipe website](https://balthazarneveu.github.io/interactive_pipe/)
|
| 3 |
|
| 4 |

|
| 5 |
|
|
|
|
| 8 |
|
| 9 |
**Note** : The same tutorial is also available on [Google Colab](https://colab.research.google.com/github/livalgo/interactive-pipe-examples/blob/main/interactive_pipe_tutorial.ipynb) to learn about the Jupyter notebook backend.
|
| 10 |
|
| 11 |
+
# Analyzing the headless pipeline
|
| 12 |
+
|
| 13 |
+
```python
|
| 14 |
+
headless_tutorial_pipeline = interactive_pipeline(gui=None)(tutorial_pipeline)
|
| 15 |
+
# gui=None allows retuning a HeadlessPipeline instance.
|
| 16 |
+
headless_tutorial_pipeline.graph_representation("__tuto_pipeline")
|
| 17 |
+
```
|
| 18 |
+
Let's now call the pipeline several times with varying parameters.
|
| 19 |
+
|
| 20 |
+
π We provide a basic code sample to generate the gif animation.
|
| 21 |
+
|
| 22 |
+
```python
|
| 23 |
+
from PIL import Image as PILImage
|
| 24 |
+
img_list = []
|
| 25 |
+
for freq in np.linspace(1, 100, 10):
|
| 26 |
+
# Let's first override some of the default parameters.
|
| 27 |
+
headless_tutorial_pipeline.parameters = {
|
| 28 |
+
"gen_color": {"frequency": freq, 'isotropy': freq/100.},
|
| 29 |
+
"compare_by_splitting": {"ratio": freq/100.}}
|
| 30 |
+
# Let's execute
|
| 31 |
+
headless_tutorial_pipeline()
|
| 32 |
+
img = (255.*headless_tutorial_pipeline.results[1][1]).astype(np.uint8)
|
| 33 |
+
img_list.append(PILImage.fromarray(img))
|
| 34 |
+
|
| 35 |
+
img_list[0].save("animation.gif", save_all=True, append_images=img_list[1:], duration=1, loop=1000)
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+

|
| 39 |
+
|
| 40 |
# Advice
|
| 41 |
|
| 42 |
|
|
|
|
| 49 |
|
| 50 |
#### 1.Decorate afterward π *= Recommended approach*
|
| 51 |
- β Less elegant to read (`add_interactivity` may be in a different file)
|
| 52 |
+
- β The decorated function can be re-used somewhere else (before being decorated).
|
| 53 |
- β Possibility to add conditions (`debug` flag)
|
| 54 |
|
| 55 |
```python
|
|
|
|
| 97 |
## Pipeline visualization
|
| 98 |
|
| 99 |
Internally, `interactive_pipe` builds an execution graph of the pipeline.
|
| 100 |
+
- If you're using the `qt` backend, press `G` to build the graph.
|
| 101 |
+
- If you're in a notebook, it's possible to easily plot the graph.
|
| 102 |
+
```python
|
| 103 |
+
headless_tutorial_pipeline = interactive_pipeline(gui=None)(tutorial_pipeline)
|
| 104 |
+
headless_tutorial_pipeline.graph_representation()
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
| pipeline's execution graph |
|
| 108 |
| :--:|
|
| 109 |
|  |
|