Spaces:
Running
Running
delete prediction if we change image
Browse files- app.py +7 -1
- modules/streamlit_utils.py +2 -1
app.py
CHANGED
|
@@ -26,7 +26,7 @@ def main():
|
|
| 26 |
if cropped_image is not None:
|
| 27 |
get_score_threshold(is_mobile)
|
| 28 |
if st.button("π Launch Prediction"):
|
| 29 |
-
launch_prediction(cropped_image, st.session_state.score_threshold, is_mobile, screen_width)
|
| 30 |
st.session_state.original_prediction = st.session_state.prediction.copy()
|
| 31 |
st.rerun()
|
| 32 |
|
|
@@ -34,6 +34,12 @@ def main():
|
|
| 34 |
#if st.button("π Refresh image"):
|
| 35 |
#st.rerun()
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
with st.expander("Show result of prediction"):
|
| 38 |
with st.spinner('Waiting for result display...'):
|
| 39 |
display_options(st.session_state.crop_image, st.session_state.score_threshold, is_mobile, int(5/6 * screen_width))
|
|
|
|
| 26 |
if cropped_image is not None:
|
| 27 |
get_score_threshold(is_mobile)
|
| 28 |
if st.button("π Launch Prediction"):
|
| 29 |
+
st.session_state.image = launch_prediction(cropped_image, st.session_state.score_threshold, is_mobile, screen_width)
|
| 30 |
st.session_state.original_prediction = st.session_state.prediction.copy()
|
| 31 |
st.rerun()
|
| 32 |
|
|
|
|
| 34 |
#if st.button("π Refresh image"):
|
| 35 |
#st.rerun()
|
| 36 |
|
| 37 |
+
if st.session_state.image != cropped_image:
|
| 38 |
+
print('Image has changed')
|
| 39 |
+
#delete the prediction
|
| 40 |
+
del st.session_state.prediction
|
| 41 |
+
return
|
| 42 |
+
|
| 43 |
with st.expander("Show result of prediction"):
|
| 44 |
with st.spinner('Waiting for result display...'):
|
| 45 |
display_options(st.session_state.crop_image, st.session_state.score_threshold, is_mobile, int(5/6 * screen_width))
|
modules/streamlit_utils.py
CHANGED
|
@@ -293,11 +293,12 @@ def get_score_threshold(is_mobile):
|
|
| 293 |
def launch_prediction(cropped_image, score_threshold, is_mobile, screen_width):
|
| 294 |
st.session_state.crop_image = cropped_image
|
| 295 |
with st.spinner('Processing...'):
|
| 296 |
-
perform_inference(
|
| 297 |
st.session_state.model_object, st.session_state.model_arrow, st.session_state.crop_image,
|
| 298 |
score_threshold, is_mobile, screen_width, iou_threshold=0.3, distance_treshold=30, percentage_text_dist_thresh=0.5
|
| 299 |
)
|
| 300 |
st.balloons()
|
|
|
|
| 301 |
|
| 302 |
|
| 303 |
def modify_results(percentage_text_dist_thresh=0.5):
|
|
|
|
| 293 |
def launch_prediction(cropped_image, score_threshold, is_mobile, screen_width):
|
| 294 |
st.session_state.crop_image = cropped_image
|
| 295 |
with st.spinner('Processing...'):
|
| 296 |
+
image, _ , _ = perform_inference(
|
| 297 |
st.session_state.model_object, st.session_state.model_arrow, st.session_state.crop_image,
|
| 298 |
score_threshold, is_mobile, screen_width, iou_threshold=0.3, distance_treshold=30, percentage_text_dist_thresh=0.5
|
| 299 |
)
|
| 300 |
st.balloons()
|
| 301 |
+
return image
|
| 302 |
|
| 303 |
|
| 304 |
def modify_results(percentage_text_dist_thresh=0.5):
|