我正在尝试使用YOLO从图像中提取边界框。 所以,我有一个包含3个元素的列表,每个元素是一个形状数组:(255,26,26),(255,52,52),(255,13,13)。你知道吗
我想将数组的第一个元素(255)减少到最后250个元素,并提取最大值。你知道吗
我尝试了下面的代码,但是我得到了很高的索引值,我不知道为什么。你知道吗
我得到这个错误:
confidence = scores[classID] IndexError: index 56097 is out of bounds for axis 0 with size 250
image = cv.imread(some image)
ln = net.getLayerNames()
ln = [ln[i[0] - 1] for i in net.getUnconnectedOutLayers()]
blob = cv.dnn.blobFromImage(cv.resize(image,(416, 416)),1 / 255.0, (416, 416),swapRB=True, crop=False)
net.setInput(blob)
layerOutputs = net.forward(ln)
boxes = []
confidences = []
classIDs = []
for output in layerOutputs:
for detection in output:
print(detection.shape)
scores = detection[5:]
classID = np.argmax(scores)
print(scores.shape)
print(classID)
confidence = scores[classID]
我期望classID输出在0到249之间,第一次迭代得到56097。 对于其他迭代,我也得到了很高的值:
不带此代码行的输出
confidence = scores[classID]
(255, 26, 26)
(250, 26, 26)
56097
(255, 52, 52)
(250, 52, 52)
454245
(255, 13, 13)
(250, 13, 13)
13570
目前没有回答
相关问题 更多 >
编程相关推荐