import os import datasets class Peter(datasets.GeneratorBasedBuilder): def _info(self): return datasets.DatasetInfo( features=datasets.Features( { "image": datasets.Image(), } ) ) def _split_generators(self, dl_manager): DL_URLS = [ "images.zip" ] data_files = dl_manager.download_and_extract(DL_URLS) return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={ "image_paths": dl_manager.iter_files(data_files), }, ), ] def _generate_examples(self, image_paths): """Generate examples.""" for idx, image_path in enumerate(image_paths): example = { "image": image_path, } yield idx, example