# dataset.py import os, glob, datasets from datasets import SplitGenerator class ITTO(datasets.GeneratorBasedBuilder): VERSION = datasets.Version("1.0.0") def _info(self): return datasets.DatasetInfo( features=datasets.Features( { "image": datasets.Image(), "label": datasets.Value("string"), } ) ) def _split_generators(self, dl_manager): # Name the split exactly how you want it shown: return [ SplitGenerator( name="val", gen_kwargs={"data_dir": self.config.data_dir or ""} ) ] # Or: name=datasets.Split.VALIDATION def _generate_examples(self, data_dir): # Example: scan local folders when a user supplies data_dir roots = ["ego4d/frames", "lvos/frames", "mose/frames"] eid = 0 for root in roots: root_path = os.path.join(data_dir, root) if not os.path.isdir(root_path): continue for cls in sorted(os.listdir(root_path)): cls_dir = os.path.join(root_path, cls) if not os.path.isdir(cls_dir): continue for fp in glob.glob(os.path.join(cls_dir, "*")): if os.path.isfile(fp): yield eid, {"image": fp, "label": cls} eid += 1