Homebreadcumb forward arrow iconBlogbreadcumb forward arrow iconArtificial Intelligencebreadcumb forward arrow iconTensorFlow Object Detection Tutorial For Beginners [With Examples]

TensorFlow Object Detection Tutorial For Beginners [With Examples]

Last updated:
27th Mar, 2020
Read Time
3 Mins
share image icon
In this article
Chevron in toc
View All
TensorFlow Object Detection Tutorial For Beginners [With Examples]

Object detection is a fantastic technology of machine learning, and many organizations use it for their benefit. The face recognition system in your phone, driverless cars, and the crowd statistics, they all have one thing in common: they use object detection. 

If you’re learning machine learning, you’d surely want to get familiar with this technology. In this article, you’ll learn about TensorFlow object detection and how you can perform the same. Be sure to check the example as you can try it out yourself and experiment. 

Top Machine Learning and AI Courses Online

What is Object Detection?

The name of ‘Object Detection’ is self-explanatory. It refers to finding real objects in images (or videos). These objects could be cars, TVs, or even humans. With object detection, you can localize, recognize, and detect multiple objects in an image. Object detection finds applications in many industries. From surveillance to product quality inspection, you’d find plenty of areas where experts use this technology. You can perform object detection in the following ways:

Ads of upGrad blog
  • Deep learning method
  • Viola-Jones method
  • Feature-based detection
  • SVM classifications (through HOG features)

In this article, we’ll focus on TensorFlow object detection. And TensorFlow performs this through deep learning. So in our tutorial, we’ll use that method. 

TensorFlow: An Introduction

It’s also important to be familiar with what TensorFlow is. It’s an Open Source Machine Learning framework and a product of Google. You can use TensorFlow to perform dataflow programming. Its name is made up of ‘Tensor’ and Flow’, both of which are vital components of this technology. Tensors are multidimensional arrays, whereas the flow stands for the dataflow programming you perform. 

Also learn: Most Popular 5 TensorFlow Projects for Beginners

Trending Machine Learning Skills

Enrol for the Machine Learning Course from the World’s top Universities. Earn Masters, Executive PGP, or Advanced Certificate Programs to fast-track your career.

TensorFlow Object Detection Tutorial

Before you work on this tutorial, you must be familiar with the following topics:

  • TensorFlow
  • Python
  • Protobuf
  • Tensorboard

In this TensorFlow object detection tutorial, you’ll need to use OpenCV. You’ll also need to use the camera module so you could use a webcam’s live feed to detect the objects in the image. 

We’ll use the Common Objects in Context dataset. It has around 330,000 labeled images. You’ll also have to import all the necessary libraries, including NumPy, to perform this task. But we’ve shared all that in our final code.

Read: Tensorflow vs Pytorch – Comparison, Features & Applications

You’ll have to add a model to perform the object detection. Here’s how you’ll add it:

MODEL_NAME = ‘ssd_mobilenet_v1_coco_2017_11_17’



PATH_TO_CKPT = MODEL_NAME + ‘/frozen_inference_graph.pb’

PATH_TO_LABELS = os.path.join(‘data’, ‘mscoco_label_map.pbtxt’)


First, we’ll need to add the OpenCV library and then the camera. Use the following code:

import cv2

cap = cv2.VideoCapture(0)

Then use the following code to load the images:

while True:

ret, image_np =

OpenCV will help us with the final image show. So use the following code for that purpose:

cv2.imshow(‘object detection’, cv2.resize(image_np, (800,600)))

if cv2.waitKey(25) & 0xFF == ord(‘q’):



Popular AI and ML Blogs & Free Courses


Ads of upGrad blog

Now you can perform object detection with TensorFlow as well. Just follow this example, and you’ll be good to go. If you have any questions on this topic, let us know in the comment section. We’d love to help you out. 

On the other hand, if you want to learn more about Machine Learning, check out our machine learning courses for that purpose. What did you think of this article? Let us know.

If you’re interested to learn more about machine learning, check out IIIT-B & upGrad’s PG Diploma in Machine Learning & AI which is designed for working professionals and offers 450+ hours of rigorous training, 30+ case studies & assignments, IIIT-B Alumni status, 5+ practical hands-on capstone projects & job assistance with top firms.


Kechit Goyal

Blog Author
Experienced Developer, Team Player and a Leader with a demonstrated history of working in startups. Strong engineering professional with a Bachelor of Technology (BTech) focused in Computer Science from Indian Institute of Technology, Delhi.
Get Free Consultation

Select Coursecaret down icon
Selectcaret down icon
By clicking 'Submit' you Agree to  
UpGrad's Terms & Conditions

Our Popular Machine Learning Course

Explore Free Courses

Suggested Blogs

Top 9 Python Libraries for Machine Learning in 2024
Machine learning is the most algorithm-intense field in computer science. Gone are those days when people had to code all algorithms for machine learn
Read More

by upGrad

19 Feb 2024

Top 15 IoT Interview Questions & Answers 2024 – For Beginners & Experienced
These days, the minute you indulge in any technology-oriented discussion, interview questions on cloud computing come up in some form or the other. Th
Read More

by Kechit Goyal

19 Feb 2024

Data Preprocessing in Machine Learning: 7 Easy Steps To Follow
Summary: In this article, you will learn about data preprocessing in Machine Learning: 7 easy steps to follow. Acquire the dataset Import all the cr
Read More

by Kechit Goyal

18 Feb 2024

Artificial Intelligence Salary in India [For Beginners & Experienced] in 2024
Artificial Intelligence (AI) has been one of the hottest buzzwords in the tech sphere for quite some time now. As Data Science is advancing, both AI a
Read More

by upGrad

18 Feb 2024

24 Exciting IoT Project Ideas & Topics For Beginners 2024 [Latest]
Summary: In this article, you will learn the 24 Exciting IoT Project Ideas & Topics. Take a glimpse at the project ideas listed below. Smart Agr
Read More

by Kechit Goyal

18 Feb 2024

Natural Language Processing (NLP) Projects & Topics For Beginners [2023]
What are Natural Language Processing Projects? NLP project ideas advanced encompass various applications and research areas that leverage computation
Read More

by Pavan Vadapalli

17 Feb 2024

45+ Interesting Machine Learning Project Ideas For Beginners [2024]
Summary: In this Article, you will learn Stock Prices Predictor Sports Predictor Develop A Sentiment Analyzer Enhance Healthcare Prepare ML Algorith
Read More

by Jaideep Khare

16 Feb 2024

AWS Salary in India in 2023 [For Freshers & Experienced]
Summary: In this article, you will learn about AWS Salary in India For Freshers & Experienced. AWS Salary in India INR 6,07,000 per annum AW
Read More

by Pavan Vadapalli

15 Feb 2024

Top 8 Exciting AWS Projects & Ideas For Beginners [2023]
AWS Projects & Topics Looking for AWS project ideas? Then you’ve come to the right place because, in this article, we’ve shared multiple AWS proj
Read More

by Pavan Vadapalli

13 Feb 2024

Schedule 1:1 free counsellingTalk to Career Expert
footer sticky close icon