balthou commited on
Commit
2815cec
·
1 Parent(s): 153d592

Support qt & gradio backends

Browse files
Files changed (1) hide show
  1. app.py +21 -14
app.py CHANGED
@@ -1,5 +1,6 @@
1
  from interactive_pipe import interactive_pipeline, interactive
2
  from interactive_pipe import Curve, SingleCurve
 
3
  import numpy as np
4
 
5
 
@@ -38,27 +39,33 @@ def profile(img):
38
  luma = img.mean(axis=-1)
39
  h_profile = SingleCurve(y=luma[0, :], label="H profile")
40
  v_profile = SingleCurve(y=luma[:, 0], label="V profile")
41
- return Curve([h_profile, v_profile], xlabel="Position", ylabel="Luminance")
 
 
 
 
42
 
43
 
44
- markdown_description = "# Code to build this app on gradio \n"
45
- markdown_description += "```python\n"+open(__file__, 'r').read()+"```"
46
-
47
-
48
- @ interactive_pipeline(
49
- gui="gradio",
50
- # gui="qt",
51
- cache=True,
52
- markdown_description=markdown_description
53
- )
54
- def simple_pipe():
55
  inp = gen_color()
56
  out_geometry = modify_geometry(inp)
57
  out_bnw = change_color(inp)
58
  out_image = split(out_geometry, out_bnw)
59
  out_profile = profile(out_image)
60
- return [inp, out_geometry, out_profile, out_image]
61
 
62
 
63
  if __name__ == "__main__":
64
- simple_pipe()
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from interactive_pipe import interactive_pipeline, interactive
2
  from interactive_pipe import Curve, SingleCurve
3
+ import argparse
4
  import numpy as np
5
 
6
 
 
39
  luma = img.mean(axis=-1)
40
  h_profile = SingleCurve(y=luma[0, :], label="H profile")
41
  v_profile = SingleCurve(y=luma[:, 0], label="V profile")
42
+ return Curve(
43
+ [h_profile, v_profile],
44
+ xlabel="Position", ylabel="Luminance",
45
+ grid=True
46
+ )
47
 
48
 
49
+ def tutorial_pipeline():
 
 
 
 
 
 
 
 
 
 
50
  inp = gen_color()
51
  out_geometry = modify_geometry(inp)
52
  out_bnw = change_color(inp)
53
  out_image = split(out_geometry, out_bnw)
54
  out_profile = profile(out_image)
55
+ return [[inp, out_geometry], [out_profile, out_image]]
56
 
57
 
58
  if __name__ == "__main__":
59
+ BACKEND_OPTIONS = ["gradio", "qt"]
60
+ parser = argparse.ArgumentParser()
61
+ parser.add_argument("-b", "--backend", type=str,
62
+ choices=BACKEND_OPTIONS, default=BACKEND_OPTIONS[0])
63
+ args = parser.parse_args()
64
+ markdown_description = "# Source code \n"
65
+ markdown_description += "```python\n"+open(__file__, 'r').read()+"```"
66
+ playable_tutorial_pipeline = interactive_pipeline(
67
+ gui=args.backend,
68
+ cache=True,
69
+ markdown_description=markdown_description
70
+ )(tutorial_pipeline)
71
+ playable_tutorial_pipeline()