文章目录
-
-
- 一、口罩检测模型
- 二、人像抠图模型
- 三、风格迁移模型
paddlehub官网 www.paddlepaddle.org.cn/hub
paddlehub git网址 github.com/PaddlePaddle/PaddleHub
paddlehub课程地址 aistudio.baidu.cn/aistudio/course/introduce/1070
paddlehub教程地址 aistudio.baidu.cn/aistudio/personalcenter/thirdview/79927
paddlehub魔性地址 github.com/PaddlePaddle/PaddleHub/tree/release/v1.6/demo
一、口罩检测模型
"""
检测是否带口罩
"""
import paddlehub as hub
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import cv2
module=hub.Module(name="pyramidbox_lite_mobile_mask")
test_img_path="qisui.jpg"
input_dict={"data":[cv2.imread(test_img_path)]}
results=module.face_detection(data=input_dict,use_multi_scale=True,
shrink=0.6,
visualization=True,
output_dir= 'result')
print(results[0])
test_img_path="./result/"+results[0]['path'][:-2]+".jpg"
print(test_img_path)
img=mpimg.imread(test_img_path)
plt.figure(figsize=(10,10))
plt.imshow(img)
plt.axis("off")
plt.show()
二、人像抠图模型
"""
安装人像抠图的模块
"""
import paddlehub as hub
humanseg=hub.Module(name="deeplabv3p_xception65_humanseg")
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
results=humanseg.segmentation(data={"image":["qisui.jpg"]},visualization=True)
test_img_path=results[0]['save_path']
img=mpimg.imread(test_img_path)
plt.figure(figsize=(10,10))
plt.imshow(img)
plt.axis("off")
plt.show()
三、风格迁移模型
"""
风格迁移
"""
import paddlehub as hub
import cv2
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
stylepro_artistic=hub.Module(name="stylepro_artistic")
test_image=[{"content":cv2.imread("qisui.jpg"),"styles":[cv2.imread("shangguan.jpg")]}]
results=stylepro_artistic.style_transfer(images=test_image,alpha=1.0,visualization=True)
test_img_path=results[0]["save_path"]
res_img=mpimg.imread(test_img_path)
plt.imshow(res_img)
plt.axis("off")
plt.show()