| |
| 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): |
| |
| return [ |
| SplitGenerator( |
| name="val", gen_kwargs={"data_dir": self.config.data_dir or ""} |
| ) |
| ] |
| |
|
|
| def _generate_examples(self, 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 |
|
|