使用paddle hub进行合影头像提取

本文介绍了在人脸识别项目中使用PaddleHub的PyramidBox模型进行头像提取的试验。虽然PyramidBox在效果上优于其他模型,但其封装不够完善,无法直接指定输出图片路径和控制可视化。作者指出,对于遮挡情况,只要露出两只眼睛,模型就能较好地识别。
摘要由CSDN通过智能技术生成

最近有人脸识别的项目需要预研,我就把paddle hub拿出来做一下试验。试用了几个模型,配置和使用大同小异,这里把pyramidbox整理出来。

官方链接

https://www.paddlepaddle.org.cn/modelbasedetail/pyramidbox

代码

import paddlehub as hub
import cv2
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline

module = hub.Module(name="pyramidbox_face_detection")

test_img_path = "test2.jpg"

# set input dict
input_dict = {"image": [test_img_path]}

# execute predict and print the result
results = module.face_detection(data=input_dict)

image=cv2.imread(test_img_path)
for result in results[0]['data']:
    #print(result)
    top=int(image.shape[0]*float(result['top']))
    bottom=int(image.shape[0]*float(result['bottom']))
    left=int(image.shape[1]*float(result['left']))
    right=int(image.shape[1]*float(result['right']))
    
    image_cut=image[top:bottom,left:right]
    image_cut=cv2.cvtColor(image_cut,cv2.COLOR_BGR2RGB)
    #plt.figure(figsize=(10,10))
    plt.imshow(image_cut)
    plt.axis("off")
    plt.show()

思考和问题

1)paddlehub的封装还不够,pyramidbox模型无法指定输出图片路径,不能通过api控制输出,相比较ultra_light_fast_generic_face_detector差一点
results = module.face_detection(data=input_dict,output_dir=’./output_ultra_light_fast_generic_face_detector_1mb_640/’,visualization=True)
2)从效果来讲,pyramidbox较好
遮挡的头像可以正确识别
‘confidence’: 0.3070993721485
遮挡的头像可以正确识别,
‘confidence’: 0.151697039604187
感觉遮挡的,只要露出两个眼睛,就很好了,侧脸测试因为在合影场景不大可能实现,下一个场景再做测试。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值