Intelligent Mobile Projects with TensorFlow
上QQ阅读APP看书,第一时间看更新

Detecting Objects and Their Locations

Object detection goes one step further than the image classification discussed in the previous chapter. Image classification just returns a label of class for an image, while object detection returns a list of objects identified in an image, along with a bounding box for each identified object. Modern object detection algorithms use deep learning to build models that can be used to detect and localize all kinds of objects in a single image. In the past few years, faster and more accurate object detection algorithms came one after another, and in June 2017, Google released the TensorFlow Object Detection API that incorporates several leading object detection algorithms.

In this chapter, we’ll first give a quick overview of object detection: the process of creating an effective deep learning model for object detection and then using the model for inference. Then, we’ll discus in detail how the TensorFlow Object Detection API works, how you can use several of its models for inference, and how you can retrain them with your own dataset. After that, we’ll show you how you can use the pre-trained object detection models as well as the retrained models in your iOS app. We’ll cover some powerful tips that let you build a custom TensorFlow iOS library manually to fix the problem with using the TensorFlow pod; this will help you get ready for dealing with any TensorFlow-supported models covered in the rest of the book. In this chapter, we won’t provide an Android example app for object detection, as the TensorFlow source code already comes with a good example of doing so, using both a TensorFlow Object Detection pre-trained model as well as the YOLO model, which we’ll cover last in this chapter. We’ll show you how to use another leading object detection model, YOLO v2, in your iOS app. In summary, we're going to cover the following topics in this chapter:

  • Object detection: a quick overview
  • Setting up the TensorFlow Object Detection API
  • Retraining SSD-MobileNet and Faster RCNN models
  • Using object detection models in iOS
  • Using YOLO2: another object detection model