[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
pull/1801/head
VVsssssk 2021-10-12 19:56:02 +08:00 committed by GitHub
parent adb1cd361b
commit 3c6cbc4a24
2 changed files with 5 additions and 8 deletions

View File

@ -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

View File

@ -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)