Pārlūkot izejas kodu

tools工具脚本

xujiayue 2 gadi atpakaļ
vecāks
revīzija
227219db73
3 mainītis faili ar 18 papildinājumiem un 1 dzēšanām
  1. 0 1
      YQ_OCR/main.py
  2. 18 0
      YQ_OCR/tools/gt2det.py
  3. 0 0
      YQ_OCR/tools/xlsx_convert_json.py

+ 0 - 1
YQ_OCR/main.py

@@ -16,7 +16,6 @@ if __name__ == '__main__':
     table_mean_acc = []
     for img_path in img_paths:
         print(img_path)
-
         true_d, true_json = open_true_json(img_path.with_suffix('.json'))
         result = send_request(img_path, true_json)
         res_d = parse_result(result)

+ 18 - 0
YQ_OCR/tools/gt2det.py

@@ -0,0 +1,18 @@
+import json
+import jsonlines
+
+
+def gen_det_label(input_label, out_label):
+    with open(out_label, 'w', encoding='UTF-8') as out_file:
+        with jsonlines.open(input_label, 'r') as rfd:
+            for data in rfd:
+                img_path = data['filename']
+                label = []
+                for cell in data['html']['cells']:
+                    a = ''
+                    for text in cell['tokens']:
+                        a += text
+                    result = {"transcription": str(a), "points": cell['bbox'][0]}
+                    label.append(result)
+                #                 print(label)
+                out_file.write(img_path + '\t' + json.dumps(label, ensure_ascii=False) + '\n')

+ 0 - 0
YQ_OCR/utils/xlsx_convert_json.py → YQ_OCR/tools/xlsx_convert_json.py