ATLAS-1 / dataset.py
DeVriesMatt
update loader
b1640a1
raw
history blame
1.91 kB
# 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,
}