使用REST和mnist来提取图像

问题描述 投票:0回答:1

我正在尝试使用REST api从mnist服务器中提取图像,类似于在以下网站的示例部分使用数字example(halft plus two)。

简而言之:我正在尝试用REST替换从mnist服务器提取图像的gRPC方式。

rest tensorflow grpc tensorflow-serving mnist
1个回答
1
投票

拉伸/推断MNIST图像的代码如下所示:

!pip install -q requests

import requests

import json

headers = {"content-type": "application/json"}

json_response = requests.post('http://localhost:8501/v1/models/fashion_model/versions/1:predict', data=data, headers=headers)

predictions = json.loads(json_response.text)['predictions']

for i in range(0,3):

show(i, 'The model thought this was a {} (class {}), and it was actually a {} (class {})'.format(
    class_names[np.argmax(predictions[i])], test_labels[i], class_names[np.argmax(predictions[i])], test_labels[i]))

有关使用REST API从MNIST Server(Fashion MNIST)提取图像的教程,请参见以下链接https://www.tensorflow.org/tfx/tutorials/serving/rest_simple#import_the_fashion_mnist_dataset

如果上面提供的链接出现任何问题,您可以导航到

Tensorflow.org网站 - >学习 - >用于制作 - >教程 - >服务 - >使用REST训练和服务模型。

© www.soinside.com 2019 - 2024. All rights reserved.