Spaces:
Sleeping
Sleeping
| 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") | |