提交 43f6ab7a 编写于 作者: littletomatodonkey's avatar littletomatodonkey

fix gen label

上级 3a18b08f
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#limitations under the License. #limitations under the License.
import os import os
import argparse import argparse
import json
def gen_rec_label(input_path, out_label): def gen_rec_label(input_path, out_label):
...@@ -32,15 +33,19 @@ def gen_det_label(root_path, input_dir, out_label): ...@@ -32,15 +33,19 @@ def gen_det_label(root_path, input_dir, out_label):
label = [] label = []
with open(os.path.join(input_dir, label_file), 'r') as f: with open(os.path.join(input_dir, label_file), 'r') as f:
for line in f.readlines(): for line in f.readlines():
tmp = line.strip("\n\r").replace("\xef\xbb\xbf", "").split(',') tmp = line.strip("\n\r").replace("\xef\xbb\xbf",
points = tmp[:-2] "").split(',')
points = tmp[:8]
s = [] s = []
for i in range(0, len(points), 2): for i in range(0, len(points), 2):
b = points[i:i + 2] b = points[i:i + 2]
b = [int(t) for t in b]
s.append(b) s.append(b)
result = {"transcription": tmp[-1], "points": s} result = {"transcription": tmp[8], "points": s}
label.append(result) label.append(result)
out_file.write(img_path + '\t' + str(label) + '\n')
out_file.write(img_path + '\t' + json.dumps(
label, ensure_ascii=False) + '\n')
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册