Commit
·
590bb1b
1
Parent(s):
317bdbc
added Professional mode
Browse files- src/app.py +33 -10
src/app.py
CHANGED
|
@@ -16,6 +16,10 @@ path_to_images, width_original = get_arguments()
|
|
| 16 |
if not os.path.isdir(path_to_images):
|
| 17 |
st.title("There is no directory: " + path_to_images)
|
| 18 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# select image
|
| 20 |
status, image = select_image(path_to_images)
|
| 21 |
if status == 0:
|
|
@@ -37,16 +41,34 @@ else:
|
|
| 37 |
)
|
| 38 |
|
| 39 |
# select a transformation
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
|
| 47 |
-
|
| 48 |
-
transform = getattr(A, transform_name)(**param_values)
|
| 49 |
-
data = A.ReplayCompose([transform])(image=image)
|
| 50 |
augmented_image = data["image"]
|
| 51 |
|
| 52 |
# TODO add convinient replay compose
|
|
@@ -65,6 +87,7 @@ else:
|
|
| 65 |
st.image(augmented_image, caption="Transformed image", width=width_transformed)
|
| 66 |
|
| 67 |
# print additional info
|
| 68 |
-
|
| 69 |
-
|
|
|
|
| 70 |
show_credentials()
|
|
|
|
| 16 |
if not os.path.isdir(path_to_images):
|
| 17 |
st.title("There is no directory: " + path_to_images)
|
| 18 |
else:
|
| 19 |
+
# select interface type
|
| 20 |
+
interface_type = st.sidebar.radio('Select the interface type',
|
| 21 |
+
['Simple', 'Professional'])
|
| 22 |
+
|
| 23 |
# select image
|
| 24 |
status, image = select_image(path_to_images)
|
| 25 |
if status == 0:
|
|
|
|
| 41 |
)
|
| 42 |
|
| 43 |
# select a transformation
|
| 44 |
+
if interface_type == 'Simple':
|
| 45 |
+
transform_names = [st.sidebar.selectbox(
|
| 46 |
+
"Select a transformation:", sorted(list(augmentations.keys()))
|
| 47 |
+
)]
|
| 48 |
+
# in the professional mode you can choose several transforms
|
| 49 |
+
elif interface_type == 'Professional':
|
| 50 |
+
transform_names = [st.sidebar.selectbox(
|
| 51 |
+
"Select transformation №1:", sorted(list(augmentations.keys()))
|
| 52 |
+
)]
|
| 53 |
+
while transform_names[-1] != 'None':
|
| 54 |
+
transform_names.append(st.sidebar.selectbox(
|
| 55 |
+
f"Select transformation №{len(transform_names) + 1}:",
|
| 56 |
+
['None'] + sorted(list(augmentations.keys()))
|
| 57 |
+
))
|
| 58 |
+
transform_names = transform_names[:-1]
|
| 59 |
+
|
| 60 |
+
original_image = image.copy()
|
| 61 |
+
transforms = []
|
| 62 |
+
for transform_name in transform_names:
|
| 63 |
+
|
| 64 |
+
# select the params values
|
| 65 |
+
st.sidebar.subheader("Params of the : " + transform_name)
|
| 66 |
+
param_values = show_transform_control(augmentations[transform_name])
|
| 67 |
|
| 68 |
+
# apply the transformation to the image
|
| 69 |
+
transforms.append(getattr(A, transform_name)(**param_values))
|
| 70 |
|
| 71 |
+
data = A.ReplayCompose(transforms)(image=image)
|
|
|
|
|
|
|
| 72 |
augmented_image = data["image"]
|
| 73 |
|
| 74 |
# TODO add convinient replay compose
|
|
|
|
| 87 |
st.image(augmented_image, caption="Transformed image", width=width_transformed)
|
| 88 |
|
| 89 |
# print additional info
|
| 90 |
+
for transform in transforms:
|
| 91 |
+
st.code(str(transform))
|
| 92 |
+
show_docstring(transform)
|
| 93 |
show_credentials()
|