File size: 1,689 Bytes
4f6789c
7bb018c
 
169b2fd
4f6789c
 
 
169b2fd
4f6789c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169b2fd
 
 
 
4f6789c
 
 
 
3187496
 
 
 
4f6789c
 
169b2fd
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from interactive_pipe import interactive_pipeline, interactive
from core import (gen_color, modify_geometry, change_color,
                  compare_by_splitting, tutorial_pipeline)
import argparse
# --------------------------------------------------------------


def add_interactivity() -> None:
    # Depending on the level of control you want,
    # you can add more or less controls to the pipeline
    interactive(
        ratio=(0.5, [0., 1.], "Side by Side comparison")
    )(compare_by_splitting)
    interactive(
        bnw=(True, "Black and White")
    )(change_color)
    interactive(
        effect=("flip", ["flip", "mirror", "flip+mirror", "identity"])
    )(modify_geometry)
    interactive(
        frequency=(80, [1, 100]),
        isotropy=(0.8, [0.1, 1.])
    )(gen_color)


def run_interactive_pipeline(
    backend: str = "gradio",
    markdown_description: str = "# Tuto"
) -> None:
    add_interactivity()
    playable_tutorial_pipeline = interactive_pipeline(
        gui=backend,
        cache=True,
        markdown_description=markdown_description,
        context={"initialized_param": 42}
        # context is shared between processing blocks.
        # Initialization allow to pre-load a neural network for example.
    )(tutorial_pipeline)
    playable_tutorial_pipeline()


if __name__ == "__main__":
    BACKEND_OPTIONS = ["gradio", "qt"]
    parser = argparse.ArgumentParser()
    parser.add_argument("-b", "--backend", type=str,
                        choices=BACKEND_OPTIONS, default=BACKEND_OPTIONS[0])
    args = parser.parse_args()
    run_interactive_pipeline(backend=args.backend,
                             markdown_description="# Tutorial")