Skip to content

Commit

Permalink
Ignore blank lines in *.txt labels (ultralytics#3366)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher authored May 27, 2021
1 parent ef4d538 commit 4d4a2b0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def cache_labels(self, path=Path('./labels.cache'), prefix=''):
if os.path.isfile(lb_file):
nf += 1 # label found
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
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...)
Expand Down

0 comments on commit 4d4a2b0

Please sign in to comment.