diff --git a/README.md b/README.md
index 297a6cf7901d0f18418b573a622a55f33bbed2cc..8aa899a3d1db797ea1a38476e5d56c425501f23e 100644
--- a/README.md
+++ b/README.md
@@ -154,10 +154,87 @@ curl -H "Content-Type:application/json" -X POST -d '{"url": "https://paddle-serv
{"label":"daisy","prob":0.9341403245925903}
```
+
More Demos
+| Key | Value |
+| :----------------- | :----------------------------------------------------------- |
+| Model Name | Bert-Base-Baike |
+| URL | [https://paddle-serving.bj.bcebos.com/bert_example/bert_seq128.tar.gz](https://paddle-serving.bj.bcebos.com/bert_example%2Fbert_seq128.tar.gz) |
+| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/bert |
+| Description | Get semantic representation from a Chinese Sentence |
+| Key | Value |
+| :----------------- | :----------------------------------------------------------- |
+| Model Name | Resnet50-Imagenet |
+| URL | [https://paddle-serving.bj.bcebos.com/imagenet-example/ResNet50_vd.tar.gz](https://paddle-serving.bj.bcebos.com/imagenet-example%2FResNet50_vd.tar.gz) |
+| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/imagenet |
+| Description | Get image semantic representation from an image |
+
+
+
+| Key | Value |
+| :----------------- | :----------------------------------------------------------- |
+| Model Name | Resnet101-Imagenet |
+| URL | https://paddle-serving.bj.bcebos.com/imagenet-example/ResNet101_vd.tar.gz |
+| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/imagenet |
+| Description | Get image semantic representation from an image |
+
+
+
+| Key | Value |
+| :----------------- | :----------------------------------------------------------- |
+| Model Name | CNN-IMDB |
+| URL | https://paddle-serving.bj.bcebos.com/imdb-demo/imdb_model.tar.gz |
+| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/imdb |
+| Description | Get category probability from an English Sentence |
+
+
+
+| Key | Value |
+| :----------------- | :----------------------------------------------------------- |
+| Model Name | LSTM-IMDB |
+| URL | https://paddle-serving.bj.bcebos.com/imdb-demo/imdb_model.tar.gz |
+| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/imdb |
+| Description | Get category probability from an English Sentence |
+
+
+
+| Key | Value |
+| :----------------- | :----------------------------------------------------------- |
+| Model Name | BOW-IMDB |
+| URL | https://paddle-serving.bj.bcebos.com/imdb-demo/imdb_model.tar.gz |
+| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/imdb |
+| Description | Get category probability from an English Sentence |
+
+
+
+| Key | Value |
+| :----------------- | :----------------------------------------------------------- |
+| Model Name | Jieba-LAC |
+| URL | https://paddle-serving.bj.bcebos.com/lac/lac_model.tar.gz |
+| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/lac |
+| Description | Get word segmentation from a Chinese Sentence |
+
+
+
+| Key | Value |
+| :----------------- | :----------------------------------------------------------- |
+| Model Name | DNN-CTR |
+| URL | None(Get model by [local_train.py](./python/examples/criteo_ctr/local_train.py)) |
+| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/criteo_ctr |
+| Description | Get click probability from a feature vector of item |
+
+
+
+| Key | Value |
+| :----------------- | :----------------------------------------------------------- |
+| Model Name | DNN-CTR(with cube) |
+| URL | None(Get model by [local_train.py](python/examples/criteo_ctr_with_cube/local_train.py)) |
+| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/criteo_ctr_with_cube |
+| Description | Get click probability from a feature vector of item |
+
Document
### New to Paddle Serving
diff --git a/doc/RUN_IN_DOCKER.md b/doc/RUN_IN_DOCKER.md
index edfd914123b2262b36e85552b179a0e412b68413..972de2d951e602d025fb5fcb8b3229dcc300f696 100644
--- a/doc/RUN_IN_DOCKER.md
+++ b/doc/RUN_IN_DOCKER.md
@@ -147,7 +147,7 @@ tar -xzf uci_housing.tar.gz
Running on the Server side (inside the container):
```bash
- python -m paddle_serving_server_gpu.serve --model uci_housing_model --thread 10 --port 9292 --name uci
+ python -m paddle_serving_server_gpu.serve --model uci_housing_model --thread 10 --port 9292 --name uci --gpu_ids 0
```
Running on the Client side (inside or outside the container):
@@ -161,7 +161,7 @@ tar -xzf uci_housing.tar.gz
Running on the Server side (inside the container):
```bash
- python -m paddle_serving_server_gpu.serve --model uci_housing_model --thread 10 --port 9292
+ python -m paddle_serving_server_gpu.serve --model uci_housing_model --thread 10 --port 9292 --gpu_ids 0
```
Running following Python code on the Client side (inside or outside the container, The `paddle-serving-client` package needs to be installed):
diff --git a/doc/RUN_IN_DOCKER_CN.md b/doc/RUN_IN_DOCKER_CN.md
index 47914a2fdd6aa78956b783ab813edb5d3a587b7d..17bdd30adbcbecd971904011208fe01d1d08f5ba 100644
--- a/doc/RUN_IN_DOCKER_CN.md
+++ b/doc/RUN_IN_DOCKER_CN.md
@@ -145,7 +145,7 @@ tar -xzf uci_housing.tar.gz
在Server端(容器内)运行:
```bash
- python -m paddle_serving_server_gpu.serve --model uci_housing_model --thread 10 --port 9292 --name uci
+ python -m paddle_serving_server_gpu.serve --model uci_housing_model --thread 10 --port 9292 --name uci --gpu_ids 0
```
在Client端(容器内或容器外)运行:
@@ -159,7 +159,7 @@ tar -xzf uci_housing.tar.gz
在Server端(容器内)运行:
```bash
- python -m paddle_serving_server_gpu.serve --model uci_housing_model --thread 10 --port 9292
+ python -m paddle_serving_server_gpu.serve --model uci_housing_model --thread 10 --port 9292 --gpu_ids 0
```
在Client端(容器内或容器外,需要安装`paddle-serving-client`包)运行下面Python代码:
diff --git a/python/examples/bert/benchmark_batch.py b/python/examples/bert/benchmark_batch.py
index 265521d484259b0e6ea2b182dbf61e2a5cf43b8d..872799e64ea599554e42264c37ab5f574c0acb13 100644
--- a/python/examples/bert/benchmark_batch.py
+++ b/python/examples/bert/benchmark_batch.py
@@ -57,7 +57,8 @@ def single_func(idx, resource):
os.getpid(),
int(round(b_start * 1000000)),
int(round(b_end * 1000000))))
- result = client.predict(feed_batch=feed_batch, fetch=fetch)
+ result = client.batch_predict(
+ feed_batch=feed_batch, fetch=fetch)
else:
print("unsupport batch size {}".format(args.batch_size))
diff --git a/python/examples/criteo_ctr/test_client.py b/python/examples/criteo_ctr/test_client.py
index 9b3681c4117d123abd490668f44e43ab9f1e855f..d53c5541c36f4eb52618e3498eda571dd2bcab53 100644
--- a/python/examples/criteo_ctr/test_client.py
+++ b/python/examples/criteo_ctr/test_client.py
@@ -21,6 +21,10 @@ import time
import criteo_reader as criteo
from paddle_serving_client.metric import auc
+import sys
+
+py_version = sys.version_info[0]
+
client = Client()
client.load_client_config(sys.argv[1])
client.connect(["127.0.0.1:9292"])
@@ -39,7 +43,10 @@ label_list = []
prob_list = []
start = time.time()
for ei in range(1000):
- data = reader().next()
+ if py_version == 2:
+ data = reader().next()
+ else:
+ data = reader().__next__()
feed_dict = {}
for i in range(1, 27):
feed_dict["sparse_{}".format(i - 1)] = data[0][i]
diff --git a/python/examples/imagenet/image_http_client.py b/python/examples/imagenet/image_http_client.py
index c567b9003bfe87f9ddd20c3553b9e2d400bce4b9..2a2e9ea20d7e428cfe42393e2fee60035c33283d 100644
--- a/python/examples/imagenet/image_http_client.py
+++ b/python/examples/imagenet/image_http_client.py
@@ -17,10 +17,16 @@ import base64
import json
import time
import os
+import sys
+
+py_version = sys.version_info[0]
def predict(image_path, server):
- image = base64.b64encode(open(image_path).read())
+ if py_version == 2:
+ image = base64.b64encode(open(image_path).read())
+ else:
+ image = base64.b64encode(open(image_path, "rb").read()).decode("utf-8")
req = json.dumps({"image": image, "fetch": ["score"]})
r = requests.post(
server, data=req, headers={"Content-Type": "application/json"})
@@ -28,18 +34,8 @@ def predict(image_path, server):
return r
-def batch_predict(image_path, server):
- image = base64.b64encode(open(image_path).read())
- req = json.dumps({"image": [image, image], "fetch": ["score"]})
- r = requests.post(
- server, data=req, headers={"Content-Type": "application/json"})
- print(r.json()["result"][1]["score"][0])
- return r
-
-
if __name__ == "__main__":
server = "http://127.0.0.1:9393/image/prediction"
- #image_path = "./data/n01440764_10026.JPEG"
image_list = os.listdir("./image_data/n01440764/")
start = time.time()
for img in image_list:
diff --git a/python/examples/imagenet/image_rpc_client.py b/python/examples/imagenet/image_rpc_client.py
index 2367f509cece4d37d61d4a2ff2c2bfb831112e5a..76f3a043474bf75e1e96a44f18ac7dfe3da11f78 100644
--- a/python/examples/imagenet/image_rpc_client.py
+++ b/python/examples/imagenet/image_rpc_client.py
@@ -19,16 +19,15 @@ import time
client = Client()
client.load_client_config(sys.argv[1])
-client.connect(["127.0.0.1:9295"])
+client.connect(["127.0.0.1:9393"])
reader = ImageReader()
start = time.time()
for i in range(1000):
- with open("./data/n01440764_10026.JPEG") as f:
+ with open("./data/n01440764_10026.JPEG", "rb") as f:
img = f.read()
img = reader.process_image(img).reshape(-1)
fetch_map = client.predict(feed={"image": img}, fetch=["score"])
- print(i)
end = time.time()
print(end - start)
diff --git a/python/examples/imdb/imdb_reader.py b/python/examples/imdb/imdb_reader.py
index 38a46c5cf3cc3d7216c47c290876951e99253115..a4ef3e163a50b0dc244ac2653df1e38d7f91699b 100644
--- a/python/examples/imdb/imdb_reader.py
+++ b/python/examples/imdb/imdb_reader.py
@@ -19,15 +19,23 @@ import paddle
import re
import paddle.fluid.incubate.data_generator as dg
+py_version = sys.version_info[0]
+
class IMDBDataset(dg.MultiSlotDataGenerator):
def load_resource(self, dictfile):
self._vocab = {}
wid = 0
- with open(dictfile) as f:
- for line in f:
- self._vocab[line.strip()] = wid
- wid += 1
+ if py_version == 2:
+ with open(dictfile) as f:
+ for line in f:
+ self._vocab[line.strip()] = wid
+ wid += 1
+ else:
+ with open(dictfile, encoding="utf-8") as f:
+ for line in f:
+ self._vocab[line.strip()] = wid
+ wid += 1
self._unk_id = len(self._vocab)
self._pattern = re.compile(r'(;|,|\.|\?|!|\s|\(|\))')
self.return_value = ("words", [1, 2, 3, 4, 5, 6]), ("label", [0])
diff --git a/python/paddle_serving_client/metric/__init__.py b/python/paddle_serving_client/metric/__init__.py
index 4f173887755e5aef5c6917fa604012cf0c1d86f0..245e740dae2e713fde3237c26d6815b4528f90d7 100644
--- a/python/paddle_serving_client/metric/__init__.py
+++ b/python/paddle_serving_client/metric/__init__.py
@@ -11,5 +11,5 @@
# 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 auc import auc
-from acc import acc
+from .auc import auc
+from .acc import acc
diff --git a/python/paddle_serving_server_gpu/serve.py b/python/paddle_serving_server_gpu/serve.py
index 9c8d10e4b36a7830aed25996a309cb4163ca126c..2cce4d4b1615584fc02aba4d70e1928083ddde62 100644
--- a/python/paddle_serving_server_gpu/serve.py
+++ b/python/paddle_serving_server_gpu/serve.py
@@ -71,7 +71,7 @@ def start_multi_card(args): # pylint: disable=doc-string-missing
else:
gpus = args.gpu_ids.split(",")
if len(gpus) <= 0:
- start_gpu_card_model(-1, args)
+ start_gpu_card_model(-1, 0, args)
else:
gpu_processes = []
for i, gpu_id in enumerate(gpus):
diff --git a/python/setup.py.client.in b/python/setup.py.client.in
index 86b3c331babccd06bdc6e206866a1c43da7b27d7..381fb2a8853cc4d5494e3eac520ab183db6eab09 100644
--- a/python/setup.py.client.in
+++ b/python/setup.py.client.in
@@ -18,6 +18,7 @@ from __future__ import print_function
import platform
import os
+import sys
from setuptools import setup, Distribution, Extension
from setuptools import find_packages
@@ -25,6 +26,7 @@ from setuptools import setup
from paddle_serving_client.version import serving_client_version
from pkg_resources import DistributionNotFound, get_distribution
+py_version = sys.version_info[0]
def python_version():
return [int(v) for v in platform.python_version().split(".")]
@@ -37,8 +39,9 @@ def find_package(pkgname):
return False
def copy_lib():
+ lib_list = ['libpython2.7.so.1.0', 'libssl.so.10', 'libcrypto.so.10'] if py_version == 2 else ['libpython3.6m.so.1.0', 'libssl.so.10', 'libcrypto.so.10']
os.popen('mkdir -p paddle_serving_client/lib')
- for lib in ['libpython2.7.so.1.0', 'libssl.so.10', 'libcrypto.so.10']:
+ for lib in lib_list:
r = os.popen('whereis {}'.format(lib))
text = r.read()
os.popen('cp {} ./paddle_serving_client/lib'.format(text.strip().split(' ')[1]))