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由專業技術人員遠程協助!