python抠出图片人像_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+OpenCV图像人脸识别人数统计:

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

本文地址:https://blog.csdn.net/alicema1111/article/details/107054963

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值