提交 d6615553 编写于 作者: Q qiaolongfei

add mnist demo client

上级 d31e0025
import requests
from PIL import Image
import numpy as np
import os
def load_image(file):
im = Image.open(file).convert('L')
im = im.resize((28, 28), Image.ANTIALIAS)
im = np.array(im).astype(np.float32).flatten()
im = im / 255.0
return im
cur_dir = os.path.dirname(os.path.realpath(__file__))
data = load_image(cur_dir + '/../image/infer_3.png')
data = data.tolist()
r = requests.post("http://0.0.0.0:8000", json={'img': data})
print(r.text)
...@@ -202,6 +202,11 @@ Here, `code` and `message` represent the status of the request. ...@@ -202,6 +202,11 @@ Here, `code` and `message` represent the status of the request.
probability of each class, could be the IDs of output sentence, and so probability of each class, could be the IDs of output sentence, and so
on. on.
## MNIST Demo Client
If you have trained an model with [train.py](https://github.com/reyoung/paddle_mnist_v2_demo/blob/master/train.py) and
start a inference server. Then you can use this [client](https://github.com/PaddlePaddle/book/tree/develop/02.recognize_digits/client/client.py) to test if it works right.
## Build ## Build
We have already prepared the pre-built docker image We have already prepared the pre-built docker image
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册