函数'cv::dnn::ConvolutionLayerImpl::getMemoryShapes'中的OpenCV深度学习人脸检测断言错误

问题描述

我跟随tutorial使用OpenCV和深度学习SSD框架从image实现了人脸检测。

modelFile = "./ssd/res10_300x300_ssd_iter_140000.caffemodel"
configFile = "./ssd/deploy.prototxt"
net = cv2.dnn.readNetFromCaffe(configFile, modelFile)
image = cv2.imread("face.jpg")
(h, w) = image.shape[:2]
blob = cv2.dnn.blobFromImage(cv2.resize(image, (300, 300)), 1.0, (300, 300), (104.0, 177.0, 123.0))
net.setInput(blob)
detections = net.forward()

detections = net.forward()返回错误:

error: OpenCV(4.0.0) C:projectsopencv-pythonopencvmodulesdnnsrclayersconvolution_layer.cpp:236: error: (-215:Assertion failed) blobs.size() != 0 in function 'cv::dnn::ConvolutionLayerImpl::getMemoryShapes'

仍在寻找更多信息,但不知道是代码错误还是库中的错误...有人知道什么会引起问题吗?任何帮助都将不胜感激。


解决方案

我无法同时使用OpenCV 3.4.2和OpenCV 4.0.0重现您的问题。

我得到的是:

附注:我从https://raw.githubusercontent.com/opencv/opencv_3rdparty/dnn_samples_face_detector_20170830/res10_300x300_ssd_iter_140000.caffemodel下载res10_300x300_SSD_ITER_140000.caffModel,从https://github.com/opencv/opencv/raw/3.4.0/samples/dnn/face_detector/deploy.prototxt下载部署.Prototxt。

相关文章