Serving icon indicating copy to clipboard operation
Serving copied to clipboard

0.7.0版本client端:No module named 'paddle_serving_client.serving_client'

Open wxf764571829 opened this issue 3 years ago • 10 comments

win10客户端使用test_client 报 F:\ruanjian\anaconda3\envs\paddle\lib\site-packages\paddle_serving_client\client.py:149: in init from .serving_client import PredictorRes E ModuleNotFoundError: No module named 'paddle_serving_client.serving_client' 求解,版本是0.7.0 client端的采用pip安装的paddle_serving_client

wxf764571829 avatar Dec 09 '21 05:12 wxf764571829

pip install paddle_serving_client

TeslaZhao avatar Dec 09 '21 06:12 TeslaZhao

https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Install_EN.md

TeslaZhao avatar Dec 09 '21 06:12 TeslaZhao

pip install paddle_serving_client

image 我是已经这样装了的

wxf764571829 avatar Dec 09 '21 06:12 wxf764571829

https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Install_EN.md

我在windows上只是client调用,我的服务是启在ubuntu的,我目前只是想在windows上使用client端 但是不知道为什么一直给我报标题中所述的错误

wxf764571829 avatar Dec 09 '21 06:12 wxf764571829

https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Install_EN.md

我就是按照这里的文档装的client端,但是ModuleNotFoundError: No module named 'paddle_serving_client.serving_client'这个错误一直存在 而且在这行代码中也定位不到PredictorRes File "F:\ruanjian\anaconda3\envs\paddle\lib\site-packages\paddle_serving_client\client.py", line 149, in init from .serving_client import PredictorRes

wxf764571829 avatar Dec 09 '21 07:12 wxf764571829

https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Install_EN.md

还是说win10环境 的python 端(pycharm跑的)无法执行Client,client端也必须依靠docker才能够执行?

wxf764571829 avatar Dec 09 '21 07:12 wxf764571829

您的情况,建议您先使用curl的方式,试试能不能通。 https://github.com/PaddlePaddle/Serving/blob/v0.7.0/doc/Quick_Start_CN.md#http%E6%9C%8D%E5%8A%A1

也可以使用不带C++的版本试试。 https://github.com/PaddlePaddle/Serving/blob/v0.7.0/examples/C%2B%2B/fit_a_line/test_httpclient.py

HexToString avatar Dec 09 '21 08:12 HexToString

还是说win10环境 的python 端(pycharm跑的)无法执行Client,client端也必须依靠docker才能够执行?

是的,windows上必须要用docker

TeslaZhao avatar Dec 09 '21 08:12 TeslaZhao

还是说win10环境 的python 端(pycharm跑的)无法执行Client,client端也必须依靠docker才能够执行?

是的,windows上必须要用docker

感谢大佬 我在ubuntu上起client调用出现这个维度问题 ,预测的图片也是我训练的图片其中之一 以下是服务端报的错误 :terminate called after throwing an instance of 'paddle::platform::EnforceNotMet' what():

Compile Traceback (most recent call last): File "tools/export_model.py", line 115, in main() File "tools/export_model.py", line 111, in main run(FLAGS, cfg) File "tools/export_model.py", line 77, in run trainer.export(FLAGS.output_dir) File "/home/code/paddle/PaddleDetection-release-2.3/ppdet/engine/trainer.py", line 647, in export static_model, pruned_input_spec = self._get_infer_cfg_and_input_spec( File "/home/code/paddle/PaddleDetection-release-2.3/ppdet/engine/trainer.py", line 625, in _get_infer_cfg_and_input_spec input_spec, static_model.forward.main_program, File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 534, in main_program concrete_program = self.concrete_program File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 454, in concrete_program return self.concrete_program_specify_input_spec(input_spec=None) File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 487, in concrete_program_specify_input_spec concrete_program, _ = self.get_concrete_program( File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 402, in get_concrete_program concrete_program, partial_program_layer = self._program_cache[cache_key] File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 711, in getitem self._caches[item] = self._build_once(item) File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 698, in _build_once concrete_program = ConcreteProgram.from_func_spec( File "", line 2, in from_func_spec

File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/wrapped_decorator.py", line 25, in __impl__
  return wrapped_func(*args, **kwargs)
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/base.py", line 40, in __impl__
  return func(*args, **kwargs)
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 652, in from_func_spec
  outputs = static_func(*inputs)
File "/tmp/tmph1_a7fhe.py", line 38, in forward
  out = paddle.jit.dy2static.convert_ifelse(self.training, true_fn_2,
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 210, in convert_ifelse
  return _run_py_ifelse(pred, true_fn, false_fn, true_args, false_args)
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 235, in _run_py_ifelse
  return true_fn(*true_args) if pred else false_fn(*false_args)
File "/home/code/paddle/PaddleDetection-release-2.3/ppdet/modeling/architectures/meta_arch.py", line 56, in forward
  out = self.get_pred()
File "/home/code/paddle/PaddleDetection-release-2.3/ppdet/modeling/architectures/yolo.py", line 124, in get_pred
  return self._forward()
File "/tmp/tmp2mzjjyyx.py", line 94, in _forward
  __return_value_0 = paddle.jit.dy2static.convert_ifelse(self.training,
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 210, in convert_ifelse
  return _run_py_ifelse(pred, true_fn, false_fn, true_args, false_args)
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 235, in _run_py_ifelse
  return true_fn(*true_args) if pred else false_fn(*false_args)
File "/home/code/paddle/PaddleDetection-release-2.3/ppdet/modeling/architectures/yolo.py", line 96, in _forward
  yolo_head_outs = self.yolo_head(neck_feats)
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 898, in __call__
  outputs = self.forward(*inputs, **kwargs)
File "/tmp/tmp73h2ebgz.py", line 115, in forward
  __return_value_2, i, yolo_outputs = paddle.jit.dy2static.convert_ifelse(
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 210, in convert_ifelse
  return _run_py_ifelse(pred, true_fn, false_fn, true_args, false_args)
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 235, in _run_py_ifelse
  return true_fn(*true_args) if pred else false_fn(*false_args)
File "/tmp/tmp73h2ebgz.py", line 110, in false_fn_26
  __return_value_2, i, yolo_outputs = (paddle.jit.dy2static.
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 210, in convert_ifelse
  return _run_py_ifelse(pred, true_fn, false_fn, true_args, false_args)
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 235, in _run_py_ifelse
  return true_fn(*true_args) if pred else false_fn(*false_args)
File "/tmp/tmp73h2ebgz.py", line 97, in true_fn_25
  ] = paddle.jit.dy2static.convert_while_loop(
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 44, in convert_while_loop
  loop_vars = _run_py_while(cond, body, loop_vars)
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py", line 58, in _run_py_while
  loop_vars = body(*loop_vars)
File "/home/code/paddle/PaddleDetection-release-2.3/ppdet/modeling/heads/yolo_head.py", line 105, in forward
  x = x.reshape((b, na, no, h * w))
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/tensor/manipulation.py", line 1570, in reshape
  return paddle.fluid.layers.reshape(x=x, shape=shape, name=name)
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/layers/nn.py", line 6202, in reshape
  helper.append_op(
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op
  return self.main_program.current_block().append_op(*args, **kwargs)
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/framework.py", line 3226, in append_op
  op = Operator(
File "/home/ubuntu01/anaconda3/envs/paddle/lib/python3.8/site-packages/paddle/fluid/framework.py", line 2312, in __init__
  for frame in traceback.extract_stack():

C++ Traceback (most recent call last):


Error Message Summary:

InvalidArgumentError: The 'shape' attribute in ReshapeOp is invalid. The input tensor X'size must be divisible by known capacity of 'shape'. But received X's shape = [1, 33, 19, 19], X's size = 11913, 'shape' is [-1, 3, 11, 400], known capacity of 'shape' is -13200. [Hint: Expected output_shape[unk_dim_idx] * capacity == -in_size, but received output_shape[unk_dim_idx] * capacity:0 != -in_size:-11913.] (at /paddle/paddle/fluid/operators/reshape_op.cc:210) [operator < reshape2 > error] Aborted (core dumped)

wxf764571829 avatar Dec 10 '21 02:12 wxf764571829

Serving部署的模型是yolov3_darknet53_270e_coco, paddle_serving_client和paddle_serving_app版本为0.9.0 在windows下使用http方式获取服务,参考resnet50_http_client.pytest_client.py 转化方法比较暴力,但可用

import sys
import numpy as np
from paddle_serving_client import HttpClient
from paddle_serving_app.reader import *
import cv2

def main(argv):

    preprocess = Sequential([
        File2Image(), BGR2RGB(), Resize(
            (608, 608), interpolation=cv2.INTER_LINEAR), Div(255.0), Transpose(
                (2, 0, 1))
    ])
    
    postprocess = RCNNPostprocess(argv[1], "output", [608, 608])
    client = HttpClient()

    # prototxt文件需要修改成自己的路径
    client.load_client_config("yolov3_darknet53_270e_coco/serving_client/serving_client_conf.prototxt")
    client.connect(['127.0.0.1:9393'])

    im = preprocess(argv[2])

    fetch_map = client.predict(
    feed={
            "image": im,
            "im_shape": np.array(list(im.shape[1:])).reshape(-1),
            "scale_factor": np.array([1.0, 1.0]).reshape(-1),
        },
        fetch=["multiclass_nms3_0.tmp_0"],
        batch=False)
    # print(fetch_map)
    # 处理
    result = fetch_map.outputs[0].tensor[0]  # 要处理的数据都在里面了,只需要进行写转化就行了
    value_shape = result.shape
    value = np.array(list(result.float_data), dtype="float32").reshape(value_shape)     # 转成ndarray,并进行reshape
    fetch_map_dict = {}
    fetch_map_dict[result.name] = value
    fetch_map_dict[result.name+'.lod'] = result.lod
    print(fetch_map_dict)
    fetch_map_dict["image"] = argv[2]
    postprocess(fetch_map_dict)


if __name__ == "__main__":
    main(sys.argv)

regainOWO avatar May 26 '22 07:05 regainOWO

win10客户端使用test_client 报 F:\ruanjian\anaconda3\envs\paddle\lib\site-packages\paddle_serving_client\client.py:149: in init from .serving_client import PredictorRes E ModuleNotFoundError: No module named 'paddle_serving_client.serving_client' 求解,版本是0.7.0 client端的采用pip安装的paddle_serving_client

from paddle_serving_client import HttpClient as Client

whtwhtw avatar Dec 28 '22 09:12 whtwhtw