BenjiELCA commited on
Commit
e49e1d2
1 Parent(s): d3a974f

can handle if there is nothing is detected with an error

Files changed (3) hide show
  1. app.py +15 -11
  2. modules/eval.py +3 -0
  3. modules/streamlit_utils.py +2 -0
app.py CHANGED
@@ -42,20 +42,24 @@ def main():
42
  del st.session_state.prediction
43
  return
44
 
45
- with prediction_result_placeholder.container():
46
- if is_mobile:
47
- display_options(st.session_state.crop_image, st.session_state.score_threshold, is_mobile, int(5/6*screen_width))
48
- else:
49
- with st.expander("Show result of prediction"):
50
  display_options(st.session_state.crop_image, st.session_state.score_threshold, is_mobile, int(5/6*screen_width))
 
 
 
51
 
52
- if not is_mobile:
53
- with additional_options_placeholder.container():
54
- modify_results()
55
 
56
- with modeler_placeholder.container():
57
- modeler_options(is_mobile)
58
- display_bpmn_modeler(is_mobile, screen_width)
 
59
  else:
60
  prediction_result_placeholder.empty()
61
  additional_options_placeholder.empty()
 
42
  del st.session_state.prediction
43
  return
44
 
45
+ if len(st.session_state.prediction['labels'])==0:
46
+ error("No prediction available. Please upload a BPMN image or decrease the detection score treshold.")
47
+ else:
48
+ with prediction_result_placeholder.container():
49
+ if is_mobile:
50
  display_options(st.session_state.crop_image, st.session_state.score_threshold, is_mobile, int(5/6*screen_width))
51
+ else:
52
+ with st.expander("Show result of prediction"):
53
+ display_options(st.session_state.crop_image, st.session_state.score_threshold, is_mobile, int(5/6*screen_width))
54
 
55
+ if not is_mobile:
56
+ with additional_options_placeholder.container():
57
+ state = modify_results()
58
 
59
+
60
+ with modeler_placeholder.container():
61
+ modeler_options(is_mobile)
62
+ display_bpmn_modeler(is_mobile, screen_width)
63
  else:
64
  prediction_result_placeholder.empty()
65
  additional_options_placeholder.empty()
modules/eval.py CHANGED
@@ -164,6 +164,9 @@ def mix_predictions(objects_pred, arrow_pred):
164
  object_keypoints.append(keypoints)
165
 
166
  #concatenate the two predictions
 
 
 
167
  boxes = np.concatenate((objects_pred['boxes'], arrow_pred['boxes']))
168
  labels = np.concatenate((objects_pred['labels'], arrow_pred['labels']))
169
  scores = np.concatenate((objects_pred['scores'], arrow_pred['scores']))
 
164
  object_keypoints.append(keypoints)
165
 
166
  #concatenate the two predictions
167
+ if len(arrow_pred['boxes']) == 0:
168
+ return objects_pred['boxes'], objects_pred['labels'], objects_pred['scores'], object_keypoints
169
+
170
  boxes = np.concatenate((objects_pred['boxes'], arrow_pred['boxes']))
171
  labels = np.concatenate((objects_pred['labels'], arrow_pred['labels']))
172
  scores = np.concatenate((objects_pred['scores'], arrow_pred['scores']))
modules/streamlit_utils.py CHANGED
@@ -411,6 +411,8 @@ def modify_results(percentage_text_dist_thresh=0.5):
411
  if changes:
412
  st.rerun()
413
 
 
 
414
 
415
 
416
 
 
411
  if changes:
412
  st.rerun()
413
 
414
+ return True
415
+
416
 
417
 
418