DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Training TensorFlow Object Detection Models

Training TensorFlow Object Detection Models

Let's take a look at training TensorFlow object detection models as well as explore a two-minute video for a quick demo.

Niklas Heidloff user avatar by
Niklas Heidloff
CORE ·
Sep. 21, 18 · Analysis
Like (3)
Save
Tweet
Share
9.26K Views

Join the DZone community and get the full member experience.

Join For Free

tensorflow object detection is a powerful technology that can recognize different objects in images, including their positions. the trained object detection models can be run on mobile and edge devices to execute predictions very quickly. i've used this technology to build a demo where anki overdrive cars and obstacles are detected via an ios app. when obstacles are detected, the cars are stopped automatically.

check out the short video (only 2 mins) for a quick demo.

this picture shows the track with two cars and a phone and the ios app which draws rectangles around the objects.

i have open sourced the code on github. the repo includes two parts:

  1. trained deep learning model to recognize items on anki overdrive tracks with an ios app
  2. documentation how to train tensorflow object detection models

the instructions in the readme are pretty detailed. below is a quick overview of the main steps that you can follow to train models to detect your own objects.

1) development environment setup

first, you need to download the trained mobilenet model, which is an optimized model for mobile devices. rather than training a new model from scratch, transfer learning is used. basically, the last layer of the neural network is replaced with your own objects.

to make the setup of the development environment as simple as possible, docker containers are provided.

2) labelimg of images

while for visual recognition models only images and the names of the categories need to be provided, the labeling for object detection is more sophisticated. in addition to the list of objects you also need to provide their positions, i've used labelimg to create the labels and rectangles as shown in the screenshot.

from what i've read, these are some best practices on how to create the training data:

  • take/get at least 50 pictures per object.
  • use a rather small resolution, for example, 640 x 480.
  • use different sizes of your objects and different angles.
  • use pictures that have multiple objects in them.
  • when marking the objects with labelimg, put the rectangles as closely as possible around the objects.

the images and the annotations exported from the labelimg tool need to be converted into a certain format (tfrecords) which tensorflow object detection expects.

3) training of the model

trainings with just a few training steps can be run locally . this is useful, for example, if you want to test whether the code runs. when you can use a gpu, trainings with many steps should also be possible locally, but i haven't tried it.

i've used kubernetes on the ibm cloud to run the training. the 17.000 training steps took roughly 1.5 days. in order to also leverage gpus, i want to look at ffdl . i'll write about it when i find out more. if you want to use the ibm cloud, you can get a free account .

after the training, a frozen graph of the model needs to be created. the repo contains a script and a docker container to do this.

4) usage of the model in notebooks and apps

the training model can be tested with a python notebook . the screenshot shows the detected objects in a test image.

the repo also contains an ios app , which i found on github .

connecting the cars and the ios app to the watson iot platform

in order to stop the anki overdrive cars when phones are put on the track, you need to set up additional components, especially the node.js controller and the watson iot platform . in order to do this, follow the instructions from my project node-mqtt-for-anki-overdrive .

here is a diagram of the high-level architecture:

the next screenshot shows a simple node-red flow that stops the cars when obstacles are detected.

if you want to run this demo yourself, you need an anki overdrive starter kit and the code from github.

Object (computer science) Machine learning TensorFlow mobile app

Published at DZone with permission of Niklas Heidloff, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Spring Boot vs Eclipse MicroProfile: Resident Set Size (RSS) and Time to First Request (TFR) Comparative
  • How Elasticsearch Works
  • A Beginner’s Guide To Styling CSS Forms
  • Front-End Troubleshooting Using OpenTelemetry

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: