Souheil-b commited on
Commit
98815d6
·
1 Parent(s): 6c49ce9

feat: add Streamlit app with image display and dropdown selection

Browse files
Files changed (1) hide show
  1. front/app.py +49 -0
front/app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """App to display images in a gallery"""
2
+
3
+ import streamlit as st
4
+ from image_preprocessing import get_image_caption, get_images, resize_image
5
+
6
+
7
+ def image_gallery(images):
8
+ """Display a gallery of images in a streamlit app
9
+
10
+ Args:
11
+ images (list): list of images to display
12
+ """
13
+ st.title("Welcome")
14
+
15
+ columns = st.columns(3)
16
+ for index, image in enumerate(images):
17
+ with columns[index % 3]:
18
+ resized_image = resize_image(image, 200)
19
+ image_caption = get_image_caption(image)
20
+ st.image(
21
+ resized_image,
22
+ width=200,
23
+ use_container_width=True,
24
+ caption=image_caption,
25
+ )
26
+
27
+
28
+ def sidebar():
29
+ """Create a sidebar to select the park
30
+
31
+ Returns:
32
+ selected_park: selected park in the sidebar
33
+ """
34
+ selected_park = st.sidebar.selectbox(
35
+ "Park List", ["Al Khaldiyah Park", "Family Park"]
36
+ )
37
+ return selected_park
38
+
39
+
40
+ def main():
41
+ """Main function to run the app"""
42
+ path = "../images/"
43
+ park = sidebar()
44
+ images = get_images(path + park)
45
+ image_gallery(images)
46
+
47
+
48
+ if __name__ == "__main__":
49
+ main()