Machine Learning Projects for Mobile Applications

Book description

Bring magic to your mobile apps using TensorFlow Lite and Core ML

Key Features

  • Explore machine learning using classification, analytics, and detection tasks.
  • Work with image, text and video datasets to delve into real-world tasks
  • Build apps for Android and iOS using Caffe, Core ML and Tensorflow Lite

Book Description

Machine learning is a technique that focuses on developing computer programs that can be modified when exposed to new data. We can make use of it for our mobile applications and this book will show you how to do so.

The book starts with the basics of machine learning concepts for mobile applications and how to get well equipped for further tasks. You will start by developing an app to classify age and gender using Core ML and Tensorflow Lite. You will explore neural style transfer and get familiar with how deep CNNs work. We will also take a closer look at Google's ML Kit for the Firebase SDK for mobile applications. You will learn how to detect handwritten text on mobile. You will also learn how to create your own Snapchat filter by making use of facial attributes and OpenCV. You will learn how to train your own food classification model on your mobile; all of this will be done with the help of deep learning techniques. Lastly, you will build an image classifier on your mobile, compare its performance, and analyze the results on both mobile and cloud using TensorFlow Lite with an RCNN.

By the end of this book, you will not only have mastered the concepts of machine learning but also learned how to resolve problems faced while building powerful apps on mobiles using TensorFlow Lite, Caffe2, and Core ML.

What you will learn

  • Demystify the machine learning landscape on mobile
  • Age and gender detection using TensorFlow Lite and Core ML
  • Use ML Kit for Firebase for in-text detection, face detection, and barcode scanning
  • Create a digit classifier using adversarial learning
  • Build a cross-platform application with face filters using OpenCV
  • Classify food using deep CNNs and TensorFlow Lite on iOS

Who this book is for

Machine Learning Projects for Mobile Applications is for you if you are a data scientist, machine learning expert, deep learning, or AI enthusiast who fancies mastering machine learning and deep learning implementation with practical examples using TensorFlow Lite and CoreML. Basic knowledge of Python programming language would be an added advantage.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Machine Learning Projects for Mobile Applications
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
  5. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the code
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  7. Mobile Landscapes in Machine Learning
    1. Machine learning basics
      1. Supervised learning
      2. Unsupervised learning
      3. Linear regression - supervised learning
    2. TensorFlow Lite and Core ML
    3. TensorFlow Lite
      1. Supported platforms
      2. TensorFlow Lite memory usage and performance 
      3. Hands-on with TensorFlow Lite 
      4. Converting SavedModel into TensorFlow Lite format
        1. Strategies
      5. TensorFlow Lite on Android
        1. Downloading the APK binary
        2. TensorFlow Lite on Android Studio
        3. Building the TensorFlow Lite demo app from the source
        4. Installing Bazel
        5. Installing using Homebrew
        6. Installing Android NDK and SDK
      6. TensorFlow Lite on iOS
        1. Prerequisites
        2. Building the iOS demo app
    4. Core ML
      1. Core ML model conversion
        1. Converting your own model into a Core ML model
      2. Core ML on an iOS app
    5. Summary
  8. CNN Based Age and Gender Identification Using Core ML
    1. Age, gender, and emotion prediction
      1. Age prediction
      2. Gender prediction
    2. Convolutional Neural Networks 
      1. Finding patterns
      2. Finding features from an image
      3. Pooling layer
      4. Rectified linear units
      5. Local response normalization layer
      6. Dropout layer
      7. Fully connected layer
      8. CNNs for age and gender prediction
        1. Architecture
        2. Training the network
          1. Initializing the dataset
    3. The implementation on iOS using Core ML
    4. Summary
  9. Applying Neural Style Transfer on Photos
    1. Artistic neural style transfer
      1. Background
      2. VGG network
        1. Layers in the VGG network
    2. Building the applications
      1. TensorFlow-to-Core ML conversion
      2. iOS application
      3. Android application
        1. Setting up the model
        2. Training your own model
        3. Building the application
        4. Setting up the camera and an image picker 
    3. Summary
    4. References
  10. Deep Diving into the ML Kit with Firebase
    1. ML Kit basics
      1. Basic feature set
      2. Building the application
        1. Adding Firebase to our application
    2. Face detection
      1. Face orientation tracking
        1. Landmarks
        2. Classification
        3. Implementing face detection
        4. Face detector configuration
      2. Running the face detector
        1. Step one: creating a FirebaseVisionImage from the input
          1. Using a bitmap
          2. From media.Image
          3. From a ByteBuffer
          4. From a ByteArray
          5. From a file
        2. Step two: creating an instance of FirebaseVisionFaceDetector object
        3. Step three: image detection
          1. Retrieving information from detected faces
    3. Barcode scanner
      1. Step one: creating a FirebaseVisionImage object
        1. From bitmap
        2. From media.Image
        3. From ByteBuffer
        4. From ByteArray
        5. From file
      2. Step two: creating a FirebaseVisionBarcodeDetector object
      3. Step three: barcode detection
    4. Text recognition
      1. On-device text recognition
        1. Detecting text on a device
      2. Cloud-based text recognition
        1. Configuring the detector
    5. Summary
  11. A Snapchat-Like AR Filter on Android
    1. MobileNet models
      1. Building the dataset
        1. Retraining of images 
        2. Model conversion from GraphDef to TFLite
          1. Gender model
          2. Emotion model
          3. Comparison of MobileNet versions
    2. Building the Android application
    3. References
    4. Questions
    5. Summary
  12. Handwritten Digit Classifier Using Adversarial Learning
    1. Generative Adversarial Networks
      1. Generative versus discriminative algorithms
        1. Steps in GAN
    2. Understanding the MNIST database
    3. Building the TensorFlow model
    4. Training the neural network
      1. Building the Android application
      2. FreeHandView for writing
      3. Digit classifier
    5. Summary
  13. Face-Swapping with Your Friends Using OpenCV
    1. Understanding face-swapping
      1. Steps in face-swapping
        1. Facial key point detection
        2. Identifying the convex hull
        3. Delaunay triangulation and Voronoi diagrams
        4. Affine warp triangles
        5. Seamless cloning
      2. Building the Android application
      3. Building a native face-swapper library
        3. Applying face-swapping logic
      4. Building the application
    2. Summary
    3. References
    4. Questions
  14. Classifying Food Using Transfer Learning
    1. Transfer learning
      1. Approaches in transfer learning
    2. Training our own TensorFlow model 
      1. Installing TensorFlow
      2. Training the images
      3. Retraining with own images
        1. Training steps parameter
        2. Architecture
        3. Distortions
        4. Hyperparameters
        5. Running the training script
        6. Model conversion
      4. Building the iOS application
    3. Summary
  15. What's Next?
    1. What you have learned so far
      1. Where to start when developing an ML application
        1. IBM Watson services
        2. Microsoft Azure Cognitive Services
        3. Amazon ML
        4. Google Cloud ML
      2. Building your own model
        1. Limitations of building your own model
        2. Personalized user experience
        3. Better search results
        4. Targeting the right user
    2. Summary
    3. Further reading
  16. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Machine Learning Projects for Mobile Applications
  • Author(s): Karthikeyan NG
  • Release date: October 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788994590