利用PaddleHub实现人脸检测
1. 安装库命令
!pip install paddlehub==1.6.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
2. Paddle代码
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import paddlehub as hub
test_img_path = ["./zhouyu.png", "./yzd.png", "./youhua.png", "./nezha.png"]
img = mpimg.imread(test_img_path[0])
with open('test.txt', 'r') as f:
test_img_path=[]
for line in f:
test_img_path.append(line.strip())
print(test_img_path)
module = hub.Module(name="ultra_light_fast_generic_face_detector_1mb_640")
input_dict = {"image": test_img_path}
results = module.face_detection(data=input_dict, visualization=True)
for result in results:
print(result)
for img_name in test_img_path:
img = mpimg.imread("face_detector_640_predict_output/" + img_name)
plt.figure(figsize=(10,10))
plt.imshow(img)
plt.axis('off')
plt.show()