diff --git a/test.py b/test.py index faad347..4ced981 100644 --- a/test.py +++ b/test.py @@ -165,7 +165,7 @@ def test(data, # Compute statistics stats = [np.concatenate(x, 0) for x in zip(*stats)] # to numpy - if len(stats): + if len(stats) and stats[0].any(): p, r, ap, f1, ap_class = ap_per_class(*stats) p, r, ap50, ap = p[:, 0], r[:, 0], ap[:, 0], ap.mean(1) # [P, R, AP@0.5, AP@0.5:0.95] mp, mr, map50, map = p.mean(), r.mean(), ap50.mean(), ap.mean() diff --git a/utils/datasets.py b/utils/datasets.py index cc5411f..4d8424c 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -416,7 +416,10 @@ class LoadImagesAndLabels(Dataset): # for training/testing pbar.desc = 'Scanning labels %s (%g found, %g missing, %g empty, %g duplicate, for %g images)' % ( cache_path, nf, nm, ne, nd, n) - assert nf > 0, 'No labels found in %s. See %s' % (os.path.dirname(file) + os.sep, help_url) + if nf == 0: + s = 'WARNING: No labels found in %s. See %s' % (os.path.dirname(file) + os.sep, help_url) + print(s) + assert not augment, '%s. Can not train without labels.' % s # Cache images into memory for faster training (WARNING: large datasets may exceed system RAM) self.imgs = [None] * n