glenn-jocher
commited on
Commit
•
47bf173
1
Parent(s):
f9bab6b
Update datasets.py
Browse files- utils/datasets.py +10 -12
utils/datasets.py
CHANGED
@@ -281,21 +281,19 @@ class LoadImagesAndLabels(Dataset): # for training/testing
|
|
281 |
cache_images=False, single_cls=False, stride=32, pad=0.0):
|
282 |
try:
|
283 |
f = []
|
284 |
-
for
|
285 |
-
|
286 |
-
parent = str(Path(
|
287 |
-
if os.path.isfile(
|
288 |
-
with open(
|
289 |
t = t.read().splitlines()
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
f = glob.iglob(subpath + os.sep + '*.*')
|
294 |
-
# Maybe change this to f += glob.glob, this should allow handling also multiple folders
|
295 |
else:
|
296 |
-
raise Exception('%s does not exist' %
|
|
|
297 |
self.img_files = [x.replace('/', os.sep) for x in f if os.path.splitext(x)[-1].lower() in img_formats]
|
298 |
-
path = subpath
|
299 |
except:
|
300 |
# Maybe avoid handling bare exceptions
|
301 |
raise Exception('Error loading data from %s. See %s' % (path, help_url))
|
|
|
281 |
cache_images=False, single_cls=False, stride=32, pad=0.0):
|
282 |
try:
|
283 |
f = []
|
284 |
+
for p in path if isinstance(path, list) else [path]:
|
285 |
+
p = str(Path(p)) # os-agnostic
|
286 |
+
parent = str(Path(p).parent) + os.sep
|
287 |
+
if os.path.isfile(p): # file
|
288 |
+
with open(p, 'r') as t:
|
289 |
t = t.read().splitlines()
|
290 |
+
f += [x.replace('./', parent) if x.startswith('./') else x for x in t] # local to global path
|
291 |
+
elif os.path.isdir(p): # folder
|
292 |
+
f += glob.iglob(p + os.sep + '*.*')
|
|
|
|
|
293 |
else:
|
294 |
+
raise Exception('%s does not exist' % p)
|
295 |
+
path = p # *.npy dir
|
296 |
self.img_files = [x.replace('/', os.sep) for x in f if os.path.splitext(x)[-1].lower() in img_formats]
|
|
|
297 |
except:
|
298 |
# Maybe avoid handling bare exceptions
|
299 |
raise Exception('Error loading data from %s. See %s' % (path, help_url))
|