提交 3a318203 编写于 作者: M MRXLT

fix imagenet ce

上级 65fc3e00
...@@ -25,36 +25,36 @@ import base64 ...@@ -25,36 +25,36 @@ import base64
from paddle_serving_client import Client from paddle_serving_client import Client
from paddle_serving_client.utils import MultiThreadRunner from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args from paddle_serving_client.utils import benchmark_args
from paddle_serving_app.reader import Sequential, URL2Image, Resize from paddle_serving_app.reader import Sequential, File2Image, Resize
from paddle_serving_app.reader import CenterCrop, RGB2BGR, Transpose, Div, Normalize from paddle_serving_app.reader import CenterCrop, RGB2BGR, Transpose, Div, Normalize
args = benchmark_args() args = benchmark_args()
seq_preprocess = Sequential([ seq_preprocess = Sequential([
URL2Image(), Resize(256), CenterCrop(224), RGB2BGR(), Transpose((2, 0, 1)), File2Image(), 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) Div(255), Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225], True)
]) ])
def single_func(idx, resource): def single_func(idx, resource):
file_list = [] file_list = []
turns = 10
for file_name in os.listdir("./image_data/n01440764"): for file_name in os.listdir("./image_data/n01440764"):
file_list.append(file_name) file_list.append(file_name)
img_list = [] img_list = []
for i in range(1000): for i in range(1000):
img_list.append(open("./image_data/n01440764/" + file_list[i]).read()) img_list.append("./image_data/n01440764/" + file_list[i])
profile_flags = False profile_flags = False
if "FLAGS_profile_client" in os.environ and os.environ[ if "FLAGS_profile_client" in os.environ and os.environ[
"FLAGS_profile_client"]: "FLAGS_profile_client"]:
profile_flags = True profile_flags = True
if args.request == "rpc": if args.request == "rpc":
reader = ImageReader()
fetch = ["score"] fetch = ["score"]
client = Client() client = Client()
client.load_client_config(args.model) client.load_client_config(args.model)
client.connect([resource["endpoint"][idx % len(resource["endpoint"])]]) client.connect([resource["endpoint"][idx % len(resource["endpoint"])]])
start = time.time() start = time.time()
for i in range(1000): for i in range(turns):
if args.batch_size >= 1: if args.batch_size >= 1:
feed_batch = [] feed_batch = []
i_start = time.time() i_start = time.time()
...@@ -77,7 +77,7 @@ def single_func(idx, resource): ...@@ -77,7 +77,7 @@ def single_func(idx, resource):
server = "http://" + resource["endpoint"][idx % len(resource[ server = "http://" + resource["endpoint"][idx % len(resource[
"endpoint"])] + "/image/prediction" "endpoint"])] + "/image/prediction"
start = time.time() start = time.time()
for i in range(1000): for i in range(turns):
if py_version == 2: if py_version == 2:
image = base64.b64encode( image = base64.b64encode(
open("./image_data/n01440764/" + file_list[i]).read()) open("./image_data/n01440764/" + file_list[i]).read())
...@@ -93,8 +93,9 @@ def single_func(idx, resource): ...@@ -93,8 +93,9 @@ def single_func(idx, resource):
if __name__ == '__main__': if __name__ == '__main__':
multi_thread_runner = MultiThreadRunner() multi_thread_runner = MultiThreadRunner()
endpoint_list = ["127.0.0.1:9393"] endpoint_list = [
#endpoint_list = endpoint_list + endpoint_list + endpoint_list "127.0.0.1:9292", "127.0.0.1:9293", "127.0.0.1:9294", "127.0.0.1:9295"
]
result = multi_thread_runner.run(single_func, args.thread, result = multi_thread_runner.run(single_func, args.thread,
{"endpoint": endpoint_list}) {"endpoint": endpoint_list})
#result = single_func(0, {"endpoint": endpoint_list}) #result = single_func(0, {"endpoint": endpoint_list})
......
...@@ -11,7 +11,7 @@ $PYTHONROOT/bin/python benchmark.py --thread 8 --batch_size 1 --model $2/serving ...@@ -11,7 +11,7 @@ $PYTHONROOT/bin/python benchmark.py --thread 8 --batch_size 1 --model $2/serving
for thread_num in 4 8 16 for thread_num in 4 8 16
do do
for batch_size in 1 4 16 64 256 for batch_size in 1 4 16 64
do do
$PYTHONROOT/bin/python benchmark.py --thread $thread_num --batch_size $batch_size --model $2/serving_client_conf.prototxt --request rpc > profile 2>&1 $PYTHONROOT/bin/python benchmark.py --thread $thread_num --batch_size $batch_size --model $2/serving_client_conf.prototxt --request rpc > profile 2>&1
echo "model name :" $1 echo "model name :" $1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册