cell_benchmark / cell_benchmark.py
alkzar90's picture
Fix typo on line 53
5d66ba4
raw
history blame
2.33 kB
import os
import datasets
#from datasets import DownloadManager, DatasetInfo
_DESCRIPTION = """\
A segmentation dataset for [TODO: complete...]
"""
_HOMEPAGE = "https://huggingface.co/datasets/alkzar90/cell_benchmark"
_EXTENSION = [".jpg", ".png"]
_URL_BASE = "https://huggingface.co/datasets/alkzar90/cell_benchmark/resolve/main/data/"
_SPLIT_URLS = {
"train": _URL_BASE + "train.zip",
"val": _URL_BASE + "val.zip",
"test": _URL_BASE + "test.zip",
"masks": _URL_BASE + "masks.zip",
}
class Cellsegmentation(datasets.GeneratorBasedBuilder):
def _info(self):
features = datasets.Features({
"image": datasets.Image(),
"masks": datasets.Image(),
"path" : datasets.Value("string"),
})
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(features),
supervised_keys=("image", "masks"),
homepage=_HOMEPAGE,
citation="",
)
def _split_generators(self, dl_manager):
data_files = dl_manager.download_and_extract(_SPLIT_URLS)
splits = [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"files" : dl_manager.iter_files([data_files["train"]]),
"masks": data_files["masks"],
"split": "training",
},
),
datasets.SplitGenerator(
name=datasets.Split.VALIDATION,
gen_kwargs={
"files" : dl_manager.iter_files([data_files["val"]]),
"masks": data_files["masks"],
"split": "validation",
},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"files" : dl_manager.iter_files([data_files["test"]]),
"masks": data_files["masks"],
"split": "test",
}
)
]
return splits
def _generate_examples(self, files, masks, split):
mask_path = os.path.basename(masks)
for i, path in enumereate(files):
file_name = os.path.basename(path)
yield i, {
"image": path,
"masks": mask_path + "mask_" + file_name.replace("jpg", "png"),
"path": path,
}