From 0effcd02bf98b9b292a6f71fd0030a7190ef2af3 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 21 May 2019 14:01:06 +0200 Subject: [PATCH] updates --- utils/datasets.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/utils/datasets.py b/utils/datasets.py index 44098898..5ebbc4de 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -194,11 +194,14 @@ class LoadImagesAndLabels(Dataset): # for training/testing for i, file in enumerate(iter): try: with open(file, 'r') as f: - self.labels[i] = np.array([x.split() for x in f.read().splitlines()], dtype=np.float32) - assert self.labels[i].shape[1] == 5, 'corrupted labels file: %s' % file + l = np.array([x.split() for x in f.read().splitlines()], dtype=np.float32) + if l.shape[0]: + assert l.shape[1] == 5, '> 5 label columns: %s' % file + assert (l >= 0).all(), 'negative labels: %s' % file + assert (l[:, 1:] <= 1).all(), 'non-normalized or out of bounds coordinate labels: %s' % file + self.labels[i] = l except: - print('Warning: missing labels for %s' % self.img_files[i]) - pass # missing label file + print('Warning: missing labels for %s' % self.img_files[i]) # missing label file assert len(np.concatenate(self.labels, 0)) > 0, 'No labels found. Incorrect label paths provided.' def __len__(self):