Only (1,2) will be called so that the 'IndexError: tuple index out of range' error occurs. Is it a matter of my cnn neural network?
1 | initial version |
Only (1,2) will be called so that the 'IndexError: tuple index out of range' error occurs. Is it a matter of my cnn neural network?
2 | retagged |
Only (1,2) will be called so that the 'IndexError: tuple index out of range' error occurs. Is it a matter of my cnn neural network?
import cv2 as cv
import numpy as np
net = cv.dnn.readNetFromTensorflow('./model/tf_model.pb', './model/model.pbtxt')
img = cv.imread('./data/frame63.jpg')
(h, w) = img.shape[:2]
#cvNet.setInput(cv.dnn.blobFromImage(img, size=(32, 32), swapRB=True, crop=False))
net.setInput (cv.dnn.blobFromImage (img, 1.0 / 127.5, (32, 32), (127.5, 127.5, 127.5), swapRB = True, crop =
False))
detections = net.forward()
print(detections.shape)
for i in range(0, detections.shape[2]):
box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
startX, startY, endX, endY) = box.astype("int")
confidence = detections[0, 0, i, 2]
# If confidence > 0.5, show box around face
if (confidence > 0.5):
cv.rectangle(img, (startX, startY), (endX, endY), (255, 255, 255), 2)
cv.imshow('img', img)
cv.waitKey()
Only (1,2) will be called so that the 'IndexError: tuple index out of range' error occurs. Is it a matter of my cnn neural network?