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

print traceback for serving (#815)

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