From cff9263490fbf4b80dcc2d87914e087e6c07b6a0 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 29 Nov 2020 11:59:52 +0100 Subject: [PATCH] f.read().strip() (#1551) --- utils/datasets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/datasets.py b/utils/datasets.py index 3438a2b7ee25..dc3c8fb74a24 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -450,7 +450,7 @@ def cache_labels(self, path=Path('./labels.cache')): if os.path.isfile(lb_file): nf += 1 # label found with open(lb_file, 'r') as f: - l = np.array([x.split() for x in f.read().splitlines()], dtype=np.float32) # labels + l = np.array([x.split() for x in f.read().strip().splitlines()], dtype=np.float32) # labels if len(l): assert l.shape[1] == 5, 'labels require 5 columns each' assert (l >= 0).all(), 'negative labels' @@ -897,7 +897,7 @@ def extract_boxes(path='../coco128/'): # from utils.datasets import *; extract_ lb_file = Path(img2label_paths([str(im_file)])[0]) if Path(lb_file).exists(): with open(lb_file, 'r') as f: - lb = np.array([x.split() for x in f.read().splitlines()], dtype=np.float32) # labels + lb = np.array([x.split() for x in f.read().strip().splitlines()], dtype=np.float32) # labels for j, x in enumerate(lb): c = int(x[0]) # class