Spaces:
Configuration error
Configuration error
Fix multiple object detection
Browse files- app.py +5 -7
- images/cyclist2.jpg +0 -0
app.py
CHANGED
@@ -73,11 +73,11 @@ def draw_boxes(image, boxes, class_names, scores, max_boxes=10, min_score=0.1):
|
|
73 |
print("Font not found, using default font.")
|
74 |
font = ImageFont.load_default()
|
75 |
|
76 |
-
for i in range(min(boxes.shape[
|
77 |
-
if scores[
|
78 |
-
ymin, xmin, ymax, xmax = tuple(boxes[
|
79 |
display_str = "{}: {}%".format(class_names[i],
|
80 |
-
int(100 * scores[
|
81 |
color = colors[hash(class_names[i]) % len(colors)]
|
82 |
image_pil = Image.fromarray(np.uint8(image)).convert("RGB")
|
83 |
draw_bounding_box_on_image(
|
@@ -106,9 +106,7 @@ def run_detector(url_input, image_input, minscore=0.1):
|
|
106 |
|
107 |
result = {key: value.numpy() for key, value in result.items()}
|
108 |
|
109 |
-
|
110 |
-
labels = ["cyclist" for _ in range(len(result["detection_scores"]))]
|
111 |
-
print(labels)
|
112 |
|
113 |
image_with_boxes = draw_boxes(
|
114 |
np.array(img), result["detection_boxes"],
|
|
|
73 |
print("Font not found, using default font.")
|
74 |
font = ImageFont.load_default()
|
75 |
|
76 |
+
for i in range(min(boxes.shape[1], max_boxes)):
|
77 |
+
if scores[0][i] >= min_score:
|
78 |
+
ymin, xmin, ymax, xmax = tuple(boxes[0][i])
|
79 |
display_str = "{}: {}%".format(class_names[i],
|
80 |
+
int(100 * scores[0][i]))
|
81 |
color = colors[hash(class_names[i]) % len(colors)]
|
82 |
image_pil = Image.fromarray(np.uint8(image)).convert("RGB")
|
83 |
draw_bounding_box_on_image(
|
|
|
106 |
|
107 |
result = {key: value.numpy() for key, value in result.items()}
|
108 |
|
109 |
+
labels = ["cyclist" for _ in range(len(result["detection_scores"][0]))]
|
|
|
|
|
110 |
|
111 |
image_with_boxes = draw_boxes(
|
112 |
np.array(img), result["detection_boxes"],
|
images/cyclist2.jpg
ADDED