From 3cc3d135f9ca4230bb5481bbc6c2eb91f61883cf Mon Sep 17 00:00:00 2001 From: Amol Dumrewal Date: Tue, 15 Nov 2022 14:11:02 +0530 Subject: [PATCH 1/3] Fix dataloader filepath modification to perform only once and not for all occurences of string --- utils/dataloaders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/dataloaders.py b/utils/dataloaders.py index 621c03cd2db1..aae9a48c546a 100644 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -470,7 +470,7 @@ def __init__(self, with open(p) as t: t = t.read().strip().splitlines() parent = str(p.parent) + os.sep - f += [x.replace('./', parent) if x.startswith('./') else x for x in t] # local to global path + f += [x.replace('./', parent, 1) if x.startswith('./') else x for x in t] # local to global path # f += [p.parent / x.lstrip(os.sep) for x in t] # local to global path (pathlib) else: raise FileNotFoundError(f'{prefix}{p} does not exist') From c6470fe5185c31f5f01ae1a7ba06d49370d0bc81 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Nov 2022 09:06:05 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- utils/dataloaders.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/dataloaders.py b/utils/dataloaders.py index aae9a48c546a..b20c9ba9a623 100644 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -470,7 +470,8 @@ def __init__(self, with open(p) as t: t = t.read().strip().splitlines() parent = str(p.parent) + os.sep - f += [x.replace('./', parent, 1) if x.startswith('./') else x for x in t] # local to global path + f += [x.replace('./', parent, 1) if x.startswith('./') else x + for x in t] # local to global path # f += [p.parent / x.lstrip(os.sep) for x in t] # local to global path (pathlib) else: raise FileNotFoundError(f'{prefix}{p} does not exist') From 18dc7c827761b59f68469cf62dfa8ecf24a7d647 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 15 Nov 2022 18:59:27 +0100 Subject: [PATCH 3/3] cleanup Signed-off-by: Glenn Jocher --- utils/dataloaders.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/dataloaders.py b/utils/dataloaders.py index b20c9ba9a623..861eac8556b1 100644 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -470,9 +470,8 @@ def __init__(self, with open(p) as t: t = t.read().strip().splitlines() parent = str(p.parent) + os.sep - f += [x.replace('./', parent, 1) if x.startswith('./') else x - for x in t] # local to global path - # f += [p.parent / x.lstrip(os.sep) for x in t] # local to global path (pathlib) + f += [x.replace('./', parent, 1) if x.startswith('./') else x for x in t] # to global path + # f += [p.parent / x.lstrip(os.sep) for x in t] # to global path (pathlib) else: raise FileNotFoundError(f'{prefix}{p} does not exist') self.im_files = sorted(x.replace('/', os.sep) for x in f if x.split('.')[-1].lower() in IMG_FORMATS)