removed normalization of bboxes
Browse files- docbank.py +23 -25
docbank.py
CHANGED
|
@@ -83,27 +83,27 @@ def load_image(image_path, size=None):
|
|
| 83 |
return image, (w, h)
|
| 84 |
|
| 85 |
|
| 86 |
-
def normalize_bbox(bbox, size):
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
def simplify_bbox(bbox):
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
def merge_bbox(bbox_list):
|
| 105 |
-
|
| 106 |
-
|
| 107 |
|
| 108 |
|
| 109 |
# TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
|
|
@@ -225,7 +225,8 @@ class Docbank(datasets.GeneratorBasedBuilder):
|
|
| 225 |
with open(f_fp_txt, newline='', encoding='utf-8') as csvfile:
|
| 226 |
reader = csv.reader(csvfile, delimiter='\t', quotechar=' ')
|
| 227 |
for row in reader:
|
| 228 |
-
normalized_bbox = normalize_bbox(row[1:5], size)
|
|
|
|
| 229 |
tokenized_input = self.TOKENIZER(
|
| 230 |
row[0],
|
| 231 |
add_special_tokens=False,
|
|
@@ -268,6 +269,3 @@ class Docbank(datasets.GeneratorBasedBuilder):
|
|
| 268 |
"labels": split_labels
|
| 269 |
}
|
| 270 |
key += 1
|
| 271 |
-
break
|
| 272 |
-
|
| 273 |
-
|
|
|
|
| 83 |
return image, (w, h)
|
| 84 |
|
| 85 |
|
| 86 |
+
# def normalize_bbox(bbox, size):
|
| 87 |
+
# return [
|
| 88 |
+
# int(1000 * int(bbox[0]) / size[0]),
|
| 89 |
+
# int(1000 * int(bbox[1]) / size[1]),
|
| 90 |
+
# int(1000 * int(bbox[2]) / size[0]),
|
| 91 |
+
# int(1000 * int(bbox[3]) / size[1]),
|
| 92 |
+
# ]
|
| 93 |
+
#
|
| 94 |
+
#
|
| 95 |
+
# def simplify_bbox(bbox):
|
| 96 |
+
# return [
|
| 97 |
+
# min(bbox[0::2]),
|
| 98 |
+
# min(bbox[1::2]),
|
| 99 |
+
# max(bbox[2::2]),
|
| 100 |
+
# max(bbox[3::2]),
|
| 101 |
+
# ]
|
| 102 |
+
#
|
| 103 |
+
#
|
| 104 |
+
# def merge_bbox(bbox_list):
|
| 105 |
+
# x0, y0, x1, y1 = list(zip(*bbox_list))
|
| 106 |
+
# return [min(x0), min(y0), max(x1), max(y1)]
|
| 107 |
|
| 108 |
|
| 109 |
# TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
|
|
|
|
| 225 |
with open(f_fp_txt, newline='', encoding='utf-8') as csvfile:
|
| 226 |
reader = csv.reader(csvfile, delimiter='\t', quotechar=' ')
|
| 227 |
for row in reader:
|
| 228 |
+
# normalized_bbox = normalize_bbox(row[1:5], size)
|
| 229 |
+
normalized_bbox = [int(x) for x in row[1:5]]
|
| 230 |
tokenized_input = self.TOKENIZER(
|
| 231 |
row[0],
|
| 232 |
add_special_tokens=False,
|
|
|
|
| 269 |
"labels": split_labels
|
| 270 |
}
|
| 271 |
key += 1
|
|
|
|
|
|
|
|
|