Difference between revisions of "TB3 Movidius Applications"
(→Install App Zoo) |
(→Preconditions) |
||
(28 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
* [https://github.com/movidius/ncappzoo NC App Zoo] | * [https://github.com/movidius/ncappzoo NC App Zoo] | ||
− | * [https://github.com/movidius/ncappzoo/blob/master/apps/README.md App Zoo | + | * [https://github.com/movidius/ncappzoo/blob/master/apps/README.md App Zoo application list] |
* [https://software.intel.com/en-us/articles/build-an-image-classifier-in-5-steps-on-the-intel-movidius-neural-compute-stick Building an Image Classifier in 5 steps]: Intel Academy. | * [https://software.intel.com/en-us/articles/build-an-image-classifier-in-5-steps-on-the-intel-movidius-neural-compute-stick Building an Image Classifier in 5 steps]: Intel Academy. | ||
= Install App Zoo = | = Install App Zoo = | ||
− | $ cd ~/workspace/ | + | $ cd ~/workspace/ |
− | + | ||
$ git clone https://github.com/movidius/ncappzoo | $ git clone https://github.com/movidius/ncappzoo | ||
$ sudo ln -s /home/eepp/workspace/ncappzoo/ /opt/movidius/ncappzoo | $ sudo ln -s /home/eepp/workspace/ncappzoo/ /opt/movidius/ncappzoo | ||
+ | |||
+ | NOTE: Use this for NCSDK 2.08 which is not supported by the ROS Movidius Wrapper. $ git clone -b ncsdk2 https://github.com/movidius/ncappzoo.git. See also section 3 [https://github.com/intel/ros_intel_movidius_ncs/blob/devel/README.md ROS Intel Movidius NCS README] | ||
= Live Image Classifier = | = Live Image Classifier = | ||
Line 21: | Line 23: | ||
$ make run | $ make run | ||
... | ... | ||
− | age_net.caffemodel 100%[===================>] 43.55M | + | age_net.caffemodel 100%[===================>] 43.55M 3.47MB/s in 18s |
− | + | ||
Last-modified header missing -- time-stamps turned off. | Last-modified header missing -- time-stamps turned off. | ||
− | + | 2019-02-05 13:50:01 (2.46 MB/s) - ‘./age_net.caffemodel’ saved [45661480/45661480] | |
− | + | ||
mvNCCompile -w age_net.caffemodel -s 12 deploy.prototxt | mvNCCompile -w age_net.caffemodel -s 12 deploy.prototxt | ||
mvNCCompile v02.00, Copyright @ Movidius Ltd 2016 | mvNCCompile v02.00, Copyright @ Movidius Ltd 2016 | ||
− | + | ||
/usr/local/bin/ncsdk/Controllers/FileIO.py:52: UserWarning: You are using a large type. Consider reducing your data sizes for best performance | /usr/local/bin/ncsdk/Controllers/FileIO.py:52: UserWarning: You are using a large type. Consider reducing your data sizes for best performance | ||
"Consider reducing your data sizes for best performance\033[0m") | "Consider reducing your data sizes for best performance\033[0m") | ||
make[1]: Leaving directory '/home/eepp/workspace/ncappzoo/caffe/AgeNet' | make[1]: Leaving directory '/home/eepp/workspace/ncappzoo/caffe/AgeNet' | ||
− | + | ||
Running live-image-classifier.py | Running live-image-classifier.py | ||
python3 live-image-classifier.py --graph ../../caffe/AgeNet/graph --labels ../../data/age_gender/age_categories.txt | python3 live-image-classifier.py --graph ../../caffe/AgeNet/graph --labels ../../data/age_gender/age_categories.txt | ||
Line 41: | Line 43: | ||
Makefile:41: recipe for target 'run' failed | Makefile:41: recipe for target 'run' failed | ||
make: *** [run] Error 1 | make: *** [run] Error 1 | ||
+ | |||
+ | Note the "import cv2" reference above. | ||
== Fix == | == Fix == | ||
Line 74: | Line 78: | ||
/usr/local/bin/ncsdk/Controllers/FileIO.py:52: UserWarning: You are using a large type. Consider reducing your data sizes for best performance | /usr/local/bin/ncsdk/Controllers/FileIO.py:52: UserWarning: You are using a large type. Consider reducing your data sizes for best performance | ||
− | + | "Consider reducing your data sizes for best performance\033[0m") | |
make[1]: Leaving directory '/home/eepp/workspace/ncappzoo/caffe/AgeNet' | make[1]: Leaving directory '/home/eepp/workspace/ncappzoo/caffe/AgeNet' | ||
− | + | ||
Running live-image-classifier.py | Running live-image-classifier.py | ||
python3 live-image-classifier.py --graph ../../caffe/AgeNet/graph --labels ../../data/age_gender/age_categories.txt | python3 live-image-classifier.py --graph ../../caffe/AgeNet/graph --labels ../../data/age_gender/age_categories.txt | ||
− | I am | + | I am 41.4% confidant you are 25-32 years ( 46.03 ms ) |
− | I am | + | I am 41.6% confidant you are 25-32 years ( 42.45 ms ) |
− | I am | + | I am 40.9% confidant you are 25-32 years ( 42.34 ms ) |
− | I am | + | I am 44.3% confidant you are 4-6 years ( 42.32 ms ) |
− | I am | + | I am 41.7% confidant you are 4-6 years ( 42.31 ms ) |
− | I am | + | I am 72.2% confidant you are 4-6 years ( 42.12 ms ) |
− | I am | + | I am 47.5% confidant you are 4-6 years ( 42.38 ms ) |
+ | I am 36.0% confidant you are 8-12 years ( 41.91 ms ) | ||
+ | I am 37.8% confidant you are 60-100 years ( 42.47 ms ) | ||
+ | I am 53.8% confidant you are 60-100 years ( 42.02 ms ) | ||
+ | ^C | ||
+ | = Live Image Classifier Tests = | ||
− | == | + | == Preconditions == |
+ | |||
+ | * Fix from above has be executed | ||
$ cd ~/workspace/ncappzoo/apps/live-image-classifier/ | $ cd ~/workspace/ncappzoo/apps/live-image-classifier/ | ||
− | === Caffe AgeNet | + | change to |
+ | |||
+ | $ cd /opt/movidius/ncappzoo/apps/live-image-classifier/ | ||
+ | |||
+ | == Tests == | ||
+ | |||
+ | === Caffe AgeNet === | ||
+ | |||
+ | From Makefile above | ||
+ | |||
+ | '''Passed Jan 2019''' | ||
# From Makefile | # From Makefile | ||
Line 101: | Line 122: | ||
I am 83.4% confidant you are 8-12 years ( 42.22 ms ) | I am 83.4% confidant you are 8-12 years ( 42.22 ms ) | ||
− | === Caffe GoogLeNet from me === | + | = OLD Tests = |
+ | |||
+ | Tests from a previous build. Need to be rechecked. | ||
+ | |||
+ | === Caffe GoogLeNet from me === | ||
+ | |||
+ | Passed 2018 | ||
+ | |||
Used the example above as a base | Used the example above as a base | ||
$ python3 live-image-classifier.py --graph ../../caffe/GoogLeNet/graph --labels ../../data/ilsvrc12/synset_words.txt | $ python3 live-image-classifier.py --graph ../../caffe/GoogLeNet/graph --labels ../../data/ilsvrc12/synset_words.txt | ||
− | + | Failed Jan 2019 Tried to fix with this | |
+ | |||
+ | $ cd ~/workspace/ncappzoo/apps/live-image-classifier/ | ||
+ | $ cd ../../caffe/GoogLeNet/ | ||
+ | |||
+ | $ make run | ||
+ | |||
+ | cd ~/workspace/ncappzoo/apps/live-image-classifier/ | ||
+ | |||
+ | $ python3 live-image-classifier.py --graph ../../caffe/GoogLeNet/graph --labels ../../data/ilsvrc12/synset_words.txt | ||
+ | |||
+ | === Two Caffe Models: Alex and SqueezeNet from README.md === | ||
+ | |||
+ | Failed Jan 2019 | ||
+ | |||
$ python3 live-image-classifier.py --graph ../../caffe/AlexNet/graph --dim 227 227 | $ python3 live-image-classifier.py --graph ../../caffe/AlexNet/graph --dim 227 227 | ||
Line 117: | Line 159: | ||
==== Build and Test the Mobilenet and Inception Models ==== | ==== Build and Test the Mobilenet and Inception Models ==== | ||
+ | |||
+ | Failed Jan 2019 | ||
$ cd ~/workspace/ncappzoo/tensorflow/mobilenets | $ cd ~/workspace/ncappzoo/tensorflow/mobilenets | ||
Line 129: | Line 173: | ||
$ python3 ../../apps/image-classifier/image-classifier.py --graph ./model/v3/graph --dim 224 224 --mean 127.5 --scale 0.00789 --colormode "RGB" --labels ./model/v3/labels.txt --image ../../data/images/pic_053.jpg | $ python3 ../../apps/image-classifier/image-classifier.py --graph ./model/v3/graph --dim 224 224 --mean 127.5 --scale 0.00789 --colormode "RGB" --labels ./model/v3/labels.txt --image ../../data/images/pic_053.jpg | ||
− | |||
==== Run the Mobilenet and Inception Models in Live View *** BEST RESULTS ==== | ==== Run the Mobilenet and Inception Models in Live View *** BEST RESULTS ==== | ||
Line 169: | Line 212: | ||
RGB vs BGR color sequence. This is network dependent. | RGB vs BGR color sequence. This is network dependent. | ||
− | = Log Image Classifier = | + | == Log Image Classifier == |
$ cd ~/workspace/ncappzoo/apps/log-image-classifier/ | $ cd ~/workspace/ncappzoo/apps/log-image-classifier/ |
Latest revision as of 15:12, 9 March 2019
Contents
Reference
Install App Zoo
$ cd ~/workspace/ $ git clone https://github.com/movidius/ncappzoo $ sudo ln -s /home/eepp/workspace/ncappzoo/ /opt/movidius/ncappzoo
NOTE: Use this for NCSDK 2.08 which is not supported by the ROS Movidius Wrapper. $ git clone -b ncsdk2 https://github.com/movidius/ncappzoo.git. See also section 3 ROS Intel Movidius NCS README
Live Image Classifier
Build
$ cd ~/workspace/ncappzoo/apps/live-image-classifier/ $ make run ... age_net.caffemodel 100%[===================>] 43.55M 3.47MB/s in 18s Last-modified header missing -- time-stamps turned off. 2019-02-05 13:50:01 (2.46 MB/s) - ‘./age_net.caffemodel’ saved [45661480/45661480] mvNCCompile -w age_net.caffemodel -s 12 deploy.prototxt mvNCCompile v02.00, Copyright @ Movidius Ltd 2016 /usr/local/bin/ncsdk/Controllers/FileIO.py:52: UserWarning: You are using a large type. Consider reducing your data sizes for best performance "Consider reducing your data sizes for best performance\033[0m") make[1]: Leaving directory '/home/eepp/workspace/ncappzoo/caffe/AgeNet' Running live-image-classifier.py python3 live-image-classifier.py --graph ../../caffe/AgeNet/graph --labels ../../data/age_gender/age_categories.txt Traceback (most recent call last): File "live-image-classifier.py", line 12, in <module> import cv2 ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type Makefile:41: recipe for target 'run' failed make: *** [run] Error 1
Note the "import cv2" reference above.
Fix
Import Error ROS python3 opencv. ROS creates its own open cv which is compatible with python2 only. I do the following.I followed zishan’s instructions
$ pwd /opt/ros/kinetic/lib/python2.7/dist-packages $ sudo mv cv2.so cv2_rename.so [sudo] password for eepp:
Finish Build
$ make run ... mvNCCompile -w gender_net.caffemodel -s 12 deploy.prototxt mvNCCompile v02.00, Copyright @ Movidius Ltd 2016 /usr/local/bin/ncsdk/Controllers/FileIO.py:52: UserWarning: You are using a large type. Consider reducing your data sizes for best performance "Consider reducing your data sizes for best performance\033[0m") make[1]: Leaving directory '/home/eepp/workspace/ncappzoo/caffe/GenderNet' making AgeNet (cd ../../caffe/AgeNet; make compile;) make[1]: Entering directory '/home/eepp/workspace/ncappzoo/caffe/AgeNet' make[2]: Entering directory '/home/eepp/workspace/ncappzoo/data/age_gender' make[2]: Leaving directory '/home/eepp/workspace/ncappzoo/data/age_gender' test -f deploy.prototxt || (wget -P . https://raw.githubusercontent.com/GilLevi/AgeGenderDeepLearning/master/age_net_definitions/deploy.prototxt; awk 'NR <2 {print}' < deploy.prototxt > temp; cat input_shape.prototxt >> temp; awk 'NR > 6 {print}' < deploy.prototxt >> temp; mv temp deploy.prototxt) test -f age_net.caffemodel || wget -P . -N https://github.com/GilLevi/AgeGenderDeepLearning/raw/master/models/age_net.caffemodel mvNCCompile -w age_net.caffemodel -s 12 deploy.prototxt mvNCCompile v02.00, Copyright @ Movidius Ltd 2016 /usr/local/bin/ncsdk/Controllers/FileIO.py:52: UserWarning: You are using a large type. Consider reducing your data sizes for best performance "Consider reducing your data sizes for best performance\033[0m") make[1]: Leaving directory '/home/eepp/workspace/ncappzoo/caffe/AgeNet' Running live-image-classifier.py python3 live-image-classifier.py --graph ../../caffe/AgeNet/graph --labels ../../data/age_gender/age_categories.txt I am 41.4% confidant you are 25-32 years ( 46.03 ms ) I am 41.6% confidant you are 25-32 years ( 42.45 ms ) I am 40.9% confidant you are 25-32 years ( 42.34 ms ) I am 44.3% confidant you are 4-6 years ( 42.32 ms ) I am 41.7% confidant you are 4-6 years ( 42.31 ms ) I am 72.2% confidant you are 4-6 years ( 42.12 ms ) I am 47.5% confidant you are 4-6 years ( 42.38 ms ) I am 36.0% confidant you are 8-12 years ( 41.91 ms ) I am 37.8% confidant you are 60-100 years ( 42.47 ms ) I am 53.8% confidant you are 60-100 years ( 42.02 ms ) ^C
Live Image Classifier Tests
Preconditions
- Fix from above has be executed
$ cd ~/workspace/ncappzoo/apps/live-image-classifier/
change to
$ cd /opt/movidius/ncappzoo/apps/live-image-classifier/
Tests
Caffe AgeNet
From Makefile above
Passed Jan 2019
# From Makefile $ python3 live-image-classifier.py --graph ../../caffe/AgeNet/graph --labels ../../data/age_gender/age_categories.txt I am 71.7% confidant you are 8-12 years ( 45.94 ms ) I am 65.4% confidant you are 8-12 years ( 42.28 ms ) I am 79.5% confidant you are 8-12 years ( 42.37 ms ) I am 83.4% confidant you are 8-12 years ( 42.22 ms )
OLD Tests
Tests from a previous build. Need to be rechecked.
Caffe GoogLeNet from me
Passed 2018
Used the example above as a base
$ python3 live-image-classifier.py --graph ../../caffe/GoogLeNet/graph --labels ../../data/ilsvrc12/synset_words.txt
Failed Jan 2019 Tried to fix with this
$ cd ~/workspace/ncappzoo/apps/live-image-classifier/ $ cd ../../caffe/GoogLeNet/ $ make run cd ~/workspace/ncappzoo/apps/live-image-classifier/ $ python3 live-image-classifier.py --graph ../../caffe/GoogLeNet/graph --labels ../../data/ilsvrc12/synset_words.txt
Two Caffe Models: Alex and SqueezeNet from README.md
Failed Jan 2019
$ python3 live-image-classifier.py --graph ../../caffe/AlexNet/graph --dim 227 227 $ python3 live-image-classifier.py --graph ../../caffe/SqueezeNet/graph --dim 227 227
Result: Didn't recognize hand-held photos or a real banana
Two Tensorflow models: Mobilenet and Inception
Build and Test the Mobilenet and Inception Models
Failed Jan 2019
$ cd ~/workspace/ncappzoo/tensorflow/mobilenets $ make run $ python3 ../../apps/image-classifier/image-classifier.py --graph ./model/graph --dim 224 224 --mean 127.5 --scale 0.00789 --colormode "RGB" --labels ./model/labels.txt --image ../../data/images/pic_053.jpg $ cd ~/workspace/ncappzoo/tensorflow/inception $ make run $ python3 ../../apps/image-classifier/image-classifier.py --graph ./model/v3/graph --dim 224 224 --mean 127.5 --scale 0.00789 --colormode "RGB" --labels ./model/v3/labels.txt --image ../../data/images/pic_053.jpg
Run the Mobilenet and Inception Models in Live View *** BEST RESULTS
$ cd ~/workspace/ncappzoo/apps/live-image-classifier/ $ python3 live-image-classifier.py --graph ../../tensorflow/mobilenets/model/graph --labels ../../tensorflow/mobilenets/model/labels.txt --mean 127.5 --scale 0.00789 --dim 224 224 --colormode="RGB" $ python3 live-image-classifier.py --graph ../../tensorflow/inception/model/v3/graph --labels ../../tensorflow/inception/model/v3/labels.txt --mean 127.5 --scale 0.00789 --dim 299 299 --colormode="RGB"
Result: Recognized electric guitar and zebra photos. A real banana in front of a white board.
Help
$ python3 live-image-classifier.py --graph ../../caffe/GoogLeNet/graph -h usage: live-image-classifier.py [-h] [-g GRAPH] [-v VIDEO] [-l LABELS] [-M MEAN [MEAN ...]] [-S SCALE] [-D DIM [DIM ...]] [-c COLORMODE] Image classifier using Intel® Movidius™ Neural Compute Stick. optional arguments: -h, --help show this help message and exit -g GRAPH, --graph GRAPH Absolute path to the neural network graph file. -v VIDEO, --video VIDEO Index of your computer's V4L2 video device. ex. 0 for /dev/video0 -l LABELS, --labels LABELS Absolute path to labels file. -M MEAN [MEAN ...], --mean MEAN [MEAN ...] ',' delimited floating point values for image mean. -S SCALE, --scale SCALE Absolute path to labels file. -D DIM [DIM ...], --dim DIM [DIM ...] Image dimensions. ex. -D 224 224 -c COLORMODE, --colormode COLORMODE RGB vs BGR color sequence. This is network dependent.
Log Image Classifier
$ cd ~/workspace/ncappzoo/apps/log-image-classifier/ $ make run ... making compile mvNCCompile -w bvlc_alexnet.caffemodel -s 12 deploy.prototxt mvNCCompile v02.00, Copyright @ Movidius Ltd 2016 /usr/local/bin/ncsdk/Controllers/FileIO.py:52: UserWarning: You are using a large type. Consider reducing your data sizes for best performance "Consider reducing your data sizes for best performance\033[0m") make[1]: Leaving directory '/home/eepp/workspace/ncappzoo/caffe/AlexNet' Running log-image-classifier.py python3 log-image-classifier.py Pre-processing images... /usr/local/lib/python3.5/dist-packages/skimage/transform/_warps.py:84: UserWarning: The default mode, 'constant', will be changed to 'reflect' in skimage 0.15. warn("The default mode, 'constant', will be changed to 'reflect' in " Performing inference on a lot of images... Inference complete! View results in ./inferences.csv.