Datasets:
Tasks:
Image Classification
Modalities:
Image
Formats:
imagefolder
Languages:
Georgian
Size:
10K - 100K
Commit
•
7098a21
1
Parent(s):
a7e63c0
Update handwriting_dataset.py
Browse files- handwriting_dataset.py +24 -13
handwriting_dataset.py
CHANGED
@@ -1,40 +1,51 @@
|
|
1 |
import datasets
|
2 |
|
3 |
logger = datasets.logging.get_logger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
_DESCRIPTION = """
|
5 |
Georgian language handwriting dataset!
|
6 |
"""
|
7 |
-
_URL =
|
|
|
|
|
8 |
class HandwritingData(datasets.GeneratorBasedBuilder):
|
9 |
def _info(self):
|
10 |
return datasets.DatasetInfo(
|
11 |
description=_DESCRIPTION,
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
16 |
),
|
17 |
-
supervised_keys
|
18 |
-
homepage
|
19 |
)
|
|
|
20 |
def _split_generators(self, dl_manager):
|
21 |
path = dl_manager.dowload(_URL)
|
22 |
image_iters = dl_manager.iter_archive(path)
|
23 |
return [
|
24 |
datasets.SplitGenerator(
|
25 |
-
|
26 |
-
|
27 |
),
|
28 |
]
|
|
|
29 |
def _generate_examples(self, images):
|
30 |
"""This function returns the examples in the raw (text) form."""
|
31 |
-
idx = 0
|
32 |
# Iterate through images
|
33 |
-
for filepath, image in images:
|
34 |
# extract the text from the filename
|
35 |
text = filepath.split("/")[-1].split(".")[0]
|
36 |
yield idx, {
|
37 |
-
"
|
38 |
"image": {"path": filepath, "bytes": image.read()}
|
39 |
}
|
40 |
-
idx += 1
|
|
|
1 |
import datasets
|
2 |
|
3 |
logger = datasets.logging.get_logger(__name__)
|
4 |
+
|
5 |
+
_CITATION = """\
|
6 |
+
@InProceedings{huggingface:dataset,
|
7 |
+
title = {Small image-text set},
|
8 |
+
author={James Briggs},
|
9 |
+
year={2022}
|
10 |
+
}
|
11 |
+
"""
|
12 |
_DESCRIPTION = """
|
13 |
Georgian language handwriting dataset!
|
14 |
"""
|
15 |
+
_URL = "https://huggingface.co/datasets/AnaChikashua/handwriting/resolve/main/handwriting_dataset.tar.gz"
|
16 |
+
|
17 |
+
|
18 |
class HandwritingData(datasets.GeneratorBasedBuilder):
|
19 |
def _info(self):
|
20 |
return datasets.DatasetInfo(
|
21 |
description=_DESCRIPTION,
|
22 |
+
citation=_CITATION,
|
23 |
+
features=datasets.Features(
|
24 |
+
{"text": datasets.Value("string"),
|
25 |
+
"image": datasets.Image()
|
26 |
+
}
|
27 |
),
|
28 |
+
supervised_keys=None,
|
29 |
+
homepage="https://huggingface.co/datasets/AnaChikashua/handwriting"
|
30 |
)
|
31 |
+
|
32 |
def _split_generators(self, dl_manager):
|
33 |
path = dl_manager.dowload(_URL)
|
34 |
image_iters = dl_manager.iter_archive(path)
|
35 |
return [
|
36 |
datasets.SplitGenerator(
|
37 |
+
name=datasets.Split.TRAIN,
|
38 |
+
gen_kwargs={"images": image_iters}
|
39 |
),
|
40 |
]
|
41 |
+
|
42 |
def _generate_examples(self, images):
|
43 |
"""This function returns the examples in the raw (text) form."""
|
|
|
44 |
# Iterate through images
|
45 |
+
for idx, filepath, image in enumerate(images):
|
46 |
# extract the text from the filename
|
47 |
text = filepath.split("/")[-1].split(".")[0]
|
48 |
yield idx, {
|
49 |
+
"text": text,
|
50 |
"image": {"path": filepath, "bytes": image.read()}
|
51 |
}
|
|