安装 paddlepaddle
https://www.paddlepaddle.org.cn/install/quick
pip3 install paddlepaddle -i https://mirror.baidu.com/pypi/simple
安装 paddlehub
pip3 install -i https://mirror.baidu.com/pypi/simple paddlehub
代码
import os
import sys
import paddlehub as hub
def matting():
humanseg = hub.Module(name="deeplabv3p_xception65_humanseg")
path = './image/matting/source/'
files = []
dirs = os.listdir(path)
for diretion in dirs:
files.append(path + diretion)
# deal
results = humanseg.segmentation(data={"image": files})
for result in results:
print(result)