Book Image

Intelligent Mobile Projects with TensorFlow

By : Jeff Tang
Book Image

Intelligent Mobile Projects with TensorFlow

By: Jeff Tang

Overview of this book

As a developer, you always need to keep an eye out and be ready for what will be trending soon, while also focusing on what's trending currently. So, what's better than learning about the integration of the best of both worlds, the present and the future? Artificial Intelligence (AI) is widely regarded as the next big thing after mobile, and Google's TensorFlow is the leading open source machine learning framework, the hottest branch of AI. This book covers more than 10 complete iOS, Android, and Raspberry Pi apps powered by TensorFlow and built from scratch, running all kinds of cool TensorFlow models offline on-device: from computer vision, speech and language processing to generative adversarial networks and AlphaZero-like deep reinforcement learning. You’ll learn how to use or retrain existing TensorFlow models, build your own models, and develop intelligent mobile apps running those TensorFlow models. You'll learn how to quickly build such apps with step-by-step tutorials and how to avoid many pitfalls in the process with lots of hard-earned troubleshooting tips.
Table of Contents (14 chapters)

Using the GAN models in Android

It turns out we don't need to use the custom TensorFlow Android library, as we did in Chapter 7, Recognizing Drawing with CNN and LSTM, to run the GAN models in Android. Simply create a new Android Studio app called GAN with all the defaults, add compile 'org.tensorflow:tensorflow-android:+' to the app's build.gradle file, create a new assets folder and copy the two GAN model files and a test blurry image there.

Your project in Android Studio should now look like Figure 9.5:

Figure 9.5: Android Studio GAN app overview, showing constant definitions

Notice that for simplicity, we set BATCH_SIZE to 1. You can easily set it to any number and get that many outputs back as we did in iOS. Other than the constants defined in Figure 9.5, we'll create a few instance variables:

private Button mButtonMNIST;
private Button mButtonPix2Pix...