sbby commited on
Commit
193fbe0
·
verified ·
1 Parent(s): d7f1a31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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
- # Optionally, you can also draw the label and score
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
- # Calculate text size using the default font
61
  text_size = draw.textbbox((xmin, ymin), text)
62
 
63
- draw.rectangle([(text_size[0], text_size[1]), (text_size[2], text_size[3])], fill="red")
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="@GenAILearniverse Project 6: Object Detector",
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()