sabaridsnfuji commited on
Commit
e16fbee
1 Parent(s): 49e4f98

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -53,8 +53,8 @@ def predict_image(image):
53
  # Draw boxes and collect prediction data
54
  for result in results:
55
  boxes = result[:4]
56
- prob = result[4]
57
- prob0 = round(prob, 2)
58
  classes = int(result[5])
59
  boxes = boxes/img_size
60
 
@@ -65,15 +65,15 @@ def predict_image(image):
65
  boxes[3] * im_height
66
  ])
67
 
68
- if prob > 0.2:
69
  cv2.rectangle(temp_image, (x1, y1), (x2, y2), (0, 0, 255), 2)
70
- label_text = f"{classes} {prob0}"
71
- cv2.putText(temp_image, label_text, (x1, y1), 0, 0.5, (0, 255, 0), 2)
72
 
73
  # Store prediction info in a JSON-compatible format
74
  predictions.append({
75
  "class": label_to_class_text[classes],
76
- "probability": round(float(prob), 2),
77
  "coordinates": {
78
  "xmin": int(x1),
79
  "ymin": int(y1),
 
53
  # Draw boxes and collect prediction data
54
  for result in results:
55
  boxes = result[:4]
56
+ probs = result[4]
57
+ #prob0 = round(prob, 2)
58
  classes = int(result[5])
59
  boxes = boxes/img_size
60
 
 
65
  boxes[3] * im_height
66
  ])
67
 
68
+ if probs > 0.2:
69
  cv2.rectangle(temp_image, (x1, y1), (x2, y2), (0, 0, 255), 2)
70
+ #label_text = f"{classes} {prob0}"
71
+ cv2.putText(temp_image, str(classes)+" "+str(round(float(probs),2)), (x1, y1), 0, 0.5, (0, 255, 0), 2)
72
 
73
  # Store prediction info in a JSON-compatible format
74
  predictions.append({
75
  "class": label_to_class_text[classes],
76
+ "probability": round(float(probs), 3),
77
  "coordinates": {
78
  "xmin": int(x1),
79
  "ymin": int(y1),