繁体   English   中英

在哪里可以找到 tensorflow 服务 URL?

[英]Where to find the tensorflow-serving URL?

我为tensorflow-serving创建了一个Dockerfile ,如下所示:

FROM tensorflow/serving

COPY /model_dir /models/model/

docker-compose这种方式docker-compose

  tensorflow-servings:
    container_name: tfserving_classifier
    build: ./some_model_dir
    ports:
      - 8501:8501

在 tensorflow-container 中,模型位于/models/model/1

这是我尝试服务的方式

# server URL
url = 'http://localhost:8501/v1/models/model/1:predict'


def make_prediction(instances):
    data = json.dumps({"signature_name": "serving_default", "instances": instances.tolist()})
    headers = {"content-type": "application/json"}
    json_response = requests.post(url, data=data, headers=headers)
    predictions = json.loads(json_response.text)['predictions']
    return predictions

这是python代码容器消息:

requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8501): Max retries exceeded with url: /v1/models/model/1:predict (由 NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f315c19c4c0 >:无法建立新连接:[Errno 111] 连接被拒绝'))

我相信这是由于 URL 不正确,我怎样才能为我的 tensorflow 服务获取正确的 URL?

这是张量流服务容器消息:

I tensorflow_serving/model_servers/server.cc:393] Running gRPC ModelServer at 0.0.0.0:8500 ...

I tensorflow_serving/model_servers/server.cc:414] Exporting HTTP/REST API at:localhost:8501 ...

localhost只到达容器内部,使用 tensorflow 的服务名或容器名从脚本容器到达

http://tensorflow-servings:8501/v1/models/model/1:predict

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM