JaredBailey commited on
Commit
399f0b6
·
verified ·
1 Parent(s): 6cf376f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -26
app.py CHANGED
@@ -46,10 +46,15 @@ if 'model' not in st.session_state:
46
 
47
  _, row0_col1, _ = st.columns([2,3,2])
48
  _, row1_col1, _ = st.columns([2,3,2])
49
- _, row2_col1, row2_col2, row2_col3, row2_col4, _ = st.columns([8,3,3,3,3,8])
50
  _, row3_col1, row3_col2, row3_col3, row3_col4, _ = st.columns([8,3,3,3,3,8])
51
- _, row4_col2, row4_col3, _ = st.columns([1,4,4,1], gap="medium")
 
52
 
 
 
 
 
53
 
54
 
55
 
@@ -60,10 +65,8 @@ _, row4_col2, row4_col3, _ = st.columns([1,4,4,1], gap="medium")
60
  #####
61
  # This displays to inform the user about the tool
62
  if st.session_state.screen == 0:
63
- with row0_col1:
64
- # heading
65
- st.markdown("<h1 style='text-align: center; color: black;'>Find Waldo and His Friends</h1>", unsafe_allow_html=True)
66
- st.markdown("<h3 style='text-align: center; color: black;'>Using Computer Vision</h3>", unsafe_allow_html=True)
67
  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)
68
 
69
  # proceed button
@@ -83,13 +86,11 @@ if st.session_state.screen == 0:
83
  #####
84
  if st.session_state.screen == 1:
85
  # heading and instructions
86
- with row0_col1:
87
- st.markdown("<h1 style='text-align: center; color: black;'>Find Waldo and His Friends</h1>", unsafe_allow_html=True)
88
- st.markdown("<h3 style='text-align: center; color: black;'>Using Computer Vision</h3>", unsafe_allow_html=True)
89
  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)
90
 
91
  # image uploader
92
- with row1_col1:
93
  uploaded_image = st.file_uploader(label="",
94
  type=['jpg'],
95
  accept_multiple_files=False,
@@ -113,7 +114,7 @@ if st.session_state.screen == 1:
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)
@@ -121,7 +122,7 @@ if st.session_state.screen == 1:
121
  st.session_state.image = img_1
122
  st.session_state.screen = 2
123
  st.rerun()
124
- with row2_col2:
125
  img_2 = Image.open(image_path + "IMG_5357.JPG")
126
  img_2 = ImageOps.exif_transpose(img_2)
127
  st.image(img_2, use_column_width=True)
@@ -129,7 +130,7 @@ if st.session_state.screen == 1:
129
  st.session_state.image = img_2
130
  st.session_state.screen = 2
131
  st.rerun()
132
- with row2_col3:
133
  img_3 = Image.open(image_path + "IMG_5368.JPG")
134
  img_3 = ImageOps.exif_transpose(img_3)
135
  st.image(img_3, use_column_width=True)
@@ -137,7 +138,7 @@ if st.session_state.screen == 1:
137
  st.session_state.image = img_3
138
  st.session_state.screen = 2
139
  st.rerun()
140
- with row2_col4:
141
  img_4 = Image.open(image_path + "IMG_5369.JPG")
142
  img_4 = ImageOps.exif_transpose(img_4)
143
  st.image(img_4, use_column_width=True)
@@ -145,7 +146,7 @@ if st.session_state.screen == 1:
145
  st.session_state.image = img_4
146
  st.session_state.screen = 2
147
  st.rerun()
148
- with row3_col1:
149
  img_5 = Image.open(image_path + "IMG_5382.JPG")
150
  img_5 = ImageOps.exif_transpose(img_5)
151
  st.image(img_5, use_column_width=True)
@@ -153,7 +154,7 @@ if st.session_state.screen == 1:
153
  st.session_state.image = img_5
154
  st.session_state.screen = 2
155
  st.rerun()
156
- with row3_col2:
157
  img_6 = Image.open(image_path + "IMG_5383.JPG")
158
  img_6 = ImageOps.exif_transpose(img_6)
159
  st.image(img_6, use_column_width=True)
@@ -161,7 +162,7 @@ if st.session_state.screen == 1:
161
  st.session_state.image = img_6
162
  st.session_state.screen = 2
163
  st.rerun()
164
- with row3_col3:
165
  img_7 = Image.open(image_path + "IMG_5408.JPG")
166
  img_7 = ImageOps.exif_transpose(img_7)
167
  st.image(img_7, use_column_width=True)
@@ -169,7 +170,7 @@ if st.session_state.screen == 1:
169
  st.session_state.image = img_7
170
  st.session_state.screen = 2
171
  st.rerun()
172
- with row3_col4:
173
  img_8 = Image.open(image_path + "IMG_5409.JPG")
174
  img_8 = ImageOps.exif_transpose(img_8)
175
  st.image(img_8, use_column_width=True)
@@ -203,26 +204,23 @@ def tile_image(image, tile_size, overlap):
203
  if st.session_state.screen == 2:
204
  # tile images
205
  tiles = tile_image(image=st.session_state.image, tile_size=640, overlap=40)
206
-
207
- st.write("\n\n")
208
- components.html("""<hr style="height:2px;border:none;color:#333;background-color:#333;" /> """)
209
 
210
- with row4_col2:
211
  st.image(st.session_state.image, use_column_width=True)
212
 
213
- with row4_col3:
214
  # navigation
215
  row4a_col0, row4a_col1, row4a_col2= st.columns([1,1,1], gap="medium")
216
- with row4a_col0:
217
  if st.button("Back"):
218
  if st.session_state.image_counter > 0:
219
  st.session_state.image_counter -= 1
220
- with row4a_col1:
221
  if st.button("Select New Photo"):
222
  st.session_state.screen = 1
223
  st.session_state.results = None
224
  st.rerun()
225
- with row4a_col2:
226
  if st.button("Next"):
227
  if st.session_state.image_counter < len(st.session_state.results) - 1:
228
  st.session_state.image_counter += 1
 
46
 
47
  _, row0_col1, _ = st.columns([2,3,2])
48
  _, row1_col1, _ = st.columns([2,3,2])
49
+ _, row2_col1, _ = st.columns([2,3,2])
50
  _, row3_col1, row3_col2, row3_col3, row3_col4, _ = st.columns([8,3,3,3,3,8])
51
+ _, row4_col1, row4_col2, row4_col3, row4_col4, _ = st.columns([8,3,3,3,3,8])
52
+ _, row5_col2, row5_col3, _ = st.columns([1,4,4,1], gap="medium")
53
 
54
+ # heading
55
+ with row0_col1:
56
+ st.markdown("<h1 style='text-align: center; color: black;'>Find Waldo and His Friends</h1>", unsafe_allow_html=True)
57
+ st.markdown("<h3 style='text-align: center; color: black;'>Using Computer Vision</h3>", unsafe_allow_html=True)
58
 
59
 
60
 
 
65
  #####
66
  # This displays to inform the user about the tool
67
  if st.session_state.screen == 0:
68
+ with row1_col1:
69
+ # overview
 
 
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
 
86
  #####
87
  if st.session_state.screen == 1:
88
  # heading and instructions
89
+ with row1_col1:
 
 
90
  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)
91
 
92
  # image uploader
93
+ with row2_col1:
94
  uploaded_image = st.file_uploader(label="",
95
  type=['jpg'],
96
  accept_multiple_files=False,
 
114
  st.markdown("<h4 style='text-align: center; color: black;'>Or Select One of the Following</h4>", unsafe_allow_html=True)
115
 
116
  image_path = "/home/user/app/test_images/"
117
+ with row3_col1:
118
  img_1 = Image.open(image_path + "IMG_5356.JPG")
119
  img_1 = ImageOps.exif_transpose(img_1)
120
  st.image(img_1, use_column_width=True)
 
122
  st.session_state.image = img_1
123
  st.session_state.screen = 2
124
  st.rerun()
125
+ with row3_col2:
126
  img_2 = Image.open(image_path + "IMG_5357.JPG")
127
  img_2 = ImageOps.exif_transpose(img_2)
128
  st.image(img_2, use_column_width=True)
 
130
  st.session_state.image = img_2
131
  st.session_state.screen = 2
132
  st.rerun()
133
+ with row3_col3:
134
  img_3 = Image.open(image_path + "IMG_5368.JPG")
135
  img_3 = ImageOps.exif_transpose(img_3)
136
  st.image(img_3, use_column_width=True)
 
138
  st.session_state.image = img_3
139
  st.session_state.screen = 2
140
  st.rerun()
141
+ with row3_col4:
142
  img_4 = Image.open(image_path + "IMG_5369.JPG")
143
  img_4 = ImageOps.exif_transpose(img_4)
144
  st.image(img_4, use_column_width=True)
 
146
  st.session_state.image = img_4
147
  st.session_state.screen = 2
148
  st.rerun()
149
+ with row4_col1:
150
  img_5 = Image.open(image_path + "IMG_5382.JPG")
151
  img_5 = ImageOps.exif_transpose(img_5)
152
  st.image(img_5, use_column_width=True)
 
154
  st.session_state.image = img_5
155
  st.session_state.screen = 2
156
  st.rerun()
157
+ with row4_col2:
158
  img_6 = Image.open(image_path + "IMG_5383.JPG")
159
  img_6 = ImageOps.exif_transpose(img_6)
160
  st.image(img_6, use_column_width=True)
 
162
  st.session_state.image = img_6
163
  st.session_state.screen = 2
164
  st.rerun()
165
+ with row4_col3:
166
  img_7 = Image.open(image_path + "IMG_5408.JPG")
167
  img_7 = ImageOps.exif_transpose(img_7)
168
  st.image(img_7, use_column_width=True)
 
170
  st.session_state.image = img_7
171
  st.session_state.screen = 2
172
  st.rerun()
173
+ with row4_col4:
174
  img_8 = Image.open(image_path + "IMG_5409.JPG")
175
  img_8 = ImageOps.exif_transpose(img_8)
176
  st.image(img_8, use_column_width=True)
 
204
  if st.session_state.screen == 2:
205
  # tile images
206
  tiles = tile_image(image=st.session_state.image, tile_size=640, overlap=40)
 
 
 
207
 
208
+ with row5_col2:
209
  st.image(st.session_state.image, use_column_width=True)
210
 
211
+ with row5_col3:
212
  # navigation
213
  row4a_col0, row4a_col1, row4a_col2= st.columns([1,1,1], gap="medium")
214
+ with row5a_col0:
215
  if st.button("Back"):
216
  if st.session_state.image_counter > 0:
217
  st.session_state.image_counter -= 1
218
+ with row5a_col1:
219
  if st.button("Select New Photo"):
220
  st.session_state.screen = 1
221
  st.session_state.results = None
222
  st.rerun()
223
+ with row5a_col2:
224
  if st.button("Next"):
225
  if st.session_state.image_counter < len(st.session_state.results) - 1:
226
  st.session_state.image_counter += 1