Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6392 Discussions

Device with "CPU" name is not registered in the InferenceEngine in function 'initPlugin'

VBura
Novice
1,659 Views

Hi, I have created .xml and .bin files using the model optimizer using the following command 

Python3 mo_caffe.py --input_model /Users/venku/Documents/PyCharmProjects/home_security_project/caffe_models/res10_300x300_ssd_iter_140000.caffemodel --input_proto /Users/venku/Documents/PyCharmProjects/home_security_project/caffe_models/deploy.prototxt  --output_dir /Users/venku/Documents/PyCharmProjects/home_security_project/caffe_models/ncs2/

And used bin and xml file in opencv in the following ways. This works fine on a CPU (mac os), however when I run the same model on Raspberry PI 4, I get an error

def recognize_faces_using_ncs():
    print(cv2.__version__)   
    detector = cv2.dnn.readNet("../caffe_models/ncs2/res10_300x300_ssd_iter_140000.xml",
                              "../caffe_models/ncs2/res10_300x300_ssd_iter_140000.bin")
    
    
    
    detector.setPreferableTarget(cv2.dnn.DNN_TARGET_MYRIAD)

    embedder = cv2.dnn.readNetFromTorch("../caffe_models/openface_nn4.small2.v1.t7")

    recognizer = None
    le = None
    with open("../Data/pickle_saving/recognizer.pickle", "rb") as rec:
        recognizer = pickle.loads(rec.read())

    with open("../Data/pickle_saving/le.pickle", "rb") as lab_encod:
        le = pickle.loads(lab_encod.read())

    vs = VideoStream(src=0).start()
    time.sleep(2.0)

    while True:
        frame = vs.read()
        frame = imutils.resize(frame, width=600)
        (h, w) = frame.shape[:2]

        image_blob = cv2.dnn.blobFromImage(cv2.resize(frame, (300, 300)), 1.0, (300, 300), (104.0, 177.0, 123.0),
                                           swapRB=False,
                                           crop=False)


        detector.setInput(image_blob)
        detections = detector.forward()
        for i in range(0, detections.shape[2]):
            confidence = detections[0, 0, i, 2]

            if confidence > 0.5:
                box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
                (startx, starty, endx, endy) = box.astype("int")

                face = frame[starty:endy, startx:endx]
                (fh, fw) = face.shape[:2]

                if fw < 20 or fh < 20:
                    continue

                faceBlob = cv2.dnn.blobFromImage(face, 1.0 / 255, (96, 96), (0, 0, 0), swapRB=True, crop=False)
                embedder.setInput(faceBlob)
                vec = embedder.forward()

                  

Error I get when I run the code:

4.1.2-openvino
[ WARN:0] global /home/jenkins/workspace/OpenCV/OpenVINO/build/opencv/modules/dnn/src/op_inf_engine.cpp (660) initPlugin DNN-IE: Can't load extension plugin (extra layers for some networks). Specify path via OPENCV_DNN_IE_EXTRA_PLUGIN_PATH parameter
Traceback (most recent call last):
  File "face_detection_and_embedings.py", line 355, in <module>
    recognize_faces_using_ncs()
  File "face_detection_and_embedings.py", line 241, in recognize_faces_using_ncs
    vec = embedder.forward()
cv2.error: OpenCV(4.1.2-openvino) /home/jenkins/workspace/OpenCV/OpenVINO/build/opencv/modules/dnn/src/op_inf_engine.cpp:704: error: (-215:Assertion failed) Failed to initialize Inference Engine backend: Device with "CPU" name is not registered in the InferenceEngine in function 'initPlugin'

 

0 Kudos
3 Replies
Sahira_Intel
Moderator
1,659 Views

Hi Venku,

Your model cannot be deployed on the Raspberry Pi 4 as CPU. The only way to run a model on the RPI is to run on a Neural Compute Stick. 

Please let me know if you have any further questions.

Sincerely,

Sahira 

0 Kudos
VBura
Novice
1,659 Views

Hi Sahira, Thank you for reply. 

Is there a way for me to convert "openface_nn4.small2.v1.t7" model using openvino to generate IR to use in a second Neural Compute Stick-2 with my RasPI? This model give me back 128-dimension facial embeddings, so that I can use some kind of distance metrics to identify faces between known vs unknown. 

 

Thank you,

Venku

0 Kudos
Sahira_Intel
Moderator
1,659 Views

Hi Venku,

The OpenVINO Model Optimizer supports the following frameworks: Caffe, Tensorflow, MXNet, ONNX and Kaldi. So long as the model is trained in one of those frameworks, you should be able to convert it using the MO. 

For your reference, here are the OpenVINO pretrained models that might be useful to you (like the facial landmark detection demo). 

Please let me know if this information is helpful.

Best Regards,
Sahira 

 

0 Kudos
Reply