Blog_Banner_Asset
    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
Views
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’

MODEL_FILE = MODEL_NAME + ‘.tar.gz’

DOWNLOAD_BASE = ‘http://download.tensorflow.org/models/object_detection/

PATH_TO_CKPT = MODEL_NAME + ‘/frozen_inference_graph.pb’

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

NUM_CLASSES = 90

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 = cap.read()

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’):

  cv2.destroyAllWindows()

  break

Popular AI and ML Blogs & Free Courses

Conclusion

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.

Profile

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

Selectcaret down icon
Select Area of interestcaret down icon
Select Work Experiencecaret down icon
By clicking 'Submit' you Agree to  
UpGrad's Terms & Conditions

Our Popular Machine Learning Course

Explore Free Courses

Suggested Blogs

15 Interesting MATLAB Project Ideas & Topics For Beginners [2024]
82457
Diving into the world of engineering and data science, I’ve discovered the potential of MATLAB as an indispensable tool. It has accelerated my c
Read More

by Pavan Vadapalli

09 Jul 2024

5 Types of Research Design: Elements and Characteristics
47126
The reliability and quality of your research depend upon several factors such as determination of target audience, the survey of a sample population,
Read More

by Pavan Vadapalli

07 Jul 2024

Biological Neural Network: Importance, Components & Comparison
50612
Humans have made several attempts to mimic the biological systems, and one of them is artificial neural networks inspired by the biological neural net
Read More

by Pavan Vadapalli

04 Jul 2024

Production System in Artificial Intelligence and its Characteristics
86790
The AI market has witnessed rapid growth on the international level, and it is predicted to show a CAGR of 37.3% from 2023 to 2030. The production sys
Read More

by Pavan Vadapalli

03 Jul 2024

AI vs Human Intelligence: Difference Between AI & Human Intelligence
112983
In this article, you will learn about AI vs Human Intelligence, Difference Between AI & Human Intelligence. Definition of AI & Human Intelli
Read More

by Pavan Vadapalli

01 Jul 2024

Career Opportunities in Artificial Intelligence: List of Various Job Roles
89547
Artificial Intelligence or AI career opportunities have escalated recently due to its surging demands in industries. The hype that AI will create tons
Read More

by Pavan Vadapalli

26 Jun 2024

Gini Index for Decision Trees: Mechanism, Perfect & Imperfect Split With Examples
70805
As you start learning about supervised learning, it’s important to get acquainted with the concept of decision trees. Decision trees are akin to
Read More

by MK Gurucharan

24 Jun 2024

Random Forest Vs Decision Tree: Difference Between Random Forest and Decision Tree
51730
Recent advancements have paved the growth of multiple algorithms. These new and blazing algorithms have set the data on fire. They help in handling da
Read More

by Pavan Vadapalli

24 Jun 2024

Basic CNN Architecture: Explaining 5 Layers of Convolutional Neural Network
270717
Introduction In the last few years of the IT industry, there has been a huge demand for once particular skill set known as Deep Learning. Deep Learni
Read More

by MK Gurucharan

21 Jun 2024

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