diff --git a/paddlehub/commands/tmpl/x_model.tmpl b/paddlehub/commands/tmpl/x_model.tmpl index 26fae122a55430e1f6fb05d177f13a9880a5ef03..4d63a6f8c5d69b4d3b65a46d89f1238755dcb987 100644 --- a/paddlehub/commands/tmpl/x_model.tmpl +++ b/paddlehub/commands/tmpl/x_model.tmpl @@ -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): diff --git a/paddlehub/serving/app_single.py b/paddlehub/serving/app_single.py index 10c3ea047af8faf24e974c5a77f1a4b71558da5f..fb2ce403e12938a64e99b6bbbbd2bdf152c701c1 100644 --- a/paddlehub/serving/app_single.py +++ b/paddlehub/serving/app_single.py @@ -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", [])