A treasure chest for visual classification and recognition powered by PaddlePaddle
5.5k
stars
1.17k
forks
source link
图片方向分类模型serving部署报错:{'err_no': 5, 'err_msg': '(log_id=2) imagenet failed to predict.', 'key': [], 'value': [], 'tensors': []} #2837
Open
MarkHe735 opened 1 year ago
将图片文字方向模型部署为serving服务。 模型参考文档:https://github.com/PaddlePaddle/PaddleClas/blob/release/2.5/docs/zh_CN/models/PULC/PULC_text_image_orientation.md 对方向分类模型进行了微调,inference模型预测正常。 部署参考文档:https://github.com/PaddlePaddle/PaddleClas/tree/release/2.5/deploy/paddleserving#readme 采用docker部署方式,没有GPU;文档中的imagenet部署成功;方向分类器始终报错。
2023/06/19 07:53:02 start proxy service grep: warning: GREP_OPTIONS is deprecated; please use an alias or script E0619 07:53:03.268620 3511 analysis_config.cc:91] Please compile with gpu to EnableGpu() I0619 07:53:03.288556 3511 analysis_predictor.cc:668] ir_optim is turned off, no IR pass will be executed ^[[1m^[[35m--- Running analysis [ir_graph_build_pass]^[[0m ^[[1m^[[35m--- Running analysis [ir_graph_clean_pass]^[[0m ^[[1m^[[35m--- Running analysis [ir_analysis_pass]^[[0m ^[[1m^[[35m--- Running analysis [ir_params_sync_among_devices_pass]^[[0m ^[[1m^[[35m--- Running analysis [adjust_cudnn_workspace_size_pass]^[[0m ^[[1m^[[35m--- Running analysis [inference_op_replace_pass]^[[0m ^[[1m^[[35m--- Running analysis [memory_optimize_pass]^[[0m I0619 07:53:03.306725 3511 memory_optimize_pass.cc:214] Cluster name : conv2d_48.tmp_1 size: 2048 I0619 07:53:03.306746 3511 memory_optimize_pass.cc:214] Cluster name : batch_norm_2.tmp_2 size: 1605632 I0619 07:53:03.306756 3511 memory_optimize_pass.cc:214] Cluster name : hardswish_33.tmp_0 size: 802816 I0619 07:53:03.306766 3511 memory_optimize_pass.cc:214] Cluster name : hardswish_30.tmp_0 size: 1605632 I0619 07:53:03.306774 3511 memory_optimize_pass.cc:214] Cluster name : x size: 602112 ^[[1m^[[35m--- Running analysis [ir_graph_to_program_pass]^[[0m I0619 07:53:03.325022 3511 analysis_predictor.cc:717] ======= optimize end ======= I0619 07:53:03.325529 3511 naive_executor.cc:98] --- skip [feed], feed -> x I0619 07:53:03.326546 3511 naive_executor.cc:98] --- skip [hardswish_30.tmp_0], fetch -> fetch
python web服务启动代码,仅修改了读取标签部分: `import sys from paddle_serving_app.reader import Sequential, URL2Image, Resize, CenterCrop, RGB2BGR, Transpose, Div, Normalize, Base64ToImage try: from paddle_serving_server_gpu.web_service import WebService, Op except ImportError: from paddle_serving_server.web_service import WebService, Op import logging import numpy as np import base64, cv2
class ImagenetOp(Op): def init_op(self): self.seq = Sequential([ Resize(256), CenterCrop(224), RGB2BGR(), Transpose((2, 0, 1)), Div(255), Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225], True) ]) self.label_dict = {} label_idx = 0 with open("pplcnet.label") as fin: for line in fin: idx, label = line.split() self.label_dict[idx] = label label_idx += 1
class ImageService(WebService): def get_pipeline_response(self, read_op): image_op = ImagenetOp(name="imagenet", input_ops=[read_op]) return image_op
uci_service = ImageService(name="imagenet") uci_service.prepare_pipeline_config("config.yml") uci_service.run_service() `
标签文件pplcnet.label内容:
0 0 1 90 2 180 3 270
配置文件config.yum内容,仅修改了serving模型目录: `worker_num: 1
http端口, rpc_port和http_port不允许同时为空。当rpc_port可用且http_port为空时,不自动生成http_port
http_port: 18080 rpc_port: 9993
dag:
op资源类型, True, 为线程模型;False,为进程模型
op: imagenet:
并发数,is_thread_op=True时,为线程并发;否则为进程并发
`
预测命令:python3.7 pipeline_http_client.py 报错信息为:{'err_no': 5, 'err_msg': '(log_id=0) imagenet failed to predict.', 'key': [], 'value': [], 'tensors': []}
请大牛们指教