IliaLarchenko commited on
Commit
a467828
1 Parent(s): 52a0611

added min_max params

Browse files
Files changed (3) hide show
  1. configs/augmentations.json +3 -12
  2. src/control.py +8 -0
  3. src/visuals.py +6 -1
configs/augmentations.json CHANGED
@@ -202,22 +202,13 @@
202
  ],
203
  "JpegCompression": [
204
  {
205
- "param_name": "quality_lower",
206
- "type": "int_interval",
207
- "limits_list": [
208
- 0,
209
- 100
210
- ],
211
- "defaults": 99
212
- },
213
- {
214
- "param_name": "quality_upper",
215
- "type": "int_interval",
216
  "limits_list": [
217
  0,
218
  100
219
  ],
220
- "defaults": 100
221
  }
222
  ],
223
  "ImageCompression": [
 
202
  ],
203
  "JpegCompression": [
204
  {
205
+ "param_name": ["quality_lower","quality_upper"],
206
+ "type": "min_max",
 
 
 
 
 
 
 
 
 
207
  "limits_list": [
208
  0,
209
  100
210
  ],
211
+ "defaults_list": [80,100]
212
  }
213
  ],
214
  "ImageCompression": [
src/control.py CHANGED
@@ -1,5 +1,7 @@
1
  import streamlit as st
2
 
 
 
3
 
4
  def select_int_interval(param_name, limits_list, defaults, **kwargs):
5
  st.sidebar.subheader(param_name)
@@ -26,6 +28,11 @@ def select_several_ints(
26
  return tuple(result)
27
 
28
 
 
 
 
 
 
29
  def select_RGB(param_name, **kwargs):
30
  result = select_several_ints(
31
  param_name,
@@ -55,4 +62,5 @@ param2func = {
55
  "radio": select_radio,
56
  "rgb": select_RGB,
57
  "checkbox": select_checkbox,
 
58
  }
 
1
  import streamlit as st
2
 
3
+ # TODO: rename everything
4
+
5
 
6
  def select_int_interval(param_name, limits_list, defaults, **kwargs):
7
  st.sidebar.subheader(param_name)
 
28
  return tuple(result)
29
 
30
 
31
+ def select_min_max(param_name, limits_list, defaults_list, **kwargs):
32
+ assert len(param_name) == 2
33
+ return select_int_interval(' and '.join(param_name), limits_list, defaults_list)
34
+
35
+
36
  def select_RGB(param_name, **kwargs):
37
  result = select_several_ints(
38
  param_name,
 
62
  "radio": select_radio,
63
  "rgb": select_RGB,
64
  "checkbox": select_checkbox,
65
+ "min_max": select_min_max,
66
  }
src/visuals.py CHANGED
@@ -22,7 +22,12 @@ def show_transform_control(transform_params: dict):
22
  else:
23
  for param in transform_params:
24
  control_function = param2func[param["type"]]
25
- param_values[param["param_name"]] = control_function(**param)
 
 
 
 
 
26
  return param_values
27
 
28
 
 
22
  else:
23
  for param in transform_params:
24
  control_function = param2func[param["type"]]
25
+ if isinstance(param["param_name"], list):
26
+ returned_values = control_function(**param)
27
+ for name, value in zip(param["param_name"], returned_values):
28
+ param_values[name] = value
29
+ else:
30
+ param_values[param["param_name"]] = control_function(**param)
31
  return param_values
32
 
33