Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,8 +15,7 @@ object_detector = pipeline("object-detection",
|
|
15 |
# model=model_path)
|
16 |
|
17 |
|
18 |
-
def draw_bounding_boxes(image, detections, font_path=None, font_size=
|
19 |
-
|
20 |
# Make a copy of the image to draw on
|
21 |
draw_image = image.copy()
|
22 |
draw = ImageDraw.Draw(draw_image)
|
@@ -25,7 +24,7 @@ def draw_bounding_boxes(image, detections, font_path=None, font_size=20):
|
|
25 |
if font_path:
|
26 |
font = ImageFont.truetype(font_path, font_size)
|
27 |
else:
|
28 |
-
# When font_path is not provided, load default font but
|
29 |
font = ImageFont.load_default()
|
30 |
# Increase font size workaround by using a TTF font file, if needed, can download and specify the path
|
31 |
|
@@ -57,6 +56,7 @@ def draw_bounding_boxes(image, detections, font_path=None, font_size=20):
|
|
57 |
return draw_image
|
58 |
|
59 |
|
|
|
60 |
def detect_object(image):
|
61 |
raw_image = image
|
62 |
output = object_detector(raw_image)
|
@@ -67,9 +67,9 @@ demo = gr.Interface(fn=detect_object,
|
|
67 |
inputs=[gr.Image(label="Select Image",type="pil")],
|
68 |
outputs=[gr.Image(label="Processed Image", type="pil")],
|
69 |
title="Object Detector",
|
70 |
-
description="
|
71 |
demo.launch()
|
72 |
|
73 |
-
|
74 |
|
75 |
|
|
|
15 |
# model=model_path)
|
16 |
|
17 |
|
18 |
+
def draw_bounding_boxes(image, detections, font_path=None, font_size=30):
|
|
|
19 |
# Make a copy of the image to draw on
|
20 |
draw_image = image.copy()
|
21 |
draw = ImageDraw.Draw(draw_image)
|
|
|
24 |
if font_path:
|
25 |
font = ImageFont.truetype(font_path, font_size)
|
26 |
else:
|
27 |
+
# When font_path is not provided, load default font but its size is fixed
|
28 |
font = ImageFont.load_default()
|
29 |
# Increase font size workaround by using a TTF font file, if needed, can download and specify the path
|
30 |
|
|
|
56 |
return draw_image
|
57 |
|
58 |
|
59 |
+
|
60 |
def detect_object(image):
|
61 |
raw_image = image
|
62 |
output = object_detector(raw_image)
|
|
|
67 |
inputs=[gr.Image(label="Select Image",type="pil")],
|
68 |
outputs=[gr.Image(label="Processed Image", type="pil")],
|
69 |
title="Object Detector",
|
70 |
+
description="Detect objects in the input image and annotate them with bounding boxes and labels.")
|
71 |
demo.launch()
|
72 |
|
73 |
+
|
74 |
|
75 |
|