Unverified 提交 d204a618 authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Alert (no detections) (#3984)

* `Detections()` class `print()` overload * Update common.py
上级 b3dabdcc
...@@ -307,7 +307,7 @@ class Detections: ...@@ -307,7 +307,7 @@ class Detections:
def display(self, pprint=False, show=False, save=False, crop=False, render=False, save_dir=Path('')): def display(self, pprint=False, show=False, save=False, crop=False, render=False, save_dir=Path('')):
for i, (im, pred) in enumerate(zip(self.imgs, self.pred)): for i, (im, pred) in enumerate(zip(self.imgs, self.pred)):
str = f'image {i + 1}/{len(self.pred)}: {im.shape[0]}x{im.shape[1]} ' str = f'image {i + 1}/{len(self.pred)}: {im.shape[0]}x{im.shape[1]} '
if pred is not None: if pred.shape[0]:
for c in pred[:, -1].unique(): for c in pred[:, -1].unique():
n = (pred[:, -1] == c).sum() # detections per class n = (pred[:, -1] == c).sum() # detections per class
str += f"{n} {self.names[int(c)]}{'s' * (n > 1)}, " # add to string str += f"{n} {self.names[int(c)]}{'s' * (n > 1)}, " # add to string
...@@ -318,6 +318,8 @@ class Detections: ...@@ -318,6 +318,8 @@ class Detections:
save_one_box(box, im, file=save_dir / 'crops' / self.names[int(cls)] / self.files[i]) save_one_box(box, im, file=save_dir / 'crops' / self.names[int(cls)] / self.files[i])
else: # all others else: # all others
plot_one_box(box, im, label=label, color=colors(cls)) plot_one_box(box, im, label=label, color=colors(cls))
else:
str += '(no detections)'
im = Image.fromarray(im.astype(np.uint8)) if isinstance(im, np.ndarray) else im # from np im = Image.fromarray(im.astype(np.uint8)) if isinstance(im, np.ndarray) else im # from np
if pprint: if pprint:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论