From e66fb58ee7a1c2b2cfeebc68c3ddeb968652e46e Mon Sep 17 00:00:00 2001 From: MRXLT Date: Thu, 21 May 2020 14:58:33 +0800 Subject: [PATCH] fix image reader and imagenet doc --- python/examples/imagenet/README.md | 2 +- python/examples/imagenet/README_CN.md | 2 +- python/paddle_serving_app/reader/image_reader.py | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/python/examples/imagenet/README.md b/python/examples/imagenet/README.md index 536440e7..415818e7 100644 --- a/python/examples/imagenet/README.md +++ b/python/examples/imagenet/README.md @@ -44,6 +44,6 @@ python -m paddle_serving_server_gpu.serve --model ResNet50_vd_model --port 9696 client send inference request ``` -python image_rpc_client.py ResNet50_vd_client_config/serving_client_conf.prototxt +python resnet50_rpc_client.py ResNet50_vd_client_config/serving_client_conf.prototxt ``` *the port of server side in this example is 9696 diff --git a/python/examples/imagenet/README_CN.md b/python/examples/imagenet/README_CN.md index c34ccca3..77ade579 100644 --- a/python/examples/imagenet/README_CN.md +++ b/python/examples/imagenet/README_CN.md @@ -44,6 +44,6 @@ python -m paddle_serving_server_gpu.serve --model ResNet50_vd_model --port 9696 client端进行预测 ``` -python image_rpc_client.py ResNet50_vd_client_config/serving_client_conf.prototxt +python resnet50_rpc_client.py ResNet50_vd_client_config/serving_client_conf.prototxt ``` *server端示例中服务端口为9696端口 diff --git a/python/paddle_serving_app/reader/image_reader.py b/python/paddle_serving_app/reader/image_reader.py index a5afb9c8..7988bf44 100644 --- a/python/paddle_serving_app/reader/image_reader.py +++ b/python/paddle_serving_app/reader/image_reader.py @@ -13,14 +13,19 @@ # limitations under the License. import cv2 import os -import urllib import numpy as np import base64 +import sys from . import functional as F from PIL import Image, ImageDraw import json _cv2_interpolation_to_str = {cv2.INTER_LINEAR: "cv2.INTER_LINEAR", None: "None"} +py_version = sys.version_info[0] +if py_version == 2: + import urllib +else: + import urllib.request as urllib def generate_colormap(num_classes): @@ -393,7 +398,7 @@ class Normalize(object): class Lambda(object): """Apply a user-defined lambda as a transform. - Very shame to just copy from + Very shame to just copy from https://github.com/pytorch/vision/blob/master/torchvision/transforms/transforms.py#L301 Args: -- GitLab