Python+Paddlehub相片人像抠图精简源码实例

Python+Paddlehub相片人像抠图实例

无需PS软件,手动制作自己的抠图工具,在只有一张图片,需要细致地抠出人物的情况下,能帮你减少抠图步骤;在有多张图片需要抠的情况下,能直接帮你输出这些人物的基本轮廓

准备相片:

安装相关的依赖包:

python -m pip install paddlepaddle

上传或拷贝需要抠图的图片和背景图片放到对应的文件夹中,并通过代码加载需要抠图的图片,进行展示:


# 待预测图片
test_img_path = ["./girl.jpg"]


import matplotlib.pyplot as plt 
import matplotlib.image as mpimg 

img = mpimg.imread(test_img_path[0]) 

# 展示待预测图片
plt.figure(figsize=(10,10))
plt.imshow(img) 
plt.axis('off') 
plt.show()

加载预训练模型

import paddlehub as hub

module = hub.Module(name="deeplabv3p_xception65_humanseg")

input_dict = {"image": test_img_path}

# execute predict and print the result
results = module.segmentation(data=input_dict)
for result in results:
    print(result)

# 预测结果展示
test_img_path = "./humanseg_output/girl.png"
img = mpimg.imread(test_img_path)
plt.figure(figsize=(10,10))
plt.imshow(img) 
plt.axis('off') 
plt.show()

 

运行效果展示:

Python学习参考实例

Python相片更换背景颜色qt窗体程序:
https://blog.csdn.net/alicema1111/article/details/106919140

Python+OpenCV图像人脸识别人数统计

https://blog.csdn.net/alicema1111/article/details/105378639

如需安装运行环境或远程调试,可加QQ905733049由专业技术人员远程协助!

 

 

  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

荷塘月色2

您的鼓励将是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值