Spaces:
Sleeping
Sleeping
update tutorial (fix image compression issues on gradio with interactive pipe)
Browse files- core.py +15 -1
- requirements.txt +1 -1
- 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 |
-
|
|
|
|
| 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.
|
|
|
|
| 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` |
|