Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,11 +13,12 @@ def draw_detections(image, detections):
|
|
13 |
np_image = cv2.cvtColor(np_image, cv2.COLOR_RGB2BGR)
|
14 |
|
15 |
for detection in detections:
|
16 |
-
#
|
17 |
score = detection['score']
|
18 |
-
label = detection['
|
19 |
-
box = detection['
|
20 |
-
x_min, y_min, x_max, y_max = map(int, box)
|
|
|
21 |
cv2.rectangle(np_image, (x_min, y_min), (x_max, y_max), (0, 255, 0), 2)
|
22 |
cv2.putText(np_image, f'{label} {score:.2f}', (x_min, max(y_min - 10, 0)),
|
23 |
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 1)
|
|
|
13 |
np_image = cv2.cvtColor(np_image, cv2.COLOR_RGB2BGR)
|
14 |
|
15 |
for detection in detections:
|
16 |
+
# Extract scores, labels, and bounding boxes properly
|
17 |
score = detection['score']
|
18 |
+
label = detection['labels']
|
19 |
+
box = detection['boxes'] # Make sure 'boxes' data structure matches expected in terms of naming and indexing
|
20 |
+
x_min, y_min, x_max, y_max = map(int, [box[0], box[1], box[2], box[3]])
|
21 |
+
|
22 |
cv2.rectangle(np_image, (x_min, y_min), (x_max, y_max), (0, 255, 0), 2)
|
23 |
cv2.putText(np_image, f'{label} {score:.2f}', (x_min, max(y_min - 10, 0)),
|
24 |
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 1)
|