• Docker部署TensorFlow Serving


    https://blog.csdn.net/weixin_40922744/article/details/102872607:docker安装、docker部署深度学习模型

    一 、docker安装

    二、使用docker拉取TensorFlow Serving最新版镜像

    docker pull tensorflow/serving  # 默认为 latest版本

    三、获取官方服务仓库(其中demo部分可以测试服务是否能够正常启动)

    # 新建一个文件用于存放官方示例代码, 本文直接放在E盘下
    git clone https://github.com/tensorflow/serving
    cd serving
    # 官方示例代码位置
    E:/serving/tensorflow_serving/servables/tensorflow/testdata

    四、Docker利用tensorFlow Serving 部署深度模型实例

    1、使用docker命令启动服务(以REST API方式,端口:8501)

    TESTDATA="E:/serving/tensorflow_serving/servables/tensorflow/testdata"
    docker run -p 8501:8501 -v "$TESTDATA/saved_model_half_plus_two_cpu:/models/half_plus_two" -e MODEL_NAME=half_plus_two tensorflow/serving "&"

    2、建立磁盘映射除了使用-v参数,也可以使用mount参数:

    docker run -p 8501:8501 --mount type=bind,source=F:/docker_wk/github/serving/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_cpu,target=/models/half_plus_two -e MODEL_NAME=half_plus_two -t tensorflow/serving "&"

    五、Windows 客户端访问服务

    1、访问格式

    https://tf.wiki/zh_hans/deployment/serving.html#zh-hans-call-serving-api

    1)TensorFlow Serving支持以gPRC和RESTful API调用以Tensorflow Serving部署的模型。

    RESTful API以标准的HTTP POST方法进行交互,请求和回复均为JSON对象。为了调用服务端的模型,我们在客户端向服务端发送以下格式的请求:

    服务端 URI:

    http://服务器地址:端口号/v1/models/模型名:predict

    请求内容:

    {
        "signature_name": "需要调用的函数签名(Sequential模式不需要)",
        "instances": 输入数据
    }

    回复为:

    {
      "predictions":返回值
    }

    2、客户实例:

    1)python代码请求

    # -*- coding: utf-8 -*-
    import requests
    headers ={"content-type": "application/json"}
    json_response =requests.post('http://192.168.99.100:8501/v1/models/half_plus_two:predict',data="{"instances": [1.0, 2.0, 5.0]}", headers=headers)
    print(json_response.text)

    2)命令行:重新打开一个测试窗口,这里使用curl命令:(测试的有问题)

    curl -XPOST http://localhost:8501/v1/models/half_plus_two:predict -d "{"instances":[1.0, 2.0, 5.0]}"

    3)用postman测试:(https://blog.csdn.net/meruru/article/details/115700381)

  • 相关阅读:
    van Emda Boas
    斐波那契堆
    NTT
    FFT
    KDTree
    扩展kmp
    kmp
    Dancing Links
    树的prufer编码
    有向图最小路径覆盖
  • 原文地址:https://www.cnblogs.com/wllwqdeai/p/15016723.html
Copyright © 2020-2023  润新知