glenn-jocher commited on
Commit
cff9263
1 Parent(s): 9fa7f9f

f.read().strip() (#1551)

Browse files
Files changed (1) hide show
  1. utils/datasets.py +2 -2
utils/datasets.py CHANGED
@@ -450,7 +450,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
450
  if os.path.isfile(lb_file):
451
  nf += 1 # label found
452
  with open(lb_file, 'r') as f:
453
- l = np.array([x.split() for x in f.read().splitlines()], dtype=np.float32) # labels
454
  if len(l):
455
  assert l.shape[1] == 5, 'labels require 5 columns each'
456
  assert (l >= 0).all(), 'negative labels'
@@ -897,7 +897,7 @@ def extract_boxes(path='../coco128/'): # from utils.datasets import *; extract_
897
  lb_file = Path(img2label_paths([str(im_file)])[0])
898
  if Path(lb_file).exists():
899
  with open(lb_file, 'r') as f:
900
- lb = np.array([x.split() for x in f.read().splitlines()], dtype=np.float32) # labels
901
 
902
  for j, x in enumerate(lb):
903
  c = int(x[0]) # class
 
450
  if os.path.isfile(lb_file):
451
  nf += 1 # label found
452
  with open(lb_file, 'r') as f:
453
+ l = np.array([x.split() for x in f.read().strip().splitlines()], dtype=np.float32) # labels
454
  if len(l):
455
  assert l.shape[1] == 5, 'labels require 5 columns each'
456
  assert (l >= 0).all(), 'negative labels'
 
897
  lb_file = Path(img2label_paths([str(im_file)])[0])
898
  if Path(lb_file).exists():
899
  with open(lb_file, 'r') as f:
900
+ lb = np.array([x.split() for x in f.read().strip().splitlines()], dtype=np.float32) # labels
901
 
902
  for j, x in enumerate(lb):
903
  c = int(x[0]) # class