Error de OpenCV: ConvolutionLayerImpl::getMemoryShapes() - Assertion failed

34 Views Asked by At

I'm encountering an error when trying to use an age detection script based on OpenCV, which I found on the PyImageSearch website (link).

Here's the relevant part of the script:

# load the input image and construct an input blob for the image

image = cv2.imread(args["image"])
(h, w) = image.shape[:2]
blob = cv2.dnn.blobFromImage(image, 1.0, (300, 300), (104.0, 177.0, 123.0))
# pass the blob through the network and obtain the face detections
print("[INFO] computing face detections...")
print("First Blob: {}".format(blob.shape))
faceNet.setInput(blob)
detections = faceNet.forward()

However, when I run the script with the following command:

python detect_age.py --image images/samuel_l_jackson.png --face face_detector --age age_detector

I consistently get the following error:

[ERROR:[email protected]] global net_impl.cpp:1169 cv::dnn::dnn4_v20231225::Net::Impl::getLayerShapesRecursively OPENCV/DNN: [Convolution]:(conv1): getMemoryShapes() throws exception. inputs=1 outputs=0/1 blobs=0
[ERROR:[email protected]] global net_impl.cpp:1172 cv::dnn::dnn4_v20231225::Net::Impl::getLayerShapesRecursively     input[0] = [ 1 3 224 224 ]
[ERROR:[email protected]] global net_impl.cpp:1182 cv::dnn::dnn4_v20231225::Net::Impl::getLayerShapesRecursively Exception message: OpenCV(4.9.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\layers\convolution_layer.cpp:368: error: (-215:Assertion failed) !blobs.empty() || inputs.size() > 1 in function 'cv::dnn::ConvolutionLayerImpl::getMemoryShapes'

I've verified that the input image and necessary files for the face and age detection models are all correctly specified and accessible. Can anyone help me understand and fix this error?

0

There are 0 best solutions below