Example for Deploying a Tensorflow Model via a RESTful API [closed]

久未见 提交于 2019-12-02 15:38:06

https://github.com/sugyan/tensorflow-mnist shows a simple restAPI example by using Flask and loading pre-trained mode (restore).

@app.route('/api/mnist', methods=['POST'])
def mnist():
    input = ((255 - np.array(request.json, dtype=np.uint8)) / 255.0).reshape(1, 784)
    output1 = simple(input)
    output2 = convolutional(input)
    return jsonify(results=[output1, output2])

Also, see the online demo at https://tensorflow-mnist.herokuapp.com/. It seems the API is fast enough.

TensorFlow Serving is a high performance, open source serving system for machine learning models, designed for production environments and optimized for TensorFlow. The initial release contains examples built with gRPC, but you can easily replace the front-end (denoted as "client" in the diagram below) with a RESTful API to suit your needs.

To get started quickly, check out the tutorial.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!