项目架构调整,模型全部采用接口调用
This commit is contained in:
@@ -2,10 +2,9 @@ import logging
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
from flask import jsonify
|
||||
from opencc import OpenCC
|
||||
|
||||
from util import string_util
|
||||
from util import string_util, model_util
|
||||
|
||||
|
||||
# 获取yyyy-MM-dd HH:mm:ss格式的当前时间
|
||||
@@ -37,7 +36,7 @@ def get_ocr_layout(ocr, img_path):
|
||||
return True
|
||||
|
||||
layout = []
|
||||
ocr_result = ocr.ocr(img_path, cls=False)
|
||||
ocr_result = model_util.request_ocr(img_path)
|
||||
ocr_result = ocr_result[0]
|
||||
if not ocr_result:
|
||||
return layout
|
||||
@@ -218,19 +217,3 @@ def chinese_money_to_number(chinese_money_amount):
|
||||
def traditional_to_simple_chinese(traditional_chinese):
|
||||
converter = OpenCC('t2s')
|
||||
return converter.convert(traditional_chinese)
|
||||
|
||||
|
||||
def process_request(func):
|
||||
"""
|
||||
api通用处理函数
|
||||
"""
|
||||
|
||||
def wrapper(*args, **kwargs):
|
||||
try:
|
||||
result = func(*args, **kwargs)
|
||||
return jsonify(result), 200
|
||||
except Exception as e:
|
||||
logging.getLogger('error').error(f'Error: {e}')
|
||||
return jsonify({'error': str(e)}), 500
|
||||
|
||||
return wrapper
|
||||
|
||||
Reference in New Issue
Block a user