-
-
Notifications
You must be signed in to change notification settings - Fork 56.3k
Closed
Labels
invalidquestion (invalid tracker)ask questions and other "no action" items here: https://forum.opencv.orgask questions and other "no action" items here: https://forum.opencv.org
Description
System information (version)
- OpenCV => :4.0.0.21:
- Operating System / Platform => : windows10:
- Compiler => :pre-build version from pip:
Detailed description
background: i wanna achieve opencv dnn model to detect face in an image
after accessing the model and prototxt from opencv_extra/testdata/dnn/download_models.py, i learned some sample code to test whether it works or not. And then, I got the following info:
[libprotobuf ERROR C:\projects\opencv-python\opencv\3rdparty\protobuf\src\google\protobuf\text_format.cc:288] Error parsing text-format opencv_caffe.NetParameter: 2:1: Invalid control characters encountered in text.
[libprotobuf ERROR C:\projects\opencv-python\opencv\3rdparty\protobuf\src\google\protobuf\text_format.cc:288] Error parsing text-format opencv_caffe.NetParameter: 2:2: Interpreting non ascii codepoint 162.
[libprotobuf ERROR C:\projects\opencv-python\opencv\3rdparty\protobuf\src\google\protobuf\text_format.cc:288] Error parsing text-format opencv_caffe.NetParameter: 2:2: Expected identifier, got: ?
Traceback (most recent call last):
File "src/facedetect/detector.py", line 103, in <module>
util.gainFaceByDNN(path, modelpath, deploypath)
File "src/facedetect/detector.py", line 26, in gainFaceByDNN
net = cv2.dnn.readNetFromCaffe(modelFile, configFile)
cv2.error: OpenCV(4.0.0) C:\projects\opencv-python\opencv\modules\dnn\src\caffe\caffe_io.cpp:1151: error: (-2:Unspecified error) FAILED: ReadProtoFromTextFile(param_file, param). Failed to parse NetParameter file: D:\project\python\IQA\src\facedetect\res10_300x300_ssd_iter_140000.caffemodel in function 'cv::dnn::ReadNetParamsFromTextFileOrDie'
i have tried to google error, and got some solutions to try but they all failed, including checking the invisible content of the deploy.prototxt, redownload the files, etc.
Steps to reproduce
below is the code i used for test and it goes wrong on the first code.
net = cv2.dnn.readNetFromCaffe(modelFile, configFile)
image = cv2.imread(imgPath)
(h, w) = image.shape[:2]
blob = cv2.dnn.blobFromImage(cv2.resize(image, (300,300)), 1.0, (300,300), (103.93, 116.77, 123.68), False)
net.setInput(blob)
detections = net.forward()
Is there any practical solutions ? thanks ~
Metadata
Metadata
Assignees
Labels
invalidquestion (invalid tracker)ask questions and other "no action" items here: https://forum.opencv.orgask questions and other "no action" items here: https://forum.opencv.org