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

问题描述 投票:1回答:2

我跟随tutorialimage用OpenCV和深度学习SSD框架实现面部检测。

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:\projects\opencv-python\opencv\modules\dnn\src\layers\convolution_layer.cpp:236: error: (-215:Assertion failed) blobs.size() != 0 in function 'cv::dnn::ConvolutionLayerImpl::getMemoryShapes'

仍在寻找更多信息,但不知道代码中的错误或库中的错误......任何人都知道什么可能导致问题?任何帮助将不胜感激。

python opencv deep-learning caffe face-detection
2个回答
2
投票

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

这是我得到的:

enter image description here

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


1
投票

我想我知道你的问题在哪里,请检查你的ssd文件夹下的这两个文件“deploy.prototxt”和“res10_300x300_ssd_iter_140000.caffemodel”。如果文件的大小不为零,则可能会发生下载被阻止/中断(被防火墙阻止,连接失败等)与原始大小进行比较的情况。如果大小为零,则根本不下载。

在这两种情况下,请转到“https://github.com/opencv/opencv/blob/master/samples/dnn/face_detector/deploy.prototxt”github存储库

https://github.com/opencv/opencv_3rdparty/raw/dnn_samples_face_detector_20170830/res10_300x300_ssd_iter_140000.caffemodel”下载具有相同名称的两个文件并替换它们。

或者您可以使用之前使用的相同来源。

© www.soinside.com 2019 - 2024. All rights reserved.