sheikh commited on
Commit
cc04e11
·
1 Parent(s): 2c5027f

Update SLR.py

Browse files
Files changed (1) hide show
  1. SLR.py +10 -9
SLR.py CHANGED
@@ -68,11 +68,11 @@ class SLR(datasets.GeneratorBasedBuilder):
68
  {
69
  "id": datasets.Value("string"),
70
  "words": datasets.Sequence(datasets.Value("string")),
71
- "tokens": datasets.Sequence(datasets.Value("string")),
72
  "bboxes": datasets.Sequence(datasets.Sequence(datasets.Value("int64"))),
73
  "ner_tags": datasets.Sequence(
74
  datasets.features.ClassLabel(
75
- names=["Borrower", "BorrowerValue", "City", "CityValue", "PUD","PerMonth","PerYear","State","StateValue"]
76
  )
77
  ),
78
  "image": datasets.Array3D(shape=(3, 224, 224), dtype="uint8"),
@@ -102,7 +102,7 @@ class SLR(datasets.GeneratorBasedBuilder):
102
  img_dir = os.path.join(filepath, "images")
103
  for guid, file in enumerate(sorted(os.listdir(ann_dir))):
104
  words=[]
105
- tokens = []
106
  bboxes = []
107
  ner_tags = []
108
 
@@ -112,13 +112,14 @@ class SLR(datasets.GeneratorBasedBuilder):
112
  image_path = os.path.join(img_dir, file)
113
  image_path = image_path.replace("json", "jpg")
114
  image, size = load_image(image_path)
115
- for item in data['categories']:
116
 
117
- labels=item['name']
118
- words.append(labels)
119
  ner_tags.append(labels)
120
- for item in data['annotations']:
 
121
  #bbox=item['bbox']
122
- bboxes.append(normalize_bbox(item['bbox'],size))
123
 
124
- yield guid, {"id": str(guid), "words": words , "tokens": tokens, "bboxes": bboxes, "ner_tags": ner_tags, "image_path": image_path, "image": image}
 
68
  {
69
  "id": datasets.Value("string"),
70
  "words": datasets.Sequence(datasets.Value("string")),
71
+ #"tokens": datasets.Sequence(datasets.Value("string")),
72
  "bboxes": datasets.Sequence(datasets.Sequence(datasets.Value("int64"))),
73
  "ner_tags": datasets.Sequence(
74
  datasets.features.ClassLabel(
75
+ names=["Property","PropertyValue","Borrower","BorrowerValue","PUD","PUDMonth","Table","TableValue"]
76
  )
77
  ),
78
  "image": datasets.Array3D(shape=(3, 224, 224), dtype="uint8"),
 
102
  img_dir = os.path.join(filepath, "images")
103
  for guid, file in enumerate(sorted(os.listdir(ann_dir))):
104
  words=[]
105
+
106
  bboxes = []
107
  ner_tags = []
108
 
 
112
  image_path = os.path.join(img_dir, file)
113
  image_path = image_path.replace("json", "jpg")
114
  image, size = load_image(image_path)
115
+ for item in data['form']:
116
 
117
+ labels=item['label']
118
+ word=item['text']
119
  ner_tags.append(labels)
120
+ words.append(word)
121
+ #for item in data['annotations']:
122
  #bbox=item['bbox']
123
+ bboxes.append(normalize_bbox(item['box'],size))
124
 
125
+ yield guid, {"id": str(guid), "words": words , "bboxes": bboxes, "ner_tags": ner_tags, "image_path": image_path, "image": image}