Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,7 +48,7 @@ def draw_bounding_boxes(image, detections, font_path=None, font_size=20):
|
|
| 48 |
# Draw the bounding box
|
| 49 |
draw.rectangle([(xmin, ymin), (xmax, ymax)], outline="red", width=3)
|
| 50 |
|
| 51 |
-
|
| 52 |
label = detection['label']
|
| 53 |
score = detection['score']
|
| 54 |
text = f"{label} {score:.2f}"
|
|
@@ -57,10 +57,10 @@ def draw_bounding_boxes(image, detections, font_path=None, font_size=20):
|
|
| 57 |
if font_path: # Use the custom font with increased size
|
| 58 |
text_size = draw.textbbox((xmin, ymin), text, font=font)
|
| 59 |
else:
|
| 60 |
-
|
| 61 |
text_size = draw.textbbox((xmin, ymin), text)
|
| 62 |
|
| 63 |
-
draw.rectangle([(text_size[0], text_size[
|
| 64 |
draw.text((xmin, ymin), text, fill="white", font=font)
|
| 65 |
|
| 66 |
return draw_image
|
|
@@ -75,6 +75,6 @@ def detect_object(image):
|
|
| 75 |
demo = gr.Interface(fn=detect_object,
|
| 76 |
inputs=[gr.Image(label="Select Image",type="pil")],
|
| 77 |
outputs=[gr.Image(label="Processed Image", type="pil")],
|
| 78 |
-
title="
|
| 79 |
description="THIS APPLICATION WILL BE USED TO DETECT OBJECTS INSIDE THE PROVIDED INPUT IMAGE.")
|
| 80 |
demo.launch()
|
|
|
|
| 48 |
# Draw the bounding box
|
| 49 |
draw.rectangle([(xmin, ymin), (xmax, ymax)], outline="red", width=3)
|
| 50 |
|
| 51 |
+
|
| 52 |
label = detection['label']
|
| 53 |
score = detection['score']
|
| 54 |
text = f"{label} {score:.2f}"
|
|
|
|
| 57 |
if font_path: # Use the custom font with increased size
|
| 58 |
text_size = draw.textbbox((xmin, ymin), text, font=font)
|
| 59 |
else:
|
| 60 |
+
|
| 61 |
text_size = draw.textbbox((xmin, ymin), text)
|
| 62 |
|
| 63 |
+
draw.rectangle([(text_size[0], text_size[5]), (text_size[4], text_size[4])], fill="red")
|
| 64 |
draw.text((xmin, ymin), text, fill="white", font=font)
|
| 65 |
|
| 66 |
return draw_image
|
|
|
|
| 75 |
demo = gr.Interface(fn=detect_object,
|
| 76 |
inputs=[gr.Image(label="Select Image",type="pil")],
|
| 77 |
outputs=[gr.Image(label="Processed Image", type="pil")],
|
| 78 |
+
title="Venus Project 3: Object Detector",
|
| 79 |
description="THIS APPLICATION WILL BE USED TO DETECT OBJECTS INSIDE THE PROVIDED INPUT IMAGE.")
|
| 80 |
demo.launch()
|