瀏覽代碼

JSON_AS_ASCII

Tinger 2 年之前
父節點
當前提交
d6ac8a4a49
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      app.py

+ 5 - 4
app.py

@@ -10,8 +10,9 @@ from paddleocr import PaddleOCR
 # from paddleocr.tools.infer.predict_system import TextSystem
 #
 app = Flask(__name__)
+app.config["JSON_AS_ASCII"] = False
 # 待优化为 TextSystem
-eng1 = PaddleOCR(
+engine = PaddleOCR(
     use_gpu=False,
     enable_mkldnn=True,
     det_model_dir="models/det/",
@@ -56,7 +57,7 @@ def ocr_raw():
 
     # 内容识别
     array = cv2.imdecode(np.fromstring(content, np.uint8), 1)  # noqa
-    ocr_res = eng1.ocr(array)[0]
+    ocr_res = engine.ocr(array)[0]
     res = [{"pos": it[0], "word": it[1][0], "rate": it[1][1]} for it in ocr_res]
     return Response(data=res)
 
@@ -80,7 +81,7 @@ def ocr_filter():
 
     # 内容识别
     array = cv2.imdecode(np.fromstring(content, np.uint8), 1)  # noqa
-    ocr_res = eng1.ocr(array)[0]
+    ocr_res = engine.ocr(array)[0]
 
     # 过滤出想要的数据
     res = [it[1][0] for it in ocr_res]
@@ -108,7 +109,7 @@ def ocr_html():
 
     # 内容识别
     array = cv2.imdecode(np.fromstring(content, np.uint8), 1)  # noqa
-    ocr_res = eng1.ocr(array)[0]
+    ocr_res = engine.ocr(array)[0]
     res = [{"pos": it[0], "word": it[1][0], "rate": it[1][1]} for it in ocr_res]
 
     # 画图