微信公众号:OpenCV学堂
关注获取更多计算机视觉与深度学习知识
YOLOv6人脸检测模型
输出解析顺序
官方代码与参考文档给出的解析顺序,xyxy, conf, cls, lmdks,这部分还有官方的参考文件:
https://github.com/meituan/YOLOv6/blob/yolov6-face/yolov6/core/inferer.py
def wrap_detection(self, input_image, out_data):
confidences = []
boxes = []
kypts = []
rows = out_data.shape[0]
image_width, image_height, _ = input_image.shape
x_factor = image_width / 640.0
y_factor = image_height / 640.0
sd = np.zeros((5, 2), dtype=np.float32)
sd[0:5] = (x_factor, y_factor)
sd = np.squeeze(sd.reshape((-1, 1)), 1)
# xyxy, lmdks, conf, cls,
for r in range(rows):
row = out_data[r]
conf = row[14]
cls = row[15]
if (conf > 0.25 and cls > 0.25):
confidences.append(conf)
x, y, w, h = row[0].item(), row[1].item(), row[2].item(), row[3].item()
left = int((x - 0.5 * w) * x_factor)
top = int((y - 0.5 * h) * y_factor)
width = int(w * x_factor)
height = int(h * y_factor)
box = np.array([left, top, width, height])
boxes.append(box)
kypts.append(np.multiply(row[4:14], sd))
indexes = cv.dnn.NMSBoxes(boxes, confidences, 0.25, 0.25)
result_confidences = []
result_boxes = []
result_kypts = []
for i in indexes:
result_confidences.append(confidences[i])
result_boxes.append(boxes[i])
result_kypts.append(kypts[i])
return result_kypts, result_confidences, result_boxes
扫码查看OpenCV+OpenVIO+Pytorch系统化学习路线图
文章引用微信公众号"OpenCV学堂",如有侵权,请联系管理员删除!