Skip to content

Commit ecad10e

Browse files
author
littletomatodonkey
authored
Merge pull request PaddlePaddle#816 from littletomatodonkey/add_tia
fix gen label
2 parents 51b57c4 + 43f6ab7 commit ecad10e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

train_data/gen_label.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#limitations under the License.
1414
import os
1515
import argparse
16+
import json
1617

1718

1819
def gen_rec_label(input_path, out_label):
@@ -32,15 +33,19 @@ def gen_det_label(root_path, input_dir, out_label):
3233
label = []
3334
with open(os.path.join(input_dir, label_file), 'r') as f:
3435
for line in f.readlines():
35-
tmp = line.strip("\n\r").replace("\xef\xbb\xbf", "").split(',')
36-
points = tmp[:-2]
36+
tmp = line.strip("\n\r").replace("\xef\xbb\xbf",
37+
"").split(',')
38+
points = tmp[:8]
3739
s = []
3840
for i in range(0, len(points), 2):
3941
b = points[i:i + 2]
42+
b = [int(t) for t in b]
4043
s.append(b)
41-
result = {"transcription": tmp[-1], "points": s}
44+
result = {"transcription": tmp[8], "points": s}
4245
label.append(result)
43-
out_file.write(img_path + '\t' + str(label) + '\n')
46+
47+
out_file.write(img_path + '\t' + json.dumps(
48+
label, ensure_ascii=False) + '\n')
4449

4550

4651
if __name__ == "__main__":

0 commit comments

Comments
 (0)