Paddlehub创意赛---给人像增加背景
Paddlehub创意赛
这次创意赛我是实现了一个简单得抠图加背景的操作,将人像抠出来之后并为其添加一个背景。原本还想加上美颜之类的效果,因为时间关系所以放弃了。
自己试了试如果选择的背景合适的话还是很不错的。
首先配置环境
!pip install paddlehub==1.6.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
!hub install deeplabv3p_xception65_humanseg==1.0.0
导入相关的库
import paddlehub as hub
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import cv2
from PIL import Image
import numpy as np
展示原图
test_img_path = "1.jpg"
img = mpimg.imread(test_img_path)
# 展示待预测图片
plt.figure(figsize=(10,10))
plt.imshow(img)
plt.axis('off')
plt.show()
使用Paddlehub进行抠图操作
# 显示处理之后的图片
humanseg = hub.Module(name