Datasets:
| import datasets | |
| class ForestSegmentationDataset(datasets.GeneratorBasedBuilder): | |
| def _info(self): | |
| return datasets.DatasetInfo( | |
| features=datasets.Features({ | |
| "sample_id": datasets.Value("string"), | |
| "image_paths": datasets.Sequence(datasets.Value("string")), | |
| "mask": datasets.Value("string"), | |
| }), | |
| ) | |
| def _split_generators(self, dl_manager): | |
| sample_stream = dl_manager.iter_jsonl("index.jsonl") | |
| return [ | |
| datasets.SplitGenerator( | |
| name=datasets.Split.TRAIN, | |
| gen_kwargs={"samples": sample_stream} | |
| ) | |
| ] | |
| def _generate_examples(self, samples): | |
| for sample in samples: | |
| yield sample["sample_id"], { | |
| "sample_id": sample["sample_id"], | |
| "image_paths": sample["image_paths"], | |
| "mask": sample["mask_path"], | |
| } | |