balthou commited on
Commit
4aa6781
·
1 Parent(s): 779f16c

Port to interactive_pipe 0.9.4 (context proxy) and gradio 6

Browse files

Fixes the runtime error on the Space (gradio 4.44 on Python 3.13:
ModuleNotFoundError: No module named 'pyaudioop').

- Filters use the `context` proxy instead of a `global_params={}` keyword
argument (removed in interactive_pipe 0.9.0)
- tone_map / modify_vibrance declare inplace=True: they modify their HSV
input in place and filter inputs are read-only since 0.9.1
- requirements.txt: pin interactive-pipe==0.9.4
- README.md: sdk_version 6.32.0 (current gradio), python_version 3.12

Files changed (3) hide show
  1. README.md +2 -1
  2. app.py +18 -19
  3. requirements.txt +1 -1
README.md CHANGED
@@ -4,7 +4,8 @@ emoji: 📈
4
  colorFrom: yellow
5
  colorTo: blue
6
  sdk: gradio
7
- sdk_version: 4.44.0
 
8
  app_file: app.py
9
  pinned: false
10
  license: unlicense
 
4
  colorFrom: yellow
5
  colorTo: blue
6
  sdk: gradio
7
+ sdk_version: 6.32.0
8
+ python_version: "3.12"
9
  app_file: app.py
10
  pinned: false
11
  license: unlicense
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from interactive_pipe import interactive_pipeline, interactive
2
  from interactive_pipe import CircularControl
3
  from interactive_pipe.data_objects.curves import SingleCurve, Curve
4
  from interactive_pipe.data_objects.image import Image
@@ -36,26 +36,25 @@ def set_tone_mapping_params(
36
  highlight_boost: float = (0., [-1., 1.]),
37
  exposure: float = (0., [-1., 1.]),
38
  contrast: float = (0., [-1., 1.]),
39
- global_params: dict = {}
40
  ) -> None:
41
- global_params["shadow_boost"] = shadow_boost
42
- global_params["highlight_boost"] = highlight_boost
43
- global_params["contrast"] = contrast
44
- global_params["exposure"] = exposure
45
 
46
 
47
  @interactive(
 
48
  apply_tone_curve_on_luma=(True,)
49
  )
50
  def tone_map(
51
  hsv: np.ndarray,
52
  apply_tone_curve_on_luma: bool = True,
53
- global_params={}
54
  ) -> np.ndarray:
55
- shadow_boost = global_params.get("shadow_boost", 0.)
56
- highlight_boost = global_params.get("highlight_boost", 0.)
57
- contrast = global_params.get("contrast", 0.)
58
- exposure = global_params.get("exposure", 0.)
59
  if not apply_tone_curve_on_luma:
60
  return rgb_to_hsv(
61
  apply_s_curve_tone_mapping(
@@ -78,6 +77,7 @@ def tone_map(
78
 
79
 
80
  @interactive(
 
81
  vibrance=(0, [0, 100]),
82
  # vibrance_mask_smoothness=(3., [-0.9, 4.])
83
  )
@@ -110,11 +110,11 @@ def modify_vibrance(
110
  return hsv_in
111
 
112
 
113
- def s_curve_visualization(global_params={}) -> Curve:
114
- shadow_boost = global_params.get("shadow_boost", 0.)
115
- highlight_boost = global_params.get("highlight_boost", 0.)
116
- contrast = global_params.get("contrast", 0.)
117
- exposure = global_params.get("exposure", 0.)
118
  x = np.linspace(0, 1, 256)
119
  y = apply_s_curve_tone_mapping(x, shadow_boost,
120
  highlight_boost,
@@ -138,17 +138,16 @@ def pick_image(
138
  default_image: np.ndarray,
139
  second_image: np.ndarray,
140
  input_image: str = "sample image",
141
- global_params={}
142
  ) -> np.ndarray:
143
  if input_image == "sample image":
144
  return default_image
145
  elif input_image == "alternative image":
146
  return second_image
147
  elif input_image == "color wheel":
148
- color_wheel = global_params.get("color wheel", None)
149
  if color_wheel is None:
150
  color_wheel = generate_color_wheel(resolution=496)
151
- global_params["color wheel"] = color_wheel
152
  return color_wheel
153
  else:
154
  return default_image
 
1
+ from interactive_pipe import interactive_pipeline, interactive, context
2
  from interactive_pipe import CircularControl
3
  from interactive_pipe.data_objects.curves import SingleCurve, Curve
4
  from interactive_pipe.data_objects.image import Image
 
36
  highlight_boost: float = (0., [-1., 1.]),
37
  exposure: float = (0., [-1., 1.]),
38
  contrast: float = (0., [-1., 1.]),
 
39
  ) -> None:
40
+ context["shadow_boost"] = shadow_boost
41
+ context["highlight_boost"] = highlight_boost
42
+ context["contrast"] = contrast
43
+ context["exposure"] = exposure
44
 
45
 
46
  @interactive(
47
+ inplace=True, # hsv is modified in place
48
  apply_tone_curve_on_luma=(True,)
49
  )
50
  def tone_map(
51
  hsv: np.ndarray,
52
  apply_tone_curve_on_luma: bool = True,
 
53
  ) -> np.ndarray:
54
+ shadow_boost = context.get("shadow_boost", 0.)
55
+ highlight_boost = context.get("highlight_boost", 0.)
56
+ contrast = context.get("contrast", 0.)
57
+ exposure = context.get("exposure", 0.)
58
  if not apply_tone_curve_on_luma:
59
  return rgb_to_hsv(
60
  apply_s_curve_tone_mapping(
 
77
 
78
 
79
  @interactive(
80
+ inplace=True, # hsv_in is modified in place
81
  vibrance=(0, [0, 100]),
82
  # vibrance_mask_smoothness=(3., [-0.9, 4.])
83
  )
 
110
  return hsv_in
111
 
112
 
113
+ def s_curve_visualization() -> Curve:
114
+ shadow_boost = context.get("shadow_boost", 0.)
115
+ highlight_boost = context.get("highlight_boost", 0.)
116
+ contrast = context.get("contrast", 0.)
117
+ exposure = context.get("exposure", 0.)
118
  x = np.linspace(0, 1, 256)
119
  y = apply_s_curve_tone_mapping(x, shadow_boost,
120
  highlight_boost,
 
138
  default_image: np.ndarray,
139
  second_image: np.ndarray,
140
  input_image: str = "sample image",
 
141
  ) -> np.ndarray:
142
  if input_image == "sample image":
143
  return default_image
144
  elif input_image == "alternative image":
145
  return second_image
146
  elif input_image == "color wheel":
147
+ color_wheel = context.get("color wheel", None)
148
  if color_wheel is None:
149
  color_wheel = generate_color_wheel(resolution=496)
150
+ context["color wheel"] = color_wheel
151
  return color_wheel
152
  else:
153
  return default_image
requirements.txt CHANGED
@@ -1 +1 @@
1
- interactive-pipe>=0.7.4
 
1
+ interactive-pipe==0.9.4