Giter Site home page Giter Site logo

deploy-pytorch-model's Introduction

A Simple PyTorch deep learning REST API

This repository contains the code of 如何用flask部署pytorch模型

Starting the pytorch server

python run_pytorch_server.py 

You can now access the REST API via http://127.0.0.1:5000/predict

Submitting requests to pytorch server

python simple_request.py --file='file_path'

Acknowledgement

This repository refers to jrosebr1/simple-keras-rest-api, and thank the author again.

deploy-pytorch-model's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

deploy-pytorch-model's Issues

hello!I meet some problems when trying to test dog.jpg

File "simple_request.py", line 38, in
predict_result(args.file)
File "simple_request.py", line 20, in predict_result
r = requests.post(PyTorch_REST_API_URL, files=payload).json()
File "D:\ananconda\lib\site-packages\requests\models.py", line 885, in json
return complexjson.loads(self.text, **kwargs)
File "D:\ananconda\lib\json_init_.py", line 354, in loads
return _default_decoder.decode(s)
File "D:\ananconda\lib\json\decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "D:\ananconda\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)

thank you for your help!

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

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.