这篇文档主要用于记录NCAPPZOO的apps文件夹中的Demo运行时的方法和注意事项。
注意 需要2个NCS设备
cd ~/ai_ws/ncappzoo/apps/street_cam/
make
(仅第一次)
* 开始下载demo视频
* bus_station_6094_960x540.mp4
* motorcycle_6098_shortened_960x540.mp4
* contrapicado_traffic_shortened_960x540.mp4
* police_car_6095_shortened_960x540.mp4
* scooters_5638_shortened_960x540.mp4
./street_cam.py
ai@ai-usb:~/ai_ws/ncappzoo/apps/street_cam$ ./street_cam.py
Running street_cam
Keys:
‘Q’/’q’ to Quit
‘B’/’b’ to inc/dec the Tiny Yolo box probability threshold
‘I’/’i’ to inc/dec the Tiny Yolo box intersection-over-union threshold
‘G’/’g’ to inc/dec the GoogLeNet probability threshold
‘2’ to toggle GoogLeNet classification
This application requires two NCS devices.
Insert two devices and try again!
ai@ai-usb:~/ai_ws/ncappzoo/apps/street_cam$
解决 插入2只NCS设备
ai@ai-usb:~/ai_ws/ncappzoo/apps/street_cam$ tree ./
./
├── bus_station_6094_960x540.mp4
├── contrapicado_traffic_shortened_960x540.mp4
├── googlenet.graph
├── install-opencv-from_source.sh
├── licenses.txt
├── Makefile
├── motorcycle_6098_shortened_960x540.mp4
├── police_car_6095_shortened_960x540.mp4
├── README.md
├── scooters_5638_shortened_960x540.mp4
├── street_cam.py
└── yolo_tiny.graph
0 directories, 12 files
cd ~/ai_ws/ncappzoo/apps/video_objects/
make
(仅第一次)
* 开始下载demo视频
* bus_station_6094_960x540.mp4
* motorcycle_6098_shortened_960x540.mp4
* contrapicado_traffic_shortened_960x540.mp4
* police_car_6095_shortened_960x540.mp4
* scooters_5638_shortened_960x540.mp4
./video_objects.py
与street_cam效果类似
只需要单只NCS设备即可使用
./
├── bus_station_6094_960x540.mp4
├── contrapicado_traffic_shortened_960x540.mp4
├── graph
├── install-opencv-from_source.sh
├── licenses.txt
├── Makefile
├── motorcycle_6098_shortened_960x540.mp4
├── police_car_6095_shortened_960x540.mp4
├── README.md
├── scooters_5638_shortened_960x540.mp4
└── video_objects.py
0 directories, 11 files
注意 需要python的tkinter库
cd ~/ai_ws/ncappzoo/apps/classifier-gui/
make
(仅第一次)
./classifier-gui.py
参见./apps_demo_run/Classifier-GUI_Demo_run.png
ai@ai-usb:~/ai_ws/ncappzoo/apps/classifier-gui$ ./classifier-gui.py
Reading package lists… Done
Building dependency tree
Reading state information… Done
python3-pil.imagetk is already the newest version (3.1.2-0ubuntu1.1).
The following packages were automatically installed and are no longer required:
libgtkglext1 libllvm4.0 libopencv-calib3d2.4v5 libopencv-contrib2.4v5
libopencv-features2d2.4v5 libopencv-flann2.4v5 libopencv-gpu2.4v5
libopencv-highgui2.4v5 libopencv-legacy2.4v5 libopencv-ml2.4v5
libopencv-objdetect2.4v5 libopencv-ocl2.4v5 libopencv-photo2.4v5
libopencv-stitching2.4v5 libopencv-superres2.4v5 libopencv-ts2.4v5
libopencv-video2.4v5 libopencv-videostab2.4v5 libopencv2.4-java
libopencv2.4-jni linux-headers-4.10.0-28 linux-headers-4.10.0-28-generic
linux-headers-4.4.0-109 linux-headers-4.4.0-109-generic
linux-image-4.10.0-28-generic linux-image-extra-4.10.0-28-generic
linux-signed-image-4.10.0-28-generic
Use ‘sudo apt autoremove’ to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Device 0 Address: 2.4 - VID/PID 03e7:2150
Device 1 Address: 2.3 - VID/PID 03e7:2150
Starting wait for connect with 2000ms timeout
Found Address: 2.4 - VID/PID 03e7:2150
Found EP 0x81 : max packet size is 512 bytes
Found EP 0x01 : max packet size is 512 bytes
Found and opened device
Performing bulk write of 865724 bytes…
Successfully sent 865724 bytes of data in 80.254161 ms (10.287551 MB/s)
Boot successful, device address 2.4
Found Address: 2.4 - VID/PID 03e7:f63b
done
Booted 2.4 -> VSC
——- predictions ——–
tiger cat 40.28 %
tabby 32.37 %
Egyptian cat 8.99 %
lynx 5.24 %
remote control 1.22 %
ai@ai-usb:~/ai_ws/ncappzoo/apps/classifier-gui$
ai@ai-usb:~/ai_ws/ncappzoo/apps/classifier-gui$ ./classifier-gui.py
Traceback (most recent call last):
File “/usr/lib/python3.5/tkinter/init.py”, line 36, in
import _tkinter
ImportError: No module named ‘_tkinter’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “./classifier-gui.py”, line 17, in
from tkinter import *
File “/usr/lib/python3.5/tkinter/init.py”, line 38, in
raise ImportError(str(msg) + ‘, please install the python3-tk package’)
ImportError: No module named ‘_tkinter’, please install the python3-tk package
解决 sudo apt-get install python3-tk
ai@ai-usb:~/ai_ws/ncappzoo/apps/classifier-gui$ ./classifier-gui.py
Traceback (most recent call last):
File “./classifier-gui.py”, line 20, in
from PIL import Image, ImageTk
ImportError: cannot import name ‘ImageTk’
解决 sudo apt-get install -y python3-pil.imagetk
./
├── AUTHORS
├── classifier-gui.py
├── Makefile
└── readme.md
0 directories, 4 files
cd ~/ai_ws/ncappzoo/apps/rapid-image-classifier/
make
(仅第一次)
python3 rapid-image-classifier.py
Prediction for pic_071.jpg: African elephant, Loxodonta africana with 94.8% confidence in 39.25 ms
Prediction for pic_003.jpg: grey fox, gray fox, Urocyon cinereoargenteus with 70.6% confidence in 39.29 ms
Prediction for pic_027.jpg: leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea with 78.2% confidence in 39.41 ms
Prediction for pic_040.jpg: American egret, great white heron, Egretta albus with 41.6% confidence in 39.19 ms
Prediction for pic_058.jpg: hare with 50.1% confidence in 39.16 ms
Prediction for pic_019.jpg: lion, king of beasts, Panthera leo with 97.7% confidence in 39.26 ms
Prediction for pic_012.jpg: cougar, puma, catamount, mountain lion, painter, panther, Felis concolor with 99.9% confidence in 39.42 ms
Prediction for pic_007.jpg: lion, king of beasts, Panthera leo with 69.4% confidence in 39.50 ms
Traceback (most recent call last):
File “image-classifier.py”, line 51, in
img = skimage.transform.resize( img, IMAGE_DIM, preserve_range=True )
TypeError: resize() got an unexpected keyword argument ‘preserve_range’
Makefile:32: recipe for target ‘run’ failed
make: * [run] Error 1
解答 :
pip3 install scikit-image
./
├── AUTHORS.txt
├── Makefile
├── rapid-image-classifier.py
└── readme.md
0 directories, 4 files
cd ~/ai_ws/ncappzoo/apps/log-image-classifier/
make run
(仅第一次)
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.
Traceback (most recent call last):
File “log-image-classifier.py”, line 177, in
main()
File “log-image-classifier.py”, line 167, in main
graph = load_graph( device )
File “log-image-classifier.py”, line 55, in load_graph
with open( GRAPH_PATH, mode=’rb’ ) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/ai/workspace/ncappzoo/caffe/GoogLeNet/graph’
Makefile:37: recipe for target ‘run’ failed
make: * [run] Error 1
解答 :
gedit log-image-classifier.py
修改NCAPPZOO_PATH为以下路径:
# User modifiable input parameters
NCAPPZOO_PATH = expanduser( ‘../..’ )
GRAPH_PATH = NCAPPZOO_PATH + ‘/caffe/GoogLeNet/graph’
Traceback (most recent call last):
File “image-classifier.py”, line 51, in
img = skimage.transform.resize( img, IMAGE_DIM, preserve_range=True )
TypeError: resize() got an unexpected keyword argument ‘preserve_range’
Makefile:32: recipe for target ‘run’ failed
make: * [run] Error 1
解答 :
pip3 install scikit-image
├── AUTHORS.txt
├── inferences.csv
├── log-image-classifier.py
├── Makefile
└── README.md
0 directories, 5 files
cd ~/ai_ws/ncappzoo/apps/live-image-classifier/
make run
(仅第一次)
python3 live-image-classifier.py
Prediction: 367 gorilla, Gorilla gorilla with 9.6% confidence in 48.79 ms
Prediction: 367 gorilla, Gorilla gorilla with 21.8% confidence in 39.40 ms
Prediction: 367 gorilla, Gorilla gorilla with 21.2% confidence in 39.34 ms
Prediction: 367 gorilla, Gorilla gorilla with 21.0% confidence in 39.24 ms
Prediction: 367 gorilla, Gorilla gorilla with 22.8% confidence in 39.12 ms
Prediction: 644 mask with 12.8% confidence in 39.13 ms
Prediction: 367 gorilla, Gorilla gorilla with 16.4% confidence in 39.19 ms
Prediction: 367 gorilla, Gorilla gorilla with 17.5% confidence in 39.18 ms
Prediction: 367 gorilla, Gorilla gorilla with 30.7% confidence in 39.27 ms
Prediction: 462 breastplate, aegis, egis with 10.8% confidence in 39.15 ms
Prediction: 367 gorilla, Gorilla gorilla with 11.4% confidence in 39.35 ms
Traceback (most recent call last):
File “live-image-classifier.py”, line 139, in
main()
File “live-image-classifier.py”, line 125, in main
graph = load_graph( device )
File “live-image-classifier.py”, line 49, in load_graph
with open( GRAPH_PATH, mode=’rb’ ) as f:
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/ai/workspace/ncappzoo/tensorflow/mobilenets/graph’
解答 :
gedit live-image-classifier.py
修改NCAPPZOO_PATH为以下路径:
User modifiable input parameters
NCAPPZOO_PATH = expanduser( ‘../..’ )
├── AUTHORS.txt
├── live-image-classifier.py
├── Makefile
└── README.md
0 directories, 4 files
cd ~/ai_ws/ncappzoo/apps/gender_age_lbp/
make run_age NOTE 单独运行识别年龄的Demo
or
make run_gender NOTE 单独运行识别性别的Demo
or
make run NOTE 同时运行2个Demo,但需要2只NCS设备
~~~
making run gender
cd cpp; ./gender_age_lbp gender; cd ..;
MVNC device 0 name: 1.1
Successfully opened MVNC device1.1
Num of NCS connected: 1
Successfully Allocated Gender graph for MVNC device.
参考:gender_lbp.jpg
~~~
making run age
cd cpp; ./gender_age_lbp age; cd ..;
MVNC device 0 name: 1.1
Successfully opened MVNC device1.1
MVNC device 1 name: 1.1
Error - mvncOpenDevice failed: -2
Num of NCS connected: 1
Successfully Allocated Age graph for MVNC device
25-32
38-43
38-43
38-43
38-43
参考:age_lbp.jpg
g++ -std=c++11 cpp/gender_age_lbp.cpp cpp/fp16.c -o cpp/gender_age_lbp -L/usr/local/lib -lmvnc -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_objdetect -lopencv_videoio
/usr/bin/ld: cannot find -lopencv_videoio
collect2: error: ld returned 1 exit status
Makefile:19: recipe for target ‘gender_age_lbp’ failed
make: * [gender_age_lbp] Error 1
解答:
从源码安装openCV
cd ~/ai_ws/ncappzoo/apps/street_cam/
./install-opencv-from_source.sh
├── age_graph
│ └── graph
├── agenet.graph
├── catstat
│ ├── Age
│ │ ├── categories.txt
│ │ └── stat.txt
│ └── Gender
│ ├── categories.txt
│ └── stat.txt
├── cpp
│ ├── fp16.c
│ ├── fp16.h
│ ├── gender_age_lbp
│ └── gender_age_lbp.cpp
├── gender_graph
│ └── graph
├── gendernet.graph
├── lbpcascade_frontalface_improved.xml
├── LICENSES
│ ├── numpy.txt
│ ├── stb_image_resize.txt
│ └── stb_image.txt
├── Makefile
└── readme.md
cd ~/ai_ws/ncappzoo/apps/video_face_matcher/
make run_py
(仅第一次)
python3 video_face_matcher.py
FAIL! File camera frame 7 does not match ./validated_images/valid.jpg
Total Difference is: 1.77696454525
FAIL! File camera frame 8 does not match ./validated_images/valid.jpg
Total Difference is: 1.7352335453
FAIL! File camera frame 9 does not match ./validated_images/valid.jpg
Total Difference is: 1.78809916973
FAIL! File camera frame 10 does not match ./validated_images/valid.jpg
Total Difference is: 1.78080058098
FAIL! File camera frame 11 does not match ./validated_images/valid.jpg
Total Difference is: 1.75348883867
FAIL! File camera frame 12 does not match ./validated_images/valid.jpg
Total Difference is: 1.73598998785
FAIL! File camera frame 13 does not match ./validated_images/valid.jpg
Total Difference is: 1.75593054295
FAIL! File camera frame 14 does not match ./validated_images/valid.jpg
├── facenet_celeb_ncs.graph
├── install-opencv-from_source.sh
├── Makefile
├── README.md
├── validated_images
│ └── valid.jpg
└── video_face_matcher.py
1 directory, 6 files
——- predictions ——–
prediction 0 is n02123159 tiger cat
prediction 1 is n02123045 tabby, tabby cat
prediction 2 is n02124075 Egyptian cat
prediction 3 is n02127052 lynx, catamount
Traceback (most recent call last):
File “image-classifier.py”, line 80, in
skimage.io.imshow( IMAGE_PATH )
File “/home/ai2/.local/lib/python3.5/site-packages/skimage/io/_io.py”, line 156, in imshow
return call_plugin(‘imshow’, arr, plugin=plugin, **plugin_args)
File “/home/ai2/.local/lib/python3.5/site-packages/skimage/io/manage_plugins.py”, line 198, in call_plugin
raise RuntimeError(msg % kind)
RuntimeError: No suitable plugin registered for imshow.
You may load I/O plugins with the skimage.io.use_plugin
command. A list of all available plugins are shown in the skimage.io
docstring.
解答:
sudo apt-get install -y python3-pil.imagetk