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.

Face Recognition with NCS2 and OpenCV

Kesavaram__Jaiganesh
864 Views

Hi,

I am trying to write an application to do face recognition with Intel NCS2 stick on Intel i7 PC. I have also installed Openvino toolkit to support for NCS2. So, to do face recognition, i have converted tensorflow facenet(https://github.com/davidsandberg/facenet) models to .bin and .xml using openvino model optimizer script as,

$ python ./mo_tf.py --input_model /mnt/work/RNA_va/face/facenet/Model/20180402-114759.pb --freeze_placeholder_with_value "phase_train->False" --data-type FP16

And here is my test application.

----

import cv2

net = cv2.dnn.readNet('20180402-114759.bin', 20180402-114759.xml')

net.setPreferableTarget(cv2.dnn.DNN_TARGET_MYRIAD)

vs = VideoStream(src=0).start()

while True:

    frame = vs.read()

    blob = cv2.dnn.blobFromImage(frame, 0.007843, (300, 300), 127.5)

    net.setInput(blob)

    detections = net.forward()

----

And i got the below error when i run this python script,

terminate called after throwing an instance of 'InferenceEngine::details::InferenceEngineException'
  what():  Failed to infer shapes for FullyConnected layer (InceptionResnetV1/Bottleneck/MatMul) with error: New shapes [1,64512] make Kernels(), Channels(64512), Output depth(512), Groups(1) not matching weights size: 33030144 vs 917504
Aborted (core dumped)
 

Can someone help to resolve this issue? Much appreciated. Thanks.

0 Kudos
4 Replies
Shubha_R_Intel
Employee
864 Views

Dear Kesavaram, Jaiganesh,

Can you first try the OpenVino Multi-Channel Face Detection Demo ?

Info is below:

https://docs.openvinotoolkit.org/latest/_inference_engine_samples_multichannel_demo_README.html

Just pass your IR *.xml for facenet into the -m switch.

Let us know how this works for you. If this works, then please compare your code to the code in this demo.

Thanks,

Shubha

0 Kudos
Kesavaram__Jaiganesh
864 Views

Hi Shubha,

Here is the output of demo app. Let me know your comments.

$ ./multi-channel-face-detection-demo -m /mnt/work/RNA_va/face/facenet/model_optimized/20180402-114759.xml -d MYRIAD -nc 1
[ INFO ] InferenceEngine: 
    API version ............ 1.6
    Build .................. custom_releases/2019/R1_ebce9728578ef3131f2f282b3fbc3232109c598e
[ INFO ] Parsing input parameters
[ INFO ]     Detection model:           /mnt/work/RNA_va/face/facenet/model_optimized/20180402-114759.xml
[ INFO ]     Detection threshold:       0.5
[ INFO ]     Utilizing device:          MYRIAD
[ INFO ]     Batch size:                1
[ INFO ]     Number of infer requests:  5
[ INFO ]     Number of input web cams:  1
[ INFO ] Model   path: /mnt/work/RNA_va/face/facenet/model_optimized/20180402-114759.xml
[ INFO ] Weights path: /mnt/work/RNA_va/face/facenet/model_optimized/20180402-114759.bin
[ INFO ]     Number of input web cams:    1
[ INFO ]     Number of input video files: 0
[ INFO ]     Duplication multiplayer:     0
[ INFO ]     Number of input channels:    1
[ INFO ] Trying to connect 1 web cams ...
To close the application, press 'CTRL+C' or any key with focus on the output window
Segmentation fault (core dumped)
 

0 Kudos
Kesavaram__Jaiganesh
864 Views

And my desktop environment is Ubuntu 18.04 Bionic with OpenVino toolkit l_openvino_toolkit_p_2019.1.133 installed.

0 Kudos
m__akshaya
New Contributor I
864 Views

Hi Kesavaram, 

The Facenet model used to extract facial features(512) from the face. Not used for face detection

Referer below link 

https://github.com/MekkaSiekka/Face-Recognition-with-OpenVino-Toolkit/blob/master/local_recognizer/main.cpp

Thanks.

0 Kudos
Reply