muhammadsalmanalfaridzi commited on
Commit
2b87afd
·
verified ·
1 Parent(s): 77c6990

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -12,6 +12,7 @@ rf = Roboflow(api_key="Otg64Ra6wNOgDyjuhMYU")
12
  project = rf.workspace("alat-pelindung-diri").project("nescafe-4base")
13
  model = project.version(16).model
14
 
 
15
  # Apply NMS (Non-Maximum Suppression)
16
  def apply_nms(predictions, iou_threshold=0.5):
17
  boxes = []
@@ -20,7 +21,14 @@ def apply_nms(predictions, iou_threshold=0.5):
20
 
21
  # Extract boxes, scores, and class info
22
  for prediction in predictions:
23
- boxes.append(prediction['bbox'])
 
 
 
 
 
 
 
24
  scores.append(prediction['confidence'])
25
  classes.append(prediction['class'])
26
 
@@ -50,7 +58,7 @@ def apply_nms(predictions, iou_threshold=0.5):
50
  for i in indices:
51
  nms_predictions.append({
52
  'class': classes[i],
53
- 'bbox': boxes[i],
54
  'confidence': scores[i]
55
  })
56
 
 
12
  project = rf.workspace("alat-pelindung-diri").project("nescafe-4base")
13
  model = project.version(16).model
14
 
15
+ # Apply NMS (Non-Maximum Suppression)
16
  # Apply NMS (Non-Maximum Suppression)
17
  def apply_nms(predictions, iou_threshold=0.5):
18
  boxes = []
 
21
 
22
  # Extract boxes, scores, and class info
23
  for prediction in predictions:
24
+ # Construct the bounding box from x, y, width, height
25
+ x = prediction['x']
26
+ y = prediction['y']
27
+ width = prediction['width']
28
+ height = prediction['height']
29
+ box = [x, y, width, height]
30
+
31
+ boxes.append(box)
32
  scores.append(prediction['confidence'])
33
  classes.append(prediction['class'])
34
 
 
58
  for i in indices:
59
  nms_predictions.append({
60
  'class': classes[i],
61
+ 'bbox': boxes[i], # Now using the constructed box
62
  'confidence': scores[i]
63
  })
64