Мой код
model = ResNet50(weights='imagenet')
def read_cam(video_capture):
if video_capture.isOpened():
windowName = "yolo"
cv2.namedWindow(windowName, cv2.WINDOW_NORMAL)
cv2.resizeWindow(windowName, 1280, 720)
cv2.moveWindow(windowName, 0, 0)
cv2.setWindowTitle(windowName, "Yolo Object Detection")
while True:
# Check to see if the user closed the window
if cv2.getWindowProperty(windowName, 0) < 0:
break
ret_val, frame = video_capture.read()
print(frame)
frame = np.expand_dims(frame, axis=0)
frame = preprocess_input(frame)
preds = model.predict(frame)
# print(preds)
print('Predicted:', decode_predictions(preds, top=3)[0])
Однако это вызывает несколько ошибок.Во-первых, очевидно, он ожидает массив другого размера:
ValueError: Error when checking input: expected input_1 to have shape (224, 224, 3) but got array with shape (720, 1280, 3)