diff --git a/deploy/paddle-serving/README.md b/deploy/paddle-serving/README.md index 5faea824f16e741b8c2fc3767f055e3fcfcae0f3..6e646e3d60d830a0e9bedcbc4cbfa639bf89ac67 100644 --- a/deploy/paddle-serving/README.md +++ b/deploy/paddle-serving/README.md @@ -13,7 +13,7 @@ PaddleServing是Paddle的在线预测服务框架,可以快速部署训练好 ```shell pip install paddle_serving_server==0.3.2 #CPU pip install paddle_serving_server_gpu==0.3.2.post9 #GPU with CUDA9.0 -pip install paddle_serving_server_gpu==0.3.2.post9 #GPU with CUDA10.0 +pip install paddle_serving_server_gpu==0.3.2.post10 #GPU with CUDA10.0 ``` 客户端安装: @@ -49,6 +49,10 @@ python pdseg/export_serving_model.py --cfg configs/unet_optic.yaml TEST.TEST_MOD 分别将serving_server和serving_client复制到server和client启动的路径下。 +本文中导出的unet模型示例[下载](https://paddle-serving.bj.bcebos.com/paddle_seg_demo/seg_unet_demo.tar.gz)。 + +解压下载后的压缩包,可以得到seving_server和serving_client两个文件夹,用于以下步骤的测试。 + ## 4.部署预测服务 ```shell @@ -62,3 +66,9 @@ python seg_client.py ../../dataset/optic_disc_seg/JPEGImages/N0060.jpg ``` 脚本执行之后,会在输入图片所在的目录下生成处理后的图片 示例中为`../../dataset/optic_disc_seg/JPEGImages/N0060_jpg_mask.png`和`../../dataset/optic_disc_seg/JPEGImages/N0060_jpg_result.png` + +如果需要使用其他模型进行预测,需要修改预处理部分和后处理部分。 + +本文中使用的是paddle_serving_app中内置的处理方法,用户可以参考导出模型时生成的deploy.yaml修改预处理部分。 + +后处理部分SegPostprocess初始化时接收的参数为分割的类别数。 diff --git a/deploy/paddle-serving/postprocess.py b/deploy/paddle-serving/postprocess.py index 6e77879d4d1a4a756210facb9e9e8d7a2dba6c7b..d4d7fb1cb5a0075a40df05483e1978a51b974d19 100644 --- a/deploy/paddle-serving/postprocess.py +++ b/deploy/paddle-serving/postprocess.py @@ -56,3 +56,4 @@ class SegPostprocess(object): fy=0, interpolation=cv2.INTER_CUBIC) cv2.imwrite(vis_result_name, result_png, [cv2.CV_8UC1]) + return result_png diff --git a/deploy/paddle-serving/seg_client.py b/deploy/paddle-serving/seg_client.py index cf90a8ab56fcf4c75ef09fd84958545598785d68..c5c6161b08d0704d853b8344ab3592d021350bcc 100644 --- a/deploy/paddle-serving/seg_client.py +++ b/deploy/paddle-serving/seg_client.py @@ -22,4 +22,4 @@ filename = sys.argv[1] im = preprocess(filename) fetch_map = client.predict(feed={"image": im}, fetch=["transpose_1.tmp_0"]) fetch_map["filename"] = filename -postprocess(fetch_map) +result_png = postprocess(fetch_map) diff --git a/pdseg/export_serving_model.py b/pdseg/export_serving_model.py index 7e9ca73bc431cdea8c60362be420c0456c8f24e2..58793b231d26c33ba258aef31c6a91bc61cd82f6 100644 --- a/pdseg/export_serving_model.py +++ b/pdseg/export_serving_model.py @@ -1,5 +1,5 @@ # coding: utf8 -# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.