IliaLarchenko
commited on
Commit
•
87fe461
1
Parent(s):
66ec950
refactoring, simple transformes added
Browse files- configs/augmentations.json +15 -3
- src/__pycache__/control.cpython-37.pyc +0 -0
- src/control.py +25 -0
- src/main.py +16 -15
configs/augmentations.json
CHANGED
@@ -1,9 +1,21 @@
|
|
1 |
{
|
2 |
"ToGray": [],
|
3 |
"ToSepia": [],
|
4 |
-
"
|
|
|
|
|
5 |
"type" : "int_interval",
|
6 |
-
"
|
7 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
]
|
9 |
}
|
|
|
1 |
{
|
2 |
"ToGray": [],
|
3 |
"ToSepia": [],
|
4 |
+
"ChannelShuffle": [],
|
5 |
+
"InvertImg": [],
|
6 |
+
"Blur": [{"param_name" : "blur_limit",
|
7 |
"type" : "int_interval",
|
8 |
+
"limits_list" : [3, 100],
|
9 |
+
"defaults_list" : [3, 7]}
|
10 |
+
],
|
11 |
+
"CLAHE": [{"param_name" : "clip_limit",
|
12 |
+
"type" : "int_interval",
|
13 |
+
"limits_list" : [1, 100],
|
14 |
+
"defaults_list" : [1, 4]},
|
15 |
+
{"param_name" : "tile_grid_size",
|
16 |
+
"type" : "several_ints",
|
17 |
+
"subparam_names": ["y", "x"],
|
18 |
+
"limits_list" : [[1, 100],[1, 100]],
|
19 |
+
"defaults_list" : [8, 8]}
|
20 |
]
|
21 |
}
|
src/__pycache__/control.cpython-37.pyc
ADDED
Binary file (814 Bytes). View file
|
|
src/control.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
|
4 |
+
def select_int_interval(param_name, limits_list, defaults_list, **kwargs):
|
5 |
+
st.sidebar.subheader(param_name)
|
6 |
+
min_max_interval = st.sidebar.slider('', limits_list[0], limits_list[1], defaults_list)
|
7 |
+
return min_max_interval
|
8 |
+
|
9 |
+
def select_several_ints(param_name, subparam_names, limits_list, defaults_list, **kwargs):
|
10 |
+
st.sidebar.subheader(param_name)
|
11 |
+
result = []
|
12 |
+
assert len(limits_list) == len(defaults_list)
|
13 |
+
assert len(subparam_names) == len(defaults_list)
|
14 |
+
|
15 |
+
for name, limits, defaults in zip(subparam_names, limits_list, defaults_list):
|
16 |
+
result.append(st.sidebar.slider(name, limits[0], limits[1], defaults))
|
17 |
+
return tuple(result)
|
18 |
+
|
19 |
+
|
20 |
+
# dict from param name to function showing this param
|
21 |
+
param2func = {
|
22 |
+
'int_interval': select_int_interval,
|
23 |
+
'several_ints': select_several_ints,
|
24 |
+
|
25 |
+
}
|
src/main.py
CHANGED
@@ -8,6 +8,8 @@ import json
|
|
8 |
import albumentations as A
|
9 |
import streamlit as st
|
10 |
|
|
|
|
|
11 |
|
12 |
def load_image(image_name, path_to_folder = '../images'):
|
13 |
path_to_image = os.path.join(path_to_folder, image_name)
|
@@ -16,19 +18,6 @@ def load_image(image_name, path_to_folder = '../images'):
|
|
16 |
return image
|
17 |
|
18 |
|
19 |
-
def show_int_interval(name, limits, defaults, **kwargs):
|
20 |
-
min_max_interval = st.sidebar.slider(name, limits[0], limits[1], defaults)
|
21 |
-
return min_max_interval
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
# dict from param name to function showing this param
|
26 |
-
param2func = {
|
27 |
-
'int_interval': show_int_interval
|
28 |
-
}
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
st.title('Demo of Albumentations transforms')
|
33 |
|
34 |
|
@@ -55,7 +44,7 @@ else:
|
|
55 |
param['value'] = param2func[param['type']](**param)
|
56 |
|
57 |
|
58 |
-
params_string = ','.join([param['
|
59 |
params_string = '(' + params_string + ')'
|
60 |
|
61 |
st.text('Press R to update')
|
@@ -63,4 +52,16 @@ exec('transform = A.' + transform_name + params_string)
|
|
63 |
st.image([image, transform(image = image)['image']],
|
64 |
caption = ['Original image', 'Transformed image'],
|
65 |
width = 320)
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
import albumentations as A
|
9 |
import streamlit as st
|
10 |
|
11 |
+
from control import *
|
12 |
+
|
13 |
|
14 |
def load_image(image_name, path_to_folder = '../images'):
|
15 |
path_to_image = os.path.join(path_to_folder, image_name)
|
|
|
18 |
return image
|
19 |
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
st.title('Demo of Albumentations transforms')
|
22 |
|
23 |
|
|
|
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')
|
|
|
52 |
st.image([image, transform(image = image)['image']],
|
53 |
caption = ['Original image', 'Transformed image'],
|
54 |
width = 320)
|
55 |
+
|
56 |
+
st.subheader('Docstring:')
|
57 |
+
st.text(str(transform.__doc__))
|
58 |
+
|
59 |
+
|
60 |
+
st.text('')
|
61 |
+
st.text('')
|
62 |
+
st.subheader('Credentials:')
|
63 |
+
st.text('Source: https://github.com/IliaLarchenko/albumentations-demo')
|
64 |
+
st.text('Albumentation library: https://github.com/albumentations-team/albumentations')
|
65 |
+
st.text('Image Source: https://www.pexels.com/royalty-free-images/')
|
66 |
+
|
67 |
+
|