IliaLarchenko
commited on
Commit
•
e2d5557
1
Parent(s):
5d4bd93
added image_width CLI param
Browse files- src/app.py +4 -6
- src/utils.py +3 -2
src/app.py
CHANGED
@@ -3,7 +3,7 @@ import streamlit as st
|
|
3 |
import albumentations as A
|
4 |
|
5 |
|
6 |
-
from utils import load_augmentations_config,
|
7 |
from visuals import (
|
8 |
show_transform_control,
|
9 |
select_image,
|
@@ -11,11 +11,12 @@ from visuals import (
|
|
11 |
show_docstring,
|
12 |
)
|
13 |
|
14 |
-
# get the path to images
|
15 |
-
path_to_images =
|
16 |
if not os.path.isdir(path_to_images):
|
17 |
st.title("There is no directory: " + path_to_images)
|
18 |
else:
|
|
|
19 |
status, image = select_image(path_to_images)
|
20 |
if status == 0:
|
21 |
st.title("Can't load image from: " + path_to_images)
|
@@ -23,8 +24,6 @@ else:
|
|
23 |
# show title
|
24 |
st.title("Demo of Albumentations")
|
25 |
|
26 |
-
# select image
|
27 |
-
|
28 |
placeholder_params = {
|
29 |
"image_width": image.shape[1],
|
30 |
"image_height": image.shape[0],
|
@@ -58,7 +57,6 @@ else:
|
|
58 |
# st.write(data["replay"])
|
59 |
|
60 |
# show the images
|
61 |
-
width_original = 400
|
62 |
width_transformed = int(
|
63 |
width_original / image.shape[1] * augmented_image.shape[1]
|
64 |
)
|
|
|
3 |
import albumentations as A
|
4 |
|
5 |
|
6 |
+
from utils import load_augmentations_config, get_arguments
|
7 |
from visuals import (
|
8 |
show_transform_control,
|
9 |
select_image,
|
|
|
11 |
show_docstring,
|
12 |
)
|
13 |
|
14 |
+
# get CLI params: the path to images and image width
|
15 |
+
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:
|
22 |
st.title("Can't load image from: " + path_to_images)
|
|
|
24 |
# show title
|
25 |
st.title("Demo of Albumentations")
|
26 |
|
|
|
|
|
27 |
placeholder_params = {
|
28 |
"image_width": image.shape[1],
|
29 |
"image_height": image.shape[0],
|
|
|
57 |
# st.write(data["replay"])
|
58 |
|
59 |
# show the images
|
|
|
60 |
width_transformed = int(
|
61 |
width_original / image.shape[1] * augmented_image.shape[1]
|
62 |
)
|
src/utils.py
CHANGED
@@ -7,11 +7,12 @@ import streamlit as st
|
|
7 |
|
8 |
|
9 |
@st.cache
|
10 |
-
def
|
11 |
parser = argparse.ArgumentParser()
|
12 |
parser.add_argument("--image_folder", default="images")
|
|
|
13 |
args = parser.parse_args()
|
14 |
-
return getattr(args, "image_folder")
|
15 |
|
16 |
|
17 |
@st.cache
|
|
|
7 |
|
8 |
|
9 |
@st.cache
|
10 |
+
def get_arguments():
|
11 |
parser = argparse.ArgumentParser()
|
12 |
parser.add_argument("--image_folder", default="images")
|
13 |
+
parser.add_argument("--image_width", default=400, type=int)
|
14 |
args = parser.parse_args()
|
15 |
+
return getattr(args, "image_folder"), getattr(args, "image_width")
|
16 |
|
17 |
|
18 |
@st.cache
|