实时扣图部署流程与能力展示

释放双眼,带上耳机,听听看~!
本文介绍了使用Python和CPU部署流程展示实时扣图模型的能力,并提供了API调用和集成到项目中的步骤。

携手创作,共同成长!这是我参与「掘金日新计划 · 8 月更文挑战」的第29天,github.com/PaddlePaddl…

实时扣图部署流程与能力展示

**### 待部署模型能力展示——实时扣图

实时扣图部署流程与能力展示

1. Python + CPU部署流程

运行Demo,感受部署能力

1.安装FastDeploy的lib2.准备实时扣图MODNet模型 和 推理示例代码
3.运行推理代码

API调用,集成到自己项目中

## 运行Demo,感受部署能力
# (1) 安装FastDeploy CPU库
!pip install fastdeploy-python -f https://www.paddlepaddle.org.cn/whl/fastdeploy.html -q
# (2)准备MODNet模型和推理示例代码
# 推理示例代码;(如果是自己调用API完成,这部分代码都可以不用下载)
# !git clone https://gitee.com/PaddlePaddle/FastDeploy.git
%cd FastDeploy/examples/vision/matting/modnet/python/
/home/aistudio/FastDeploy/examples/vision/matting/modnet/python
!pip list|grep fastdeploy
fastdeploy-python      0.2.0
# 下载提前转换好的推理模型和图像
!wget https://bj.bcebos.com/paddlehub/fastdeploy/modnet_photographic_portrait_matting.onnx
# !wget https://raw.githubusercontent.com/DefTruth/lite.ai.toolkit/main/examples/lite/resources/test_lite_matting_input.jpg

--2022-08-26 16:39:02--  https://raw.githubusercontent.com/DefTruth/lite.ai.toolkit/main/examples/lite/resources/test_lite_matting_input.jpg
正在解析主机 raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...
正在连接 raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 278476 (272K) [image/jpeg]
正在保存至: “test_lite_matting_input.jpg”

         test_lite_   0%[                    ]   1.34K   327 B/s    eta 14m 7s ^C
# CPU 推理预测,输出结果保存在FastDeploy/examples/vision/matting/modnet/python/visualized_result.jpg图像中
!python infer.py --model modnet_photographic_portrait_matting.onnx --image 1.jpg --device cpu
Visualized result save in ./visualized_result.jpg

#API调用,集成到自己项目中(需按FastDeploy模型文档要求,准备好部署模型;或者直接下载FastDeploy中已经提供好的模型)

(此处打开infer.py直接讲解就行。)

实时扣图部署流程与能力展示

实时扣图部署流程与能力展示

2. Python + GPU部署流程

特别说明:

  1. GPU部署与CPU部署流程区别:
  • GPU部署,需要提前准备好CUDA>=11.2环境要求,CUCA版本需要按照FastDeploy软硬件要求来
  • aistudio上的GPU环境,目前只有A100 40G满足CUDA>=11.2要求
#安装FastDeploy-GPU版本
!pip install fastdeploy-gpu-python -f https://www.paddlepaddle.org.cn/whl/fastdeploy.html
# 准备MODNet模型和推理示例代码
# 推理示例代码
!git clone https://github.com/PaddlePaddle/FastDeploy.git
%cd FastDeploy/examples/vision/matting/modnet/python/

# 下载提前转换好的推理模型和图像
# 注意:测试图像目前放在github上,wget有一些慢,如果自己有测试图像,可以选择跳过。
!wget https://bj.bcebos.com/paddlehub/fastdeploy/modnet_photographic_portrait_matting.onnx
!wget https://raw.githubusercontent.com/DefTruth/lite.ai.toolkit/main/examples/lite/resources/test_lite_matting_input.jpg

# GPU 推理预测,输出结果保存在FastDeploy/examples/vision/matting/modnet/python/visualized_result.jpg图像中
!python infer.py --model modnet_photographic_portrait_matting.onnx --image test_lite_matting_input.jpg --device gpu
本网站的内容主要来自互联网上的各种资源,仅供参考和信息分享之用,不代表本网站拥有相关版权或知识产权。如您认为内容侵犯您的权益,请联系我们,我们将尽快采取行动,包括删除或更正。
AI教程

Reetail: AI Powered E-commerce Store Builder

2023-12-8 7:12:14

AI教程

前向梯度学习的实用性:来自图灵奖得主 Geoffrey Hinton 的最新研究

2023-12-8 8:20:14

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索