From 0a768a4ff4c5c88c122d0602f241564d70d81da8 Mon Sep 17 00:00:00 2001 From: MRXLT Date: Mon, 25 May 2020 12:14:39 +0800 Subject: [PATCH] change imagenet benchmark --- python/examples/imagenet/benchmark.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/python/examples/imagenet/benchmark.py b/python/examples/imagenet/benchmark.py index 00e9fbe7..caa952f1 100644 --- a/python/examples/imagenet/benchmark.py +++ b/python/examples/imagenet/benchmark.py @@ -19,16 +19,22 @@ from __future__ import unicode_literals, absolute_import import os import sys import time -from paddle_serving_client import Client -from paddle_serving_client.utils import MultiThreadRunner -from paddle_serving_client.utils import benchmark_args import requests import json import base64 -from image_reader import ImageReader +from paddle_serving_client import Client +from paddle_serving_client.utils import MultiThreadRunner +from paddle_serving_client.utils import benchmark_args +from paddle_serving_app.reader import Sequential, URL2Image, Resize +from paddle_serving_app.reader import CenterCrop, RGB2BGR, Transpose, Div, Normalize args = benchmark_args() +seq_preprocess = Sequential([ + URL2Image(), Resize(256), CenterCrop(224), RGB2BGR(), Transpose((2, 0, 1)), + Div(255), Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225], True) +]) + def single_func(idx, resource): file_list = [] @@ -53,7 +59,7 @@ def single_func(idx, resource): feed_batch = [] i_start = time.time() for bi in range(args.batch_size): - img = reader.process_image(img_list[i]) + img = seq_preprocess(img_list[i]) feed_batch.append({"image": img}) i_end = time.time() if profile_flags: -- GitLab