Spaces:
Sleeping
Sleeping
Eric P. Nusbaum
commited on
Commit
·
9bad826
1
Parent(s):
de40de9
UI Fixes
Browse files
app.py
CHANGED
@@ -77,7 +77,7 @@ def draw_boxes(image: Image.Image, outputs: dict):
|
|
77 |
|
78 |
# Set label box dimensions
|
79 |
text_width = right - left
|
80 |
-
text_height = (bottom - top) //
|
81 |
|
82 |
# Calculate label background position
|
83 |
label_top = max(top - text_height - 10, 0)
|
@@ -97,7 +97,7 @@ def draw_boxes(image: Image.Image, outputs: dict):
|
|
97 |
font = ImageFont.truetype(font_path, size=font_size)
|
98 |
text_bbox = draw.textbbox((0, 0), text, font=font)
|
99 |
text_pixel_height = text_bbox[3] - text_bbox[1]
|
100 |
-
if text_pixel_height >= text_height or font_size >
|
101 |
break
|
102 |
font_size += 1
|
103 |
|
@@ -142,8 +142,8 @@ iface = gr.Interface(
|
|
142 |
gr.Image(type="pil", label="Detected Objects"),
|
143 |
gr.Textbox(label="Detections")
|
144 |
],
|
145 |
-
title="JunkWaxHero - Baseball Card Set Detection (ONNX Model)",
|
146 |
-
description="Upload an image to itentify the set of the baseball card.",
|
147 |
examples=["examples/card1.jpg", "examples/card2.jpg", "examples/card3.jpg"],
|
148 |
theme="default", # You can choose other themes if desired
|
149 |
allow_flagging="never" # Disable flagging if not needed
|
|
|
77 |
|
78 |
# Set label box dimensions
|
79 |
text_width = right - left
|
80 |
+
text_height = (bottom - top) // 5 # 10% of the bounding box height
|
81 |
|
82 |
# Calculate label background position
|
83 |
label_top = max(top - text_height - 10, 0)
|
|
|
97 |
font = ImageFont.truetype(font_path, size=font_size)
|
98 |
text_bbox = draw.textbbox((0, 0), text, font=font)
|
99 |
text_pixel_height = text_bbox[3] - text_bbox[1]
|
100 |
+
if text_pixel_height >= text_height or font_size > 200: # Cap font size to prevent infinite loops
|
101 |
break
|
102 |
font_size += 1
|
103 |
|
|
|
142 |
gr.Image(type="pil", label="Detected Objects"),
|
143 |
gr.Textbox(label="Detections")
|
144 |
],
|
145 |
+
title="JunkWaxHero ⚾ - Baseball Card Set Detection (ONNX Model)",
|
146 |
+
description="Upload an image to itentify the set of the baseball card (1980-1999).",
|
147 |
examples=["examples/card1.jpg", "examples/card2.jpg", "examples/card3.jpg"],
|
148 |
theme="default", # You can choose other themes if desired
|
149 |
allow_flagging="never" # Disable flagging if not needed
|