Update SLR.py
Browse files
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=["
|
| 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 |
-
|
| 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['
|
| 116 |
|
| 117 |
-
labels=item['
|
| 118 |
-
|
| 119 |
ner_tags.append(labels)
|
| 120 |
-
|
|
|
|
| 121 |
#bbox=item['bbox']
|
| 122 |
-
bboxes.append(normalize_bbox(item['
|
| 123 |
|
| 124 |
-
yield guid, {"id": str(guid), "words": words , "
|
|
|
|
| 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}
|