Я просматриваю среднюю страницу для обнаружения лиц, все работает нормально, пока я не дохожу до детали model.forward (), где я получаю сообщение об ошибке -215 assertionfailed
https://towardsdatascience.com/extracting-faces-using-opencv-face-detection-neural-network-475c5cd0c260
import os
import cv2
import numpy as np
import os.path
print(os.path.dirname(os.path.abspath("__file__")))
base_dir = os.path.dirname(os.path.abspath("__file__"))
prototxt_path = os.path.join(base_dir + '/modeling/deploy.prototxt')
print(prototxt_path)
caffemodel_path = os.path.join(base_dir + '/modeling/weights.caffemodel')
model = cv2.dnn.readNetFromCaffe(prototxt_path, caffemodel_path)
# Create directory 'updated_images' if it does not exist
if not os.path.exists('updated_images'):
print("New directory created")
os.makedirs('updated_images')
# Create directory 'faces' if it does not exist
if not os.path.exists('faces'):
print("New directory created")
os.makedirs('faces')
# Loop through all images and save images with marked faces
for file in os.listdir(base_dir + '/images'):
file_name, file_extension = os.path.splitext(file)
if (file_extension in ['.png','.jpg']):
print("Image path: {}".format(base_dir + '/images/' + file))
#detecting faces
image = cv2.imread(base_dir + '/images/'+ "IMG_3452.jpg")
(h, w) = image.shape[:2]
print(h,w)
blob = cv2.dnn.blobFromImage(cv2.resize(image, (300, 300)), 1, (300, 300), (104, 177, 123))
model.setInput(blob)
detection = model.forward()
Это ошибка, которую я получаю, когда достигаю model.forward ()
detection = model.forward()
Traceback (most recent call last):
File "<ipython-input-99-f09773792d09>", line 1, in <module>
detection = model.forward()
error: OpenCV(3.4.2) C:\Miniconda3\conda-bld\opencv-suite_1534379934306\work\modules\dnn\src\layers\batch_norm_layer.cpp:35: error: (-215:Assertion failed) blobs.size() >= 2 in function 'cv::dnn::BatchNormLayerImpl::BatchNormLayerImpl'