Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -79,27 +79,27 @@ def detect_objects_in_image(image):
|
|
| 79 |
print("passed4")
|
| 80 |
mask = pred[:, 4] > conf_thres
|
| 81 |
pred = pred[mask]
|
| 82 |
-
|
| 83 |
if len(pred) == 0:
|
| 84 |
return Image.fromarray(np.array(image)), None # Return only image and None for graph
|
| 85 |
-
|
| 86 |
boxes, scores, class_probs = pred[:, :4], pred[:, 4], pred[:, 5:]
|
| 87 |
class_ids = np.argmax(class_probs, axis=1)
|
| 88 |
-
|
| 89 |
boxes[:, 0] = boxes[:, 0] - (boxes[:, 2] / 2)
|
| 90 |
boxes[:, 1] = boxes[:, 1] - (boxes[:, 3] / 2)
|
| 91 |
boxes[:, 2] = boxes[:, 0] + boxes[:, 2]
|
| 92 |
boxes[:, 3] = boxes[:, 1] + boxes[:, 3]
|
| 93 |
-
|
| 94 |
boxes[:, [0, 2]] *= orig_w / 640
|
| 95 |
boxes[:, [1, 3]] *= orig_h / 640
|
| 96 |
boxes = np.clip(boxes, 0, [orig_w, orig_h, orig_w, orig_h])
|
| 97 |
-
|
| 98 |
indices = cv2.dnn.NMSBoxes(boxes.tolist(), scores.tolist(), conf_thres, 0.5)
|
| 99 |
-
|
| 100 |
object_counts = {name: 0 for name in OBJECT_NAMES}
|
| 101 |
img_array = np.array(image)
|
| 102 |
-
|
| 103 |
if len(indices) > 0:
|
| 104 |
for i in indices.flatten():
|
| 105 |
x1, y1, x2, y2 = map(int, boxes[i])
|
|
|
|
| 79 |
print("passed4")
|
| 80 |
mask = pred[:, 4] > conf_thres
|
| 81 |
pred = pred[mask]
|
| 82 |
+
print("passed5")
|
| 83 |
if len(pred) == 0:
|
| 84 |
return Image.fromarray(np.array(image)), None # Return only image and None for graph
|
| 85 |
+
print("passed6")
|
| 86 |
boxes, scores, class_probs = pred[:, :4], pred[:, 4], pred[:, 5:]
|
| 87 |
class_ids = np.argmax(class_probs, axis=1)
|
| 88 |
+
print("passed7")
|
| 89 |
boxes[:, 0] = boxes[:, 0] - (boxes[:, 2] / 2)
|
| 90 |
boxes[:, 1] = boxes[:, 1] - (boxes[:, 3] / 2)
|
| 91 |
boxes[:, 2] = boxes[:, 0] + boxes[:, 2]
|
| 92 |
boxes[:, 3] = boxes[:, 1] + boxes[:, 3]
|
| 93 |
+
print("passed8")
|
| 94 |
boxes[:, [0, 2]] *= orig_w / 640
|
| 95 |
boxes[:, [1, 3]] *= orig_h / 640
|
| 96 |
boxes = np.clip(boxes, 0, [orig_w, orig_h, orig_w, orig_h])
|
| 97 |
+
print("passed9")
|
| 98 |
indices = cv2.dnn.NMSBoxes(boxes.tolist(), scores.tolist(), conf_thres, 0.5)
|
| 99 |
+
print("passed10")
|
| 100 |
object_counts = {name: 0 for name in OBJECT_NAMES}
|
| 101 |
img_array = np.array(image)
|
| 102 |
+
print("passed11")
|
| 103 |
if len(indices) > 0:
|
| 104 |
for i in indices.flatten():
|
| 105 |
x1, y1, x2, y2 = map(int, boxes[i])
|