Eric P. Nusbaum commited on
Commit
e7ef62f
·
1 Parent(s): 2d9409a

Update Space

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -78,15 +78,22 @@ def draw_boxes(image: Image.Image, outputs: dict):
78
  bottom = ymax * image_height
79
 
80
  # Draw bounding box
81
- draw.rectangle([left, top, right, bottom], outline="red", width=3)
82
 
83
  # Prepare label text
84
  text = f"{label}: {score:.2f}"
85
 
 
 
 
 
 
 
 
86
  # Calculate text size using textbbox
87
- text_bbox = draw.textbbox((0, 0), text, font=font)
88
- text_width = text_bbox[2] - text_bbox[0]
89
- text_height = text_bbox[3] - text_bbox[1]
90
 
91
  # Calculate label background position
92
  # Ensure the label box does not go above the image
 
78
  bottom = ymax * image_height
79
 
80
  # Draw bounding box
81
+ draw.rectangle([left, top, right, bottom], outline="red", width=4)
82
 
83
  # Prepare label text
84
  text = f"{label}: {score:.2f}"
85
 
86
+ #Text Box will occupy the top left corner of the bounding box
87
+ #Size of the box (and text) will be 10% of the height of the bounding box
88
+ #And width of the entire bounding box
89
+
90
+ text_width = right - left
91
+ text_height = (bottom - top) // 10
92
+
93
  # Calculate text size using textbbox
94
+ #text_bbox = draw.textbbox((0, 0), text, font=font)
95
+ #text_width = text_bbox[2] - text_bbox[0]
96
+ #text_height = text_bbox[3] - text_bbox[1]
97
 
98
  # Calculate label background position
99
  # Ensure the label box does not go above the image