According to Wikipedia, "The Raspberry Pi is a series of small single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science in schools and in developing countries." The official site of Raspberry Pi (https://www.raspberrypi.org) describes it as "a small and affordable computer that you can use to learn programming." If you have never heard of or used Raspberry Pi before, just go its website and chances are you'll quickly fall in love with the cool little thing. Little yet powerful—in fact, developers of TensorFlow made TensorFlow available on Raspberry Pi from early versions around mid-2016, so we can run complicated TensorFlow models on the tiny computer that you can buy for about $35. This is probably beyond "the teaching of basic computer science" or "to learn programming," but on the other hand, if we think about all the rapid advances in mobile devices in the past few years, we shouldn't be surprised to see how greater and greater features have been implemented in smaller and smaller devices.
In this chapter, we'll enter the fun and exciting world of Raspberry Pi, the smallest device officially supported by TensorFlow. We'll first cover how to get and set up a new Raspberry Pi 3 B board, including all the necessary accessories used in this chapter to make it see, listen, and speak. Then we'll cover how to use the GoPiGo Robot Base Kit (https://www.dexterindustries.com/shop/gopigo3-robot-base-kit) to turn a Raspberry Pi board into a robot that can move. After that, we'll provide the simplest working steps to set up TensorFlow 1.6 on Raspberry Pi and build its example Raspberry Pi apps. We'll also discuss how to integrate image classification, the model we used in Chapter 2, Classifying Images with Transfer Learning, with text to speech to make the robot tell us what it recognizes, and how to integrate audio recognition, the model we used in Chapter 5, Understanding Simple Speech Commands, with the GoPiGo API to let you use voice commands to control the movement of your robot.
Finally, we'll show you how to use TensorFlow and OpenAI Gym, a Python toolkit for developing and comparing reinforcement learning algorithms, to implement a powerful reinforcement learning algorithm in a simulated environment to get our robot ready to move and balance in a real physical environment.
In Google I/O 2016, there's a session called How to build a smart RasPi Bot with Cloud Vision and Speech API (you can watch the video on YouTube). It uses Google's Cloud APIs to perform image classification and speech recognition and synthesis. In this chapter, we'll see how we can implement the tasks in the demo, as well as reinforcement learning, offline on device, showing the power of TensorFlow on Raspberry Pi.
In summary, we'll cover the following topics in this chapter to build a robot that moves, sees, listens, speaks, and learns:
- Setting up Raspberry Pi and making it move
- Setting up TensorFlow on Raspberry Pi
- Image recognition and text to speech
- Audio recognition and robot movement
- Reinforcement learning on Raspberry Pi