在哪里可以找到 tensorflow-serving URL?
Where to find the tensorflow-serving URL?
我为 tensorflow-serving
创建了一个 Dockerfile
如下:
FROM tensorflow/serving
COPY /model_dir /models/model/
我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 (Caused by
NewConnectionError('<urllib3.connection.HTTPConnection object at
0x7f315c19c4c0>: Failed to establish a new connection: [Errno 111]
Connection refused'))
我认为这是由于 URL 不正确造成的,我怎样才能为我的 tensorflow-serving 获得正确的 URL?
这是 tensorflow-serving 容器消息:
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
我为 tensorflow-serving
创建了一个 Dockerfile
如下:
FROM tensorflow/serving
COPY /model_dir /models/model/
我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 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f315c19c4c0>: Failed to establish a new connection: [Errno 111] Connection refused'))
我认为这是由于 URL 不正确造成的,我怎样才能为我的 tensorflow-serving 获得正确的 URL?
这是 tensorflow-serving 容器消息:
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