cv2.dnn_Net.forward()函数到底返回了什么



我使用cv2.dnn_Net.forward()(前向传播(用于人脸检测预训练模型。然而,我无法理解使用cv2.dnn_Net.forward()函数返回的变量(下面是detections变量(的想法。

face_net = cv2.dnn.readNet(face_prototxt_path, face_weights_path) 
image = cv2.imread(args["image_path"])
(h, w) = image.shape[:2]
blob = cv2.dnn.blobFromImage(image, 1.0, (300, 300),
(104.0, 177.0, 123.0))
face_net.setInput(blob)   
detections = face_net.forward() # cv2.dnn_Net.forward() function
# Utilizing 'detections' variable
confidence = detections[0, 0, i, 2]
box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])

cv2.dnn_Net.forward()究竟返回了什么?它们如何被用作detections[0, 0, i, 2]detections[0, 0, i, 3:7]

cv2.dnn.readNet获取您的模型的权重文件和配置文件来加载您保存的模型。

net.forward()-运行正向传递以计算净输出。

你的检测,即net.forward()将给出Numpy ndarray作为输出,你可以使用它在给定的输入图像上绘制方框。

最新更新