Ignore blank lines in *.txt labels (#3366)
Fix for https://github.com/ultralytics/yolov5/issues/958#issuecomment-849512083
This commit is contained in:
1 parent
ef4d53818d
commit
4d4a2b0520
1 file changed
+1
-1
+1
-1
@@ -474,7 +474,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
|
|||||||
if os.path.isfile(lb_file):
|
if os.path.isfile(lb_file):
|
||||||
nf += 1 # label found
|
nf += 1 # label found
|
||||||
with open(lb_file, 'r') as f:
|
with open(lb_file, 'r') as f:
|
||||||
l = [x.split() for x in f.read().strip().splitlines()]
|
l = [x.split() for x in f.read().strip().splitlines() if len(x)]
|
||||||
if any([len(x) > 8 for x in l]): # is segment
|
if any([len(x) > 8 for x in l]): # is segment
|
||||||
classes = np.array([x[0] for x in l], dtype=np.float32)
|
classes = np.array([x[0] for x in l], dtype=np.float32)
|
||||||
segments = [np.array(x[1:], dtype=np.float32).reshape(-1, 2) for x in l] # (cls, xy1...)
|
segments = [np.array(x[1:], dtype=np.float32).reshape(-1, 2) for x in l] # (cls, xy1...)
|
||||||
|
|||||||
Reference in new issue
Block a user