首页 > 解决方案 > Tensorflow-Serving :requests.exceptions.HTTPError: 400 Client

问题描述

我已经为我的自定义模型提供了一个基于预训练模型的手机对象检测 API。所以,我想向服务发送请求: http://localhost:8501/v1/models/cellphone:predict HTTP\REST API 运行正常。

我使用了 Docker 和 TensorFlow 服务。

对于请求,我使用了一个返回平均时间的 python 脚本,这里是 python 脚本: https ://raw.githubusercontent.com/tensorflow/serving/master/tensorflow_serving/example/resnet_client.py

唯一的变化是图像和我的服务器模型:

# The server URL specifies the endpoint of your server running the ResNet
# model with the name "resnet" and using the predict interface.
SERVER_URL = 'http://localhost:8501/v1/models/cellphone:predict'

# The image URL is the location of the image we should send to the server
IMAGE_URL = 'https://assets.kotsovolos.gr/product/199086-b.jpg'

当我运行 $ python resnet_client.py 时,我遇到了这个错误:

Traceback (most recent call last): File "resnet_client.py", line 73, in <module> main() File `resnet_client.py", line 57, in main response.raise_for_status() File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 941, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://localhost:8501/v1/models/cellphone:predict`

有没有人可以帮助我发送正确的请求?提前感谢你

系统信息 Linux Ubuntu 16.04 -python 3.5 TensorFlow Serving 从二进制 TensorFlow ModelServer 安装:2.1.0-rc1 TensorFlow Library:2.1.0

标签: python-3.xhttprequesttensorflow-servingrest

解决方案


推荐阅读