Auto-UTF handling (#4594)
This commit is contained in:
1 parent
de44376d1b
commit
e5e5ebc799
3 files changed
+10
-8
No files matched your search
+5
-4
@@ -18,9 +18,9 @@ from PIL import Image
|
||||
from torch.cuda import amp
|
||||
|
||||
from utils.datasets import exif_transpose, letterbox
|
||||
from utils.general import colorstr, non_max_suppression, make_divisible, scale_coords, increment_path, xyxy2xywh, \
|
||||
save_one_box
|
||||
from utils.plots import colors, Annotator
|
||||
from utils.general import colorstr, increment_path, is_ascii, make_divisible, non_max_suppression, save_one_box, \
|
||||
scale_coords, xyxy2xywh
|
||||
from utils.plots import Annotator, colors
|
||||
from utils.torch_utils import time_sync
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
@@ -354,6 +354,7 @@ class Detections:
|
||||
self.imgs = imgs # list of images as numpy arrays
|
||||
self.pred = pred # list of tensors pred[0] = (xyxy, conf, cls)
|
||||
self.names = names # class names
|
||||
self.ascii = is_ascii(names) # names are ascii (use PIL for UTF-8)
|
||||
self.files = files # image filenames
|
||||
self.xyxy = pred # xyxy pixels
|
||||
self.xywh = [xyxy2xywh(x) for x in pred] # xywh pixels
|
||||
@@ -371,7 +372,7 @@ class Detections:
|
||||
n = (pred[:, -1] == c).sum() # detections per class
|
||||
str += f"{n} {self.names[int(c)]}{'s' * (n > 1)}, " # add to string
|
||||
if show or save or render or crop:
|
||||
annotator = Annotator(im, pil=False)
|
||||
annotator = Annotator(im, pil=not self.ascii)
|
||||
for *box, conf, cls in reversed(pred): # xyxy, confidence, class
|
||||
label = f'{self.names[int(cls)]} {conf:.2f}'
|
||||
if crop:
|
||||
|
||||
Reference in new issue
Block a user