[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/PaddlePaddle/PaddleVideo/develop/deploy/python_serving/readme.md [Back]  [Original]

 | [English](./readme_en.md)
# 

## 

[Paddle Serving](https://github.com/PaddlePaddle/Serving) 

 HTTP  PaddleVideo  PaddleServing  Linux  Windows 

## Serving 
Serving  docker  Serving  docker  Serving  docker

```bash
# GPU docker
docker pull paddlepaddle/serving:0.7.0-cuda10.2-cudnn7-devel
nvidia-docker run -p 9292:9292 --name test -dit paddlepaddle/serving:0.7.0-cuda10.2-cudnn7-devel bash
nvidia-docker exec -it test bash

# CPU docker
docker pull paddlepaddle/serving:0.7.0-devel
docker run -p 9292:9292 --name test -dit paddlepaddle/serving:0.7.0-devel bash
docker exec -it test bash
```

 docker  Serving  python 
```bash
python3.7 -m pip install paddle-serving-client==0.7.0
python3.7 -m pip install paddle-serving-app==0.7.0
python3.7 -m pip install faiss-cpu==1.7.1post2

#CPU:
python3.7 -m pip install paddle-serving-server==0.7.0  # CPU
python3.7 -m pip install paddlepaddle==2.2.0           # CPU

#GPU
python3.7 -m pip install paddle-serving-server-gpu==0.7.0.post102  # GPU with CUDA10.2 + TensorRT6
python3.7 -m pip install paddlepaddle-gpu==2.2.0                   # GPU with CUDA10.2

#GPU
python3.7 -m pip install paddle-serving-server-gpu==0.7.0.post101  # GPU with CUDA10.1 + TensorRT6
python3.7 -m pip install paddle-serving-server-gpu==0.7.0.post112  # GPU with CUDA11.2 + TensorRT8
```

*  `-i https://pypi.tuna.tsinghua.edu.cn/simple` 
* https://github.com/PaddlePaddle/Serving/blob/v0.9.0/doc/Install_Linux_Env_CN.md

## 
### 
 PaddleServing  inference  Serving  PP-TSM 
-  PP-TSM 
  ```bash
  # PaddleVideo
  cd PaddleVideo

  wget -P data/ https://videotag.bj.bcebos.com/PaddleVideo-release2.1/PPTSM/ppTSM_k400_uniform.pdparams

  python3.7 tools/export_model.py \
  -c configs/recognition/pptsm/pptsm_k400_frames_uniform.yaml \
  -p data/ppTSM_k400_uniform.pdparams \
  -o inference/ppTSM
  ```

- 
  ```bash
  mkdir ./inference
  wget -nc -P ./inference https://videotag.bj.bcebos.com/PaddleVideo-release2.3/ppTSM.zip --no-check-certificate
  pushd ./inference
  unzip ppTSM.zip
  popd
  ```
-  paddle_serving_client  Server 
  ```bash
  python3.7 -m paddle_serving_client.convert \
  --dirname inference/ppTSM \
  --model_filename ppTSM.pdmodel \
  --params_filename ppTSM.pdiparams \
  --serving_server ./deploy/python_serving/ppTSM_serving_server/ \
  --serving_client ./deploy/python_serving/ppTSM_serving_client/
  ```
  |               |  |              |                                                          |
  | ----------------- | ---- | ------------------ | ------------------------------------------------------------ |
  | `dirname`         | str  | -                  | Program |
  | `model_filename`  | str  | None               | Inference ProgramNone `__model__`  |
  | `params_filename` | str  | None               | >None |
  | `serving_server`  | str  | `"serving_server"` | serving_server |
  | `serving_client`  | str  | `"serving_client"` | serving_client       |

PP-TSM  `ppTSM_serving_server`  `ppTSM_serving_client` 
  ```bash
  PaddleVideo/deploy/python_serving
   ppTSM_serving_server
       ppTSM.pdiparams
       ppTSM.pdmodel
       serving_server_conf.prototxt
       serving_server_conf.stream.prototxt
   ppTSM_serving_client
       serving_client_conf.prototxt
       serving_client_conf.stream.prototxt
  ```
 `ppTSM_serving_server`  `ppTSM_serving_client`  `serving_server_conf.prototxt` `fetch_var`  `alias_name`  `outputs`

****:  Serving `alias_name`
`serving_server_conf.prototxt`:

```yaml
feed_var {
  name: "data_batch_0"
  alias_name: "data_batch_0"
  is_lod_tensor: false
  feed_type: 1
  shape: 8
  shape: 3
  shape: 224
  shape: 224
}
fetch_var {
  name: "linear_2.tmp_1"
  alias_name: "outputs"
  is_lod_tensor: false
  fetch_type: 1
  shape: 400
}

```
### 
`python_serving`  pipeline C++ serving(TODO)
```bash
__init__.py
configs/xxx.yaml            # pipeline
pipeline_http_client.py     # httppipelinepython
pipeline_rpc_client.py      # rpcpipelinepython
recognition_web_service.py  # pipelinepython
utils.py                    # parse_file_paths, numpy_to_base64, video_to_numpy
```
#### Python Serving
- 
```bash
cd deploy/python_serving
```

- 
```bash
# 
python3.7 recognition_web_service.py -n PPTSM -c configs/PP-TSM.yaml
# log.txt
python3.7 recognition_web_service.py -n PPTSM -c configs/PP-TSM.yaml &>log.txt &
```

- 
```bash
# http
python3.7 pipeline_http_client.py -i ../../data/example.avi

# rpc
python3.7 pipeline_rpc_client.py -i ../../data/example.avi
```
 cmd 

```bash
# http
{'err_no': 0, 'err_msg': '', 'key': ['label', 'prob'], 'value': ["['archery']", '[0.9907388687133789]'], 'tensors': []}

# rpc
PipelineClient::predict pack_data time:1645631086.764019
PipelineClient::predict before time:1645631086.8485317
key: "label"
key: "prob"
value: "[\'archery\']"
value: "[0.9907388687133789]"
```

## FAQ
**Q1** 

**A1** 
```
unset https_proxy
unset http_proxy
```

**Q2** `start proxy service`

**A2** `./deploy/python_serving/PipelineServingLogs/pipeline.log`

 `RPC `  Serving [github ](https://github.com/PaddlePaddle/Serving/tree/v0.7.0/examples)

Web Proxy Viewer  |  New URL  |  Original Page