[Docs] rename ppseg kunlun docs -> kunlunxin (#1662)

* [Docs] rename ppseg kunlun -> kunlunxin

* [Docs] rename ppseg fastdeploy kunlun docs -> kunlunxin
This commit is contained in:
DefTruth
2023-03-20 19:46:18 +08:00
committed by GitHub
parent d522ef28b4
commit af18e597d0
10 changed files with 20 additions and 20 deletions

View File

@@ -0,0 +1,44 @@
[English](README.md) | 简体中文
# PaddleSeg XPU Python部署示例
本目录下提供`infer.py`快速完成PP-LiteSeg昆仑芯 XPU上部署的示例。
## 1. 部署环境准备
在部署前需自行编译基于昆仑XPU的FastDeploy python wheel包并安装参考文档[昆仑芯XPU部署环境](https://github.com/PaddlePaddle/FastDeploy/blob/develop/docs/cn/build_and_install#自行编译安装)
## 2. 部署模型准备
在部署前,请准备好您所需要运行的推理模型,你可以选择使用[预导出的推理模型](../README.md)或者[自行导出PaddleSeg部署模型](../README.md),如果你部署的为**PP-Matting**、**PP-HumanMatting**以及**ModNet**请参考[Matting模型部署](../../../matting)。
## 3. 运行部署示例
```bash
# 下载部署示例代码
git clone https://github.com/PaddlePaddle/FastDeploy.git
cd FastDeploy/examples/vision/segmentation/semantic_segmentation/kunlunxin/python
# 如果您希望从PaddleSeg下载示例代码请运行
# git clone https://github.com/PaddlePaddle/PaddleSeg.git
# # 注意如果当前分支找不到下面的fastdeploy测试代码请切换到develop分支
# # git checkout develop
# cd PaddleSeg/deploy/fastdeploy/semantic_segmentation/kunlunxin/python
# 下载PP-LiteSeg模型文件和测试图片
wget https://bj.bcebos.com/paddlehub/fastdeploy/PP_LiteSeg_B_STDC2_cityscapes_without_argmax_infer.tgz
tar -xvf PP_LiteSeg_B_STDC2_cityscapes_without_argmax_infer.tgz
wget https://paddleseg.bj.bcebos.com/dygraph/demo/cityscapes_demo.png
# 华为昇腾推理
python infer.py --model PP_LiteSeg_B_STDC2_cityscapes_without_argmax_infer --image cityscapes_demo.png
```
运行完成可视化结果如下图所示
<div align="center">
<img src="https://user-images.githubusercontent.com/16222477/191712880-91ae128d-247a-43e0-b1e3-cafae78431e0.jpg", width=512px, height=256px />
</div>
## 4. 更多指南
- [PaddleSeg python API文档](https://www.paddlepaddle.org.cn/fastdeploy-api-doc/python/html/semantic_segmentation.html)
- [FastDeploy部署PaddleSeg模型概览](..)
- [PaddleSeg C++部署](../cpp)
## 5. 常见问题
- [如何将模型预测结果SegmentationResult转为numpy格式](https://github.com/PaddlePaddle/FastDeploy/blob/develop/docs/cn/faq/vision_result_related_problems.md)

View File

@@ -0,0 +1,34 @@
import fastdeploy as fd
import cv2
import os
def parse_arguments():
import argparse
import ast
parser = argparse.ArgumentParser()
parser.add_argument(
"--model", required=True, help="Path of PaddleSeg model.")
parser.add_argument(
"--image", type=str, required=True, help="Path of test image file.")
return parser.parse_args()
runtime_option = fd.RuntimeOption()
runtime_option.use_kunlunxin()
# setup runtime
model_file = os.path.join(args.model, "model.pdmodel")
params_file = os.path.join(args.model, "model.pdiparams")
config_file = os.path.join(args.model, "deploy.yaml")
model = fd.vision.segmentation.PaddleSegModel(
model_file, params_file, config_file, runtime_option=runtime_option)
# predict
im = cv2.imread(args.image)
result = model.predict(im)
print(result)
# visualize
vis_im = fd.vision.vis_segmentation(im, result, weight=0.5)
cv2.imwrite("vis_img.png", vis_im)