Monday, July 09, 2018

Testing with Intel Movidius Neural Compute Stick

One day, I came across this USB stick.

It is an USB stick with Myriad VPU 2 which is a chip specialized for convolution neural network. It is generally a good news as not all computers come with an expensive graphics card. Some device is not even capable for a graphics card like Raspberry Pi. So, a USB stick seems to be a perfect solution.

It has a FaceNet example for Tensorflow so I decided to try it out. It is target for Ubuntu on PC at the moment and specifically supports only version 16.04. Luckily, Virtual PC is supported as well so it is OK to run on my Windows 10 PC.

The NCSDK v2 installation is pretty painless. Then the NC App Zoo for the FaceNet sample. The run.py in the sample is pretty useless. It is just taking an image without getting the face and resampling it to a 180x180 image and feed it into the model. Obviously, it is not how FaceNet works.

Since the original TensorFlow implementation from David already got a compare.py. So, I copied it and the MTCNN dependencies over and renamed it to compare_tf.py. Then made a copy and updated it with the NCSDK as compare_nc.py. The results as as follows:

compare_nc.py
Images:
0: elvis-presley-401920_640.jpg
1: neal_2017-12-19-155037.jpg
2: president-67550_640.jpg
3: trump.jpg
4: valid.jpg

Distance matrix
        0         1         2         3         4
0    0.0000    0.6212    0.6725    0.7981    0.5387
1    0.6212    0.0000    0.8101    0.7106    0.5050
2    0.6725    0.8101    0.0000    0.6509    0.6273
3    0.7981    0.7106    0.6509    0.0000    0.6946
4    0.5387    0.5050    0.6273    0.6946    0.0000
compare_tf.py
Images:
0: elvis-presley-401920_640.jpg
1: neal_2017-12-19-155037.jpg
2: president-67550_640.jpg
3: trump.jpg
4: valid.jpg

Distance matrix
        0         1         2         3         4
0    0.0000    1.4255    1.3354    1.3078    1.4498
1    1.4255    0.0000    1.5454    1.4255    0.6372
2    1.3354    1.5454    0.0000    1.2032    1.4949
3    1.3078    1.4255    1.2032    0.0000    1.4904
4    1.4498    0.6372    1.4949    1.4904    0.0000
Hmmm, not the same result expected. I think it shouldn't be the hardware failure. It could be there are some conversion problem when converting TensorFlow model to the NCSDK model.

Conclusion: it is quite primitive at the moment. For common models like inception or mobilenet, it might work well. For custom models, good luck.

GitHub Link: https://github.com/compustar/ncappzoo/tree/ncsdk2/tensorflow/facenet

No comments: