Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,9 @@
|
|
| 2 |
###
|
| 3 |
# 00 Imports
|
| 4 |
# 01 Setup
|
| 5 |
-
# 02 Screen 0
|
|
|
|
|
|
|
| 6 |
###
|
| 7 |
#####
|
| 8 |
|
|
@@ -45,13 +47,15 @@ if 'model' not in st.session_state:
|
|
| 45 |
|
| 46 |
_, row0_col1, _ = st.columns([2,3,2])
|
| 47 |
_, row1_col1, _ = st.columns([2,3,2])
|
|
|
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
#####
|
| 53 |
###
|
| 54 |
-
# 02 Screen 0
|
| 55 |
###
|
| 56 |
#####
|
| 57 |
# This displays to inform the user about the tool
|
|
@@ -60,29 +64,34 @@ _, row1_col1, _ = st.columns([2,3,2])
|
|
| 60 |
# load model
|
| 61 |
if st.session_state.screen == 0:
|
| 62 |
with row0_col1:
|
|
|
|
| 63 |
st.markdown("<h1 style='text-align: center; color: black;'>Find Waldo and His Friends</h1>", unsafe_allow_html=True)
|
| 64 |
st.markdown("<h3 style='text-align: center; color: black;'>Using Computer Vision</h3>", unsafe_allow_html=True)
|
| 65 |
st.markdown("<p style='text-align: left; color: black;'>This tool allows you to take a photo with your phone of a <i>Where's Waldo?</i> book page. Using the computer vision model YOLOv8-large, this tool find Waldo and his friends Wenda, Odlaw, Wizard, and Woof.</p>", unsafe_allow_html=True)
|
|
|
|
|
|
|
| 66 |
if st.button(f"Proceed", key="Proceed"):
|
| 67 |
st.session_state.screen = 1
|
| 68 |
st.rerun()
|
|
|
|
|
|
|
| 69 |
st.image("/home/user/app/home_page_images/Waldo_Friends.jpg", use_column_width=True)
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
#####
|
| 74 |
###
|
| 75 |
-
# Upload
|
| 76 |
###
|
| 77 |
#####
|
| 78 |
-
if st.session_state.screen == 1:
|
|
|
|
| 79 |
with row0_col1:
|
| 80 |
st.markdown("<h1 style='text-align: center; color: black;'>Find Waldo and His Friends</h1>", unsafe_allow_html=True)
|
| 81 |
st.markdown("<h3 style='text-align: center; color: black;'>Using Computer Vision</h3>", unsafe_allow_html=True)
|
| 82 |
-
st.markdown("<p style='text-align: center; color: black;'>Upload an image using your cell phone (single book page), or select an
|
| 83 |
-
|
| 84 |
-
|
| 85 |
|
|
|
|
| 86 |
with row1_col1:
|
| 87 |
uploaded_image = st.file_uploader(label="",
|
| 88 |
type=['jpg'],
|
|
@@ -100,60 +109,66 @@ if st.session_state.screen == 1:
|
|
| 100 |
uploaded_image = ImageOps.exif_transpose(uploaded_image)
|
| 101 |
st.session_state.image = uploaded_image
|
| 102 |
|
|
|
|
| 103 |
st.markdown("<h4 style='text-align: center; color: black;'>Or Select One of the Following</h4>", unsafe_allow_html=True)
|
| 104 |
|
| 105 |
-
_, row2_col2, row2_col3, row2_col4, row2_col5, _ = st.columns([8,3,3,3,3,8])
|
| 106 |
-
_, row3_col2, row3_col3, row3_col4, row3_col5, _ = st.columns([8,3,3,3,3,8])
|
| 107 |
-
|
| 108 |
image_path = "/home/user/app/test_images/"
|
| 109 |
-
with
|
| 110 |
img_1 = Image.open(image_path + "IMG_5356.JPG")
|
| 111 |
img_1 = ImageOps.exif_transpose(img_1)
|
| 112 |
st.image(img_1, use_column_width=True)
|
| 113 |
if st.button(f"Select Image β", key="button_1"):
|
| 114 |
st.session_state.image = img_1
|
| 115 |
-
|
|
|
|
| 116 |
img_2 = Image.open(image_path + "IMG_5357.JPG")
|
| 117 |
img_2 = ImageOps.exif_transpose(img_2)
|
| 118 |
st.image(img_2, use_column_width=True)
|
| 119 |
if st.button(f"Select Image β", key="button_2"):
|
| 120 |
st.session_state.image = img_2
|
| 121 |
-
|
|
|
|
| 122 |
img_3 = Image.open(image_path + "IMG_5368.JPG")
|
| 123 |
img_3 = ImageOps.exif_transpose(img_3)
|
| 124 |
st.image(img_3, use_column_width=True)
|
| 125 |
if st.button(f"Select Image β", key="button_3"):
|
| 126 |
st.session_state.image = img_3
|
| 127 |
-
|
|
|
|
| 128 |
img_4 = Image.open(image_path + "IMG_5369.JPG")
|
| 129 |
img_4 = ImageOps.exif_transpose(img_4)
|
| 130 |
st.image(img_4, use_column_width=True)
|
| 131 |
if st.button(f"Select Image β", key="button_4"):
|
| 132 |
st.session_state.image = img_4
|
| 133 |
-
|
|
|
|
| 134 |
img_5 = Image.open(image_path + "IMG_5382.JPG")
|
| 135 |
img_5 = ImageOps.exif_transpose(img_5)
|
| 136 |
st.image(img_5, use_column_width=True)
|
| 137 |
if st.button(f"Select Image β", key="button_5"):
|
| 138 |
st.session_state.image = img_5
|
| 139 |
-
|
|
|
|
| 140 |
img_6 = Image.open(image_path + "IMG_5383.JPG")
|
| 141 |
img_6 = ImageOps.exif_transpose(img_6)
|
| 142 |
st.image(img_6, use_column_width=True)
|
| 143 |
if st.button(f"Select Image β", key="button_6"):
|
| 144 |
st.session_state.image = img_6
|
| 145 |
-
|
|
|
|
| 146 |
img_7 = Image.open(image_path + "IMG_5408.JPG")
|
| 147 |
img_7 = ImageOps.exif_transpose(img_7)
|
| 148 |
st.image(img_7, use_column_width=True)
|
| 149 |
if st.button(f"Select Image β", key="button_7"):
|
| 150 |
st.session_state.image = img_7
|
| 151 |
-
|
|
|
|
| 152 |
img_8 = Image.open(image_path + "IMG_5409.JPG")
|
| 153 |
img_8 = ImageOps.exif_transpose(img_8)
|
| 154 |
st.image(img_8, use_column_width=True)
|
| 155 |
if st.button(f"Select Image β", key="button_8"):
|
| 156 |
-
st.session_state.image = img_8
|
|
|
|
| 157 |
|
| 158 |
#####
|
| 159 |
###
|
|
|
|
| 2 |
###
|
| 3 |
# 00 Imports
|
| 4 |
# 01 Setup
|
| 5 |
+
# 02 Screen 0 - Introduction
|
| 6 |
+
# 03 Screen 1 - Upload or Select Image
|
| 7 |
+
|
| 8 |
###
|
| 9 |
#####
|
| 10 |
|
|
|
|
| 47 |
|
| 48 |
_, row0_col1, _ = st.columns([2,3,2])
|
| 49 |
_, row1_col1, _ = st.columns([2,3,2])
|
| 50 |
+
_, row2_col1, row2_col2, row2_col3, row2_col4, _ = st.columns([8,3,3,3,3,8])
|
| 51 |
+
_, row3_col1, row3_col2, row3_col3, row3_col4, _ = st.columns([8,3,3,3,3,8])
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
#####
|
| 57 |
###
|
| 58 |
+
# 02 Screen 0 - Introduction
|
| 59 |
###
|
| 60 |
#####
|
| 61 |
# This displays to inform the user about the tool
|
|
|
|
| 64 |
# load model
|
| 65 |
if st.session_state.screen == 0:
|
| 66 |
with row0_col1:
|
| 67 |
+
# heading
|
| 68 |
st.markdown("<h1 style='text-align: center; color: black;'>Find Waldo and His Friends</h1>", unsafe_allow_html=True)
|
| 69 |
st.markdown("<h3 style='text-align: center; color: black;'>Using Computer Vision</h3>", unsafe_allow_html=True)
|
| 70 |
st.markdown("<p style='text-align: left; color: black;'>This tool allows you to take a photo with your phone of a <i>Where's Waldo?</i> book page. Using the computer vision model YOLOv8-large, this tool find Waldo and his friends Wenda, Odlaw, Wizard, and Woof.</p>", unsafe_allow_html=True)
|
| 71 |
+
|
| 72 |
+
# proceed button
|
| 73 |
if st.button(f"Proceed", key="Proceed"):
|
| 74 |
st.session_state.screen = 1
|
| 75 |
st.rerun()
|
| 76 |
+
|
| 77 |
+
# image of Waldo and his friends
|
| 78 |
st.image("/home/user/app/home_page_images/Waldo_Friends.jpg", use_column_width=True)
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
#####
|
| 83 |
###
|
| 84 |
+
# 03 Screen 1 - Upload or Select Image
|
| 85 |
###
|
| 86 |
#####
|
| 87 |
+
if st.session_state.screen == 1:
|
| 88 |
+
# heading and instructions
|
| 89 |
with row0_col1:
|
| 90 |
st.markdown("<h1 style='text-align: center; color: black;'>Find Waldo and His Friends</h1>", unsafe_allow_html=True)
|
| 91 |
st.markdown("<h3 style='text-align: center; color: black;'>Using Computer Vision</h3>", unsafe_allow_html=True)
|
| 92 |
+
st.markdown("<p style='text-align: center; color: black;'>Upload an image using your cell phone (single book page), or select an image from the below list</p>", unsafe_allow_html=True)
|
|
|
|
|
|
|
| 93 |
|
| 94 |
+
# image uploader
|
| 95 |
with row1_col1:
|
| 96 |
uploaded_image = st.file_uploader(label="",
|
| 97 |
type=['jpg'],
|
|
|
|
| 109 |
uploaded_image = ImageOps.exif_transpose(uploaded_image)
|
| 110 |
st.session_state.image = uploaded_image
|
| 111 |
|
| 112 |
+
# image selector
|
| 113 |
st.markdown("<h4 style='text-align: center; color: black;'>Or Select One of the Following</h4>", unsafe_allow_html=True)
|
| 114 |
|
|
|
|
|
|
|
|
|
|
| 115 |
image_path = "/home/user/app/test_images/"
|
| 116 |
+
with row2_col1:
|
| 117 |
img_1 = Image.open(image_path + "IMG_5356.JPG")
|
| 118 |
img_1 = ImageOps.exif_transpose(img_1)
|
| 119 |
st.image(img_1, use_column_width=True)
|
| 120 |
if st.button(f"Select Image β", key="button_1"):
|
| 121 |
st.session_state.image = img_1
|
| 122 |
+
st.session_state.screen = 2
|
| 123 |
+
with row2_col2:
|
| 124 |
img_2 = Image.open(image_path + "IMG_5357.JPG")
|
| 125 |
img_2 = ImageOps.exif_transpose(img_2)
|
| 126 |
st.image(img_2, use_column_width=True)
|
| 127 |
if st.button(f"Select Image β", key="button_2"):
|
| 128 |
st.session_state.image = img_2
|
| 129 |
+
st.session_state.screen = 2
|
| 130 |
+
with row2_col3:
|
| 131 |
img_3 = Image.open(image_path + "IMG_5368.JPG")
|
| 132 |
img_3 = ImageOps.exif_transpose(img_3)
|
| 133 |
st.image(img_3, use_column_width=True)
|
| 134 |
if st.button(f"Select Image β", key="button_3"):
|
| 135 |
st.session_state.image = img_3
|
| 136 |
+
st.session_state.screen = 2
|
| 137 |
+
with row2_col4:
|
| 138 |
img_4 = Image.open(image_path + "IMG_5369.JPG")
|
| 139 |
img_4 = ImageOps.exif_transpose(img_4)
|
| 140 |
st.image(img_4, use_column_width=True)
|
| 141 |
if st.button(f"Select Image β", key="button_4"):
|
| 142 |
st.session_state.image = img_4
|
| 143 |
+
st.session_state.screen = 2
|
| 144 |
+
with row3_col1:
|
| 145 |
img_5 = Image.open(image_path + "IMG_5382.JPG")
|
| 146 |
img_5 = ImageOps.exif_transpose(img_5)
|
| 147 |
st.image(img_5, use_column_width=True)
|
| 148 |
if st.button(f"Select Image β", key="button_5"):
|
| 149 |
st.session_state.image = img_5
|
| 150 |
+
st.session_state.screen = 2
|
| 151 |
+
with row3_col2:
|
| 152 |
img_6 = Image.open(image_path + "IMG_5383.JPG")
|
| 153 |
img_6 = ImageOps.exif_transpose(img_6)
|
| 154 |
st.image(img_6, use_column_width=True)
|
| 155 |
if st.button(f"Select Image β", key="button_6"):
|
| 156 |
st.session_state.image = img_6
|
| 157 |
+
st.session_state.screen = 2
|
| 158 |
+
with row3_col3:
|
| 159 |
img_7 = Image.open(image_path + "IMG_5408.JPG")
|
| 160 |
img_7 = ImageOps.exif_transpose(img_7)
|
| 161 |
st.image(img_7, use_column_width=True)
|
| 162 |
if st.button(f"Select Image β", key="button_7"):
|
| 163 |
st.session_state.image = img_7
|
| 164 |
+
st.session_state.screen = 2
|
| 165 |
+
with row3_col4:
|
| 166 |
img_8 = Image.open(image_path + "IMG_5409.JPG")
|
| 167 |
img_8 = ImageOps.exif_transpose(img_8)
|
| 168 |
st.image(img_8, use_column_width=True)
|
| 169 |
if st.button(f"Select Image β", key="button_8"):
|
| 170 |
+
st.session_state.image = img_8
|
| 171 |
+
st.session_state.screen = 2
|
| 172 |
|
| 173 |
#####
|
| 174 |
###
|