After two days of debugging and countless bugs, I finally installed the deep learning framework TensorFlow on my Raspberry Pi and successfully recognized a batch of images. For example, the AI thinks that this image is 90% likely to be a Samoyed dog.
Below is a detailed tutorial on installing TensorFlow on the Raspberry Pi, which I have personally tested:
sudo apt-get update
sudo apt-get install python-pip python-dev
wget https://github.com/samjabrahams/tensorflow-on-raspberry-pi/releases/download/v1.1.0/tensorflow-1.1.0-cp27-none-linux_armv7l.whl
sudo pip install tensorflow-1.1.0-cp27-none-linux_armv7l.whl
sudo pip uninstall mock
sudo pip install mock
Download this file on your laptop
https://pan.baidu.com/s/1Idub4dwi4rJqv7GWRK3zrQ
This compressed package is called models
Send this compressed package to your QQ email from your laptop
Open the browser on the remote desktop of the Raspberry Pi, enter mail.qq.com to download the models compressed package
Unzip the models compressed package to get the models folder
Enter the following command in the Raspberry Pi command line:
sudo cp -r /home/pi/Downloads/models* /usr/local/lib/python2.7/dist-packages/tensorflow
Open the remote desktop of the Raspberry Pi and create a tensorflow-related folder in the /home/pi directory, placing the panda image into this new folder
Open the command line interface
cd /usr/local/lib/python3.4/dist-packages/tensorflow/models/tutorials/image/imagenet
python3.4 classify_image.py –model_dir /home/pi/tensorflow-related/model –image_file /home/pi/tensorflow-related/panda.jpg
If you start installing the image recognition library
inception-2015-12-05, it means success, just wait a moment
This page appears, indicating that the panda image was recognized successfully, with the AI believing that this image is a panda with a probability of 89.107%
If you want to recognize other images, you need to place the image in the tensorflow-related folder of the Raspberry Pi, and then re-enter the previous python 3.4 command, just change the image name at the end of the command to the image you want to recognize.
If bugs occur during installation and use, be sure to carefully check the file directory addresses, image names, and file names in the code.
This installation of TensorFlow has greatly impacted me. Although there are many tutorials online teaching you how to install TensorFlow on a Raspberry Pi, it feels like the authors of those tutorials are just showing off their skills without considering each step for beginners and those with no foundation. To them, “using the command line to achieve folder copying after obtaining root privileges” only requires one line of code and is very easy, so they don’t need to write it in the tutorial. However, I spent two hours figuring out how to get past this hurdle. The Raspberry Pi itself is very interesting, but as a tool originally designed for children to learn programming, its entry threshold is too high. Any bug along the way or expensive peripherals can discourage even the most curious young makers from continuing their learning. I remember when I bought my first Raspberry Pi two years ago, I was filled with curiosity and excitement when I unboxed it, but after connecting it to a screen, it wouldn’t display anything. I was so frustrated that I gave up learning about the Raspberry Pi until now. After I got started, I realized that there’s no need for a keyboard, mouse, or screen; you can completely control it remotely using a laptop or even a smartphone. Therefore, from today, I am determined to create a Raspberry Pi course for beginners, completely new learners, third-grade elementary school students, and liberal arts students who know nothing about programming, using a “human language” approach to popularize knowledge about operating systems, networks, artificial intelligence, big data, blockchain, IoT, and programming. Starting from the simplest cases and from the bare metal, I will guide them into the world of makers and enjoy the joy of creation.
You only need the Raspberry Pi motherboard, case, power supply, TF card, and TF card reader (totaling less than 260 yuan, and you may need an additional camera for several dozen yuan later), completely without the need for a display, keyboard, or mouse.
The following will be some case studies for future Raspberry Pi courses:
Connect the Raspberry Pi to WiFi, obtain the Raspberry Pi IP address, remotely control the Raspberry Pi from anywhere in the world using a laptop, configure the Raspberry Pi with Chinese settings, make a router, radio, broadcast station, face recognition, image processing, Linux operating system, Python programming language, create a web server, remote video monitoring and push to a live streaming site, set-top box, explain the principles of virtual currency mining, and equip various sensors, internal network penetration, private cloud server, temperature monitoring, and network speed monitoring.