天天看點

【人工智能】比PS還好用!paddlehub批量摳圖大法好!python

比PS還好用!paddlehub批量摳圖大法好!不得不說,這個模型還是非常智能的,可以識别到主體是什麼,然後進行智能化摳圖處理。

1. 子產品下載下傳

python -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
           
pip install paddlehub
           

2. 代碼傳送門

import os
import sys
import paddlehub as hub

# 加載模型
humanseg = hub.Module(name = "deeplabv3p_xception65_humanseg")

# 指定摳圖圖檔目錄
path = './image/'
files = []
dirs = os.listdir(path)
for diretion in dirs:
    files.append(path + diretion)

# 摳圖
results = humanseg.segmentation(data = {"image":files})

for result in results:
    print(result['origin'])
    print(result['processed'])
           

效果展示:

【人工智能】比PS還好用!paddlehub批量摳圖大法好!python