diff --git a/python/examples/encryption/README.md b/python/examples/encryption/README.md index 87664e4ca84cb51051a0f8abcb76d980e6260761..d8a04e29bf56439a24db7dadfdfe3ab5d9626e14 100644 --- a/python/examples/encryption/README.md +++ b/python/examples/encryption/README.md @@ -13,9 +13,21 @@ sh get_data.sh ## Encrypt Model The `paddlepaddle` package is used in this example, you may need to download the corresponding package(`pip install paddlepaddle`). + +[python encrypt.py](./encrypt.py) + +[//file]:#encrypt.py +``` python +def serving_encryption(): + inference_model_to_serving( + dirname="./uci_housing_model", + params_filename=None, + serving_server="encrypt_server", + serving_client="encrypt_client", + encryption=True) ``` -python encrypt.py -``` +dirname is the folder path where the model is located. If the parameter is discrete, it is unnecessary to specify params_filename, else you need to set `params_filename="__params__"`. + The key is stored in the `key` file, and the encrypted model file and server-side configuration file are stored in the `encrypt_server` directory. client-side configuration file are stored in the `encrypt_client` directory. diff --git a/python/examples/encryption/README_CN.md b/python/examples/encryption/README_CN.md index ed8fec338f9680cf42cebeff6745b3bb63f07607..bb853ff37f914a5e2cfe1c6bbb097d17eb99a29a 100644 --- a/python/examples/encryption/README_CN.md +++ b/python/examples/encryption/README_CN.md @@ -12,9 +12,23 @@ sh get_data.sh ## 模型加密 本示例中使用了`paddlepaddle`包中的模块,需要进行下载(`pip install paddlepaddle`)。 -``` -python encrypt.py -``` + +运行[python encrypt.py](./encrypt.py)进行模型加密 + +[//file]:#encrypt.py +``` python +def serving_encryption(): + inference_model_to_serving( + dirname="./uci_housing_model", + params_filename=None, + serving_server="encrypt_server", + serving_client="encrypt_client", + encryption=True) +``` +其中dirname为模型所在的文件夹路径 + +当参数为离散参数时,无须指定params_filename,当参数为__params__时,需指定`params_filename="__params__"` + 密钥保存在`key`文件中,加密模型文件以及server端配置文件保存在`encrypt_server`目录下,client端配置文件保存在`encrypt_client`目录下。 ## 启动加密预测服务 diff --git a/python/examples/encryption/encrypt.py b/python/examples/encryption/encrypt.py index 9e01b5c63c95100c46b91c7f0c9c59191e66ae26..e233784390f0899cd81ec7862ceef0d506bbcd1f 100644 --- a/python/examples/encryption/encrypt.py +++ b/python/examples/encryption/encrypt.py @@ -18,6 +18,7 @@ from paddle_serving_client.io import inference_model_to_serving def serving_encryption(): inference_model_to_serving( dirname="./uci_housing_model", + params_filename=None, serving_server="encrypt_server", serving_client="encrypt_client", encryption=True)