diff --git a/python/paddle_serving_app/__init__.py b/python/paddle_serving_app/__init__.py index 0b3f60e28d3094ebb695c2caa0cc9f333030cf3f..3db901249df41f5d9cd5846d131ec6cfed376a18 100644 --- a/python/paddle_serving_app/__init__.py +++ b/python/paddle_serving_app/__init__.py @@ -15,3 +15,4 @@ from .reader.chinese_bert_reader import ChineseBertReader from .reader.image_reader import ImageReader from .reader.lac_reader import LACReader from .reader.senta_reader import SentaReader +from .models import ServingModels diff --git a/python/paddle_serving_app/models/__init__.py b/python/paddle_serving_app/models/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..900030e23baa6649ce372a2ac0ad3d78f1b45ff5 --- /dev/null +++ b/python/paddle_serving_app/models/__init__.py @@ -0,0 +1,15 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .model_list import ServingModels diff --git a/python/paddle_serving_app/models/model_list.py b/python/paddle_serving_app/models/model_list.py index 4eb109c1fc5f36a5d39b31233dff648ea0f29c44..6709c8aea06c3fa0cce2acdc0cbaf7d4a9c9c64e 100644 --- a/python/paddle_serving_app/models/model_list.py +++ b/python/paddle_serving_app/models/model_list.py @@ -57,7 +57,7 @@ class ServingModels(object): "resnet_v2_151_imagenet", "resnet_v2_18_imagenet", "resnet_v2_34_imagenet", - " resnet_v2_50_imagenet", + "resnet_v2_50_imagenet", "resnext101_32x16d_wsl", "resnext101_32x32d_wsl", "resnext101_32x48d_wsl", diff --git a/python/paddle_serving_app/package.py b/python/paddle_serving_app/package.py new file mode 100644 index 0000000000000000000000000000000000000000..98e42f365397e6ecae5171c47eb1cfabee182a7d --- /dev/null +++ b/python/paddle_serving_app/package.py @@ -0,0 +1,60 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Usage: + Download a package for serving directly + Example: + python -m paddle_serving_app.models --get_model senta_bilstm + python -m paddle_serving_app.models --list_model +""" + +import argparse +from .models import ServingModels + + +def parse_args(): # pylint: disable=doc-string-missing + parser = argparse.ArgumentParser("serve") + parser.add_argument( + "--get_model", type=str, default="", help="Download a specific model") + parser.add_argument( + '--list_model', nargs='*', default=None, help="List Models") + return parser.parse_args() + + +if __name__ == "__main__": + args = parse_args() + if args.list_model != None: + model_handle = ServingModels() + model_names = model_handle.get_model_list() + for key in model_names: + print(key) + elif args.get_model != "": + model_handle = ServingModels() + model_names = model_handle.get_model_list() + if args.get_model not in model_names: + print( + "Your model name does not exist in current model list, stay tuned" + ) + sys.exit(0) + model_handle.download(args.get_model) + else: + print("Wrong argument") + print(""" + Usage: + Download a package for serving directly + Example: + python -m paddle_serving_app.models --get senta_bilstm + python -m paddle_serving_app.models --list_model + """) + pass diff --git a/python/setup.py.app.in b/python/setup.py.app.in index 3c0f8e065a5072919d808ba1da67f5c37eee0594..d981caa7c34ff1f84d4cdee0e64a2b03e47b7b66 100644 --- a/python/setup.py.app.in +++ b/python/setup.py.app.in @@ -48,7 +48,8 @@ REQUIRED_PACKAGES = [ packages=['paddle_serving_app', 'paddle_serving_app.reader', 'paddle_serving_app.utils', - 'paddle_serving_app.reader.pddet'] + 'paddle_serving_app.models', + 'paddle_serving_app.reader.pddet'] package_data={} package_dir={'paddle_serving_app': @@ -57,8 +58,10 @@ package_dir={'paddle_serving_app': '${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_app/reader', 'paddle_serving_app.utils': '${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_app/utils', - 'paddle_serving_app.reader.pddet': - '${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_app/reader/pddet',} + 'paddle_serving_app.models': + '${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_app/models', + 'paddle_serving_app.reader.pddet': + '${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_app/reader/pddet',} setup( name='paddle-serving-app',