katanaml commited on
Commit
ce6e90b
·
1 Parent(s): 0fad370

Update cord.py

Browse files
Files changed (1) hide show
  1. cord.py +10 -5
cord.py CHANGED
@@ -130,17 +130,22 @@ class Cord(datasets.GeneratorBasedBuilder):
130
  image_path = image_path.replace("json", "png")
131
 
132
  width, height = data["meta"]["image_size"]["width"], data["meta"]["image_size"]["height"]
133
-
134
  for item in data["valid_line"]:
135
  for word in item['words']:
136
  # get word
137
  txt = word['text']
138
 
139
  # get bounding box
140
- x1 = word['quad']['x1']
141
- y1 = word['quad']['y1']
142
- x3 = word['quad']['x3']
143
- y3 = word['quad']['y3']
 
 
 
 
 
144
 
145
  box = [x1, y1, x3, y3]
146
  box = normalize_bbox(box, width=width, height=height)
 
130
  image_path = image_path.replace("json", "png")
131
 
132
  width, height = data["meta"]["image_size"]["width"], data["meta"]["image_size"]["height"]
133
+ image_id = data["meta"]["image_id"]
134
  for item in data["valid_line"]:
135
  for word in item['words']:
136
  # get word
137
  txt = word['text']
138
 
139
  # get bounding box
140
+ x1 = abs(word['quad']['x1'])
141
+ y1 = abs(word['quad']['y1'])
142
+ x3 = abs(word['quad']['x3'])
143
+ y3 = abs(word['quad']['y3'])
144
+
145
+ x1 = width if x1 > width else x1
146
+ y1 = height if y1 > height else y1
147
+ x3 = width if x3 > width else x3
148
+ y3 = height if y3 > height else y3
149
 
150
  box = [x1, y1, x3, y3]
151
  box = normalize_bbox(box, width=width, height=height)