PaddleHub 视频人脸检测

测试视频效果特别差,漏检很多,比ritinaface都差 

import time

import cv2

import paddlehub as hub

# 将模型保存在test_program文件夹之中
# module.processor.save_inference_model(dirname="test_program")

# module = hub.Module(name="pyramidbox_lite_mobile_mask")
module = hub.Module(name="pyramidbox_lite_mobile")


def detct_video():
    # vc = cv2.VideoCapture(r"D:\project\face\torch_Retina_face_bifpn_bce_0112_158_eval\models\capture\0.mp4")  # 读入视频文件
    vc = cv2.VideoCapture(0)  # 读入视频文件

    index=0
    while True:  # 循环读取视频帧
        index+=1
        rval, img_o = vc.read()

        if img_o is None:
            break
        if index%2==0:
            continue
        input_dict = {"data": [img_o]}
        start = time.time()
        # execute predict and print the result
        results = module.face_detection(data=input_dict)
        for result in results:
            if len(result['data'])>0:
                left = float(result['data'][0]['left'])
                right = float(result['data'][0]['right'])
                bottom = float(result['data'][0]['bottom'])
                top = float(result['data'][0]['top'])
                conf = float(result['data'][0]['confidence'])
                color = (0, 255, 0)
                # if result['data']['label'] != 'MASK':
                #     color = (0, 0, 255)
                cv2.rectangle(img_o, (int(left), int(top)), (int(right), int(bottom)), color, 1)
        print("time", time.time() - start)
        cv2.imshow("asdf", img_o)
        cv2.waitKey(1)

if __name__ == '__main__':
    detct_video()
    #640 480 100ms 有漏检

 

你可能感兴趣的:(深度学习)