Follow links during dataset scanning

pull/334/head
Csaba Kertesz 4 years ago
parent 392595c7eb
commit 7cae7e7035

@ -26,7 +26,7 @@ def natural_key(string_):
def find_images_and_targets(folder, types=IMG_EXTENSIONS, class_to_idx=None, leaf_name_only=True, sort=True): def find_images_and_targets(folder, types=IMG_EXTENSIONS, class_to_idx=None, leaf_name_only=True, sort=True):
labels = [] labels = []
filenames = [] filenames = []
for root, subdirs, files in os.walk(folder, topdown=False): for root, subdirs, files in os.walk(folder, topdown=False, followlinks=True):
rel_path = os.path.relpath(root, folder) if (root != folder) else '' rel_path = os.path.relpath(root, folder) if (root != folder) else ''
label = os.path.basename(rel_path) if leaf_name_only else rel_path.replace(os.path.sep, '_') label = os.path.basename(rel_path) if leaf_name_only else rel_path.replace(os.path.sep, '_')
for f in files: for f in files:

Loading…
Cancel
Save