Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -16,13 +16,6 @@ def detect(image):
|
|
16 |
threshold=0.9,
|
17 |
target_sizes=target_sizes)[0]
|
18 |
|
19 |
-
# Bounding box in COCO format:
|
20 |
-
# [x_min, y_min, width, height]
|
21 |
-
|
22 |
-
# model predicts bounding boxes and corresponding COCO classes
|
23 |
-
#logits = outputs.logits
|
24 |
-
#bboxes = outputs.pred_boxes
|
25 |
-
|
26 |
draw = ImageDraw.Draw(image)
|
27 |
|
28 |
# label and the count
|
@@ -36,15 +29,15 @@ def detect(image):
|
|
36 |
counts[label_name] += 1
|
37 |
|
38 |
x1, y1, x2, y2 = tuple(box)
|
39 |
-
draw.rectangle((x1, y1, x2, y2), outline="red", width=
|
40 |
-
draw.text((x1,
|
41 |
|
42 |
-
return
|
43 |
|
44 |
demo = gr.Interface(
|
45 |
fn=detect,
|
46 |
inputs=[gr.inputs.Image(label="Input image", type="pil")],
|
47 |
-
outputs=[
|
48 |
title="Object Counts in Image"
|
49 |
)
|
50 |
|
|
|
16 |
threshold=0.9,
|
17 |
target_sizes=target_sizes)[0]
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
draw = ImageDraw.Draw(image)
|
20 |
|
21 |
# label and the count
|
|
|
29 |
counts[label_name] += 1
|
30 |
|
31 |
x1, y1, x2, y2 = tuple(box)
|
32 |
+
draw.rectangle((x1, y1, x2, y2), outline="red", width=2)
|
33 |
+
draw.text((x1, y1), label_name, fill="white")
|
34 |
|
35 |
+
return counts, image
|
36 |
|
37 |
demo = gr.Interface(
|
38 |
fn=detect,
|
39 |
inputs=[gr.inputs.Image(label="Input image", type="pil")],
|
40 |
+
outputs=[gr.Label(num_top_classes=10), "text", "text", "image"], #, gr.Label(num_top_classes=10)],
|
41 |
title="Object Counts in Image"
|
42 |
)
|
43 |
|