balthou commited on
Commit
88a0677
Β·
1 Parent(s): 21848e9

add headless animation

Browse files
Files changed (2) hide show
  1. animation.gif +3 -0
  2. tutorial.md +38 -2
animation.gif ADDED

Git LFS Details

  • SHA256: 8ae6dd947a68882ac0ad5f582f84be88e1bacdde06dd26217b3427d51c91499a
  • Pointer size: 131 Bytes
  • Size of remote file: 269 kB
tutorial.md CHANGED
@@ -1,5 +1,5 @@
1
 
2
- # ⏯ [`interactive_pipe` website](https://balthazarneveu.github.io/interactive_pipe/)
3
 
4
  ![](https://balthazarneveu.github.io/interactive_pipe/static/interact-pipe-logo-horizontal-rgb.svg)
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't be re-used somewhere else.
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
  | ![Pipeline](https://huggingface.co/spaces/balthou/interactive-pipe-tutorial/resolve/main/pipeline.png) |
 
1
 
2
+ # ⏯ [interactive pipe website](https://balthazarneveu.github.io/interactive_pipe/)
3
 
4
  ![](https://balthazarneveu.github.io/interactive_pipe/static/interact-pipe-logo-horizontal-rgb.svg)
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
+ ![animation](https://huggingface.co/spaces/balthou/interactive-pipe-tutorial/resolve/main/animation.gif)
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
  | ![Pipeline](https://huggingface.co/spaces/balthou/interactive-pipe-tutorial/resolve/main/pipeline.png) |