From a82dce7faa5d13d6f9c342f04aaaa3b5de80d749 Mon Sep 17 00:00:00 2001 From: Iden Craven Date: Thu, 25 Feb 2021 19:05:38 -0700 Subject: [PATCH] Fix labels being missed when image extension appears twice in filename (#2300) --- utils/datasets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/datasets.py b/utils/datasets.py index 4f2939d4bef2..d6ab16518034 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -335,7 +335,7 @@ def __len__(self): def img2label_paths(img_paths): # Define label paths as a function of image paths sa, sb = os.sep + 'images' + os.sep, os.sep + 'labels' + os.sep # /images/, /labels/ substrings - return [x.replace(sa, sb, 1).replace('.' + x.split('.')[-1], '.txt') for x in img_paths] + return ['txt'.join(x.replace(sa, sb, 1).rsplit(x.split('.')[-1], 1)) for x in img_paths] class LoadImagesAndLabels(Dataset): # for training/testing