From 5e03f5fc8cbd658e183bb3812fe1c8553cb8cf05 Mon Sep 17 00:00:00 2001 From: Amol Dumrewal Date: Tue, 15 Nov 2022 23:30:33 +0530 Subject: [PATCH] Fix dataloader filepath modification to perform replace only once and not for all occurences of string (#10163) * Fix dataloader filepath modification to perform only once and not for all occurences of string * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * cleanup Signed-off-by: Glenn Jocher Signed-off-by: Glenn Jocher Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher --- utils/dataloaders.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/dataloaders.py b/utils/dataloaders.py index 54d3f7bbba00..0418293a6e21 100644 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -470,8 +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) 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)