muhammadsalmanalfaridzi commited on
Commit
cb1e9a1
·
verified ·
1 Parent(s): ed878d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -30,8 +30,12 @@ def apply_nms(predictions, iou_threshold=0.5):
30
  # Perform NMS using OpenCV
31
  indices = cv2.dnn.NMSBoxes(boxes.tolist(), scores.tolist(), score_threshold=0.25, nms_threshold=iou_threshold)
32
 
33
- # Convert tuple of indices to a flat NumPy array
34
- indices = indices.flatten() if isinstance(indices, tuple) else indices
 
 
 
 
35
 
36
  nms_predictions = []
37
 
 
30
  # Perform NMS using OpenCV
31
  indices = cv2.dnn.NMSBoxes(boxes.tolist(), scores.tolist(), score_threshold=0.25, nms_threshold=iou_threshold)
32
 
33
+ # Ensure indices are a numpy array (if returned as a tuple)
34
+ if isinstance(indices, tuple):
35
+ indices = indices[0] # Extracting the first element which contains the indices
36
+
37
+ # Now indices is a numpy array, we can safely call .flatten()
38
+ indices = indices.flatten()
39
 
40
  nms_predictions = []
41