muddokon commited on
Commit
05c904b
·
verified ·
1 Parent(s): 72c63d1

Create outlined-text-captcha.py

Browse files
Files changed (1) hide show
  1. outlined-text-captcha.py +51 -0
outlined-text-captcha.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from pathlib import Path
3
+ import datasets
4
+
5
+ _DESCRIPTION = """\
6
+ Outlined Text Captcha Images.
7
+ """
8
+ _LICENSE = "mit"
9
+ _DATA_DIR = ""
10
+
11
+ class Captcha(datasets.GeneratorBasedBuilder):
12
+ def _info(self):
13
+ return datasets.DatasetInfo(
14
+ description=_DESCRIPTION,
15
+ features=datasets.Features(
16
+ {
17
+ "image": datasets.Image(),
18
+ "solution": datasets.Value("string"),
19
+ }
20
+ ),
21
+ license=_LICENSE,
22
+ )
23
+
24
+ def _split_generators(self, dl_manager):
25
+ return [
26
+ datasets.SplitGenerator(
27
+ name=datasets.Split.TRAIN,
28
+ gen_kwargs={
29
+ "images": dl_manager.iter_archive(dl_manager.download(os.path.join(_DATA_DIR, "train.zip"))),
30
+ },
31
+ ),
32
+ datasets.SplitGenerator(
33
+ name=datasets.Split.VALIDATION,
34
+ gen_kwargs={
35
+ "images": dl_manager.iter_archive(dl_manager.download(os.path.join(_DATA_DIR, "validation.zip"))),
36
+ },
37
+ ),
38
+ datasets.SplitGenerator(
39
+ name=datasets.Split.TEST,
40
+ gen_kwargs={
41
+ "images": dl_manager.iter_archive(dl_manager.download(os.path.join(_DATA_DIR, "test.zip"))),
42
+ },
43
+ ),
44
+ ]
45
+
46
+ def _generate_examples(self, images):
47
+ for file_path, file_obj in images:
48
+ yield file_path, {
49
+ "image": {"path": file_path, "bytes": file_obj.read()},
50
+ "solution": Path(file_path).name.split('.')[0],
51
+ }