百度飞桨paddlepaddle人脸检测主题创意赛参加记录

百度飞桨人脸检测主题创意赛参加记录

  • 今天报名参加了百度飞桨的人脸检测主题创意赛,重在(xiao)参(li)与(pin)~~~

今天报名参加了百度飞桨的人脸检测主题创意赛,重在(xiao)参(li)与(pin)~~~

https://aistudio.baidu.com/aistudio/projectdetail/402840

这是我的项目地址,fork了官方的人脸检测示例,结果运行的时候提示没有保存预测图片,(paddlehub真的太好用了,几行代码运行各种深度学习模型,伸手党的福利啊,这里墙裂推荐一波)
这是官方代码块

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/test_face_detection.jpg")
plt.figure(figsize=(10,10))
plt.imshow(img) 
plt.axis('off') 
plt.show()

没发现里面有存result的矩形框的代码,当然我也不太熟悉,就没去太多了解,为了速度参赛拿早鸟奖(坏笑),我就打算自己写一段画矩形框的代码。
于是自己利用patches,把模型预测的人脸矩形图数据进行了处理,在坐标轴上用红线画出来了。详见项目内部
部分代码如下:

import matplotlib.patches as patches
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['data'][0])

#get the rectangle's start point and width and hight
temp = result['data'][0]
start_point = (temp['left'],temp['top'])
width = int(temp['right']) - int(temp['left'])
hight = int(temp['bottom']) - int(temp['top'])
# 预测结果展示
img = mpimg.imread("./test_face_detection.jpg")
#plt.figure(figsize=(10,10))
fig,ax = plt.subplots(1)
# Display the image
ax.imshow(img)
# Create a Rectangle patch
rect = patches.Rectangle(start_point,width,hight,linewidth=2,edgecolor='r',facecolor='none')
# Add the patch to the Axes
ax.add_patch(rect)
#plt.axis('off') 
plt.show()

礼品多多,惊喜多多,大家多多参与官方的比赛奥~~~冲鸭!!!

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