百度AI攻略:Paddlehub人臉檢測

PaddleHub能夠便捷地獲取PaddlePaddle生態下的預訓練模型,完成模型的管理和一鍵預測。配合使用Fine-tune API,能夠基於大規模預訓練模型快速完成遷移學習,讓預訓練模型能更好地服務於用戶特定場景的應用。學習

本次介紹如何使用paddlehub實現人臉檢測。設計

模型概述blog

Ultra-Light-Fast-Generic-Face-Detector-1MB是針對邊緣計算設備或低算力設備(如用ARM推理)設計的實時超輕量級通用人臉檢測模型,能夠在低算力設備中如用ARM進行實時的通用場景的人臉檢測推理。該PaddleHub Module的預訓練數據集爲WIDER FACE數據集,可支持預測,在預測時會將圖片輸入縮放爲640 * 480。圖片

代碼以下:input

import matplotlib.pyplot as pltio

import matplotlib.image as mpimgast

import paddlehub as hubtest

module = hub.Module(name="ultra_light_fast_generic_face_detector_1mb_640")import

# 待預測圖片module

test_img_path = ["./crowd1.jpg"]

img = mpimg.imread(test_img_path[0])

# 展現待預測圖片

plt.imshow(img)

plt.axis('off')

plt.show()

input_dict = {"image": test_img_path}

# execute predict and print the result

results = module.face_detection(data=input_dict)

for result in results:

    print(result)

# 預測結果展現

img = mpimg.imread("./face_detector_640_predict_output/crowd1.jpg")

plt.imshow(img)

plt.axis('off')

plt.show()

效果:

相關文章
相關標籤/搜索