提交 12ab1380 编写于 作者: T TeslaZhao

House cleaning

上级 d2d95908
......@@ -45,22 +45,22 @@ this script will download Chinese Dictionary File vocab.txt and Chinese Sample D
### Inference Service(Support BRPC-Client、GRPC-Client、Http-Client)
start cpu inference service,Run
```
python -m paddle_serving_server.serve --model bert_seq128_model/ --port 9292 #cpu inference service
python3 -m paddle_serving_server.serve --model bert_seq128_model/ --port 9292 #cpu inference service
```
Or,start gpu inference service,Run
```
python -m paddle_serving_server.serve --model bert_seq128_model/ --port 9292 --gpu_ids 0 #launch gpu inference service at GPU 0
python3 -m paddle_serving_server.serve --model bert_seq128_model/ --port 9292 --gpu_ids 0 #launch gpu inference service at GPU 0
```
### BRPC-Client Inference
before prediction we should install paddle_serving_app. This module provides data preprocessing for BERT model.
```
pip install paddle_serving_app
pip3 install paddle_serving_app
```
Run
```
head data-c.txt | python bert_client.py --model bert_seq128_client/serving_client_conf.prototxt
head data-c.txt | python3 bert_client.py --model bert_seq128_client/serving_client_conf.prototxt
```
the client reads data from data-c.txt and send prediction request, the prediction is given by word vector. (Due to massive data in the word vector, we do not print it).
......@@ -68,7 +68,7 @@ the client reads data from data-c.txt and send prediction request, the predictio
#### GRPC-Client/HTTP-Client
Run
```
head data-c.txt | python bert_httpclient.py --model bert_seq128_client/serving_client_conf.prototxt
head data-c.txt | python3 bert_httpclient.py --model bert_seq128_client/serving_client_conf.prototxt
```
......
......@@ -43,12 +43,12 @@ sh get_data.sh
### 启动预测服务(支持BRPC-Client、GRPC-Client、HTTP-Client三种方式访问)
启动cpu预测服务,执行
```
python -m paddle_serving_server.serve --model bert_seq128_model/ --port 9292 #启动cpu预测服务
python3 -m paddle_serving_server.serve --model bert_seq128_model/ --port 9292 #启动cpu预测服务
```
或者,启动gpu预测服务,执行
```
python -m paddle_serving_server.serve --model bert_seq128_model/ --port 9292 --gpu_ids 0 #在gpu 0上启动gpu预测服务
python3 -m paddle_serving_server.serve --model bert_seq128_model/ --port 9292 --gpu_ids 0 #在gpu 0上启动gpu预测服务
```
......@@ -56,13 +56,13 @@ python -m paddle_serving_server.serve --model bert_seq128_model/ --port 9292 --g
执行预测前需要安装paddle_serving_app,模块中提供了BERT模型的数据预处理方法。
```
pip install paddle_serving_app
pip3 install paddle_serving_app
```
#### BRPC-Client
执行
```
head data-c.txt | python bert_client.py --model bert_seq128_client/serving_client_conf.prototxt
head data-c.txt | python3 bert_client.py --model bert_seq128_client/serving_client_conf.prototxt
```
启动client读取data-c.txt中的数据进行预测,预测结果为文本的向量表示(由于数据较多,脚本中没有将输出进行打印),server端的地址在脚本中修改。
......@@ -70,7 +70,7 @@ head data-c.txt | python bert_client.py --model bert_seq128_client/serving_clien
#### GRPC-Client/HTTP-Client
执行
```
head data-c.txt | python bert_httpclient.py --model bert_seq128_client/serving_client_conf.prototxt
head data-c.txt | python3 bert_httpclient.py --model bert_seq128_client/serving_client_conf.prototxt
```
......
......@@ -2,7 +2,7 @@
## Get Model
```
python -m paddle_serving_app.package --get_model blazeface
python3 -m paddle_serving_app.package --get_model blazeface
tar -xf blazeface.tar.gz
```
......@@ -11,13 +11,13 @@ tar -xf blazeface.tar.gz
### Start Service
```
python -m paddle_serving_server.serve --model serving_server --port 9494
python3 -m paddle_serving_server.serve --model serving_server --port 9494
```
### Client Prediction
```
python test_client.py serving_client/serving_client_conf.prototxt test.jpg
python3 test_client.py serving_client/serving_client_conf.prototxt test.jpg
```
the result is in `output` folder, including a json file and image file with bounding boxes.
......@@ -10,12 +10,12 @@ If you want to have more detection models, please refer to [Paddle Detection Mod
### Start the service
```
python -m paddle_serving_server.serve --model serving_server --port 9292 --gpu_id 0
python3 -m paddle_serving_server.serve --model serving_server --port 9292 --gpu_id 0
```
### Perform prediction
```
python test_client.py
python3 test_client.py
```
Image with bounding boxes and json result would be saved in `output` folder.
......@@ -10,12 +10,12 @@ sh get_data.sh
### 启动服务
```
python -m paddle_serving_server.serve --model serving_server --port 9292 --gpu_id 0
python3 -m paddle_serving_server.serve --model serving_server --port 9292 --gpu_id 0
```
### 执行预测
```
python test_client.py
python3 test_client.py
```
客户端已经为图片做好了后处理,在`output`文件夹下存放各个框的json格式信息还有后处理结果图片。
......@@ -19,13 +19,13 @@ the directories like `ctr_serving_model` and `ctr_client_conf` will appear.
### Start RPC Inference Service
```
python -m paddle_serving_server.serve --model ctr_serving_model/ --port 9292 #CPU RPC Service
python -m paddle_serving_server.serve --model ctr_serving_model/ --port 9292 --gpu_ids 0 #RPC Service on GPU 0
python3 -m paddle_serving_server.serve --model ctr_serving_model/ --port 9292 #CPU RPC Service
python3 -m paddle_serving_server.serve --model ctr_serving_model/ --port 9292 --gpu_ids 0 #RPC Service on GPU 0
```
### RPC Infer
```
python test_client.py ctr_client_conf/serving_client_conf.prototxt raw_data/part-0
python3 test_client.py ctr_client_conf/serving_client_conf.prototxt raw_data/part-0
```
the latency will display in the end.
......@@ -19,13 +19,13 @@ mv models/ctr_serving_model .
### 启动RPC预测服务
```
python -m paddle_serving_server.serve --model ctr_serving_model/ --port 9292 #启动CPU预测服务
python -m paddle_serving_server.serve --model ctr_serving_model/ --port 9292 --gpu_ids 0 #在GPU 0上启动预测服务
python3 -m paddle_serving_server.serve --model ctr_serving_model/ --port 9292 #启动CPU预测服务
python3 -m paddle_serving_server.serve --model ctr_serving_model/ --port 9292 --gpu_ids 0 #在GPU 0上启动预测服务
```
### 执行预测
```
python test_client.py ctr_client_conf/serving_client_conf.prototxt raw_data/part-0
python3 test_client.py ctr_client_conf/serving_client_conf.prototxt raw_data/part-0
```
预测完毕会输出预测过程的耗时。
......@@ -32,13 +32,13 @@ Here, the sparse parameter is loaded by cube sparse parameter indexing service C
### Start RPC Predictor, the number of serving thread is 4(configurable in test_server.py)
```
python test_server.py ctr_serving_model_kv
python3 test_server.py ctr_serving_model_kv
```
### Run Prediction
```
python test_client.py ctr_client_conf/serving_client_conf.prototxt ./raw_data
python3 test_client.py ctr_client_conf/serving_client_conf.prototxt ./raw_data
```
### Benchmark
......
......@@ -30,13 +30,13 @@ sh cube_prepare.sh &
### 启动RPC预测服务,服务端线程数为4(可在test_server.py配置)
```
python test_server.py ctr_serving_model_kv
python3 test_server.py ctr_serving_model_kv
```
### 执行预测
```
python test_client.py ctr_client_conf/serving_client_conf.prototxt ./raw_data
python3 test_client.py ctr_client_conf/serving_client_conf.prototxt ./raw_data
```
### Benchmark
......
......@@ -3,7 +3,7 @@
## Get Model
```
python -m paddle_serving_app.package --get_model deeplabv3
python3 -m paddle_serving_app.package --get_model deeplabv3
tar -xzvf deeplabv3.tar.gz
```
......@@ -12,11 +12,11 @@ tar -xzvf deeplabv3.tar.gz
### Start Service
```
python -m paddle_serving_server.serve --model deeplabv3_server --gpu_ids 0 --port 9494
python3 -m paddle_serving_server.serve --model deeplabv3_server --gpu_ids 0 --port 9494
```
### Client Prediction
```
python deeplabv3_client.py
python3 deeplabv3_client.py
```
......@@ -3,7 +3,7 @@
## 获取模型
```
python -m paddle_serving_app.package --get_model deeplabv3
python3 -m paddle_serving_app.package --get_model deeplabv3
tar -xzvf deeplabv3.tar.gz
```
......@@ -12,10 +12,10 @@ tar -xzvf deeplabv3.tar.gz
### 启动服务端
```
python -m paddle_serving_server.serve --model deeplabv3_server --gpu_ids 0 --port 9494
python3 -m paddle_serving_server.serve --model deeplabv3_server --gpu_ids 0 --port 9494
```
### 客户端预测
```
python deeplabv3_client.py
python3 deeplabv3_client.py
......@@ -10,7 +10,7 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### Start the service
```
tar xf faster_rcnn_hrnetv2p_w18_1x.tar
python -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
python3 -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
```
This model support TensorRT, if you want a faster inference, please use `--use_trt`. But you need to do some extra work.
......@@ -19,5 +19,5 @@ Please reference to https://github.com/PaddlePaddle/Paddle-Inference-Demo/blob/m
### Prediction
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
......@@ -11,12 +11,12 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### 启动服务
```
tar xf faster_rcnn_hrnetv2p_w18_1x.tar
python -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
python3 -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
```
该模型支持TensorRT,如果想要更快的预测速度,可以开启`--use_trt`选项,但此时需要额外设置子图的TRT变长最大最小最优shape.
请参考https://github.com/PaddlePaddle/Paddle-Inference-Demo/blob/master/c%2B%2B/paddle-trt/trt_dynamic_shape_test.cc#L40
### 执行预测
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
......@@ -10,7 +10,7 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### Start the service
```
tar xf faster_rcnn_r50_fpn_1x_coco.tar
python -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
python3 -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
```
This model support TensorRT, if you want a faster inference, please use `--use_trt`. But you need to do some extra work.
......@@ -19,7 +19,7 @@ Please reference to https://github.com/PaddlePaddle/Paddle-Inference-Demo/blob/m
### Perform prediction
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
## 3. Result analysis
......
......@@ -11,14 +11,14 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### 启动服务
```
tar xf faster_rcnn_r50_fpn_1x_coco.tar
python -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
python3 -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
```
该模型支持TensorRT,如果想要更快的预测速度,可以开启`--use_trt`选项,但此时需要额外设置子图的TRT变长最大最小最优shape.
请参考https://github.com/PaddlePaddle/Paddle-Inference-Demo/blob/master/c%2B%2B/paddle-trt/trt_dynamic_shape_test.cc#L40
### 执行预测
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
## 3. 结果分析
......
......@@ -10,11 +10,11 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### Start the service
```
tar xf fcos_dcn_r50_fpn_1x_coco.tar
python -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
python3 -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
```
This model support TensorRT, if you want a faster inference, please use `--use_trt`.
### Perform prediction
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
......@@ -11,12 +11,12 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### 启动服务
```
tar xf fcos_dcn_r50_fpn_1x_coco.tar
python -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
python3 -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
```
该模型支持TensorRT,如果想要更快的预测速度,可以开启`--use_trt`选项。
### 执行预测
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
......@@ -10,13 +10,12 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### Start the service
```
tar xf ppyolo_r50vd_dcn_1x_coco.tar
python -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
python3 -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
```
This model support TensorRT, if you want a faster inference, please use `--use_trt`.
### Perform prediction
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
......@@ -11,13 +11,12 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### 启动服务
```
tar xf ppyolo_r50vd_dcn_1x_coco.tar
python -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
python3 -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
```
该模型支持TensorRT,如果想要更快的预测速度,可以开启`--use_trt`选项。
### 执行预测
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
......@@ -10,11 +10,11 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### Start the service
```
tar xf ssd_vgg16_300_240e_voc.tar
python -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
python3 -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
```
This model support TensorRT, if you want a faster inference, please use `--use_trt`.
### Perform prediction
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
......@@ -11,12 +11,12 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### 启动服务
```
tar xf ssd_vgg16_300_240e_voc.tar
python -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
python3 -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
```
该模型支持TensorRT,如果想要更快的预测速度,可以开启`--use_trt`选项。
### 执行预测
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
......@@ -10,12 +10,11 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### Start the service
```
tar xf ttfnet_darknet53_1x_coco.tar
python -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
python3 -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
```
This model support TensorRT, if you want a faster inference, please use `--use_trt`.
### Perform prediction
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
......@@ -11,13 +11,12 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### 启动服务
```
tar xf ttfnet_darknet53_1x_coco.tar
python -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
python3 -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
```
该模型支持TensorRT,如果想要更快的预测速度,可以开启`--use_trt`选项。
### 执行预测
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
......@@ -10,13 +10,12 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### Start the service
```
tar xf yolov3_darknet53_270e_coco.tar
python -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
python3 -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
```
This model support TensorRT, if you want a faster inference, please use `--use_trt`.
### Perform prediction
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
......@@ -11,13 +11,12 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### 启动服务
```
tar xf yolov3_darknet53_270e_coco.tar
python -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
python3 -m paddle_serving_server.serve --model serving_server --port 9494 --gpu_ids 0
```
该模型支持TensorRT,如果想要更快的预测速度,可以开启`--use_trt`选项。
### 执行预测
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
......@@ -12,9 +12,9 @@ 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`).
The `paddlepaddle` package is used in this example, you may need to download the corresponding package(`pip3 install paddlepaddle`).
[python encrypt.py](./encrypt.py)
[python3 encrypt.py](./encrypt.py)
[//file]:#encrypt.py
``` python
......@@ -35,14 +35,14 @@ client-side configuration file are stored in the `encrypt_client` directory.
## Start Encryption Service
CPU Service
```
python -m paddle_serving_server.serve --model encrypt_server/ --port 9393 --use_encryption_model
python3 -m paddle_serving_server.serve --model encrypt_server/ --port 9393 --use_encryption_model
```
GPU Service
```
python -m paddle_serving_server.serve --model encrypt_server/ --port 9393 --use_encryption_model --gpu_ids 0
python3 -m paddle_serving_server.serve --model encrypt_server/ --port 9393 --use_encryption_model --gpu_ids 0
```
## Prediction
```
python test_client.py encrypt_client/serving_client_conf.prototxt
python3 test_client.py encrypt_client/serving_client_conf.prototxt
```
......@@ -11,9 +11,9 @@ sh get_data.sh
```
## 模型加密
本示例中使用了`paddlepaddle`包中的模块,需要进行下载(`pip install paddlepaddle`)。
本示例中使用了`paddlepaddle`包中的模块,需要进行下载(`pip3 install paddlepaddle`)。
运行[python encrypt.py](./encrypt.py)进行模型加密
运行[python3 encrypt.py](./encrypt.py)进行模型加密
[//file]:#encrypt.py
``` python
......@@ -36,14 +36,14 @@ def serving_encryption():
## 启动加密预测服务
CPU预测服务
```
python -m paddle_serving_server.serve --model encrypt_server/ --port 9393 --use_encryption_model
python3 -m paddle_serving_server.serve --model encrypt_server/ --port 9393 --use_encryption_model
```
GPU预测服务
```
python -m paddle_serving_server.serve --model encrypt_server/ --port 9393 --use_encryption_model --gpu_ids 0
python3 -m paddle_serving_server.serve --model encrypt_server/ --port 9393 --use_encryption_model --gpu_ids 0
```
## 预测
```
python test_client.py encrypt_client/serving_client_conf.prototxt
python3 test_client.py encrypt_client/serving_client_conf.prototxt
```
......@@ -15,22 +15,22 @@ sh get_data.sh
### Start server
```shell
python -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393
python3 -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393
```
## Client prediction
### RPC Client
The `paddlepaddle` package is used in `test_client.py`, and you may need to download the corresponding package(`pip install paddlepaddle`).
The `paddlepaddle` package is used in `test_client.py`, and you may need to download the corresponding package(`pip3 install paddlepaddle`).
``` shell
python test_client.py uci_housing_client/serving_client_conf.prototxt
python3 test_client.py uci_housing_client/serving_client_conf.prototxt
```
### Http Client
``` shell
python test_httpclient.py uci_housing_client/serving_client_conf.prototxt
python3 test_httpclient.py uci_housing_client/serving_client_conf.prototxt
```
......
......@@ -12,23 +12,23 @@ sh get_data.sh
## 开启服务端(支持BRPC-Client/GRPC Client/Http-Client)
```shell
python -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393
python3 -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393
```
## 客户端预测
### BRPC-Client
`test_client.py`中使用了`paddlepaddle`包,需要进行下载(`pip install paddlepaddle`)。
`test_client.py`中使用了`paddlepaddle`包,需要进行下载(`pip3 install paddlepaddle`)。
``` shell
python test_client.py uci_housing_client/serving_client_conf.prototxt
python3 test_client.py uci_housing_client/serving_client_conf.prototxt
```
### GRPC-Client/Http-Client
``` shell
python test_httpclient.py uci_housing_client/serving_client_conf.prototxt
python3 test_httpclient.py uci_housing_client/serving_client_conf.prototxt
```
......
......@@ -12,7 +12,7 @@ sh get_model.sh
### Install preprocess module
```
pip install paddle_serving_app
pip3 install paddle_serving_app
```
......@@ -20,22 +20,22 @@ pip install paddle_serving_app
launch server side
```
python -m paddle_serving_server.serve --model ResNet50_vd_model --port 9696 #cpu inference service
python3 -m paddle_serving_server.serve --model ResNet50_vd_model --port 9696 #cpu inference service
```
```
python -m paddle_serving_server.serve --model ResNet50_vd_model --port 9696 --gpu_ids 0 #gpu inference service
python3 -m paddle_serving_server.serve --model ResNet50_vd_model --port 9696 --gpu_ids 0 #gpu inference service
```
### BRPC-Client
client send inference request
```
python resnet50_rpc_client.py ResNet50_vd_client_config/serving_client_conf.prototxt
python3 resnet50_rpc_client.py ResNet50_vd_client_config/serving_client_conf.prototxt
```
*the port of server side in this example is 9696
### GRPC-Client/Http-Client
client send inference request
```
python resnet50_http_client.py ResNet50_vd_client_config/serving_client_conf.prototxt
python3 resnet50_http_client.py ResNet50_vd_client_config/serving_client_conf.prototxt
```
......@@ -12,24 +12,24 @@ sh get_model.sh
### 安装数据预处理模块
```
pip install paddle_serving_app
pip3 install paddle_serving_app
```
### 启动服务端(支持BRPC-Client、GRPC-Client、Http-Client)
启动server端
```
python -m paddle_serving_server.serve --model ResNet50_vd_model --port 9696 #cpu预测服务
python3 -m paddle_serving_server.serve --model ResNet50_vd_model --port 9696 #cpu预测服务
```
```
python -m paddle_serving_server.serve --model ResNet50_vd_model --port 9696 --gpu_ids 0 #gpu预测服务
python3 -m paddle_serving_server.serve --model ResNet50_vd_model --port 9696 --gpu_ids 0 #gpu预测服务
```
### BRPC-Client预测
client端进行预测
```
python resnet50_rpc_client.py ResNet50_vd_client_config/serving_client_conf.prototxt
python3 resnet50_rpc_client.py ResNet50_vd_client_config/serving_client_conf.prototxt
```
*server端示例中服务端口为9696端口
......@@ -37,5 +37,5 @@ python resnet50_rpc_client.py ResNet50_vd_client_config/serving_client_conf.prot
### GRPC-Client/Http-Client预测
client端进行预测
```
python resnet50_http_client.py ResNet50_vd_client_config/serving_client_conf.prototxt
python3 resnet50_http_client.py ResNet50_vd_client_config/serving_client_conf.prototxt
```
......@@ -12,11 +12,11 @@ the package downloaded contains cnn, lstm and bow model config along with their
### Start inference service(Support BRPC-Client/GRPC-Client/Http-Client)
```
python -m paddle_serving_server.serve --model imdb_cnn_model/ --port 9292
python3 -m paddle_serving_server.serve --model imdb_cnn_model/ --port 9292
```
### BRPC-Client Infer
```
head test_data/part-0 | python test_client.py imdb_cnn_client_conf/serving_client_conf.prototxt imdb.vocab
head test_data/part-0 | python3 test_client.py imdb_cnn_client_conf/serving_client_conf.prototxt imdb.vocab
```
it will get predict results of the first 10 test cases.
......@@ -24,5 +24,5 @@ it will get predict results of the first 10 test cases.
### GRPC-Client/Http-Client Infer
```
head test_data/part-0 | python test_http_client.py imdb_cnn_client_conf/serving_client_conf.prototxt imdb.vocab
head test_data/part-0 | python3 test_http_client.py imdb_cnn_client_conf/serving_client_conf.prototxt imdb.vocab
```
......@@ -12,15 +12,15 @@ sh get_data.sh
### 启动预测服务(支持BRPC-Client/GRPC-Client/Http-Client)
```
python -m paddle_serving_server.serve --model imdb_cnn_model/ --port 9292
python3 -m paddle_serving_server.serve --model imdb_cnn_model/ --port 9292
```
### BRPC-Client预测
```
head test_data/part-0 | python test_client.py imdb_cnn_client_conf/serving_client_conf.prototxt imdb.vocab
head test_data/part-0 | python3 test_client.py imdb_cnn_client_conf/serving_client_conf.prototxt imdb.vocab
```
预测test_data/part-0的前十个样例。
### BRPC-Client预测
```
head test_data/part-0 | python test_http_client.py imdb_cnn_client_conf/serving_client_conf.prototxt imdb.vocab
head test_data/part-0 | python3 test_http_client.py imdb_cnn_client_conf/serving_client_conf.prototxt imdb.vocab
```
......@@ -4,23 +4,23 @@
### Get Model
```
python -m paddle_serving_app.package --get_model lac
python3 -m paddle_serving_app.package --get_model lac
tar -xzvf lac.tar.gz
```
#### Start inference service(Support BRPC-Client/GRPC-Client/Http-Client)
```
python -m paddle_serving_server.serve --model lac_model/ --port 9292
python3 -m paddle_serving_server.serve --model lac_model/ --port 9292
```
### BRPC Infer
```
echo "我爱北京天安门" | python lac_client.py lac_client/serving_client_conf.prototxt
echo "我爱北京天安门" | python3 lac_client.py lac_client/serving_client_conf.prototxt
```
It will get the segmentation result.
### GRPC/Http Infer
```
echo "我爱北京天安门" | python lac_http_client.py lac_client/serving_client_conf.prototxt
echo "我爱北京天安门" | python3 lac_http_client.py lac_client/serving_client_conf.prototxt
```
......@@ -4,23 +4,23 @@
### 获取模型
```
python -m paddle_serving_app.package --get_model lac
python3 -m paddle_serving_app.package --get_model lac
tar -xzvf lac.tar.gz
```
#### 开启预测服务(支持BRPC-Client/GRPC-Client/Http-Client)
```
python -m paddle_serving_server.serve --model lac_model/ --port 9292
python3 -m paddle_serving_server.serve --model lac_model/ --port 9292
```
### 执行BRPC预测
```
echo "我爱北京天安门" | python lac_client.py lac_client/serving_client_conf.prototxt
echo "我爱北京天安门" | python3 lac_client.py lac_client/serving_client_conf.prototxt
```
我们就能得到分词结果
### 执行GRPC/Http预测
```
echo "我爱北京天安门" | python lac_http_client.py lac_client/serving_client_conf.prototxt
echo "我爱北京天安门" | python3 lac_http_client.py lac_client/serving_client_conf.prototxt
```
......@@ -11,15 +11,15 @@ Firstly, download the [Resnet50 int8 model](https://paddle-inference-dist.bj.bce
wget https://paddle-inference-dist.bj.bcebos.com/inference_demo/python/resnet50/ResNet50_quant.tar.gz
tar zxvf ResNet50_quant.tar.gz
python -m paddle_serving_client.convert --dirname ResNet50_quant
python3 -m paddle_serving_client.convert --dirname ResNet50_quant
```
Start RPC service, specify the GPU id and precision mode
```
python -m paddle_serving_server.serve --model serving_server --port 9393 --gpu_ids 0 --use_trt --precision int8
python3 -m paddle_serving_server.serve --model serving_server --port 9393 --gpu_ids 0 --use_trt --precision int8
```
Request the serving service with Client
```
python resnet50_client.py
python3 resnet50_client.py
```
## Reference
......
......@@ -10,15 +10,15 @@
wget https://paddle-inference-dist.bj.bcebos.com/inference_demo/python/resnet50/ResNet50_quant.tar.gz
tar zxvf ResNet50_quant.tar.gz
python -m paddle_serving_client.convert --dirname ResNet50_quant
python3 -m paddle_serving_client.convert --dirname ResNet50_quant
```
启动rpc服务, 设定所选GPU id、部署模型精度
```
python -m paddle_serving_server.serve --model serving_server --port 9393 --gpu_ids 0 --use_trt --precision int8
python3 -m paddle_serving_server.serve --model serving_server --port 9393 --gpu_ids 0 --use_trt --precision int8
```
使用client进行请求
```
python resnet50_client.py
python3 resnet50_client.py
```
## 参考文档
......
......@@ -3,7 +3,7 @@
## Get Model
```
python -m paddle_serving_app.package --get_model mobilenet_v2_imagenet
python3 -m paddle_serving_app.package --get_model mobilenet_v2_imagenet
tar -xzvf mobilenet_v2_imagenet.tar.gz
```
......@@ -12,11 +12,11 @@ tar -xzvf mobilenet_v2_imagenet.tar.gz
### Start Service
```
python -m paddle_serving_server.serve --model mobilenet_v2_imagenet_model --gpu_ids 0 --port 9393
python3 -m paddle_serving_server.serve --model mobilenet_v2_imagenet_model --gpu_ids 0 --port 9393
```
### Client Prediction
```
python mobilenet_tutorial.py
python3 mobilenet_tutorial.py
```
......@@ -3,7 +3,7 @@
## 获取模型
```
python -m paddle_serving_app.package --get_model mobilenet_v2_imagenet
python3 -m paddle_serving_app.package --get_model mobilenet_v2_imagenet
tar -xzvf mobilenet_v2_imagenet.tar.gz
```
......@@ -12,11 +12,11 @@ tar -xzvf mobilenet_v2_imagenet.tar.gz
### 启动服务端
```
python -m paddle_serving_server.serve --model mobilenet_v2_imagenet_model --gpu_ids 0 --port 9393
python3 -m paddle_serving_server.serve --model mobilenet_v2_imagenet_model --gpu_ids 0 --port 9393
```
### 客户端预测
```
python mobilenet_tutorial.py
python3 mobilenet_tutorial.py
```
......@@ -4,9 +4,9 @@
## Get Model
```
python -m paddle_serving_app.package --get_model ocr_rec
python3 -m paddle_serving_app.package --get_model ocr_rec
tar -xzvf ocr_rec.tar.gz
python -m paddle_serving_app.package --get_model ocr_det
python3 -m paddle_serving_app.package --get_model ocr_det
tar -xzvf ocr_det.tar.gz
```
......@@ -23,16 +23,16 @@ tar xf test_imgs.tar
```
#choose one of cpu/gpu commands as following
#for cpu user
python -m paddle_serving_server.serve --model ocr_det_model --port 9293
python ocr_web_server.py cpu
python3 -m paddle_serving_server.serve --model ocr_det_model --port 9293
python3 ocr_web_server.py cpu
#for gpu user
python -m paddle_serving_server.serve --model ocr_det_model --port 9293 --gpu_ids 0
python ocr_web_server.py gpu
python3 -m paddle_serving_server.serve --model ocr_det_model --port 9293 --gpu_ids 0
python3 ocr_web_server.py gpu
```
### Client Prediction
```
python ocr_web_client.py
python3 ocr_web_client.py
```
If you want a faster web service, please try Web LocalPredictor Service
......@@ -40,14 +40,14 @@ If you want a faster web service, please try Web LocalPredictor Service
```
#choose one of cpu/gpu commands as following
#for cpu user
python ocr_debugger_server.py cpu
python3 ocr_debugger_server.py cpu
#for gpu user
python ocr_debugger_server.py gpu
python3 ocr_debugger_server.py gpu
```
## Web LocalPredictor Client Prediction
```
python ocr_web_client.py
python3 ocr_web_client.py
```
## Benchmark
......@@ -69,34 +69,34 @@ if you are going to detect images not recognize it or directly recognize the wor
### Det Server
```
python det_web_server.py cpu #for cpu user
python det_web_server.py gpu #for gpu user
python3 det_web_server.py cpu #for cpu user
python3 det_web_server.py gpu #for gpu user
#or
python det_debugger_server.py cpu #for cpu user
python det_debugger_server.py gpu #for gpu user
python3 det_debugger_server.py cpu #for cpu user
python3 det_debugger_server.py gpu #for gpu user
```
### Det Client
```
# also use ocr_web_client.py
python ocr_web_client.py
python3 ocr_web_client.py
```
### Rec Server
```
python rec_web_server.py cpu #for cpu user
python rec_web_server.py gpu #for gpu user
python3 rec_web_server.py cpu #for cpu user
python3 rec_web_server.py gpu #for gpu user
#or
python rec_debugger_server.py cpu #for cpu user
python rec_debugger_server.py gpu #for gpu user
python3 rec_debugger_server.py cpu #for cpu user
python3 rec_debugger_server.py gpu #for gpu user
```
### Rec Client
```
python rec_web_client.py
python3 rec_web_client.py
```
## C++ OCR Service
......@@ -109,9 +109,9 @@ Select a startup mode according to CPU / GPU device
After the -- model parameter, the folder path of multiple model files is passed in to start the prediction service of multiple model concatenation.
```
#for cpu user
python -m paddle_serving_server.serve --model ocr_det_model ocr_rec_model --port 9293
python3 -m paddle_serving_server.serve --model ocr_det_model ocr_rec_model --port 9293
#for gpu user
python -m paddle_serving_server.serve --model ocr_det_model ocr_rec_model --port 9293 --gpu_ids 0
python3 -m paddle_serving_server.serve --model ocr_det_model ocr_rec_model --port 9293 --gpu_ids 0
```
### Client Prediction
......@@ -123,5 +123,5 @@ for this case, `feed_type` should be 3(which means the data type is string),`sha
By passing in multiple client folder paths, the client can be started for multi model prediction.
```
python ocr_cpp_client.py ocr_det_client ocr_rec_client
python3 ocr_cpp_client.py ocr_det_client ocr_rec_client
```
......@@ -4,9 +4,9 @@
## 获取模型
```
python -m paddle_serving_app.package --get_model ocr_rec
python3 -m paddle_serving_app.package --get_model ocr_rec
tar -xzvf ocr_rec.tar.gz
python -m paddle_serving_app.package --get_model ocr_det
python3 -m paddle_serving_app.package --get_model ocr_det
tar -xzvf ocr_det.tar.gz
```
## 获取数据集(可选)
......@@ -22,16 +22,16 @@ tar xf test_imgs.tar
```
#根据CPU/GPU设备选择一种启动方式
#for cpu user
python -m paddle_serving_server.serve --model ocr_det_model --port 9293
python ocr_web_server.py cpu
python3 -m paddle_serving_server.serve --model ocr_det_model --port 9293
python3 ocr_web_server.py cpu
#for gpu user
python -m paddle_serving_server.serve --model ocr_det_model --port 9293 --gpu_ids 0
python ocr_web_server.py gpu
python3 -m paddle_serving_server.serve --model ocr_det_model --port 9293 --gpu_ids 0
python3 ocr_web_server.py gpu
```
### 启动客户端
```
python ocr_web_client.py
python3 ocr_web_client.py
```
如果用户需要更快的执行速度,请尝试LocalPredictor版Web服务
......@@ -39,14 +39,14 @@ python ocr_web_client.py
```
#根据CPU/GPU设备选择一种启动方式
#for cpu user
python ocr_debugger_server.py cpu
python3 ocr_debugger_server.py cpu
#for gpu user
python ocr_debugger_server.py gpu
python3 ocr_debugger_server.py gpu
```
## 启动客户端
```
python ocr_web_client.py
python3 ocr_web_client.py
```
## 性能指标
......@@ -69,34 +69,34 @@ GPU: Nvidia Tesla V100单卡
### 启动检测服务
```
python det_web_server.py cpu #for cpu user
python det_web_server.py gpu #for gpu user
python3 det_web_server.py cpu #for cpu user
python3 det_web_server.py gpu #for gpu user
#or
python det_debugger_server.py cpu #for cpu user
python det_debugger_server.py gpu #for gpu user
python3 det_debugger_server.py cpu #for cpu user
python3 det_debugger_server.py gpu #for gpu user
```
### 检测服务客户端
```
# also use ocr_web_client.py
python ocr_web_client.py
python3 ocr_web_client.py
```
### 启动识别服务
```
python rec_web_server.py cpu #for cpu user
python rec_web_server.py gpu #for gpu user
python3 rec_web_server.py cpu #for cpu user
python3 rec_web_server.py gpu #for gpu user
#or
python rec_debugger_server.py cpu #for cpu user
python rec_debugger_server.py gpu #for gpu user
python3 rec_debugger_server.py cpu #for cpu user
python3 rec_debugger_server.py gpu #for gpu user
```
### 识别服务客户端
```
python rec_web_client.py
python3 rec_web_client.py
```
## C++ OCR Service服务
......@@ -108,9 +108,9 @@ python rec_web_client.py
通过--model后,指定多个模型文件的文件夹路径来启动多模型串联的预测服务。
```
#for cpu user
python -m paddle_serving_server.serve --model ocr_det_model ocr_rec_model --port 9293
python3 -m paddle_serving_server.serve --model ocr_det_model ocr_rec_model --port 9293
#for gpu user
python -m paddle_serving_server.serve --model ocr_det_model ocr_rec_model --port 9293 --gpu_ids 0
python3 -m paddle_serving_server.serve --model ocr_det_model ocr_rec_model --port 9293 --gpu_ids 0
```
### 启动客户端
......@@ -122,5 +122,5 @@ python -m paddle_serving_server.serve --model ocr_det_model ocr_rec_model --port
通过在客户端启动后加入多个client模型的client配置文件夹路径,启动client进行预测。
```
python ocr_cpp_client.py ocr_det_client ocr_rec_client
python3 ocr_cpp_client.py ocr_det_client ocr_rec_client
```
......@@ -10,10 +10,10 @@ sh get_model.sh
## Start server
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## RPC test
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
......@@ -10,11 +10,10 @@ sh get_model.sh
## 启动服务
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## 测试
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import base64
......@@ -5,13 +19,13 @@ import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -24,6 +38,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -37,9 +52,11 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18080/imagenet/prediction"
......@@ -68,6 +85,7 @@ def run_http(idx, batch_size):
end = time.time()
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -87,6 +105,7 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
client = PipelineClient()
client.connect(['127.0.0.1:18080'])
......@@ -107,7 +126,8 @@ def run_rpc(thread, batch_size):
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -131,4 +151,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -11,10 +11,8 @@
# 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.
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
import requests
import json
......
......@@ -10,10 +10,10 @@ sh get_model.sh
## Start server
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## RPC test
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
......@@ -10,11 +10,10 @@ sh get_model.sh
## 启动服务
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## 测试
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import base64
......@@ -5,13 +19,13 @@ import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -24,6 +38,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -37,9 +52,11 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18080/imagenet/prediction"
......@@ -68,6 +85,7 @@ def run_http(idx, batch_size):
end = time.time()
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -87,6 +105,7 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
client = PipelineClient()
client.connect(['127.0.0.1:18080'])
......@@ -107,7 +126,8 @@ def run_rpc(thread, batch_size):
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -131,4 +151,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -11,10 +11,8 @@
# 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.
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
import requests
import json
......
......@@ -13,10 +13,8 @@
# limitations under the License.
import sys
from paddle_serving_app.reader import Sequential, URL2Image, Resize, CenterCrop, RGB2BGR, Transpose, Div, Normalize, Base64ToImage
try:
from paddle_serving_server_gpu.web_service import WebService, Op
except ImportError:
from paddle_serving_server.web_service import WebService, Op
from paddle_serving_server.web_service import WebService, Op
import logging
import numpy as np
import base64, cv2
......
......@@ -10,10 +10,10 @@ sh get_model.sh
## Start server
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## RPC test
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
......@@ -10,11 +10,10 @@ sh get_model.sh
## 启动服务
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## 测试
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import base64
......@@ -5,13 +19,13 @@ import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -24,6 +38,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -37,9 +52,11 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18080/imagenet/prediction"
......@@ -68,6 +85,7 @@ def run_http(idx, batch_size):
end = time.time()
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -87,6 +105,7 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
client = PipelineClient()
client.connect(['127.0.0.1:18080'])
......@@ -107,7 +126,8 @@ def run_rpc(thread, batch_size):
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -131,4 +151,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -11,10 +11,8 @@
# 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.
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
import requests
import json
......
......@@ -13,10 +13,8 @@
# limitations under the License.
import sys
from paddle_serving_app.reader import Sequential, URL2Image, Resize, CenterCrop, RGB2BGR, Transpose, Div, Normalize, Base64ToImage
try:
from paddle_serving_server_gpu.web_service import WebService, Op
except ImportError:
from paddle_serving_server.web_service import WebService, Op
from paddle_serving_server.web_service import WebService, Op
import logging
import numpy as np
import base64, cv2
......
......@@ -10,10 +10,10 @@ sh get_model.sh
## Start server
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## RPC test
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
......@@ -10,11 +10,10 @@ sh get_model.sh
## 启动服务
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## 测试
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import base64
......@@ -5,13 +19,13 @@ import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -24,6 +38,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -37,9 +52,11 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18080/imagenet/prediction"
......@@ -68,6 +85,7 @@ def run_http(idx, batch_size):
end = time.time()
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -87,6 +105,7 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
client = PipelineClient()
client.connect(['127.0.0.1:18080'])
......@@ -107,7 +126,8 @@ def run_rpc(thread, batch_size):
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -131,4 +151,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -11,10 +11,8 @@
# 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.
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
import requests
import json
......
......@@ -13,10 +13,8 @@
# limitations under the License.
import sys
from paddle_serving_app.reader import Sequential, URL2Image, Resize, CenterCrop, RGB2BGR, Transpose, Div, Normalize, Base64ToImage
try:
from paddle_serving_server_gpu.web_service import WebService, Op
except ImportError:
from paddle_serving_server.web_service import WebService, Op
from paddle_serving_server.web_service import WebService, Op
import logging
import numpy as np
import base64, cv2
......
......@@ -10,10 +10,10 @@ sh get_model.sh
## Start server
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## RPC test
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
......@@ -10,11 +10,10 @@ sh get_model.sh
## 启动服务
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## 测试
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import base64
......@@ -5,13 +19,13 @@ import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -24,6 +38,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -37,9 +52,11 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18080/imagenet/prediction"
......@@ -68,6 +85,7 @@ def run_http(idx, batch_size):
end = time.time()
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -87,6 +105,7 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
client = PipelineClient()
client.connect(['127.0.0.1:18080'])
......@@ -107,7 +126,8 @@ def run_rpc(thread, batch_size):
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -131,4 +151,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -11,10 +11,8 @@
# 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.
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
import requests
import json
......
......@@ -13,10 +13,8 @@
# limitations under the License.
import sys
from paddle_serving_app.reader import Sequential, URL2Image, Resize, CenterCrop, RGB2BGR, Transpose, Div, Normalize, Base64ToImage
try:
from paddle_serving_server_gpu.web_service import WebService, Op
except ImportError:
from paddle_serving_server.web_service import WebService, Op
from paddle_serving_server.web_service import WebService, Op
import logging
import numpy as np
import base64, cv2
......
......@@ -10,10 +10,10 @@ sh get_model.sh
## Start server
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## RPC test
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
......@@ -10,11 +10,10 @@ sh get_model.sh
## 启动服务
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## 测试
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import base64
......@@ -5,13 +19,13 @@ import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -24,6 +38,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -37,9 +52,11 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18080/imagenet/prediction"
......@@ -68,6 +85,7 @@ def run_http(idx, batch_size):
end = time.time()
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -87,6 +105,7 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
client = PipelineClient()
client.connect(['127.0.0.1:18080'])
......@@ -107,7 +126,8 @@ def run_rpc(thread, batch_size):
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -131,4 +151,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -11,10 +11,8 @@
# 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.
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
import requests
import json
......
......@@ -13,10 +13,8 @@
# limitations under the License.
import sys
from paddle_serving_app.reader import Sequential, URL2Image, Resize, CenterCrop, RGB2BGR, Transpose, Div, Normalize, Base64ToImage
try:
from paddle_serving_server_gpu.web_service import WebService, Op
except ImportError:
from paddle_serving_server.web_service import WebService, Op
from paddle_serving_server.web_service import WebService, Op
import logging
import numpy as np
import base64, cv2
......
......@@ -10,10 +10,10 @@ sh get_model.sh
## Start server
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## RPC test
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
......@@ -10,11 +10,10 @@ sh get_model.sh
## 启动服务
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## 测试
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import base64
......@@ -5,13 +19,13 @@ import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -24,6 +38,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -37,9 +52,11 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18080/imagenet/prediction"
......@@ -68,6 +85,7 @@ def run_http(idx, batch_size):
end = time.time()
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -87,6 +105,7 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
client = PipelineClient()
client.connect(['127.0.0.1:18080'])
......@@ -107,7 +126,8 @@ def run_rpc(thread, batch_size):
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -131,4 +151,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -11,10 +11,8 @@
# 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.
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
import requests
import json
......
......@@ -13,10 +13,8 @@
# limitations under the License.
import sys
from paddle_serving_app.reader import Sequential, URL2Image, Resize, CenterCrop, RGB2BGR, Transpose, Div, Normalize, Base64ToImage
try:
from paddle_serving_server_gpu.web_service import WebService, Op
except ImportError:
from paddle_serving_server.web_service import WebService, Op
from paddle_serving_server.web_service import WebService, Op
import logging
import numpy as np
import base64, cv2
......
......@@ -10,10 +10,10 @@ sh get_model.sh
## Start server
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## RPC test
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
......@@ -10,11 +10,10 @@ sh get_model.sh
## 启动服务
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## 测试
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import base64
......@@ -5,13 +19,13 @@ import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -24,6 +38,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -37,9 +52,11 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18080/imagenet/prediction"
......@@ -68,6 +85,7 @@ def run_http(idx, batch_size):
end = time.time()
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -87,6 +105,7 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
client = PipelineClient()
client.connect(['127.0.0.1:18080'])
......@@ -107,7 +126,8 @@ def run_rpc(thread, batch_size):
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -131,4 +151,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -11,10 +11,8 @@
# 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.
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
import requests
import json
......
......@@ -13,10 +13,8 @@
# limitations under the License.
import sys
from paddle_serving_app.reader import Sequential, URL2Image, Resize, CenterCrop, RGB2BGR, Transpose, Div, Normalize, Base64ToImage
try:
from paddle_serving_server_gpu.web_service import WebService, Op
except ImportError:
from paddle_serving_server.web_service import WebService, Op
from paddle_serving_server.web_service import WebService, Op
import logging
import numpy as np
import base64, cv2
......
......@@ -10,10 +10,10 @@ sh get_model.sh
## Start server
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## RPC test
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
......@@ -10,11 +10,10 @@ sh get_model.sh
## 启动服务
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## 测试
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import base64
......@@ -5,13 +19,13 @@ import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -24,6 +38,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -37,9 +52,11 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18080/imagenet/prediction"
......@@ -68,6 +85,7 @@ def run_http(idx, batch_size):
end = time.time()
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -87,6 +105,7 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
client = PipelineClient()
client.connect(['127.0.0.1:18080'])
......@@ -107,7 +126,8 @@ def run_rpc(thread, batch_size):
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -131,4 +151,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -11,10 +11,8 @@
# 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.
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
import requests
import json
......
......@@ -13,10 +13,8 @@
# limitations under the License.
import sys
from paddle_serving_app.reader import Sequential, URL2Image, Resize, CenterCrop, RGB2BGR, Transpose, Div, Normalize, Base64ToImage
try:
from paddle_serving_server_gpu.web_service import WebService, Op
except ImportError:
from paddle_serving_server.web_service import WebService, Op
from paddle_serving_server.web_service import WebService, Op
import logging
import numpy as np
import base64, cv2
......
......@@ -10,10 +10,10 @@ sh get_model.sh
## Start server
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## RPC test
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
......@@ -10,11 +10,10 @@ sh get_model.sh
## 启动服务
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## 测试
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import base64
......@@ -5,13 +19,13 @@ import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -24,6 +38,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -37,9 +52,11 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18080/imagenet/prediction"
......@@ -68,6 +85,7 @@ def run_http(idx, batch_size):
end = time.time()
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -87,6 +105,7 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
client = PipelineClient()
client.connect(['127.0.0.1:18080'])
......@@ -107,7 +126,8 @@ def run_rpc(thread, batch_size):
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -131,4 +151,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -11,10 +11,8 @@
# 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.
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
import requests
import json
......
......@@ -13,10 +13,8 @@
# limitations under the License.
import sys
from paddle_serving_app.reader import Sequential, URL2Image, Resize, CenterCrop, RGB2BGR, Transpose, Div, Normalize, Base64ToImage
try:
from paddle_serving_server_gpu.web_service import WebService, Op
except ImportError:
from paddle_serving_server.web_service import WebService, Op
from paddle_serving_server.web_service import WebService, Op
import logging
import numpy as np
import base64, cv2
......
......@@ -4,17 +4,17 @@ This document will takes Imagenet service as an example to introduce how to use
## Get model
```
python -m paddle_serving_app.package --get_model resnet_v2_50_imagenet
python3 -m paddle_serving_app.package --get_model resnet_v2_50_imagenet
tar -xzvf resnet_v2_50_imagenet.tar.gz
```
## Start server
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## RPC test
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
......@@ -4,18 +4,17 @@
## 获取模型
```
python -m paddle_serving_app.package --get_model resnet_v2_50_imagenet
python3 -m paddle_serving_app.package --get_model resnet_v2_50_imagenet
tar -xzvf resnet_v2_50_imagenet.tar.gz
```
## 启动服务
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## 测试
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import base64
......@@ -5,13 +19,13 @@ import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -24,6 +38,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -37,9 +52,11 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18000/imagenet/prediction"
......@@ -68,6 +85,7 @@ def run_http(idx, batch_size):
end = time.time()
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -87,6 +105,7 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
client = PipelineClient()
client.connect(['127.0.0.1:18080'])
......@@ -107,7 +126,8 @@ def run_rpc(thread, batch_size):
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -131,4 +151,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -11,10 +11,8 @@
# 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.
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
import requests
import json
......
......@@ -10,10 +10,10 @@ sh get_model.sh
## Start server
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## RPC test
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
......@@ -10,11 +10,10 @@ sh get_model.sh
## 启动服务
```
python resnet50_web_service.py &>log.txt &
python3 resnet50_web_service.py &>log.txt &
```
## 测试
```
python pipeline_rpc_client.py
python3 pipeline_rpc_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import base64
......@@ -5,13 +19,13 @@ import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -24,6 +38,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -37,9 +52,11 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18080/imagenet/prediction"
......@@ -68,6 +85,7 @@ def run_http(idx, batch_size):
end = time.time()
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -87,6 +105,7 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
client = PipelineClient()
client.connect(['127.0.0.1:18080'])
......@@ -107,7 +126,8 @@ def run_rpc(thread, batch_size):
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -131,4 +151,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -11,10 +11,7 @@
# 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.
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
import requests
import json
......
......@@ -13,10 +13,8 @@
# limitations under the License.
import sys
from paddle_serving_app.reader import Sequential, URL2Image, Resize, CenterCrop, RGB2BGR, Transpose, Div, Normalize, Base64ToImage
try:
from paddle_serving_server_gpu.web_service import WebService, Op
except ImportError:
from paddle_serving_server.web_service import WebService, Op
from paddle_serving_server.web_service import WebService, Op
import logging
import numpy as np
import base64, cv2
......
......@@ -8,11 +8,11 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### Start the service
```
tar xf faster_rcnn_r50_fpn_1x_coco.tar
python web_service.py
python3 web_service.py
```
### Perform prediction
```
python pipeline_http_client.py
python3 pipeline_http_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import yaml
......@@ -6,17 +20,17 @@ import time
import json
import cv2
import base64
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -29,6 +43,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -40,6 +55,7 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18082/faster_rcnn/prediction"
......@@ -65,6 +81,7 @@ def run_http(idx, batch_size):
break
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -84,12 +101,15 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
pass
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -110,4 +130,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -10,11 +10,10 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### Start the service
```
tar xf ppyolo_mbv3_large_coco.tar
python web_service.py
python3 web_service.py
```
### Perform prediction
```
python pipeline_http_client.py
python3 pipeline_http_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import yaml
......@@ -6,17 +20,17 @@ import time
import json
import cv2
import base64
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -29,6 +43,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -40,6 +55,7 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18082/ppyolo_mbv3/prediction"
......@@ -65,6 +81,7 @@ def run_http(idx, batch_size):
break
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -84,12 +101,15 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
pass
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -110,4 +130,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -10,11 +10,10 @@ wget --no-check-certificate https://paddle-serving.bj.bcebos.com/pddet_demo/2.0/
### Start the service
```
tar xf yolov3_darknet53_270e_coco.tar
python web_service.py
python3 web_service.py
```
### Perform prediction
```
python pipeline_http_client.py
python3 pipeline_http_client.py
```
# Copyright (c) 2021 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.
import sys
import os
import yaml
......@@ -6,17 +20,17 @@ import time
import json
import cv2
import base64
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8')
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -29,6 +43,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device, gpu_id):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -40,6 +55,7 @@ def gen_yml(device, gpu_id):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18082/yolov3/prediction"
......@@ -65,6 +81,7 @@ def run_http(idx, batch_size):
break
return [[end - start], latency_list, [total_num]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
start = time.time()
......@@ -84,12 +101,15 @@ def multithread_http(thread, batch_size):
total_cost))
show_latency(result[1])
def run_rpc(thread, batch_size):
pass
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -110,4 +130,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
# Copyright (c) 2021 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.
import sys
import os
import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
......@@ -38,6 +50,8 @@ from paddle_serving_client.utils import benchmark_args, show_latency
2021-03-16 10:26:01,840 chl0(In: ['@DAGExecutor'], Out: ['bert']) size[0/0]
2021-03-16 10:26:01,841 chl1(In: ['bert'], Out: ['@DAGExecutor']) size[0/0]
'''
def parse_benchmark(filein, fileout):
with open(filein, "r") as fin:
res = yaml.load(fin)
......@@ -50,6 +64,7 @@ def parse_benchmark(filein, fileout):
with open(fileout, "w") as fout:
yaml.dump(res, fout, default_flow_style=False)
def gen_yml(device):
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -61,6 +76,7 @@ def gen_yml(device):
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18082/bert/prediction"
......@@ -84,9 +100,11 @@ def run_http(idx, batch_size):
end = time.time()
return [[end - start]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_http , thread, batch_size)
result = multi_thread_runner.run(run_http, thread, batch_size)
def run_rpc(thread, batch_size):
client = PipelineClient()
......@@ -110,7 +128,8 @@ def run_rpc(thread, batch_size):
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -130,4 +149,3 @@ if __name__ == "__main__":
filein = sys.argv[2]
fileout = sys.argv[3]
parse_benchmark(filein, fileout)
......@@ -19,10 +19,8 @@ import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
......
......@@ -10,7 +10,7 @@ sh get_data.sh
## Start server
```
python web_service.py &>log.txt &
python3 web_service.py &>log.txt &
```
## Http test
......
......@@ -10,7 +10,7 @@ sh get_data.sh
## 启动服务
```
python web_service.py &>log.txt &
python3 web_service.py &>log.txt &
```
## 测试
......
# Copyright (c) 2021 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.
import sys
import os
import yaml
import requests
import time
import json
try:
from paddle_serving_server_gpu.pipeline import PipelineClient
except ImportError:
from paddle_serving_server.pipeline import PipelineClient
from paddle_serving_server.pipeline import PipelineClient
import numpy as np
from paddle_serving_client.utils import MultiThreadRunner
from paddle_serving_client.utils import benchmark_args, show_latency
def gen_yml():
fin = open("config.yml", "r")
config = yaml.load(fin)
......@@ -20,6 +33,7 @@ def gen_yml():
with open("config2.yml", "w") as fout:
yaml.dump(config, fout, default_flow_style=False)
def run_http(idx, batch_size):
print("start thread ({})".format(idx))
url = "http://127.0.0.1:18082/uci/prediction"
......@@ -33,9 +47,11 @@ def run_http(idx, batch_size):
end = time.time()
return [[end - start]]
def multithread_http(thread, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_http , thread, batch_size)
result = multi_thread_runner.run(run_http, thread, batch_size)
def run_rpc(thread, batch_size):
client = PipelineClient()
......@@ -44,12 +60,15 @@ def run_rpc(thread, batch_size):
all_value = ";".join([value for i in range(batch_size)])
data = {"key": "x", "value": all_value}
for i in range(1000):
ret = client.predict(feed_dict={data["key"]: data["value"]}, fetch=["res"])
ret = client.predict(
feed_dict={data["key"]: data["value"]}, fetch=["res"])
print(ret)
def multithread_rpc(thraed, batch_size):
multi_thread_runner = MultiThreadRunner()
result = multi_thread_runner.run(run_rpc , thread, batch_size)
result = multi_thread_runner.run(run_rpc, thread, batch_size)
if __name__ == "__main__":
if sys.argv[1] == "yaml":
......@@ -64,5 +83,3 @@ if __name__ == "__main__":
multithread_http(thread, batch_size)
elif mode == "rpc":
multithread_rpc(thread, batch_size)
......@@ -3,7 +3,7 @@
## Get Model
```
python -m paddle_serving_app.package --get_model resnet_v2_50_imagenet
python3 -m paddle_serving_app.package --get_model resnet_v2_50_imagenet
tar -xzvf resnet_v2_50_imagenet.tar.gz
```
......@@ -12,11 +12,11 @@ tar -xzvf resnet_v2_50_imagenet.tar.gz
### Start Service
```
python -m paddle_serving_server.serve --model resnet_v2_50_imagenet_model --gpu_ids 0 --port 9393
python3 -m paddle_serving_server.serve --model resnet_v2_50_imagenet_model --gpu_ids 0 --port 9393
```
### Client Prediction
```
python resnet50_v2_tutorial.py
python3 resnet50_v2_tutorial.py
```
......@@ -3,7 +3,7 @@
## 获取模型
```
python -m paddle_serving_app.package --get_model resnet_v2_50_imagenet
python3 -m paddle_serving_app.package --get_model resnet_v2_50_imagenet
tar -xzvf resnet_v2_50_imagenet.tar.gz
```
......@@ -12,11 +12,11 @@ tar -xzvf resnet_v2_50_imagenet.tar.gz
### 启动服务端
```
python -m paddle_serving_server.serve --model resnet_v2_50_imagenet_model --gpu_ids 0 --port 9393
python3 -m paddle_serving_server.serve --model resnet_v2_50_imagenet_model --gpu_ids 0 --port 9393
```
### 客户端预测
```
python resnet50_v2_tutorial.py
python3 resnet50_v2_tutorial.py
```
......@@ -3,16 +3,16 @@
## Get Model
```
python -m paddle_serving_app.package --get_model senta_bilstm
python -m paddle_serving_app.package --get_model lac
python3 -m paddle_serving_app.package --get_model senta_bilstm
python3 -m paddle_serving_app.package --get_model lac
tar -xzvf senta_bilstm.tar.gz
tar -xzvf lac.tar.gz
```
## Start HTTP Service
```
python -m paddle_serving_server.serve --model lac_model --port 9300
python senta_web_service.py
python3 -m paddle_serving_server.serve --model lac_model --port 9300
python3 senta_web_service.py
```
In the Chinese sentiment classification task, the Chinese word segmentation needs to be done through [LAC task] (../lac).
In this demo, the LAC task is placed in the preprocessing part of the HTTP prediction service of the sentiment classification task.
......
......@@ -3,16 +3,16 @@
## 获取模型文件
```
python -m paddle_serving_app.package --get_model senta_bilstm
python -m paddle_serving_app.package --get_model lac
python3 -m paddle_serving_app.package --get_model senta_bilstm
python3 -m paddle_serving_app.package --get_model lac
tar -xzvf lac.tar.gz
tar -xzvf senta_bilstm.tar.gz
```
## 启动HTTP服务
```
python -m paddle_serving_server.serve --model lac_model --port 9300
python senta_web_service.py
python3 -m paddle_serving_server.serve --model lac_model --port 9300
python3 senta_web_service.py
```
中文情感分类任务中需要先通过[LAC任务](../lac)进行中文分词。
示例中将LAC任务放在情感分类任务的HTTP预测服务的预处理部分。
......
......@@ -3,7 +3,7 @@
## Get Model
```
python -m paddle_serving_app.package --get_model unet
python3 -m paddle_serving_app.package --get_model unet
tar -xzvf unet.tar.gz
```
......@@ -12,11 +12,11 @@ tar -xzvf unet.tar.gz
### Start Service
```
python -m paddle_serving_server.serve --model unet_model --gpu_ids 0 --port 9494
python3 -m paddle_serving_server.serve --model unet_model --gpu_ids 0 --port 9494
```
### Client Prediction
```
python seg_client.py
python3 seg_client.py
```
......@@ -3,7 +3,7 @@
## 获取模型
```
python -m paddle_serving_app.package --get_model unet
python3 -m paddle_serving_app.package --get_model unet
tar -xzvf unet.tar.gz
```
......@@ -12,11 +12,11 @@ tar -xzvf unet.tar.gz
### 启动服务端
```
python -m paddle_serving_server.serve --model unet_model --gpu_ids 0 --port 9494
python3 -m paddle_serving_server.serve --model unet_model --gpu_ids 0 --port 9494
```
### 客户端预测
```
python seg_client.py
python3 seg_client.py
```
......@@ -13,14 +13,14 @@ In order to show the time consuming of each stage more intuitively, a script is
When using, first save the output of the client to a file, taking `profile` as an example.
```
python show_profile.py profile ${thread_num}
python3 show_profile.py profile ${thread_num}
```
Here the `thread_num` parameter is the number of processes when the client is running, and the script will calculate the average time spent in each phase according to this parameter.
The script calculates the time spent in each stage, divides by the number of threads to average, and prints to standard output.
```
python timeline_trace.py profile trace
python3 timeline_trace.py profile trace
```
The script converts the time-dot information in the log into a json format and saves it to a trace file. The trace file can be visualized through the tracing function of the Chrome browser.
......
......@@ -13,14 +13,14 @@ export FLAGS_profile_server=1 #开启server端各阶段时间打点
使用时先将client的输出保存到文件,以profile为例。
```
python show_profile.py profile ${thread_num}
python3 show_profile.py profile ${thread_num}
```
这里thread_num参数为client运行时的进程数,脚本将按照这个参数来计算各阶段的平均耗时。
脚本将计算各阶段的耗时,并除以线程数做平均,打印到标准输出。
```
python timeline_trace.py profile trace
python3 timeline_trace.py profile trace
```
脚本将日志中的时间打点信息转换成json格式保存到trace文件,trace文件可以通过chrome浏览器的tracing功能进行可视化。
......
......@@ -13,15 +13,15 @@ sh get_data.sh
### Start server
You can use the following code to start the RPC service
```shell
python -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393 --use_lite --use_xpu --ir_optim
python3 -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393 --use_lite --use_xpu --ir_optim
```
### Client prediction
The `paddlepaddle` package is used in `test_client.py`, and you may need to download the corresponding package(`pip install paddlepaddle`).
The `paddlepaddle` package is used in `test_client.py`, and you may need to download the corresponding package(`pip3 install paddlepaddle`).
``` shell
python test_client.py uci_housing_client/serving_client_conf.prototxt
python3 test_client.py uci_housing_client/serving_client_conf.prototxt
```
## HTTP service
......@@ -30,7 +30,7 @@ python test_client.py uci_housing_client/serving_client_conf.prototxt
Start a web service with default web service hosting modules:
``` shell
python -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393 --use_lite --use_xpu --ir_optim --name uci
python3 -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393 --use_lite --use_xpu --ir_optim --name uci
```
### Client prediction
......
......@@ -15,21 +15,21 @@ sh get_data.sh
### 开启服务端
``` shell
python test_server.py uci_housing_model/
python3 test_server.py uci_housing_model/
```
也可以通过下面的一行代码开启默认RPC服务:
```shell
python -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393 --use_lite --use_xpu --ir_optim
python3 -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393 --use_lite --use_xpu --ir_optim
```
### 客户端预测
`test_client.py`中使用了`paddlepaddle`包,需要进行下载(`pip install paddlepaddle`)。
`test_client.py`中使用了`paddlepaddle`包,需要进行下载(`pip3 install paddlepaddle`)。
``` shell
python test_client.py uci_housing_client/serving_client_conf.prototxt
python3 test_client.py uci_housing_client/serving_client_conf.prototxt
```
## HTTP服务
......@@ -39,7 +39,7 @@ python test_client.py uci_housing_client/serving_client_conf.prototxt
通过下面的一行代码开启默认web服务:
``` shell
python -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393 --use_lite --use_xpu --ir_optim --name uci
python3 -m paddle_serving_server.serve --model uci_housing_model --thread 10 --port 9393 --use_lite --use_xpu --ir_optim --name uci
```
### 客户端预测
......
......@@ -3,7 +3,7 @@
## Get Model
```
python -m paddle_serving_app.package --get_model resnet_v2_50_imagenet
python3 -m paddle_serving_app.package --get_model resnet_v2_50_imagenet
tar -xzvf resnet_v2_50_imagenet.tar.gz
```
......@@ -12,11 +12,11 @@ tar -xzvf resnet_v2_50_imagenet.tar.gz
### Start Service
```
python -m paddle_serving_server.serve --model resnet_v2_50_imagenet_model --port 9393 --use_lite --use_xpu --ir_optim
python3 -m paddle_serving_server.serve --model resnet_v2_50_imagenet_model --port 9393 --use_lite --use_xpu --ir_optim
```
### Client Prediction
```
python resnet50_client.py
python3 resnet50_client.py
```
......@@ -3,7 +3,7 @@
## 获取模型
```
python -m paddle_serving_app.package --get_model resnet_v2_50_imagenet
python3 -m paddle_serving_app.package --get_model resnet_v2_50_imagenet
tar -xzvf resnet_v2_50_imagenet.tar.gz
```
......@@ -12,11 +12,11 @@ tar -xzvf resnet_v2_50_imagenet.tar.gz
### 启动服务端
```
python -m paddle_serving_server.serve --model resnet_v2_50_imagenet_model --port 9393 --use_lite --use_xpu --ir_optim
python3 -m paddle_serving_server.serve --model resnet_v2_50_imagenet_model --port 9393 --use_lite --use_xpu --ir_optim
```
### 客户端预测
```
python resnet50_client.py
python3 resnet50_client.py
```
......@@ -26,5 +26,5 @@ python3 -m paddle_serving_server.serve --model serving_server --port 7702 --use_
### Client Prediction
```
python vgg19_client.py
python3 vgg19_client.py
```
......@@ -5,19 +5,19 @@
## Get Model
```
python -m paddle_serving_app.package --get_model yolov4
python3 -m paddle_serving_app.package --get_model yolov4
tar -xzvf yolov4.tar.gz
```
## Start RPC Service
```
python -m paddle_serving_server.serve --model yolov4_model --port 9393 --gpu_ids 0
python3 -m paddle_serving_server.serve --model yolov4_model --port 9393 --gpu_ids 0
```
## Prediction
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
After the prediction is completed, a json file to save the prediction result and a picture with the detection result box will be generated in the `./outpu folder.
......@@ -5,20 +5,20 @@
## 获取模型
```
python -m paddle_serving_app.package --get_model yolov4
python3 -m paddle_serving_app.package --get_model yolov4
tar -xzvf yolov4.tar.gz
```
## 启动RPC服务
```
python -m paddle_serving_server.serve --model yolov4_model --port 9393 --gpu_ids 0
python3 -m paddle_serving_server.serve --model yolov4_model --port 9393 --gpu_ids 0
```
## 预测
```
python test_client.py 000000570688.jpg
python3 test_client.py 000000570688.jpg
```
预测完成会在`./output`文件夹下生成保存预测结果的json文件以及标出检测结果框的图片。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册