提交 bdf6e568 编写于 作者: M MRXLT

fix imagenet demo

上级 f5a809b5
...@@ -31,14 +31,14 @@ class ImageService(WebService): ...@@ -31,14 +31,14 @@ class ImageService(WebService):
sample = base64.b64decode(image) sample = base64.b64decode(image)
img = reader.process_image(sample) img = reader.process_image(sample)
res_feed = {} res_feed = {}
res_feed["image"] = img.reshape(-1) res_feed["image"] = img
feed_batch.append(res_feed) feed_batch.append(res_feed)
return feed_batch, fetch return feed_batch, fetch
else: else:
sample = base64.b64decode(feed["image"]) sample = base64.b64decode(feed["image"])
img = reader.process_image(sample) img = reader.process_image(sample)
res_feed = {} res_feed = {}
res_feed["image"] = img.reshape(-1) res_feed["image"] = img
return res_feed, fetch return res_feed, fetch
......
...@@ -32,14 +32,14 @@ class ImageService(WebService): ...@@ -32,14 +32,14 @@ class ImageService(WebService):
sample = base64.b64decode(image) sample = base64.b64decode(image)
img = reader.process_image(sample) img = reader.process_image(sample)
res_feed = {} res_feed = {}
res_feed["image"] = img.reshape(-1) res_feed["image"] = img
feed_batch.append(res_feed) feed_batch.append(res_feed)
return feed_batch, fetch return feed_batch, fetch
else: else:
sample = base64.b64decode(feed["image"]) sample = base64.b64decode(feed["image"])
img = reader.process_image(sample) img = reader.process_image(sample)
res_feed = {} res_feed = {}
res_feed["image"] = img.reshape(-1) res_feed["image"] = img
return res_feed, fetch return res_feed, fetch
......
...@@ -31,7 +31,7 @@ def predict(image_path, server): ...@@ -31,7 +31,7 @@ def predict(image_path, server):
r = requests.post( r = requests.post(
server, data=req, headers={"Content-Type": "application/json"}) server, data=req, headers={"Content-Type": "application/json"})
try: try:
print(r.json()["score"][0]) print(r.json()["result"]["score"])
except ValueError: except ValueError:
print(r.text) print(r.text)
return r return r
......
...@@ -26,7 +26,7 @@ start = time.time() ...@@ -26,7 +26,7 @@ start = time.time()
for i in range(1000): for i in range(1000):
with open("./data/n01440764_10026.JPEG", "rb") as f: with open("./data/n01440764_10026.JPEG", "rb") as f:
img = f.read() img = f.read()
img = reader.process_image(img).reshape(-1) img = reader.process_image(img)
fetch_map = client.predict(feed={"image": img}, fetch=["score"]) fetch_map = client.predict(feed={"image": img}, fetch=["score"])
end = time.time() end = time.time()
print(end - start) print(end - start)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册