Iden Craven commited on
Commit
a82dce7
1 Parent(s): 71dd276

Fix labels being missed when image extension appears twice in filename (#2300)

Browse files
Files changed (1) hide show
  1. utils/datasets.py +1 -1
utils/datasets.py CHANGED
@@ -335,7 +335,7 @@ class LoadStreams: # multiple IP or RTSP cameras
335
  def img2label_paths(img_paths):
336
  # Define label paths as a function of image paths
337
  sa, sb = os.sep + 'images' + os.sep, os.sep + 'labels' + os.sep # /images/, /labels/ substrings
338
- return [x.replace(sa, sb, 1).replace('.' + x.split('.')[-1], '.txt') for x in img_paths]
339
 
340
 
341
  class LoadImagesAndLabels(Dataset): # for training/testing
 
335
  def img2label_paths(img_paths):
336
  # Define label paths as a function of image paths
337
  sa, sb = os.sep + 'images' + os.sep, os.sep + 'labels' + os.sep # /images/, /labels/ substrings
338
+ return ['txt'.join(x.replace(sa, sb, 1).rsplit(x.split('.')[-1], 1)) for x in img_paths]
339
 
340
 
341
  class LoadImagesAndLabels(Dataset): # for training/testing