import os import datasets class Demo(datasets.GeneratorBasedBuilder): def _info(self): return datasets.DatasetInfo( features=datasets.Features({ "id": datasets.Value("string"), "problem": datasets.Value("string"), "solution": datasets.Value("string"), "image": datasets.Image(), # Enables image previews "img_height": datasets.Value("int32"), }), ) def _split_generators(self, dl_manager): parquet_path = os.path.join(dl_manager.manual_dir, "visionreasoner_dataset.parquet") return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, gen_kwargs={"filepath": parquet_path} ), ] def _generate_examples(self, filepath): import pandas as pd df = pd.read_parquet(filepath) for idx, row in df.iterrows(): yield idx, { "id": row["id"], "problem": row["problem"], "solution": row["solution"], "image": row["image"]["path"], "img_height": row["img_height"], }