AnaChikashua commited on
Commit
a891ed9
1 Parent(s): f5315f8

Update handwriting_dataset.py

Browse files
Files changed (1) hide show
  1. handwriting_dataset.py +4 -4
handwriting_dataset.py CHANGED
@@ -1,4 +1,5 @@
1
  import datasets
 
2
  _NAMES = ['ა', 'ბ', 'გ', 'დ', 'ე', 'ვ', 'ზ', 'თ', 'ი', 'კ', 'ლ', 'მ', 'ნ', 'ო', 'პ', 'ჟ', 'რ', 'ს', 'ტ', 'უ', 'ფ', 'ქ', 'ღ', 'ყ', 'შ', 'ჩ', 'ც', 'ძ', 'წ', 'ჭ', 'ხ', 'ჯ', 'ჰ']
3
  logger = datasets.logging.get_logger(__name__)
4
 
@@ -21,14 +22,14 @@ class HandwritingData(datasets.GeneratorBasedBuilder):
21
  description=_DESCRIPTION,
22
  citation=_CITATION,
23
  features=datasets.Features(
24
- {"text": datasets.Value("string"),
25
  "label": datasets.features.ClassLabel(names=_NAMES),
26
  "image": datasets.Image()
27
  }
28
  ),
29
  supervised_keys=("image", "label"),
30
  homepage="https://huggingface.co/datasets/AnaChikashua/handwriting",
31
- task_templates=[datasets.ImageClassification(image_column="image", label_column="label")],
32
 
33
  )
34
 
@@ -49,7 +50,6 @@ class HandwritingData(datasets.GeneratorBasedBuilder):
49
  # extract the text from the filename
50
  text = [c for c in filepath if not 0 <= ord(c) <= 127][0]
51
  yield idx, {
52
- "text": str(filepath),
53
- "label": str(idx),
54
  "image": {"path": filepath, "bytes": image.read()}
55
  }
 
1
  import datasets
2
+ from datasets.tasks import ImageClassification
3
  _NAMES = ['ა', 'ბ', 'გ', 'დ', 'ე', 'ვ', 'ზ', 'თ', 'ი', 'კ', 'ლ', 'მ', 'ნ', 'ო', 'პ', 'ჟ', 'რ', 'ს', 'ტ', 'უ', 'ფ', 'ქ', 'ღ', 'ყ', 'შ', 'ჩ', 'ც', 'ძ', 'წ', 'ჭ', 'ხ', 'ჯ', 'ჰ']
4
  logger = datasets.logging.get_logger(__name__)
5
 
 
22
  description=_DESCRIPTION,
23
  citation=_CITATION,
24
  features=datasets.Features(
25
+ {
26
  "label": datasets.features.ClassLabel(names=_NAMES),
27
  "image": datasets.Image()
28
  }
29
  ),
30
  supervised_keys=("image", "label"),
31
  homepage="https://huggingface.co/datasets/AnaChikashua/handwriting",
32
+ task_templates=[ImageClassification(image_column="image", label_column="label")],
33
 
34
  )
35
 
 
50
  # extract the text from the filename
51
  text = [c for c in filepath if not 0 <= ord(c) <= 127][0]
52
  yield idx, {
53
+ "label": str(text),
 
54
  "image": {"path": filepath, "bytes": image.read()}
55
  }