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 <glenn.jocher@ultralytics.com> Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>pull/10133/head^2
parent
9dd40f0723
commit
5e03f5fc8c
|
@ -470,8 +470,8 @@ class LoadImagesAndLabels(Dataset):
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue