├── images_input └── b.jpg ├── humanseg_output └── b.png ├── 先看这个.txt └── skin.py /images_input/b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3150601355/PaddleDemo/HEAD/images_input/b.jpg -------------------------------------------------------------------------------- /humanseg_output/b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3150601355/PaddleDemo/HEAD/humanseg_output/b.png -------------------------------------------------------------------------------- /先看这个.txt: -------------------------------------------------------------------------------- 1 | 0. 这个例子使用百度飞桨给人物去除背景,可以用来做证件照之类的。 2 | 3 | 1. 使用代码前建议仔细看一下我在B站的视频。 该安装的轮子一定要装。 4 | 5 | 2. 预训练模型“deeplabv3p_xception65_humanseg”在第一次使用时会被自动下载,这会占用一些时间(取决于你的网速),第二次运行时会从本地自动加载,运行起来就快多了。 6 | -------------------------------------------------------------------------------- /skin.py: -------------------------------------------------------------------------------- 1 | import os 2 | import paddlehub as hub 3 | 4 | # 加载模型 5 | seg = hub.Module(name='deeplabv3p_xception65_humanseg', version="1.0.0") 6 | 7 | # 要处理的文件目录 8 | path = './images_input/' 9 | 10 | # 获取文件列表 11 | files = [path + i for i in os.listdir(path)] 12 | 13 | # 抠图 14 | results = seg.segmentation(data={'image': files}, 15 | output_dir = './humanseg_output/') 16 | --------------------------------------------------------------------------------