File size: 1,911 Bytes
b1640a1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | # dataset.py (place at the repo root)
import os, glob, datasets
_CITATION = ""
_DESCRIPTION = "ATLAS-1: mesh dataset of single-cell 3D OBJ files."
_HOMEPAGE = "https://huggingface.co/datasets/Sentinal4D/ATLAS-1"
_LICENSE = "CC-BY-4.0" # change if needed
class AtlasConfig(datasets.BuilderConfig):
def __init__(self, **kwargs):
super().__init__(version=datasets.Version("1.0.0"), **kwargs)
class Atlas(datasets.GeneratorBasedBuilder):
BUILDER_CONFIGS = [AtlasConfig(name="default", description=_DESCRIPTION)]
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features({
"id": datasets.Value("string"),
"path": datasets.Value("string"), # local cached path to the .obj
# Add whatever metadata you want here:
# "drug": datasets.Value("string"),
# "cell_line": datasets.Value("string"),
}),
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
# Let users override with data_files=... if they want
data_files = self.config.data_files or {"train": ["data/**/*.obj"]}
# This resolves HF repo-relative patterns, downloads/caches them
downloaded = dl_manager.download(data_files)
return [
datasets.SplitGenerator(name=getattr(datasets.Split, split.upper(), datasets.Split.TRAIN),
gen_kwargs={"files": downloaded[split]})
for split in downloaded
]
def _generate_examples(self, files):
# files is a list of local cached .obj paths
for idx, p in enumerate(sorted(files)):
yield idx, {
"id": os.path.splitext(os.path.basename(p))[0],
"path": p,
}
|