jordyvl commited on
Commit
7ada262
1 Parent(s): 888c160

overriding to use OCR data under data/

Browse files
Files changed (2) hide show
  1. rvl_cdip_easyOCR.py +13 -13
  2. test_loader.py +26 -9
rvl_cdip_easyOCR.py CHANGED
@@ -72,26 +72,27 @@ _CLASSES = [
72
  ]
73
 
74
  _IMAGES_DIR = "images/"
 
75
 
76
 
77
- # class OCRConfig(datasets.BuilderConfig):
78
- # """BuilderConfig for RedCaps."""
79
 
80
- # def __init__(self, name, **kwargs):
81
- # """BuilderConfig for RedCaps.
82
- # Args:
83
- # **kwargs: keyword arguments forwarded to super.
84
- # """
85
- # assert "description" not in kwargs
86
- # super(OCRConfig, self).__init__(
87
- # version=kwargs['version'], name=name, **kwargs
88
- # )
89
 
90
 
91
  class RvlCdipEasyOcr(datasets.GeneratorBasedBuilder):
92
  """Ryerson Vision Lab Complex Document Information Processing dataset."""
93
 
94
  VERSION = datasets.Version("1.0.0")
 
95
  DEFAULT_CONFIG_NAME = "default"
96
 
97
  def _info(self):
@@ -194,7 +195,7 @@ class RvlCdipEasyOcr(datasets.GeneratorBasedBuilder):
194
  with open(labels_filepath, encoding="utf-8") as f:
195
  data = f.read().splitlines()
196
 
197
- image_to_OCR = self._get_image_to_OCR(self.config.data_dir, split)
198
  image_to_class_id = self._get_image_to_class_map(data)
199
 
200
  for file_path, file_obj in archive_iterator:
@@ -211,4 +212,3 @@ class RvlCdipEasyOcr(datasets.GeneratorBasedBuilder):
211
  boxes=boxes,
212
  )
213
  yield file_path, a
214
-
 
72
  ]
73
 
74
  _IMAGES_DIR = "images/"
75
+ _OCR_DIR = "data/" # np files live under here with OCR results
76
 
77
 
78
+ class OCRConfig(datasets.BuilderConfig):
79
+ """BuilderConfig for RedCaps."""
80
 
81
+ def __init__(self, name, OCR_dir, **kwargs):
82
+ """BuilderConfig for RedCaps.
83
+ Args:
84
+ **kwargs: keyword arguments forwarded to super.
85
+ """
86
+ assert "description" not in kwargs
87
+ super(OCRConfig, self).__init__(version=kwargs["version"], name=name, **kwargs)
88
+ self.OCR_dir = OCR_dir
 
89
 
90
 
91
  class RvlCdipEasyOcr(datasets.GeneratorBasedBuilder):
92
  """Ryerson Vision Lab Complex Document Information Processing dataset."""
93
 
94
  VERSION = datasets.Version("1.0.0")
95
+ # BUILDER_CONFIGS = [OCRConfig("default",version=VERSION)]
96
  DEFAULT_CONFIG_NAME = "default"
97
 
98
  def _info(self):
 
195
  with open(labels_filepath, encoding="utf-8") as f:
196
  data = f.read().splitlines()
197
 
198
+ image_to_OCR = self._get_image_to_OCR(_OCR_DIR, split)
199
  image_to_class_id = self._get_image_to_class_map(data)
200
 
201
  for file_path, file_obj in archive_iterator:
 
212
  boxes=boxes,
213
  )
214
  yield file_path, a
 
test_loader.py CHANGED
@@ -1,4 +1,16 @@
1
- from datasets import load_dataset_builder, get_dataset_config_names, get_dataset_infos, load_dataset
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  # print(get_dataset_infos('jordyvl/rvl-cdip_easyOCR'))
4
  # print(get_dataset_config_names("jordyvl/rvl-cdip_easyOCR"))
@@ -7,12 +19,16 @@ from datasets import load_dataset_builder, get_dataset_config_names, get_dataset
7
 
8
  builder = load_dataset_builder("rvl_cdip")
9
 
10
- from pdb import set_trace; set_trace()
 
 
11
  builder = load_dataset_builder("jordyvl/rvl-cdip_easyOCR")
12
  print(builder._info())
13
  print(builder.get_all_exported_dataset_infos())
14
  ds = builder.download_and_prepare()
15
- from pdb import set_trace; set_trace()
 
 
16
  # data = load_dataset(
17
  # "jordyvl/rvl-cdip_easyOCR",
18
  # split="test",
@@ -24,16 +40,17 @@ from pdb import set_trace; set_trace()
24
  # #data_dir="/home/jordy/Downloads/OCRedText", # this is the path to the OCR data
25
  # )
26
 
27
- from pdb import set_trace; set_trace()
 
 
28
 
29
 
30
  data = load_dataset(
31
  "./rvl_cdip_easyOCR.py",
32
  split="test",
33
- #cache_dir="/mnt/lerna/data/HFcache",
34
- data_files={ # this is the path to the images if it does not download it
35
- "binary": __file__#"/mnt/lerna/data/HFcache/downloads/c8cc6f89129255a9adf3e97e319ebe2055cf97662135b3ad26c79e9432544db5",
36
  },
37
- data_dir="/home/jordy/Downloads/OCRedText", # this is the path to the OCR data
38
  )
39
-
 
1
+ from datasets import (
2
+ load_dataset_builder,
3
+ get_dataset_config_names,
4
+ get_dataset_infos,
5
+ load_dataset,
6
+ )
7
+
8
+
9
+ data = load_dataset(
10
+ "jordyvl/rvl-cdip_easyOCR",
11
+ data_dir="/cw/liir_data/NoCsBack/jordy/BDPC", # this is the path to the OCR data
12
+ )
13
+
14
 
15
  # print(get_dataset_infos('jordyvl/rvl-cdip_easyOCR'))
16
  # print(get_dataset_config_names("jordyvl/rvl-cdip_easyOCR"))
 
19
 
20
  builder = load_dataset_builder("rvl_cdip")
21
 
22
+ from pdb import set_trace
23
+
24
+ set_trace()
25
  builder = load_dataset_builder("jordyvl/rvl-cdip_easyOCR")
26
  print(builder._info())
27
  print(builder.get_all_exported_dataset_infos())
28
  ds = builder.download_and_prepare()
29
+ from pdb import set_trace
30
+
31
+ set_trace()
32
  # data = load_dataset(
33
  # "jordyvl/rvl-cdip_easyOCR",
34
  # split="test",
 
40
  # #data_dir="/home/jordy/Downloads/OCRedText", # this is the path to the OCR data
41
  # )
42
 
43
+ from pdb import set_trace
44
+
45
+ set_trace()
46
 
47
 
48
  data = load_dataset(
49
  "./rvl_cdip_easyOCR.py",
50
  split="test",
51
+ # cache_dir="/mnt/lerna/data/HFcache",
52
+ data_files={ # this is the path to the images if it does not download it
53
+ "binary": __file__ # "/mnt/lerna/data/HFcache/downloads/c8cc6f89129255a9adf3e97e319ebe2055cf97662135b3ad26c79e9432544db5",
54
  },
55
+ data_dir="/home/jordy/Downloads/OCRedText", # this is the path to the OCR data
56
  )