Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,6 +43,9 @@ if 'image' not in st.session_state:
|
|
| 43 |
if 'image_counter' not in st.session_state:
|
| 44 |
st.session_state.image_counter = 0
|
| 45 |
|
|
|
|
|
|
|
|
|
|
| 46 |
if 'model' not in st.session_state:
|
| 47 |
st.session_state.model = YOLO("/home/user/app/models/head_model/best.pt") # load
|
| 48 |
|
|
@@ -204,16 +207,17 @@ if st.session_state.screen == 2:
|
|
| 204 |
st.session_state.image_counter += 1
|
| 205 |
|
| 206 |
# predictions
|
| 207 |
-
if 'results' not in st.session_state:
|
| 208 |
st.write("The model is working. Please be patient...")
|
| 209 |
st.write("This process takes around 30 seconds.")
|
| 210 |
-
st.session_state.results = st.session_state.model.predict(st.session_state.tiles, conf=
|
| 211 |
st.rerun()
|
| 212 |
|
| 213 |
# plot predicted image
|
| 214 |
im_bgr = st.session_state.results[st.session_state.image_counter].plot() # BGR-order numpy array
|
| 215 |
im_rgb = Image.fromarray(im_bgr[..., ::-1]) # RGB-order PIL image
|
| 216 |
st.image(im_rgb)
|
|
|
|
| 217 |
|
| 218 |
|
| 219 |
|
|
|
|
| 43 |
if 'image_counter' not in st.session_state:
|
| 44 |
st.session_state.image_counter = 0
|
| 45 |
|
| 46 |
+
if 'confidence' not in st.session_state:
|
| 47 |
+
st.session_state.confidence = 50
|
| 48 |
+
|
| 49 |
if 'model' not in st.session_state:
|
| 50 |
st.session_state.model = YOLO("/home/user/app/models/head_model/best.pt") # load
|
| 51 |
|
|
|
|
| 207 |
st.session_state.image_counter += 1
|
| 208 |
|
| 209 |
# predictions
|
| 210 |
+
if 'results' not in st.session_state or st.session_state.results = None:
|
| 211 |
st.write("The model is working. Please be patient...")
|
| 212 |
st.write("This process takes around 30 seconds.")
|
| 213 |
+
st.session_state.results = st.session_state.model.predict(st.session_state.tiles, conf=st.session_state.confidence) # predict
|
| 214 |
st.rerun()
|
| 215 |
|
| 216 |
# plot predicted image
|
| 217 |
im_bgr = st.session_state.results[st.session_state.image_counter].plot() # BGR-order numpy array
|
| 218 |
im_rgb = Image.fromarray(im_bgr[..., ::-1]) # RGB-order PIL image
|
| 219 |
st.image(im_rgb)
|
| 220 |
+
st.session_state.confidence = st.slider(label="Change Model Confidence Level and Rerun", min_value=1, max_value=99, value=50, step=1)
|
| 221 |
|
| 222 |
|
| 223 |
|