| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| """TODO""" |
|
|
| import os |
| import pandas as pd |
| import datasets |
| from PIL import Image |
|
|
| |
| |
| _CITATION = """TODO""" |
|
|
|
|
| _DESCRIPTION = """\ |
| TODO""" |
|
|
| _HOMEPAGE = "TODO" |
|
|
| _LICENSE = "Public Domain" |
|
|
|
|
| class EncyclopaediaBritannica(datasets.GeneratorBasedBuilder): |
| """TODO: Short description of my dataset.""" |
|
|
| VERSION = datasets.Version("1.1.0") |
|
|
| def _info(self): |
|
|
| features = datasets.Features( |
| { |
| "metadata": datasets.Value("string"), |
| "image": datasets.Value("string"), |
| "label": datasets.ClassLabel(names=["text-only", "illustrated"]), |
| } |
| ) |
|
|
| return datasets.DatasetInfo( |
| description=_DESCRIPTION, |
| features=features, |
| homepage=_HOMEPAGE, |
| license=_LICENSE, |
| citation=_CITATION, |
| ) |
|
|
| def _split_generators(self, dl_manager): |
| csv = dl_manager.download("annotations.csv") |
| df = pd.read_csv(csv, low_memory=False) |
| df = df[df["choice"].notna()] |
| df = df[["meta", "choice", "image"]] |
| annotations = df.to_dict(orient="records") |
| return [ |
| datasets.SplitGenerator( |
| name=datasets.Split.TRAIN, |
| gen_kwargs={ |
| "annotations": annotations, |
| }, |
| ), |
| ] |
|
|
| def _generate_examples(self, annotations): |
| for id_, row in enumerate(annotations): |
| row["image"] = row.pop("image") |
| row["metadata"] = row.pop("meta") |
| row["label"] = row.pop("choice") |
| yield id_, row |
|
|