From da0f7b12e82be25aef40b3d6878b54c5ccd2e978 Mon Sep 17 00:00:00 2001 From: huangjianhui <852142024@qq.com> Date: Mon, 18 Oct 2021 17:19:46 +0800 Subject: [PATCH] Update test_client.py --- .../ttfnet_darknet53_1x_coco/test_client.py | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/python/examples/detection/ttfnet_darknet53_1x_coco/test_client.py b/python/examples/detection/ttfnet_darknet53_1x_coco/test_client.py index 59024d01..114f43c1 100644 --- a/python/examples/detection/ttfnet_darknet53_1x_coco/test_client.py +++ b/python/examples/detection/ttfnet_darknet53_1x_coco/test_client.py @@ -11,16 +11,18 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - -from paddle_serving_client import Client -from paddle_serving_app.reader import * import sys import numpy as np +from paddle_serving_client import Client +from paddle_serving_app.reader import * +import cv2 preprocess = Sequential([ - File2Image(), BGR2RGB(), - Normalize([123.675, 116.28, 103.53], [58.395, 57.12, 57.375], False), - Resize((512, 512)), Transpose((2, 0, 1)) + File2Image(), + Resize( + (512, 512), False, interpolation=cv2.INTER_LINEAR), + Normalize([123.675, 116.28, 103.53], [58.395, 57.12, 57.375], False), + Transpose((2,0,1)) ]) postprocess = RCNNPostprocess("label_list.txt", "output") @@ -29,11 +31,14 @@ client = Client() client.load_client_config("serving_client/serving_client_conf.prototxt") client.connect(['127.0.0.1:9494']) -im = preprocess(sys.argv[1]) +im, im_info = preprocess(sys.argv[1]) + + fetch_map = client.predict( feed={ "image": im, - "scale_factor": np.array([1.0, 1.0]).reshape(-1), + "im_shape": np.array(list(im.shape[1:])).reshape(-1), + "scale_factor": im_info['scale_factor'], }, fetch=["save_infer_model/scale_0.tmp_1"], batch=False) -- GitLab