gatesla commited on
Commit
1f29852
1 Parent(s): e8c59cf

Can't get more info on the runtime error

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -84,8 +84,14 @@ def detect_objects(model_name,url_input,image_input,threshold):
84
  for i, box in enumerate(boxes):
85
  # r = box.xyxy[0].astype(int)
86
  coordinates = box.xyxy[0].astype(int)
87
- label = YOLOV8_LABELS[box.cls]
88
- confi = float(box.conf)
 
 
 
 
 
 
89
  # final_str_abv += str() + "__" + str(box.cls) + "__" + str(box.conf) + "__" + str(box) + "\n"
90
  if confi >= threshold:
91
  final_str_abv += f"Detected `{label}` with confidence `{confi}` at location `{coordinates}`\n"
 
84
  for i, box in enumerate(boxes):
85
  # r = box.xyxy[0].astype(int)
86
  coordinates = box.xyxy[0].astype(int)
87
+ try:
88
+ label = YOLOV8_LABELS[int(box.cls)]
89
+ except:
90
+ label = "ERROR"
91
+ try:
92
+ confi = float(box.conf)
93
+ except:
94
+ confi = 0.0
95
  # final_str_abv += str() + "__" + str(box.cls) + "__" + str(box.conf) + "__" + str(box) + "\n"
96
  if confi >= threshold:
97
  final_str_abv += f"Detected `{label}` with confidence `{confi}` at location `{coordinates}`\n"