NVIDIA Jetson Nano學習筆記(四):安裝與執行Tensorflow Lite Model官方範例


sudo apt-get update
sudo apt-get upgrade


pip3 install Cython
pip3 install --upgrade Cython


sudo apt-get install python3-numpy
pip3 install numpy

安裝Tensorflow Lite(Python 3.6/ Linux ARM 64)

依照自己Nano的環境去調整Python 3.5 or 3.6 or 3.7。但是ARM 64 是肯定的。(Raspberry Pi為Linux ARM 32)

pip3 install https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp36-cp36m-linux_aarch64.whl


# 取得 photo(grace_hopper.bmp)
curl https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/lite/examples/label_image/testdata/grace_hopper.bmp > /tmp/grace_hopper.bmp
# 取得 model(mobilenet_v1_1.0_224.tflite)
curl https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_2018_02_22/mobilenet_v1_1.0_224.tgz | tar xzv -C /tmp
# 取得labels(labels.txt)
curl https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_1.0_224_frozen.tgz | tar xzv -C /tmp mobilenet_v1_1.0_224/labels.txt
# 將labels.txt移動到/tmp/
mv /tmp/mobilenet_v1_1.0_224/labels.txt /tmp/



python3 label_image.py \
--model_file /tmp/mobilenet_v1_1.0_224.tflite \
--label_file /tmp/labels.txt \
--image /tmp/grace_hopper.bmp
0.728693: military uniform
0.116163: Windsor tie
0.035517: bow tie
0.014874: mortarboard
0.011758: bolo tie

Written by

Machine Learning / Deep Learning / Python / Flutter cakeresume.com/yanwei-liu

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store