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

    技术2022-07-10  139

    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由专业技术人员远程协助!

     

     

    Processed: 0.012, SQL: 9