I downloaded dkurt's great pre-trained models from the contrib repo following Adrian Rosebrock's blog, and am able to run the floating-point Caffe models, but not the uint8 model which is in Tensorflow format. I'm using a rpi3, but the issue seems unrelated to the architecture: it throws the errors in the model importing stage.
Please help! Solving this would help a lot with the performance on rpi - the caffe models take about 800 millis per frame to process, which is just a little too slow for real-time processing. This must be working for others, as I can see a test being checked in that runs this model...
If I don't use a pbtxt, it stops on unknown nodes, which I believe is expected:
OpenCV(3.4.1) Error: Unspecified error (Unknown layer type Square in op conv4_3_norm/l2_normalize/Square) in populateNet, file /home/pi/opencv/opencv-3.4.1/modules/dnn/src/tensorflow/tf_importer.cpp, line 1582 Traceback (most recent call last): File "detect_faces_video.py", line 33, in <module> net = cv2.dnn.readNetFromTensorflow(model) cv2.error: OpenCV(3.4.1) /home/pi/opencv/opencv-3.4.1/modules/dnn/src/tensorflow/tf_importer.cpp:1582: error: (-2) Unknown layer type Square in op conv4_3_norm/l2_normalize/Square in function populateNet
If I use the pbtxt I found in the repo, then I get this
OpenCV(3.4.1) Error: Assertion failed (layer.input_size() == 1) in populateNet, file /home/pi/opencv/opencv-3.4.1/modules/dnn/src/tensorflow/tf_importer.cpp, line 1485 Traceback (most recent call last): File "detect_faces_video.py", line 32, in <module> net = cv2.dnn.readNetFromTensorflow(model, prototxt) cv2.error: OpenCV(3.4.1) /home/pi/opencv/opencv-3.4.1/modules/dnn/src/tensorflow/tf_importer.cpp:1485: error: (-215) layer.input_size() == 1 in function populateNet
If I export my own pbtxt with this
python tf_text_graph_ssd.py --input opencv_face_detector_uint8.pb --output opencv_face_detector_uint8.pbtxt
then I get the following:
Traceback (most recent call last): File "detect_faces_video.py", line 31, in <module> net = cv2.dnn.readNetFromTensorflow(model, prototxt) cv2.error: OpenCV(3.4.1) /home/pi/opencv/opencv-3.4.1/modules/dnn/src/tensorflow/tf_importer.cpp:553: error: (-2) Input layer not found: BoxPredictor_0/ClassPredictor/BiasAdd in function connect
import cv2
print("[INFO] loading model...")
#prototxt = "deploy.prototxt.txt"
#model = "res10_300x300_ssd_iter_140000.caffemodel"
#model = "res10_300x300_ssd_iter_140000_fp16.caffemodel"
#net = cv2.dnn.readNetFromCaffe(prototxt, model) # This works with either model
prototxt = "opencv_face_detector_uint8.pbtxt"
model = "opencv_face_detector_uint8.pb"
net = cv2.dnn.readNetFromTensorflow(model, prototxt) # This doesn't