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