AnaChikashua commited on
Commit
e9dbced
1 Parent(s): 6ec69a0

Update handwriting_dataset.py

Browse files
Files changed (1) hide show
  1. handwriting_dataset.py +3 -0
handwriting_dataset.py CHANGED
@@ -1,4 +1,5 @@
1
  import datasets
 
2
  _NAMES = ['ა', 'ბ', 'გ', 'დ', 'ე', 'ვ', 'ზ', 'თ', 'ი', 'კ', 'ლ', 'მ', 'ნ', 'ო', 'პ', 'ჟ', 'რ', 'ს', 'ტ', 'უ', 'ფ', 'ქ', 'ღ', 'ყ', 'შ', 'ჩ', 'ც', 'ძ', 'წ', 'ჭ', 'ხ', 'ჯ', 'ჰ']
3
  logger = datasets.logging.get_logger(__name__)
4
 
@@ -28,6 +29,7 @@ class HandwritingData(datasets.GeneratorBasedBuilder):
28
  ),
29
  supervised_keys=("image", "label"),
30
  homepage="https://huggingface.co/datasets/AnaChikashua/handwriting",
 
31
 
32
  )
33
 
@@ -48,6 +50,7 @@ class HandwritingData(datasets.GeneratorBasedBuilder):
48
  # extract the text from the filename
49
  text = [c for c in filepath if not 0 <= ord(c) <= 127][0]
50
  yield idx, {
 
51
  "label": str(text),
52
  "image": {"path": filepath, "bytes": image.read()}
53
  }
 
1
  import datasets
2
+ from datasets.tasks import ImageClassification
3
  _NAMES = ['ა', 'ბ', 'გ', 'დ', 'ე', 'ვ', 'ზ', 'თ', 'ი', 'კ', 'ლ', 'მ', 'ნ', 'ო', 'პ', 'ჟ', 'რ', 'ს', 'ტ', 'უ', 'ფ', 'ქ', 'ღ', 'ყ', 'შ', 'ჩ', 'ც', 'ძ', 'წ', 'ჭ', 'ხ', 'ჯ', 'ჰ']
4
  logger = datasets.logging.get_logger(__name__)
5
 
 
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
+ "text": str(filepath),
54
  "label": str(text),
55
  "image": {"path": filepath, "bytes": image.read()}
56
  }