from typing import Dict, List import os class DatasetLoader: def __init__(self, path: str): self.path=path #This function loads the data from the given path and returns a dict with entries for each subfolder in the given path the folder name and strings def load_data(self, verbose=False) -> Dict[str, List[str]]: if verbose: print(f"Loading data from {self.path}") subdirs = [sub for sub in os.listdir(self.path) if os.path.isdir(os.path.join(self.path, sub))] data_dict = {} for subdir in subdirs: data_dict[subdir] = [] for file in os.listdir(os.path.join(self.path, subdir)): if file.endswith((".jpg", ".jpeg", ".png")): data_dict[subdir].append(os.path.join(self.path, subdir, file)) return data_dict