Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,6 +29,7 @@ from ultralytics import YOLO
|
|
| 29 |
# 01 Setup
|
| 30 |
###
|
| 31 |
#####
|
|
|
|
| 32 |
st.set_page_config(layout="wide")
|
| 33 |
|
| 34 |
uploaded_image = None
|
|
@@ -60,9 +61,6 @@ _, row4_col2, row4_col3, _ = st.columns([1,4,4,1], gap="medium")
|
|
| 60 |
###
|
| 61 |
#####
|
| 62 |
# This displays to inform the user about the tool
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
# load model
|
| 66 |
if st.session_state.screen == 0:
|
| 67 |
with row0_col1:
|
| 68 |
# heading
|
|
@@ -212,13 +210,6 @@ if st.session_state.screen == 2:
|
|
| 212 |
|
| 213 |
with row4_col2:
|
| 214 |
st.image(st.session_state.image, use_column_width=True)
|
| 215 |
-
|
| 216 |
-
# predictions
|
| 217 |
-
if 'results' not in st.session_state:
|
| 218 |
-
st.session_state.results = st.session_state.model.predict(tiles, conf=0.5) # predict
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
|
| 223 |
with row4_col3:
|
| 224 |
row4a_col3, row4b_col3= st.columns([1,1], gap="medium")
|
|
@@ -226,12 +217,21 @@ if st.session_state.screen == 2:
|
|
| 226 |
if st.button("Back"):
|
| 227 |
if st.session_state.image_counter > 0:
|
| 228 |
st.session_state.image_counter -= 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
with row4b_col3:
|
| 230 |
if st.button("Next"):
|
| 231 |
if st.session_state.image_counter < len(st.session_state.results):
|
| 232 |
st.session_state.image_counter += 1
|
| 233 |
-
|
| 234 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
im_bgr = st.session_state.results[st.session_state.image_counter].plot() # BGR-order numpy array
|
| 236 |
im_rgb = Image.fromarray(im_bgr[..., ::-1]) # RGB-order PIL image
|
| 237 |
st.image(im_rgb)
|
|
|
|
| 29 |
# 01 Setup
|
| 30 |
###
|
| 31 |
#####
|
| 32 |
+
# This loads general code for use by the tool
|
| 33 |
st.set_page_config(layout="wide")
|
| 34 |
|
| 35 |
uploaded_image = None
|
|
|
|
| 61 |
###
|
| 62 |
#####
|
| 63 |
# This displays to inform the user about the tool
|
|
|
|
|
|
|
|
|
|
| 64 |
if st.session_state.screen == 0:
|
| 65 |
with row0_col1:
|
| 66 |
# heading
|
|
|
|
| 210 |
|
| 211 |
with row4_col2:
|
| 212 |
st.image(st.session_state.image, use_column_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
with row4_col3:
|
| 215 |
row4a_col3, row4b_col3= st.columns([1,1], gap="medium")
|
|
|
|
| 217 |
if st.button("Back"):
|
| 218 |
if st.session_state.image_counter > 0:
|
| 219 |
st.session_state.image_counter -= 1
|
| 220 |
+
with row4b_col3:
|
| 221 |
+
if st.button("Select New Photo"):
|
| 222 |
+
st.session_state.screen = 1
|
| 223 |
+
st.session_state.results = None
|
| 224 |
+
st.rerun()
|
| 225 |
with row4b_col3:
|
| 226 |
if st.button("Next"):
|
| 227 |
if st.session_state.image_counter < len(st.session_state.results):
|
| 228 |
st.session_state.image_counter += 1
|
| 229 |
+
|
| 230 |
+
# predictions
|
| 231 |
+
if 'results' not in st.session_state:
|
| 232 |
+
st.session_state.results = st.session_state.model.predict(tiles, conf=0.5) # predict
|
| 233 |
+
|
| 234 |
+
# plot predicted image
|
| 235 |
im_bgr = st.session_state.results[st.session_state.image_counter].plot() # BGR-order numpy array
|
| 236 |
im_rgb = Image.fromarray(im_bgr[..., ::-1]) # RGB-order PIL image
|
| 237 |
st.image(im_rgb)
|