mirror of
https://github.com/open-mmlab/mmsegmentation.git
synced 2025-06-03 22:03:48 +08:00
[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
This commit is contained in:
parent
adb1cd361b
commit
3c6cbc4a24
@ -51,7 +51,6 @@ class MMsegHandler(BaseHandler):
|
|||||||
|
|
||||||
for image_result in data:
|
for image_result in data:
|
||||||
_, buffer = cv2.imencode('.png', image_result[0].astype('uint8'))
|
_, buffer = cv2.imencode('.png', image_result[0].astype('uint8'))
|
||||||
bast64_data = base64.b64encode(buffer.tobytes())
|
content = buffer.tobytes()
|
||||||
bast64_str = str(bast64_data, 'utf-8')
|
output.append(content)
|
||||||
output.append(bast64_str)
|
|
||||||
return output
|
return output
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import base64
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
@ -37,15 +36,14 @@ def main(args):
|
|||||||
url = 'http://' + args.inference_addr + '/predictions/' + args.model_name
|
url = 'http://' + args.inference_addr + '/predictions/' + args.model_name
|
||||||
with open(args.img, 'rb') as image:
|
with open(args.img, 'rb') as image:
|
||||||
tmp_res = requests.post(url, image)
|
tmp_res = requests.post(url, image)
|
||||||
base64_str = tmp_res.content
|
content = tmp_res.content
|
||||||
buffer = base64.b64decode(base64_str)
|
|
||||||
if args.result_image:
|
if args.result_image:
|
||||||
with open(args.result_image, 'wb') as out_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.imshow(mmcv.imread(args.result_image, 'grayscale'))
|
||||||
plt.show()
|
plt.show()
|
||||||
else:
|
else:
|
||||||
plt.imshow(plt.imread(BytesIO(buffer)))
|
plt.imshow(plt.imread(BytesIO(content)))
|
||||||
plt.show()
|
plt.show()
|
||||||
model = init_segmentor(args.config, args.checkpoint, args.device)
|
model = init_segmentor(args.config, args.checkpoint, args.device)
|
||||||
image = mmcv.imread(args.img)
|
image = mmcv.imread(args.img)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user