Ask Your Question

Revision history [back]

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

I am using openvino Neural compute stick 2 on raspberry pi4 and trying to run the following code. But I get an error in my Raspberry pi but run fine on my Mac pc. Any clue on why this could be happening?

   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'

Code Below:

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()

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

I am using openvino two models to infer face and get embedding of the face. One model runs on Neural compute stick 2 for the inference and other models is running on CPU. I am running the code on raspberry pi4 and trying to run the following code. But pi4, but I get an error in on my Raspberry pi but whereas it run fine on my Mac pc. Any clue on why this could be happening?

   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'

Code Below:

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()