From bdf6e5689aa5b5cb5962aa8e2282735df8f37453 Mon Sep 17 00:00:00 2001 From: MRXLT Date: Wed, 22 Apr 2020 16:48:43 +0800 Subject: [PATCH] fix imagenet demo --- python/examples/imagenet/image_classification_service.py | 4 ++-- python/examples/imagenet/image_classification_service_gpu.py | 4 ++-- python/examples/imagenet/image_http_client.py | 2 +- python/examples/imagenet/image_rpc_client.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/examples/imagenet/image_classification_service.py b/python/examples/imagenet/image_classification_service.py index 159a590a..ee3ae6dd 100644 --- a/python/examples/imagenet/image_classification_service.py +++ b/python/examples/imagenet/image_classification_service.py @@ -31,14 +31,14 @@ class ImageService(WebService): sample = base64.b64decode(image) img = reader.process_image(sample) res_feed = {} - res_feed["image"] = img.reshape(-1) + res_feed["image"] = img feed_batch.append(res_feed) return feed_batch, fetch else: sample = base64.b64decode(feed["image"]) img = reader.process_image(sample) res_feed = {} - res_feed["image"] = img.reshape(-1) + res_feed["image"] = img return res_feed, fetch diff --git a/python/examples/imagenet/image_classification_service_gpu.py b/python/examples/imagenet/image_classification_service_gpu.py index 4f620bfd..d8ba4ed8 100644 --- a/python/examples/imagenet/image_classification_service_gpu.py +++ b/python/examples/imagenet/image_classification_service_gpu.py @@ -32,14 +32,14 @@ class ImageService(WebService): sample = base64.b64decode(image) img = reader.process_image(sample) res_feed = {} - res_feed["image"] = img.reshape(-1) + res_feed["image"] = img feed_batch.append(res_feed) return feed_batch, fetch else: sample = base64.b64decode(feed["image"]) img = reader.process_image(sample) res_feed = {} - res_feed["image"] = img.reshape(-1) + res_feed["image"] = img return res_feed, fetch diff --git a/python/examples/imagenet/image_http_client.py b/python/examples/imagenet/image_http_client.py index cda0f33a..d920eccb 100644 --- a/python/examples/imagenet/image_http_client.py +++ b/python/examples/imagenet/image_http_client.py @@ -31,7 +31,7 @@ def predict(image_path, server): r = requests.post( server, data=req, headers={"Content-Type": "application/json"}) try: - print(r.json()["score"][0]) + print(r.json()["result"]["score"]) except ValueError: print(r.text) return r diff --git a/python/examples/imagenet/image_rpc_client.py b/python/examples/imagenet/image_rpc_client.py index 76f3a043..f9051796 100644 --- a/python/examples/imagenet/image_rpc_client.py +++ b/python/examples/imagenet/image_rpc_client.py @@ -26,7 +26,7 @@ start = time.time() for i in range(1000): with open("./data/n01440764_10026.JPEG", "rb") as f: img = f.read() - img = reader.process_image(img).reshape(-1) + img = reader.process_image(img) fetch_map = client.predict(feed={"image": img}, fetch=["score"]) end = time.time() print(end - start) -- GitLab