From 47052f7e755779611fd28b13c45850afabfc7f5e Mon Sep 17 00:00:00 2001 From: VVsssssk <88368822+VVsssssk@users.noreply.github.com> Date: Tue, 12 Oct 2021 19:56:02 +0800 Subject: [PATCH] [Update] Update torchserve about (#951) * test_torchserver1.1 * test_torchserver1.2 * update * update mmseg_handler.py * update docs * update torchserver * tranfer torchserver to torchserve * update docs * updata torchserve support --- tools/torchserve/mmseg_handler.py | 5 ++--- tools/torchserve/test_torchserve.py | 8 +++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tools/torchserve/mmseg_handler.py b/tools/torchserve/mmseg_handler.py index e195f6d5d..28fe5016f 100644 --- a/tools/torchserve/mmseg_handler.py +++ b/tools/torchserve/mmseg_handler.py @@ -51,7 +51,6 @@ class MMsegHandler(BaseHandler): for image_result in data: _, buffer = cv2.imencode('.png', image_result[0].astype('uint8')) - bast64_data = base64.b64encode(buffer.tobytes()) - bast64_str = str(bast64_data, 'utf-8') - output.append(bast64_str) + content = buffer.tobytes() + output.append(content) return output diff --git a/tools/torchserve/test_torchserve.py b/tools/torchserve/test_torchserve.py index 824dee952..59752853f 100644 --- a/tools/torchserve/test_torchserve.py +++ b/tools/torchserve/test_torchserve.py @@ -1,4 +1,3 @@ -import base64 from argparse import ArgumentParser from io import BytesIO @@ -37,15 +36,14 @@ def main(args): url = 'http://' + args.inference_addr + '/predictions/' + args.model_name with open(args.img, 'rb') as image: tmp_res = requests.post(url, image) - base64_str = tmp_res.content - buffer = base64.b64decode(base64_str) + content = tmp_res.content if args.result_image: with open(args.result_image, 'wb') as out_image: - out_image.write(buffer) + out_image.write(content) plt.imshow(mmcv.imread(args.result_image, 'grayscale')) plt.show() else: - plt.imshow(plt.imread(BytesIO(buffer))) + plt.imshow(plt.imread(BytesIO(content))) plt.show() model = init_segmentor(args.config, args.checkpoint, args.device) image = mmcv.imread(args.img)