leedoming commited on
Commit
054c8f7
1 Parent(s): 8f016cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -9,8 +9,13 @@ import json
9
  import numpy as np
10
  from ultralytics import YOLO
11
  import cv2
12
- from streamlit_img_label import st_img_label
13
- from streamlit_img_label.manage import ImageManager
 
 
 
 
 
14
 
15
  # Load CLIP model and tokenizer
16
  @st.cache_resource
@@ -139,7 +144,11 @@ def adjust_bounding_boxes(image, detections):
139
  "label": detection['category']
140
  })
141
 
142
- adjusted_rects = st_img_label(image, box_color="red", rects=rects)
 
 
 
 
143
 
144
  adjusted_detections = []
145
  for rect, detection in zip(adjusted_rects, detections):
 
9
  import numpy as np
10
  from ultralytics import YOLO
11
  import cv2
12
+
13
+ try:
14
+ from streamlit_img_label import st_img_label
15
+ from streamlit_img_label.manage import ImageManager
16
+ except ImportError:
17
+ st.error("Required modules are not installed. Please install 'streamlit-img-label' and 'pascal-voc-writer'.")
18
+ st.stop()
19
 
20
  # Load CLIP model and tokenizer
21
  @st.cache_resource
 
144
  "label": detection['category']
145
  })
146
 
147
+ try:
148
+ adjusted_rects = st_img_label(image, box_color="red", rects=rects)
149
+ except Exception as e:
150
+ st.error(f"Error in st_img_label: {str(e)}")
151
+ return detections
152
 
153
  adjusted_detections = []
154
  for rect, detection in zip(adjusted_rects, detections):