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

update tutorial (fix image compression issues on gradio with interactive pipe)

Browse files
Files changed (3) hide show
  1. core.py +15 -1
  2. requirements.txt +1 -1
  3. tutorial.md +0 -1
core.py CHANGED
@@ -68,6 +68,19 @@ def extract_profile(img: np.ndarray, context={}) -> Curve:
68
  title=f"Luminance profiles\n(global context parameter {init_shared_param})"
69
  )
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  # -------------------
72
  # Pipeline definition
73
  # -------------------
@@ -79,7 +92,8 @@ def tutorial_pipeline():
79
  out_bnw = change_color(inp)
80
  out_image = compare_by_splitting(out_geometry, out_bnw)
81
  out_profile = extract_profile(out_image)
82
- return [[inp, out_geometry], [out_profile, out_image]]
 
83
 
84
  # -----------------------------------------------------------------------------------------
85
  # Other layout you can try! None will create an empty space.
 
68
  title=f"Luminance profiles\n(global context parameter {init_shared_param})"
69
  )
70
 
71
+
72
+ def create_audio(img, context={}):
73
+ audio_length_seconds = 0.5
74
+ time_axis = np.linspace(0, audio_length_seconds,
75
+ int(audio_length_seconds*44100))
76
+ modulation = np.interp(time_axis, np.linspace(
77
+ 0., 1., img.shape[0]), img[:, 0, 0])
78
+ frequency = 440 * (1 + context.get('freq', 0)/100.)
79
+ audio_1 = (np.sin(2 * np.pi * frequency * time_axis))
80
+ audio_2 = (modulation*np.sin(2 * np.pi * 300 * time_axis))
81
+ return audio_1, audio_2
82
+
83
+
84
  # -------------------
85
  # Pipeline definition
86
  # -------------------
 
92
  out_bnw = change_color(inp)
93
  out_image = compare_by_splitting(out_geometry, out_bnw)
94
  out_profile = extract_profile(out_image)
95
+ audio_1, audio_2 = create_audio(out_image)
96
+ return [[inp, out_geometry], [out_profile, out_image], [audio_1, audio_2]]
97
 
98
  # -----------------------------------------------------------------------------------------
99
  # Other layout you can try! None will create an empty space.
requirements.txt CHANGED
@@ -1 +1 @@
1
- interactive-pipe>=0.7.6
 
1
+ interactive-pipe>=0.7.9
tutorial.md CHANGED
@@ -119,7 +119,6 @@ headless_tutorial_pipeline.graph_representation()
119
  | Shareable | βž– No, only 1 local Qt Window | βž• Share a link with others, (βž• Optional: standalone hosting on HF spaces πŸ€— ) |
120
  | Keyboard controls | βž• Yes | βž– No |
121
  | Full screen | βž• Yes | βž– No |
122
- | Image compression | βž• No image compression | βž– Some image compression |
123
 
124
 
125
  | πŸš€ `Qt` | 🐒 `Gradio` |
 
119
  | Shareable | βž– No, only 1 local Qt Window | βž• Share a link with others, (βž• Optional: standalone hosting on HF spaces πŸ€— ) |
120
  | Keyboard controls | βž• Yes | βž– No |
121
  | Full screen | βž• Yes | βž– No |
 
122
 
123
 
124
  | πŸš€ `Qt` | 🐒 `Gradio` |