diff --git a/python/examples/bert/bert_gpu_server.py b/python/examples/bert/bert_gpu_server.py index 7708a078636fd876c40e88d1441bc711d599f8a6..3fd64c345405e7ea031345f0694cce84029af385 100644 --- a/python/examples/bert/bert_gpu_server.py +++ b/python/examples/bert/bert_gpu_server.py @@ -14,9 +14,9 @@ import os import sys -from paddle_serving_server import OpMaker -from paddle_serving_server import OpSeqMaker -from paddle_serving_server import Server +from paddle_serving_server_gpu import OpMaker +from paddle_serving_server_gpu import OpSeqMaker +from paddle_serving_server_gpu import Server op_maker = OpMaker() read_op = op_maker.create('general_reader') diff --git a/python/examples/bert/bert_web_service_gpu.py b/python/examples/bert/bert_web_service_gpu.py index fb332bca3b16ee6a2c8c25dc7ab8f1b70998e874..cbdd321c0932bf68c1e37f02f0c08e08a6c0e43e 100644 --- a/python/examples/bert/bert_web_service_gpu.py +++ b/python/examples/bert/bert_web_service_gpu.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=doc-string-missing -from paddle_serving_server.web_service import WebService +from paddle_serving_server_gpu.web_service import WebService from paddle_serving_app.reader import ChineseBertReader import sys import os diff --git a/python/examples/fit_a_line/test_server.py b/python/examples/fit_a_line/test_server.py index d055b309d7530ccbe928d50e2bcaba23fb1ddaff..958fb2b6bf2732f66ba1e7e6194e9ebeebbaa223 100644 --- a/python/examples/fit_a_line/test_server.py +++ b/python/examples/fit_a_line/test_server.py @@ -13,7 +13,10 @@ # limitations under the License. # pylint: disable=doc-string-missing -from paddle_serving_server.web_service import WebService +try: + from paddle_serving_server_gpu.web_service import WebService +except ImportError: + from paddle_serving_server.web_service import WebService import numpy as np diff --git a/python/examples/grpc_impl_example/fit_a_line/test_server_gpu.py b/python/examples/grpc_impl_example/fit_a_line/test_server_gpu.py index 62361d9994ca1c532a2f07384c8b089d3b0fad65..1547ee445f4f8ceebe58e6f9e4f05b92520911eb 100644 --- a/python/examples/grpc_impl_example/fit_a_line/test_server_gpu.py +++ b/python/examples/grpc_impl_example/fit_a_line/test_server_gpu.py @@ -15,9 +15,9 @@ import os import sys -from paddle_serving_server import OpMaker -from paddle_serving_server import OpSeqMaker -from paddle_serving_server import MultiLangServer as Server +from paddle_serving_server_gpu import OpMaker +from paddle_serving_server_gpu import OpSeqMaker +from paddle_serving_server_gpu import MultiLangServer as Server op_maker = OpMaker() read_op = op_maker.create('general_reader') diff --git a/python/examples/imagenet/resnet50_web_service.py b/python/examples/imagenet/resnet50_web_service.py index ca111615deb9d240f9d8b042f1f7edb599a1b775..7033103717621807ecd74093bf5eba8d31a9b877 100644 --- a/python/examples/imagenet/resnet50_web_service.py +++ b/python/examples/imagenet/resnet50_web_service.py @@ -25,7 +25,7 @@ device = sys.argv[2] if device == "cpu": from paddle_serving_server.web_service import WebService else: - from paddle_serving_server.web_service import WebService + from paddle_serving_server_gpu.web_service import WebService class ImageService(WebService): diff --git a/python/examples/imdb/text_classify_service.py b/python/examples/imdb/text_classify_service.py index ca1e26002baf0284f282add235706080f7902c33..c973150eb3e3ac824825f81834c24f08c81973e6 100755 --- a/python/examples/imdb/text_classify_service.py +++ b/python/examples/imdb/text_classify_service.py @@ -13,7 +13,11 @@ # limitations under the License. # pylint: disable=doc-string-missing -from paddle_serving_server.web_service import WebService +try: + from paddle_serving_server.web_service import WebService +except ImportError: + from paddle_serving_server_gpu.web_service import WebService + from paddle_serving_app.reader.imdb_reader import IMDBDataset import sys import numpy as np diff --git a/python/examples/lac/lac_web_service.py b/python/examples/lac/lac_web_service.py index cf37f66294bd154324f2c7cacd1a35571b6c6350..3cbf441eb1298e9068e22229a09e9c3efee37695 100644 --- a/python/examples/lac/lac_web_service.py +++ b/python/examples/lac/lac_web_service.py @@ -12,7 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from paddle_serving_server.web_service import WebService +try: + from paddle_serving_server.web_service import WebService +except ImportError: + from paddle_serving_server_gpu.web_service import WebService import sys from paddle_serving_app.reader import LACReader import numpy as np diff --git a/python/examples/ocr/det_debugger_server.py b/python/examples/ocr/det_debugger_server.py index 8c8305012368d1307ce75983233f6d3af8e35a76..ebaf0a3066c7e948b4ca37dda06c60423ad28da9 100644 --- a/python/examples/ocr/det_debugger_server.py +++ b/python/examples/ocr/det_debugger_server.py @@ -22,7 +22,7 @@ from paddle_serving_app.reader import Sequential, ResizeByFactor from paddle_serving_app.reader import Div, Normalize, Transpose from paddle_serving_app.reader import DBPostProcess, FilterBoxes if sys.argv[1] == 'gpu': - from paddle_serving_server.web_service import WebService + from paddle_serving_server_gpu.web_service import WebService elif sys.argv[1] == 'cpu': from paddle_serving_server.web_service import WebService import time diff --git a/python/examples/ocr/det_web_server.py b/python/examples/ocr/det_web_server.py index c72dc6af964694ee2d364add100d52930576b798..e90efc7813e96e6b768a09b4ec9f5108c5878527 100644 --- a/python/examples/ocr/det_web_server.py +++ b/python/examples/ocr/det_web_server.py @@ -22,7 +22,7 @@ from paddle_serving_app.reader import Sequential, ResizeByFactor from paddle_serving_app.reader import Div, Normalize, Transpose from paddle_serving_app.reader import DBPostProcess, FilterBoxes if sys.argv[1] == 'gpu': - from paddle_serving_server.web_service import WebService + from paddle_serving_server_gpu.web_service import WebService elif sys.argv[1] == 'cpu': from paddle_serving_server.web_service import WebService import time diff --git a/python/examples/ocr/ocr_debugger_server.py b/python/examples/ocr/ocr_debugger_server.py index 1828b4fd78f2a6456653d2aef04d1b9bde6d2f42..e29f1b47980530cc8a278da0d14ba69a43f4f6a0 100644 --- a/python/examples/ocr/ocr_debugger_server.py +++ b/python/examples/ocr/ocr_debugger_server.py @@ -23,7 +23,7 @@ from paddle_serving_app.reader import Sequential, URL2Image, ResizeByFactor from paddle_serving_app.reader import Div, Normalize, Transpose from paddle_serving_app.reader import DBPostProcess, FilterBoxes, GetRotateCropImage, SortedBoxes if sys.argv[1] == 'gpu': - from paddle_serving_server.web_service import WebService + from paddle_serving_server_gpu.web_service import WebService elif sys.argv[1] == 'cpu': from paddle_serving_server.web_service import WebService from paddle_serving_app.local_predict import LocalPredictor @@ -107,7 +107,7 @@ ocr_service.prepare_server(workdir="workdir", port=9292) ocr_service.init_det_debugger(det_model_config="ocr_det_model") if sys.argv[1] == 'gpu': ocr_service.set_gpus("2") - ocr_service.run_debugger_service(gpu = True) + ocr_service.run_debugger_service(gpu=True) elif sys.argv[1] == 'cpu': ocr_service.run_debugger_service() ocr_service.run_web_service() diff --git a/python/examples/ocr/rec_debugger_server.py b/python/examples/ocr/rec_debugger_server.py index 5775feb71d2622c8cc2de4ae71b4cb55189cf446..29c0639776fa8c7338233ccf1ecf23fd263fb97f 100644 --- a/python/examples/ocr/rec_debugger_server.py +++ b/python/examples/ocr/rec_debugger_server.py @@ -23,7 +23,7 @@ from paddle_serving_app.reader import Sequential, URL2Image, ResizeByFactor from paddle_serving_app.reader import Div, Normalize, Transpose from paddle_serving_app.reader import DBPostProcess, FilterBoxes, GetRotateCropImage, SortedBoxes if sys.argv[1] == 'gpu': - from paddle_serving_server.web_service import WebService + from paddle_serving_server_gpu.web_service import WebService elif sys.argv[1] == 'cpu': from paddle_serving_server.web_service import WebService import time @@ -71,7 +71,8 @@ ocr_service.load_model_config("ocr_rec_model") if sys.argv[1] == 'gpu': ocr_service.set_gpus("0") ocr_service.init_rec() - ocr_service.prepare_server(workdir="workdir", port=9292, device="gpu", gpuid=0) + ocr_service.prepare_server( + workdir="workdir", port=9292, device="gpu", gpuid=0) elif sys.argv[1] == 'cpu': ocr_service.init_rec() ocr_service.prepare_server(workdir="workdir", port=9292, device="cpu") diff --git a/python/examples/ocr/rec_web_server.py b/python/examples/ocr/rec_web_server.py index 61669fddf34fe361460c6d18049905e7e3400db0..a3de120aff910f72a224a61cdc67d1ff50e65ab2 100644 --- a/python/examples/ocr/rec_web_server.py +++ b/python/examples/ocr/rec_web_server.py @@ -23,7 +23,7 @@ from paddle_serving_app.reader import Sequential, URL2Image, ResizeByFactor from paddle_serving_app.reader import Div, Normalize, Transpose from paddle_serving_app.reader import DBPostProcess, FilterBoxes, GetRotateCropImage, SortedBoxes if sys.argv[1] == 'gpu': - from paddle_serving_server.web_service import WebService + from paddle_serving_server_gpu.web_service import WebService elif sys.argv[1] == 'cpu': from paddle_serving_server.web_service import WebService import time diff --git a/python/examples/pipeline/bert/web_service.py b/python/examples/pipeline/bert/web_service.py index 7dca62a8fcfa9566b856fb3d025f045942499ed4..da4ec0e6043919052eb41857e98c10f3dfc5a1d1 100644 --- a/python/examples/pipeline/bert/web_service.py +++ b/python/examples/pipeline/bert/web_service.py @@ -37,7 +37,8 @@ class BertOp(Op): for i in range(batch_size): feed_dict = self.reader.process(input_dict[str(i)].encode("utf-8")) for key in feed_dict.keys(): - feed_dict[key] = np.array(feed_dict[key]).reshape((1, len(feed_dict[key]), 1)) + feed_dict[key] = np.array(feed_dict[key]).reshape( + (1, len(feed_dict[key]), 1)) feed_res.append(feed_dict) feed_dict = {} for key in feed_res[0].keys(): @@ -57,5 +58,5 @@ class BertService(WebService): bert_service = BertService(name="bert") -bert_service.prepare_pipeline_config("config2.yml") +bert_service.prepare_pipeline_config("config.yml") bert_service.run_service() diff --git a/python/examples/pipeline/imagenet/resnet50_web_service.py b/python/examples/pipeline/imagenet/resnet50_web_service.py index d6bb793a8c75a4bab63024d9fe25b94180f9ef2a..b0a62c5131dd0384d6cbb14708a15c969f081b63 100644 --- a/python/examples/pipeline/imagenet/resnet50_web_service.py +++ b/python/examples/pipeline/imagenet/resnet50_web_service.py @@ -16,7 +16,7 @@ from paddle_serving_app.reader import Sequential, URL2Image, Resize, CenterCrop, try: from paddle_serving_server.web_service import WebService, Op except ImportError: - from paddle_serving_server.web_service import WebService, Op + from paddle_serving_server_gpu.web_service import WebService, Op import logging import numpy as np import base64, cv2 diff --git a/python/examples/pipeline/imdb_model_ensemble/test_pipeline_server.py b/python/examples/pipeline/imdb_model_ensemble/test_pipeline_server.py index 8ff408550fab40ac359575c1414f41a1780b12a8..69a3e3460a7df18e580962284d7ca077f1f96de4 100644 --- a/python/examples/pipeline/imdb_model_ensemble/test_pipeline_server.py +++ b/python/examples/pipeline/imdb_model_ensemble/test_pipeline_server.py @@ -12,17 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=doc-string-missing -from paddle_serving_server.pipeline import Op, RequestOp, ResponseOp -from paddle_serving_server.pipeline import PipelineServer -from paddle_serving_server.pipeline.proto import pipeline_service_pb2 -from paddle_serving_server.pipeline.channel import ChannelDataErrcode import numpy as np from paddle_serving_app.reader.imdb_reader import IMDBDataset import logging try: from paddle_serving_server.web_service import WebService + from paddle_serving_server.pipeline import Op, RequestOp, ResponseOp + from paddle_serving_server.pipeline import PipelineServer + from paddle_serving_server.pipeline.proto import pipeline_service_pb2 + from paddle_serving_server.pipeline.channel import ChannelDataErrcode except ImportError: - from paddle_serving_server.web_service import WebService + from paddle_serving_server_gpu.web_service import WebService + from paddle_serving_server_gpu.pipeline import Op, RequestOp, ResponseOp + from paddle_serving_server_gpu.pipeline import PipelineServer + from paddle_serving_server_gpu.pipeline.proto import pipeline_service_pb2 + from paddle_serving_server_gpu.pipeline.channel import ChannelDataErrcode _LOGGER = logging.getLogger() user_handler = logging.StreamHandler() diff --git a/python/examples/pipeline/simple_web_service/web_service_java.py b/python/examples/pipeline/simple_web_service/web_service_java.py index d06bc58492c812f36a5bb9446f0078dec3d30210..7c573c6be7e7846431f15160ed4f7d7b570f904c 100644 --- a/python/examples/pipeline/simple_web_service/web_service_java.py +++ b/python/examples/pipeline/simple_web_service/web_service_java.py @@ -14,7 +14,7 @@ try: from paddle_serving_server.web_service import WebService, Op except ImportError: - from paddle_serving_server.web_service import WebService, Op + from paddle_serving_server_gpu.web_service import WebService, Op import logging import numpy as np from numpy import array diff --git a/python/examples/senta/senta_web_service.py b/python/examples/senta/senta_web_service.py index 6a1009412d6a4192bacce0ef7bce0685119713b1..51e530695c8b41da4d6ca0f8128244197ff8a8ad 100644 --- a/python/examples/senta/senta_web_service.py +++ b/python/examples/senta/senta_web_service.py @@ -13,14 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -from paddle_serving_server.web_service import WebService -from paddle_serving_client import Client -from paddle_serving_app.reader import LACReader, SentaReader import os import sys import numpy as np -#senta_web_service.py -from paddle_serving_server.web_service import WebService +try: + from paddle_serving_server.web_service import WebService +except ImportError: + from paddle_serving_server_gpu.web_service import WebService + from paddle_serving_client import Client from paddle_serving_app.reader import LACReader, SentaReader diff --git a/python/examples/xpu/fit_a_line_xpu/test_server.py b/python/examples/xpu/fit_a_line_xpu/test_server.py index a53e89f7e7b299260337c43e2b0db914049adf45..27499f45ffa442fb3b26cc692695028619aa62b7 100644 --- a/python/examples/xpu/fit_a_line_xpu/test_server.py +++ b/python/examples/xpu/fit_a_line_xpu/test_server.py @@ -13,7 +13,11 @@ # limitations under the License. # pylint: disable=doc-string-missing -from paddle_serving_server.web_service import WebService +try: + from paddle_serving_server.web_service import WebService +except ImportError: + from paddle_serving_server_gpu.web_service import WebService + import numpy as np @@ -31,6 +35,7 @@ class UciService(WebService): uci_service = UciService(name="uci") uci_service.load_model_config("uci_housing_model") -uci_service.prepare_server(workdir="workdir", port=9393, use_lite=True, use_xpu=True, ir_optim=True) +uci_service.prepare_server( + workdir="workdir", port=9393, use_lite=True, use_xpu=True, ir_optim=True) uci_service.run_rpc_service() uci_service.run_web_service()