0%

AI is nothing without somewhere to run it. Now that mobile devices have become the primary computing device for most people, it's essential that mobile developers add AI to their toolbox. This insightful book is your guide to creating and running models on popular mobile platforms such as iOS and Android.

Laurence Moroney, lead AI advocate at Google, offers an introduction to machine learning techniques and tools, then walks you through writing Android and iOS apps powered by common ML models like computer vision and text recognition, using tools such as ML Kit, TensorFlow Lite, and Core ML. If you're a mobile developer, this book will help you take advantage of the ML revolution today.

  • Explore the options for implementing ML and AI on mobile devices
  • Create ML models for iOS and Android
  • Write ML Kit and TensorFlow Lite apps for iOS and Android, and Core ML/Create ML apps for iOS
  • Choose the best techniques and tools for your use case, such as cloud-based versus on-device inference and high-level versus low-level APIs
  • Learn privacy and ethics best practices for ML on devices

Table of Contents

  1. Preface
    1. Who Should Read This Book?
    2. Why I Wrote This Book
    3. Navigating This Book
    4. Technology You Need to Understand
    5. Conventions Used in This Book
    6. Using Code Examples
    7. O’Reilly Online Learning
    8. How to Contact Us
    9. Acknowledgements
  2. 1. Introduction to AI and Machine Learning
    1. What Is Artificial Intelligence?
    2. What Is Machine Learning?
    3. Moving from Traditional Programming to Machine Learning
    4. How Can a Machine Learn?
    5. Comparing Machine Learning with Traditional Programming
    6. Building and Using Models on Mobile
    7. Summary
  3. 2. Introduction to Computer Vision
    1. Using Neurons for Vision
    2. Your First Classifier: Recognizing Clothing Items
    3. The Data: Fashion MNIST
    4. A Model Architecture to Parse Fashion MNIST
    5. Coding the Fashion MNIST Model
    6. Transfer Learning for Computer Vision
    7. Summary
  4. 3. Introduction to ML Kit
    1. Building a Face Detection App on Android
    2. Step 1: Create the App with Android Studio
    3. Step 2: Add and Configure ML Kit
    4. Step 3: Define the User Interface
    5. Step 4: Add the Images as Assets
    6. Step 5: Load the UI with a Default Picture
    7. Step 6: Call the Face Detector
    8. Step 7: Add the Bounding Rectangles
    9. Building a Face Detector App for iOS
    10. Step 1: Create the Project in Xcode
    11. Step 2: Using CocoaPods and Podfiles
    12. Step 3: Create the User Interface
    13. Step 4: Add the Application Logic
    14. Summary
  5. 4. Computer Vision Apps with ML Kit on Android
    1. Image Labeling and Classification
    2. Step 1: Create the App and Configure ML Kit
    3. Step 2: Create the User Interface
    4. Step 3: Add the Images as Assets
    5. Step 4: Load an Image to the ImageView
    6. Step 5: Write the Button Handler Code
    7. Next Steps
    8. Object Detection
    9. Step 1: Create the App and Import ML Kit
    10. Step 2: Create the Activity Layout XML
    11. Step 3: Load an Image into the ImageView
    12. Step 4: Set Up the Object Detector Options
    13. Step 5: Handling the Button Interaction
    14. Step 6: Draw the Bounding Boxes
    15. Step 7: Label the Objects
    16. Detecting and Tracking Objects in Video
    17. Exploring the Layout
    18. The GraphicOverlay Class
    19. Capturing the Camera
    20. The ObjectAnalyzer Class
    21. The ObjectGraphic Class
    22. Putting It All Together
    23. Summary
  6. 5. Text Processing Apps with ML Kit on Android
    1. Entity Extraction
    2. Start Creating the App
    3. Create the Layout for the Activity
    4. Write the Entity Extraction Code
    5. Putting It All Together
    6. Handwriting and Other Recognition
    7. Start the App
    8. Creating a Drawing Surface
    9. Parsing the Ink with ML Kit
    10. Smart Reply to Conversations
    11. Start the App
    12. Mock a Conversation
    13. Generating a Smart Reply
    14. Summary
  7. 6. Computer Vision Apps with ML Kit on iOS
    1. Image Labeling and Classification
    2. Step 1: Create the App in Xcode
    3. Step 2: Create the Podfile
    4. Step 3: Set Up the Storyboard
    5. Step 4: Edit the View Controller Code to Use ML Kit
    6. Object Detection in iOS with ML Kit
    7. Step 1: Get Started
    8. Step 2: Create Your UI on the Storyboard
    9. Step 3: Create a Subview for Annotation
    10. Step 4: Perform the Object Detection
    11. Step 5: Handle the Callback
    12. Combining Object Detection with Image Classification
    13. Object Detection and Tracking in Video
    14. Summary
  8. 7. Text Processing Apps with ML Kit on iOS
    1. Entity Extraction
    2. Step 1: Create the App and Add the ML Kit Pods
    3. Step 2: Create the Storyboard with Actions and Outlets
    4. Step 3: Allow Your View Controller to be Used for Text Entry
    5. Step 4: Initialize the Model
    6. Step 5: Extract Entities from Text
    7. Handwriting Recognition
    8. Step 1: Create the App and Add the ML Kit Pods
    9. Step 2: Create the Storyboard, Actions, and Outlets
    10. Step 3: Strokes, Points, and Ink
    11. Step 4: Capture User Input
    12. Step 5: Initialize the Model
    13. Step 6: Do the Ink Recognition
    14. Smart Reply to Conversations
    15. Step 1: Create an App and Integrate ML Kit
    16. Step 2: Create Storyboard, Outlets, and Actions
    17. Step 3: Create a Simulated Conversation
    18. Step 4: Get Smart Reply
    19. Summary
  9. 8. Going Deeper: Understanding TensorFlow Lite
    1. What Is TensorFlow Lite?
    2. Getting Started with TensorFlow Lite
    3. Save the Model
    4. Convert the Model
    5. Testing the Model with a Standalone Interpreter
    6. Create an Android App to Host TFLite
    7. Import the TFLite File
    8. Write Kotlin Code to Interface with the Model
    9. Going Beyond the Basics
    10. Create an iOS App to Host TFLite
    11. Step 1: Create a Basic iOS App
    12. Step 2: Add TensorFlow Lite to Your Project
    13. Step 3: Create the User Interface
    14. Step 4: Add and Initialize the Model Inference Class
    15. Step 5: Perform the Inference
    16. Step 6: Add the Model to Your App
    17. Step 7: Add the UI Logic
    18. Moving Beyond “Hello World”: Processing Images
    19. Exploring Model Optimization
    20. Quantization
    21. Using Representative Data
    22. Summary
  10. 9. Creating Custom Models
    1. Creating a Model with TensorFlow Lite Model Maker
    2. Creating a Model with Cloud AutoML
    3. Using AutoML Vision Edge
    4. Creating a Model with TensorFlow and Transfer Learning
    5. Creating Language Models
    6. Create a Language Model with Model Maker
    7. Summary
  11. 10. Using Custom Models in Android
    1. Bridging Models to Android
    2. Building an Image Classification App from a Model Maker Output
    3. Using a Model Maker Output with ML Kit
    4. Using Language Models
    5. Creating an Android App for Language Classification
    6. Summary
  12. 11. Using Custom Models in iOS
    1. Bridging Models to iOS
    2. A Custom Model Image Classifier
    3. Step 1: Create the App and Add the TensorFlow Lite Pod
    4. Step 2: Create the UI and Image Assets
    5. Step 3: Load and Navigate Through the Image Assets
    6. Step 4: Load the Model
    7. Step 5: Convert an Image to an Input Tensor
    8. Step 6: Get Inference for the Tensor
    9. Use a Custom Model in ML Kit
    10. Building an App for Natural Language Processing in Swift
    11. Step 1: Load the Vocab
    12. Step 2: Convert the Sentence to a Sequence
    13. Step 3: Extend Array to Handle Unsafe Data
    14. Step 4: Copy the Array to a Data Buffer
    15. Step 5: Run Inference on the Data and Process the Results
    16. Summary
  13. 12. Productizing Your App Using Firebase
    1. Why Use Firebase Custom Model Hosting?
    2. Create Multiple Model Versions
    3. Using Firebase Model Hosting
    4. Step 1: Create a Firebase Project
    5. Step 2: Use Custom Model Hosting
    6. Step 3: Create a Basic Android App
    7. Step 4: Add Firebase to the App
    8. Step 5: Get the Model from Firebase Model Hosting
    9. Step 6: Use Remote Configuration
    10. Step 7: Read Remote Configuration in Your App
    11. Next Steps
    12. Summary
  14. 13. Create ML and Core ML for Simple iOS Apps
    1. A Core ML Image Classifier Built Using Create ML
    2. Making a Core ML App That Uses a Create ML Model
    3. Add the MLModel File
    4. Run the Inference
    5. Using Create ML to Build a Text Classifier
    6. Use the Model in an App
    7. Summary
  15. 14. Accessing Cloud-Based Models from Mobile Apps
    1. Installing TensorFlow Serving
    2. Installing Using Docker
    3. Installing Directly on Linux
    4. Building and Serving a Model
    5. Accessing a Server Model from Android
    6. Accessing a Server Model from iOS
    7. Summary
  16. 15. Ethics, Fairness, and Privacy for Mobile Apps
    1. Ethics, Fairness, and Privacy with Responsible AI
    2. Responsibly Defining Your Problem
    3. Avoiding Bias in Your Data
    4. Building and Training Your Model
    5. Evaluating Your Model
    6. Google’s AI Principles
    7. Summary
  17. Index
3.145.151.141