Datasets:
Tasks:
Image Classification
Modalities:
Image
Formats:
imagefolder
Languages:
Georgian
Size:
10K - 100K
File size: 1,446 Bytes
e9cbbe3 |
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 |
import datasets
logger = datasets.logging.get_logger(__name__)
_DESCRIPTION = """
Georgian language handwriting dataset!
"""
_URL = 'https://huggingface.co/datasets/AnaChikashua/handwriting/resolve/main/handwriting_dataset.rar'
class HandwritingData(datasets.GeneratorBasedBuilder):
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features = datasets.Features(
{"alphabet": datasets.Value("string"),
"image": datasets.Image()
}
),
supervised_keys = None,
homepage = "https://huggingface.co/datasets/AnaChikashua/handwriting",
)
def _split_generators(self, dl_manager):
path = dl_manager.dowload(_URL)
image_iters = dl_manager.iter_archive(path)
return [
datasets.SplitGenerator(
name = datasets.Split.TRAIN,
gen_kwargs = {"images": image_iters}
),
]
def _generate_examples(self, images):
"""This function returns the examples in the raw (text) form."""
idx = 0
# Iterate through images
for filepath, image in images:
# extract the text from the filename
text = filepath.split("/")[-1].split(".")[0]
yield idx, {
"alphabet": text,
"image": {"path": filepath, "bytes": image.read()}
}
idx += 1 |