deploy-pytorch-model icon indicating copy to clipboard operation
deploy-pytorch-model copied to clipboard

post返回的结果:404,是什么原因呢

Open PingYufeng opened this issue 5 years ago • 3 comments

flask_server: Loading PyTorch model and Flask starting server ... Please wait until server has fully started

  • Serving Flask app "run_pytorch_server" (lazy loading)
  • Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
  • Debug mode: off
  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) 127.0.0.1 - - [21/Feb/2020 16:47:21] "?[33mPOST /predict/ HTTP/1.1?[0m" 404 -

client: 打印post返回的结果 <Response [404]> Traceback (most recent call last): File "e:/RiseFile/Deeplearning/Deploy/myModleDeploy/Flask/examples/deploy-pytorch-model/simple_request.py", line 40, in predict_result(args.file) File "e:/RiseFile/Deeplearning/Deploy/myModleDeploy/Flask/examples/deploy-pytorch-model/simple_request.py", line 22, in predict_result r = r.json() File "D:\Anaconda3\envs\py36\lib\site-packages\requests\models.py", line 898, in json return complexjson.loads(self.text, **kwargs) File "D:\Anaconda3\envs\py36\lib\json_init_.py", line 354, in loads return _default_decoder.decode(s) File "D:\Anaconda3\envs\py36\lib\json\decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "D:\Anaconda3\envs\py36\lib\json\decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

PingYufeng avatar Feb 21 '20 08:02 PingYufeng

同样问题

Salary-only-17k avatar Dec 17 '20 15:12 Salary-only-17k

In run_pytorch_server file, at around line 89, try converting the label to float before passing it idx2label. label_name = idx2label[float(label)] like this, this solved it for me.

HamzaManzoor66 avatar Sep 14 '22 17:09 HamzaManzoor66

yes, this solved it also for me. thanks!

WangYichenCode avatar Dec 12 '22 11:12 WangYichenCode