【人工智能】python代码检测人脸是否佩戴口罩,paddlehub

检测人脸是否佩戴口罩需要用到的是人工智能的paddlehub模块中的pyramidbox_lite_mobile_mask模型。

代码传送门:

import paddlehub as hub
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

# 待预测图图片
test_img_path = ["1.jpg"]

# 载入模型
module = hub.Module(name = "pyramidbox_lite_mobile_mask")

# 预测
input_dict = {"image": test_img_path}
results = module.face_detection(data = input_dict)

# 结果展示
img = mpimg.imread("1.jpg")
plt.figure(figsize = (10, 10))
plt.imshow(img)
plt.axis('off')
plt.show()

极简两行代码:

import paddlehub as hub

# 载入模型
module = hub.Module(name = "pyramidbox_lite_mobile_mask")

results = module.face_detection(data = {"image": ["1.jpg"]})

效果展示:

红色框代表没有佩戴,绿色框代表已经佩戴口罩,后面的百分比代表概率

从测试结果可以看到,这个模型还是准确度很高。 

原文地址:https://www.cnblogs.com/helenlee01/p/12707315.html