Update layoutlmv3.py
Browse files- layoutlmv3.py +5 -5
layoutlmv3.py
CHANGED
|
@@ -63,7 +63,7 @@ class Funsd(datasets.GeneratorBasedBuilder):
|
|
| 63 |
{
|
| 64 |
"id": datasets.Value("string"),
|
| 65 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
| 66 |
-
"words": datasets.Sequence(datasets.Value("string")),
|
| 67 |
"bboxes": datasets.Sequence(datasets.Sequence(datasets.Value("int64"))),
|
| 68 |
"ner_tags": datasets.Sequence(
|
| 69 |
datasets.features.ClassLabel(
|
|
@@ -107,7 +107,7 @@ class Funsd(datasets.GeneratorBasedBuilder):
|
|
| 107 |
img_dir = os.path.join(filepath, "images")
|
| 108 |
for guid, file in enumerate(sorted(os.listdir(ann_dir))):
|
| 109 |
tokens = []
|
| 110 |
-
words = []
|
| 111 |
bboxes = []
|
| 112 |
ner_tags = []
|
| 113 |
|
|
@@ -123,7 +123,7 @@ class Funsd(datasets.GeneratorBasedBuilder):
|
|
| 123 |
word=item['text']
|
| 124 |
ner_tags.append(labels)
|
| 125 |
tokens.append(word)
|
| 126 |
-
words.append(word)
|
| 127 |
bboxes.append(normalize_bbox(item['box'],size))
|
| 128 |
|
| 129 |
#cur_line_bboxes = []
|
|
@@ -146,5 +146,5 @@ class Funsd(datasets.GeneratorBasedBuilder):
|
|
| 146 |
#cur_line_bboxes.append(normalize_bbox(w["box"], size))
|
| 147 |
#cur_line_bboxes = self.get_line_bbox(cur_line_bboxes)
|
| 148 |
#bboxes.extend(cur_line_bboxes)
|
| 149 |
-
yield guid, {"id": str(guid), "tokens": tokens,
|
| 150 |
-
"image": image, "image_path":image_path}
|
|
|
|
| 63 |
{
|
| 64 |
"id": datasets.Value("string"),
|
| 65 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
| 66 |
+
#"words": datasets.Sequence(datasets.Value("string")),
|
| 67 |
"bboxes": datasets.Sequence(datasets.Sequence(datasets.Value("int64"))),
|
| 68 |
"ner_tags": datasets.Sequence(
|
| 69 |
datasets.features.ClassLabel(
|
|
|
|
| 107 |
img_dir = os.path.join(filepath, "images")
|
| 108 |
for guid, file in enumerate(sorted(os.listdir(ann_dir))):
|
| 109 |
tokens = []
|
| 110 |
+
#words = []
|
| 111 |
bboxes = []
|
| 112 |
ner_tags = []
|
| 113 |
|
|
|
|
| 123 |
word=item['text']
|
| 124 |
ner_tags.append(labels)
|
| 125 |
tokens.append(word)
|
| 126 |
+
#words.append(word)
|
| 127 |
bboxes.append(normalize_bbox(item['box'],size))
|
| 128 |
|
| 129 |
#cur_line_bboxes = []
|
|
|
|
| 146 |
#cur_line_bboxes.append(normalize_bbox(w["box"], size))
|
| 147 |
#cur_line_bboxes = self.get_line_bbox(cur_line_bboxes)
|
| 148 |
#bboxes.extend(cur_line_bboxes)
|
| 149 |
+
yield guid, {"id": str(guid), "tokens": tokens, "bboxes": bboxes, "ner_tags": ner_tags,
|
| 150 |
+
"image": image, "image_path":image_path}#"words":words,
|