Handle multiple datasets

pull/334/head
lorenzomammana 2020-07-09 11:52:12 +02:00
parent 6b95d6d2c0
commit 94342acbe1
1 changed files with 21 additions and 9 deletions

View File

@ -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,
cache_images=False, single_cls=False, stride=32, pad=0.0):
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
parent = str(Path(path).parent) + os.sep
if os.path.isfile(path): # file