Introduction and Use - Tensorflow Object Detection API Tutorial

Hello and welcome to a miniseries and introduction to the TensorFlow Object Detection API. This API can be used to detect, with bounding boxes, objects in images and/or video using either some of the pre-trained models made available or through models you can train on your own (which the API also makes easier).

To begin, you're going to want to make sure you have TensorFlow and all of the dependencies. For CPU TensorFlow, you can just do pip install tensorflow, but, of course, the GPU version of TensorFlow is much faster at processing so it is ideal. If you need to install GPU TensorFlow:

Installing GPU TensorFlow links:

  • GPU TensorFlow on Ubuntu tutorial
  • GPU TensorFlow on Windows tutorial
  • If you do not have a powerful enough GPU to run the GPU version of TensorFlow, one option is to use PaperSpace. Using that link should give you $10 in credit to get started, giving you ~10-20 hours of use.

    Beyond this, the other Python dependencies are covered with:

    pip install pillow
    pip install lxml
    pip install jupyter
    pip install matplotlib

    Next, we need to clone the github. We can do this with git, or you can just download the repository to .zip:

    git clone OR click the green "clone or download" button on the page, download the .zip, and extract it.

    Once you have the models directory (or models-master if you downloaded and extracted the .zip), navigate to that directory in your terminal/cmd.exe. The next steps are slightly different on Ubuntu vs Windows.

    On Ubuntu:

    protoc object_detection/protos/*.proto --python_out=.


    export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

    If you get an error on the protoc command on Ubuntu, check the version you are running with protoc --version, if it's not the latest version, you might want to update. As of my writing of this, we're using 3.4.0. In order to update or get protoc, head to the protoc releases page. Download the python version, extract, navigate into the directory and then do:

    sudo ./configure
    sudo make check
    sudo make install

    After that, try the protoc command again (again, make sure you are issuing this from the models dir).

    On Windows:

    Head to the protoc releases page and download the, extract it, and you will find protoc.exe in the bin directory.

    You can move this to something more appropriate if you like, or leave it here. I eventually put mine in program files, making a "protoc" directory and dropping it in there.

    Now, from within the models (or models-master) directory, you can use the protoc command like so:

    "C:/Program Files/protoc/bin/protoc" object_detection/protos/*.proto --python_out=.

    Next, open terminal/cmd.exe from the models/object_detection directory and open the Jupyter Notebook with jupyter notebook. From here, choose the object_detection_tutorial.ipynb. From here, you should be able to cell in the main menu, and choose run all

    You should get the following results:

    Object Detection machine learning tutorials Object Detection machine learning tutorials

    In the next tutorial, we'll cover how we can label data live from a webcam stream by modifying this sample code slightly.

    The next tutorial:

  • Introduction and Use - Tensorflow Object Detection API Tutorial
  • Streaming Object Detection Video - Tensorflow Object Detection API Tutorial
  • Tracking Custom Objects Intro - Tensorflow Object Detection API Tutorial
  • Creating TFRecords - Tensorflow Object Detection API Tutorial
  • Training Custom Object Detector - Tensorflow Object Detection API Tutorial
  • Testing Custom Object Detector - Tensorflow Object Detection API Tutorial