mustafa2ak commited on
Commit
c6b8113
·
verified ·
1 Parent(s): 0b5dbf0

Update detector.py

Browse files
Files changed (1) hide show
  1. 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
- text_w, text_h = draw.textsize(label, font=font)
 
 
 
 
 
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