Handle multiple datasets
parent
6b95d6d2c0
commit
94342acbe1
|
@ -280,6 +280,18 @@ class LoadImagesAndLabels(Dataset): # for training/testing
|
||||||
def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, rect=False, image_weights=False,
|
def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, rect=False, image_weights=False,
|
||||||
cache_images=False, single_cls=False, stride=32, pad=0.0):
|
cache_images=False, single_cls=False, stride=32, pad=0.0):
|
||||||
try:
|
try:
|
||||||
|
if type(path) is list:
|
||||||
|
# Multiple datasets handler
|
||||||
|
f = []
|
||||||
|
for subpath in path:
|
||||||
|
with open(subpath, 'r') as t:
|
||||||
|
subpath = str(Path(subpath)) # os-agnostic
|
||||||
|
parent = str(Path(subpath).parent) + os.sep
|
||||||
|
t = t.read().splitlines()
|
||||||
|
t = [x.replace('./', parent) if x.startswith('./') else x for x in t] # local to global path
|
||||||
|
f += t
|
||||||
|
path = str(Path(path[0])) # from now on treat multiple datasets as single
|
||||||
|
else:
|
||||||
path = str(Path(path)) # os-agnostic
|
path = str(Path(path)) # os-agnostic
|
||||||
parent = str(Path(path).parent) + os.sep
|
parent = str(Path(path).parent) + os.sep
|
||||||
if os.path.isfile(path): # file
|
if os.path.isfile(path): # file
|
||||||
|
|
Loading…
Reference in New Issue