IliaLarchenko commited on
Commit
ab818d6
1 Parent(s): 86c6aac

a lot of new augs

Browse files
configs/augmentations.json CHANGED
@@ -3,11 +3,76 @@
3
  "ToSepia": [],
4
  "ChannelShuffle": [],
5
  "InvertImg": [],
 
 
 
 
 
 
 
 
 
 
6
  "Blur": [{"param_name" : "blur_limit",
7
  "type" : "int_interval",
8
  "limits_list" : [3, 100],
9
  "defaults" : [3, 7]}
10
  ],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  "JpegCompression": [{"param_name" : "quality_lower",
12
  "type" : "int_interval",
13
  "limits_list" : [0, 100],
@@ -64,8 +129,42 @@
64
  "defaults" : 0.1},
65
  {"param_name" : "brightness_coeff",
66
  "type" : "int_interval",
67
- "limits_list" : [0.9, 20.0],
68
  "defaults" : 2.5}
69
- ]
70
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  }
 
3
  "ToSepia": [],
4
  "ChannelShuffle": [],
5
  "InvertImg": [],
6
+ "VerticalFlip": [],
7
+ "HorizontalFlip": [],
8
+ "Flip": [],
9
+ "RandomGridShuffle": [
10
+ {"param_name" : "grid",
11
+ "type" : "several_ints",
12
+ "subparam_names": ["y", "x"],
13
+ "limits_list" : [[1, 10],[1, 10]],
14
+ "defaults_list" : [3, 3]}
15
+ ],
16
  "Blur": [{"param_name" : "blur_limit",
17
  "type" : "int_interval",
18
  "limits_list" : [3, 100],
19
  "defaults" : [3, 7]}
20
  ],
21
+ "MotionBlur": [{"param_name" : "blur_limit",
22
+ "type" : "int_interval",
23
+ "limits_list" : [3, 100],
24
+ "defaults" : [3, 7]}
25
+ ],
26
+ "MedianBlur": [{"param_name" : "blur_limit",
27
+ "type" : "int_interval",
28
+ "limits_list" : [3, 100],
29
+ "defaults" : [3, 7]}
30
+ ],
31
+ "GaussNoise": [{"param_name" : "var_limit",
32
+ "type" : "int_interval",
33
+ "limits_list" : [0.0, 500.0],
34
+ "defaults" : [10.0, 50.0]},
35
+ {"param_name" : "mean",
36
+ "type" : "int_interval",
37
+ "limits_list" : [-100.0, 100.0],
38
+ "defaults" : 0.0}
39
+ ],
40
+ "RandomBrightness": [{"param_name" : "limit",
41
+ "type" : "int_interval",
42
+ "limits_list" : [-1.0, 1.0],
43
+ "defaults" : [-0.2, 0.2]}
44
+ ],
45
+ "RandomContrast": [{"param_name" : "limit",
46
+ "type" : "int_interval",
47
+ "limits_list" : [-1.0, 1.0],
48
+ "defaults" : [-0.2, 0.2]}
49
+ ],
50
+ "HueSaturationValue": [{ "param_name" : "hue_shift_limit",
51
+ "type" : "int_interval",
52
+ "limits_list" : [-100, 100],
53
+ "defaults" : [-20, 20]},
54
+ { "param_name" : "sat_shift_limit",
55
+ "type" : "int_interval",
56
+ "limits_list" : [-100, 100],
57
+ "defaults" : [-30, 30]},
58
+ { "param_name" : "val_shift_limit",
59
+ "type" : "int_interval",
60
+ "limits_list" : [-100, 100],
61
+ "defaults" : [-20, 20]}
62
+ ],
63
+ "RGBShift": [{ "param_name" : "r_shift_limit",
64
+ "type" : "int_interval",
65
+ "limits_list" : [-255, 255],
66
+ "defaults" : [-20, 20]},
67
+ { "param_name" : "g_shift_limit",
68
+ "type" : "int_interval",
69
+ "limits_list" : [-255, 255],
70
+ "defaults" : [-20, 20]},
71
+ { "param_name" : "b_shift_limit",
72
+ "type" : "int_interval",
73
+ "limits_list" : [-255, 255],
74
+ "defaults" : [-20, 20]}
75
+ ],
76
  "JpegCompression": [{"param_name" : "quality_lower",
77
  "type" : "int_interval",
78
  "limits_list" : [0, 100],
 
129
  "defaults" : 0.1},
130
  {"param_name" : "brightness_coeff",
131
  "type" : "int_interval",
132
+ "limits_list" : [0.0, 20.0],
133
  "defaults" : 2.5}
134
+ ],
135
+ "RandomFog": [{"param_name" : "fog_coef_lower",
136
+ "type" : "int_interval",
137
+ "limits_list" : [0.0, 1.0],
138
+ "defaults" : 0.1},
139
+ {"param_name" : "fog_coef_upper",
140
+ "type" : "int_interval",
141
+ "limits_list" : [0.0, 1.0],
142
+ "defaults" : 0.1},
143
+ {"param_name" : "alpha_coef",
144
+ "type" : "int_interval",
145
+ "limits_list" : [0.0, 1.0],
146
+ "defaults" : 0.08}
147
+ ],
148
+ "ChannelDropout": [{"param_name" : "channel_drop_range",
149
+ "type" : "int_interval",
150
+ "limits_list" : [1, 3],
151
+ "defaults" : [1, 1]},
152
+ {"param_name" : "fill_value",
153
+ "type" : "int_interval",
154
+ "limits_list" : [0, 255],
155
+ "defaults" : 0}
156
+ ],
157
+ "Solarize": [{"param_name" : "threshold",
158
+ "type" : "int_interval",
159
+ "limits_list" : [0, 255],
160
+ "defaults" : 128}
161
+ ],
162
+ "Equalize": [
163
+ {"param_name" : "mode",
164
+ "type" : "radio",
165
+ "options_list" : ["cv", "pil"]},
166
+ {"param_name" : "by_channels",
167
+ "type" : "checkbox",
168
+ "defaults": 1}
169
+ ]
170
  }
src/__pycache__/control.cpython-37.pyc CHANGED
Binary files a/src/__pycache__/control.cpython-37.pyc and b/src/__pycache__/control.cpython-37.pyc differ
 
src/control.py CHANGED
@@ -25,18 +25,27 @@ def select_several_RGB(param_name, **kwargs):
25
  return tuple(result)
26
 
27
 
28
-
29
  def select_radio(param_name, options_list, **kwargs):
30
  st.sidebar.subheader(param_name)
31
  result = st.sidebar.radio('', options_list)
 
 
 
 
 
 
 
 
32
  return result
33
 
34
 
 
35
  # dict from param name to function showing this param
36
  param2func = {
37
  'int_interval': select_int_interval,
38
  'several_ints': select_several_ints,
39
  'radio': select_radio,
40
- 'rgb': select_several_RGB
 
41
 
42
  }
 
25
  return tuple(result)
26
 
27
 
 
28
  def select_radio(param_name, options_list, **kwargs):
29
  st.sidebar.subheader(param_name)
30
  result = st.sidebar.radio('', options_list)
31
+ if isinstance(options_list[0],str):
32
+ result = '"' + result + '"'
33
+ return result
34
+
35
+
36
+ def select_checkbox(param_name, defaults, **kwargs):
37
+ st.sidebar.subheader(param_name)
38
+ result = st.sidebar.checkbox("True", defaults)
39
  return result
40
 
41
 
42
+
43
  # dict from param name to function showing this param
44
  param2func = {
45
  'int_interval': select_int_interval,
46
  'several_ints': select_several_ints,
47
  'radio': select_radio,
48
+ 'rgb': select_several_RGB,
49
+ 'checkbox': select_checkbox
50
 
51
  }
src/main.py CHANGED
@@ -32,7 +32,7 @@ image = load_image(image_name, path_to_images)
32
  path_to_config = 'configs/augmentations.json'
33
  with open(path_to_config, 'r') as config_file:
34
  augmentations = json.load(config_file)
35
- transform_name = st.sidebar.selectbox('Select a transformation:', list(augmentations.keys()))
36
  transform_params = augmentations[transform_name]
37
 
38
 
@@ -44,9 +44,10 @@ else:
44
  param['value'] = param2func[param['type']](**param)
45
 
46
 
47
- params_string = ','.join([param['param_name'] + '=' + str(param['value']) for param in transform_params] + ['p=1.0'])
48
  params_string = '(' + params_string + ')'
49
 
 
50
  st.text('Press R to update')
51
  exec('transform = A.' + transform_name + params_string)
52
  st.image([image, transform(image = image)['image']],
 
32
  path_to_config = 'configs/augmentations.json'
33
  with open(path_to_config, 'r') as config_file:
34
  augmentations = json.load(config_file)
35
+ transform_name = st.sidebar.selectbox('Select a transformation:', sorted(list(augmentations.keys())))
36
  transform_params = augmentations[transform_name]
37
 
38
 
 
44
  param['value'] = param2func[param['type']](**param)
45
 
46
 
47
+ params_string = ", ".join([param['param_name'] + '=' + str(param['value']) for param in transform_params] + ['p=1.0'])
48
  params_string = '(' + params_string + ')'
49
 
50
+ st.text(transform_name + params_string)
51
  st.text('Press R to update')
52
  exec('transform = A.' + transform_name + params_string)
53
  st.image([image, transform(image = image)['image']],