Alert (no detections) (#3984)
Browse files* `Detections()` class `print()` overload
* Update common.py
- models/common.py +3 -1
models/common.py
CHANGED
@@ -307,7 +307,7 @@ class Detections:
|
|
307 |
def display(self, pprint=False, show=False, save=False, crop=False, render=False, save_dir=Path('')):
|
308 |
for i, (im, pred) in enumerate(zip(self.imgs, self.pred)):
|
309 |
str = f'image {i + 1}/{len(self.pred)}: {im.shape[0]}x{im.shape[1]} '
|
310 |
-
if pred
|
311 |
for c in pred[:, -1].unique():
|
312 |
n = (pred[:, -1] == c).sum() # detections per class
|
313 |
str += f"{n} {self.names[int(c)]}{'s' * (n > 1)}, " # add to string
|
@@ -318,6 +318,8 @@ class Detections:
|
|
318 |
save_one_box(box, im, file=save_dir / 'crops' / self.names[int(cls)] / self.files[i])
|
319 |
else: # all others
|
320 |
plot_one_box(box, im, label=label, color=colors(cls))
|
|
|
|
|
321 |
|
322 |
im = Image.fromarray(im.astype(np.uint8)) if isinstance(im, np.ndarray) else im # from np
|
323 |
if pprint:
|
|
|
307 |
def display(self, pprint=False, show=False, save=False, crop=False, render=False, save_dir=Path('')):
|
308 |
for i, (im, pred) in enumerate(zip(self.imgs, self.pred)):
|
309 |
str = f'image {i + 1}/{len(self.pred)}: {im.shape[0]}x{im.shape[1]} '
|
310 |
+
if pred.shape[0]:
|
311 |
for c in pred[:, -1].unique():
|
312 |
n = (pred[:, -1] == c).sum() # detections per class
|
313 |
str += f"{n} {self.names[int(c)]}{'s' * (n > 1)}, " # add to string
|
|
|
318 |
save_one_box(box, im, file=save_dir / 'crops' / self.names[int(cls)] / self.files[i])
|
319 |
else: # all others
|
320 |
plot_one_box(box, im, label=label, color=colors(cls))
|
321 |
+
else:
|
322 |
+
str += '(no detections)'
|
323 |
|
324 |
im = Image.fromarray(im.astype(np.uint8)) if isinstance(im, np.ndarray) else im # from np
|
325 |
if pprint:
|