未验证 提交 16af2100 编写于 作者: 走神的阿圆's avatar 走神的阿圆 提交者: GitHub

print traceback for serving (#811)

上级 6fe6cf64
......@@ -20,9 +20,9 @@ def base64_to_cv2(b64str):
def cv2_to_base64(image):
return base64.b64encode(image)
# data = cv2.imencode('.jpg', image)[1]
# return base64.b64encode(data.tostring()).decode('utf8')
# return base64.b64encode(image)
data = cv2.imencode('.jpg', image)[1]
return base64.b64encode(data.tostring()).decode('utf8')
def read_images(paths):
......
......@@ -17,6 +17,7 @@ from paddlehub.serving.model_service.base_model_service import nlp_module_info
from paddlehub.serving.model_service.base_model_service import v2_module_info
from paddlehub.common import utils
import functools
import traceback
import time
import os
import base64
......@@ -40,8 +41,7 @@ def predict_v2_advanced(module_info, input):
try:
output = serving_method(**predict_args)
except Exception as err:
curr = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
print(curr, " - ", err)
traceback.print_exc()
return gen_result("-1", "Please check data format!", "")
return gen_result("0", "", output)
......@@ -66,8 +66,7 @@ def predict_nlp(module_info, input_text, req_id, extra=None):
try:
res = predict_method(**predict_args)
except Exception as err:
curr = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
print(curr, " - ", err)
traceback.print_exc()
return gen_result("-1", "Please check data format!", "")
finally:
user_dict = extra.get("user_dict", [])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册