Spaces:
Sleeping
Sleeping
Update detector.py
Browse files- detector.py +6 -1
detector.py
CHANGED
|
@@ -55,7 +55,12 @@ class RoadsideDetector:
|
|
| 55 |
draw.rectangle([x1, y1, x2, y2], outline="lime", width=4)
|
| 56 |
|
| 57 |
label = f"{cls_name} ({conf:.2f})"
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
draw.rectangle([x1, y1 - text_h - 4, x1 + text_w + 4, y1], fill="black")
|
| 60 |
draw.text((x1 + 2, y1 - text_h - 2), label, font=font, fill="yellow")
|
| 61 |
|
|
|
|
| 55 |
draw.rectangle([x1, y1, x2, y2], outline="lime", width=4)
|
| 56 |
|
| 57 |
label = f"{cls_name} ({conf:.2f})"
|
| 58 |
+
|
| 59 |
+
# ✅ Yeni Pillow sürümü için textsize yerine textbbox kullanalım
|
| 60 |
+
bbox = draw.textbbox((0, 0), label, font=font)
|
| 61 |
+
text_w = bbox[2] - bbox[0]
|
| 62 |
+
text_h = bbox[3] - bbox[1]
|
| 63 |
+
|
| 64 |
draw.rectangle([x1, y1 - text_h - 4, x1 + text_w + 4, y1], fill="black")
|
| 65 |
draw.text((x1 + 2, y1 - text_h - 2), label, font=font, fill="yellow")
|
| 66 |
|