{"id":18067,"date":"2021-12-25T02:14:00","date_gmt":"2021-12-24T20:44:00","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/"},"modified":"2024-09-02T17:01:46","modified_gmt":"2024-09-02T11:31:46","slug":"object-detection-using-tensorflow","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/","title":{"rendered":"Real-Time Object Detection Using TensorFlow"},"content":{"rendered":"\n<p>Object Detection using Tensorflow is a computer vision technique to detect objects in an image or a video in real time. As the name suggests, it helps us in locating, understanding and tracing an object from an image or a video. Let us gain a deeper understanding about how object detection works, <a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/tensorflow-python\">what Tensorflow is<\/a>, and more.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"#sh1\">What is object detection?<\/a><\/li>\n\n\n\n<li><a href=\"#sh2\">How does object detection work?<\/a><\/li>\n\n\n\n<li><a href=\"#sh3\">What is Tensorflow?<\/a><\/li>\n\n\n\n<li><a href=\"#sh4\">What is Tensorflow object detection API?<\/a><\/li>\n\n\n\n<li><a href=\"#sh5\">Object Detection Using Tensorflow<\/a><\/li>\n\n\n\n<li><a href=\"#sh6\">Real-Tim Object detection using Tensorflow<\/a><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-object-detection\"><strong>What is Object detection?<\/strong><\/h2>\n\n\n\n<p>Object detection is a <a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/computer-vision-essentials\">computer vision<\/a> technique in which a software system can detect, locate, and trace the object from a given image or video. <\/p>\n\n\n\n<p>The special thing about object detection using tensorflow is that it identifies the class of objects (person, table, chair, etc.) and their location-specific coordinates in the given image. <\/p>\n\n\n\n<p>The location is pointed out by drawing a bounding box around the object. The bounding box may or may not accurately locate the position of the object. <\/p>\n\n\n\n<p>The ability to locate the object inside an image defines the performance of the algorithm used for detection. <a href=\"https:\/\/www.mygreatlearning.com\/blog\/real-time-face-detection\/\">Face detection<\/a> is one of the examples of object detection.<\/p>\n\n\n\n<p>These object detection algorithms might be pre-trained or can be trained from scratch. In most use cases, we use pre-trained weights from pre-trained models and then <a href=\"https:\/\/www.mygreatlearning.com\/blog\/what-is-fine-tuning\/\">fine-tune<\/a> them as per our requirements and different use cases.<\/p>\n\n\n\n<p><strong><em><a href=\"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Object Detection using YOLO algorithm (opens in a new tab)\">Object Detection using YOLO algorithm<\/a><\/em><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-does-object-detection-work\"><strong>How does Object detection work?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Object Detection Tutorial | Real Time Object Detection Using Keras | Great Learning\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/K2NmpMUSlaQ?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Generally, the object detection task is carried out in three steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Generates the small segments in the input as shown in the image below. As you can see the large set of bounding boxes are&nbsp; spanning the full image<\/li>\n<\/ul>\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized td-caption-align-https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121.jpg zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121.jpg\"><img decoding=\"async\" width=\"1024\" height=\"475\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121-1024x475.jpg\" alt=\"Object detection using TensorFlow\" class=\"wp-image-18068\" style=\"width:564px;height:261px\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121-1024x475.jpg 1024w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121-300x139.jpg 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121-768x356.jpg 768w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121-1536x713.jpg 1536w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121-2048x950.jpg 2048w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121-696x323.jpg 696w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121-1068x496.jpg 1068w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121-905x420.jpg 905w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Feature extraction is carried out for each segmented rectangular area to predict whether the rectangle contains a valid object.<\/li>\n<\/ul>\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized td-caption-align-https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2.jpg zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2.jpg\"><img decoding=\"async\" width=\"1024\" height=\"996\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-1024x996.jpg\" alt=\"Object detection using TensorFlow\" class=\"wp-image-18069\" style=\"width:350px;height:341px\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-1024x996.jpg 1024w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-300x292.jpg 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-768x747.jpg 768w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-1536x1494.jpg 1536w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-2048x1991.jpg 2048w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-696x677.jpg 696w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-1068x1038.jpg 1068w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-432x420.jpg 432w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Overlapping boxes are combined into a single bounding rectangle (Non-Maximum Suppression)<\/li>\n<\/ul>\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized td-caption-align-https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3.jpg zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3.jpg\"><img decoding=\"async\" width=\"1024\" height=\"984\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3-1024x984.jpg\" alt=\"Object detection using TensorFlow\" class=\"wp-image-18070\" style=\"width:353px;height:339px\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3-1024x984.jpg 1024w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3-300x288.jpg 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3-768x738.jpg 768w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3-1536x1476.jpg 1536w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3-2048x1967.jpg 2048w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3-696x669.jpg 696w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3-1068x1026.jpg 1068w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3-437x420.jpg 437w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-tensorflow\"><strong>What is TensorFlow?<\/strong><\/h2>\n\n\n\n<p><a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/introduction-to-tensorflow-and-keras\" target=\"_blank\" rel=\"noreferrer noopener\">Tensorflow and Keras<\/a> are open-source libraries for numerical computation and large-scale machine learning that ease Google Brain TensorFlow, the process of acquiring data, training models, serving predictions, and refining future results.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Tensorflow bundles together <a href=\"https:\/\/www.mygreatlearning.com\/blog\/what-is-machine-learning\/\" target=\"_blank\" rel=\"noreferrer noopener\">Machine Learning<\/a> and <a href=\"https:\/\/www.mygreatlearning.com\/blog\/what-is-deep-learning\/\" target=\"_blank\" rel=\"noreferrer noopener\">Deep Learning<\/a> models and algorithms.&nbsp;<\/li>\n\n\n\n<li>It uses Python as a convenient front-end and runs it efficiently in optimized C++.<\/li>\n\n\n\n<li>Tensorflow allows developers to create a graph of computations to perform.&nbsp;<\/li>\n\n\n\n<li>Each node in the graph represents a mathematical operation and each connection represents data. Hence, instead of dealing with low-details like figuring out proper ways to hitch the output of one function to the input of another, the developer can focus on the overall logic of the application.<\/li>\n<\/ul>\n\n\n\n<p>The deep learning artificial intelligence research team at Google, Google Brain, in the year 2015 developed TensorFlow for Google\u2019s internal use. This Open-Source Software library is used by the research team to perform several important tasks.<\/p>\n\n\n\n<p>TensorFlow is at present the most popular software library. There are several real-world applications of deep learning that makes TensorFlow popular. Being an Open-Source library for deep learning and machine learning, TensorFlow finds a role to play in text-based applications, image recognition, voice search, and many more. DeepFace, Facebook\u2019s image recognition system, uses TensorFlow for image recognition. It is used by Apple\u2019s Siri for voice recognition. Every Google app that you use has made good use of TensorFlow to make your experience better.<\/p>\n\n\n\n    <div class=\"courses-cta-container\">\n        <div class=\"courses-cta-card\">\n            <div class=\"courses-cta-header\">\n                <div class=\"courses-learn-icon\"><\/div>\n                <span class=\"courses-learn-text\">Transform Healthcare with AI<\/span>\n            <\/div>\n            <p class=\"courses-cta-title\">\n                <a href=\"https:\/\/online.lifelonglearning.jhu.edu\/jhu-ai-in-healthcare-certificate-program\" class=\"courses-cta-title-link\">AI in Healthcare Program<\/a>\n            <\/p>\n            <p class=\"courses-cta-description\">Transform healthcare with AI. Apply now for Johns Hopkins AI in Healthcare Program and enhance patient outcomes with cutting-edge skills<\/p>\n            <div class=\"courses-cta-stats\">\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-user-icon\"><\/div>\n                    <span>Duration: 10 weeks<\/span>\n                <\/div>\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-star-icon\"><\/div>\n                    <span>8+ Case Studies<\/span>\n                <\/div>\n            <\/div>\n            <a href=\"https:\/\/online.lifelonglearning.jhu.edu\/jhu-ai-in-healthcare-certificate-program\" class=\"courses-cta-button\">\n                Discover the Program\n                <div class=\"courses-arrow-icon\"><\/div>\n            <\/a>\n        <\/div>\n    <\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-tensorflow-object-detection-api\"><strong>What is Tensorflow object detection API?<\/strong><\/h2>\n\n\n\n<p>The TensorFlow Object Detection API is an open-source framework built on top of TensorFlow. It makes it easy to construct, train, and deploy object detection models. It lets the developers focus on the main logic of the application, and it takes care of object detection. Housing a great deal of pre-trained object detection models, Tensorflow gives you the power to work on crucial stuff rather than fighting over unimportant details as to which algorithm, Machine Learning, or Deep Learning to use.&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>There are already pre-trained models in their framework which are referred to as Model Zoo.&nbsp;<\/li>\n\n\n\n<li>It includes a collection of pre-trained models trained on various datasets such as the\n<ul class=\"wp-block-list\">\n<li>COCO (Common Objects in Context) dataset,&nbsp;<\/li>\n\n\n\n<li>the KITTI dataset,&nbsp;<\/li>\n\n\n\n<li>and the Open Images Dataset.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>As you may see below there are various models available so what is different in these models. These various models have different architecture and thus provide different accuracies but there is a trade-off between speed of execution and the accuracy in placing bounding boxes.<\/p>\n\n\n<figure class=\"wp-block-image size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121.png\"><img decoding=\"async\" width=\"844\" height=\"548\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121.png\" alt=\"Tensorflow 1 Model Zoo\" class=\"wp-image-18072\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121.png 844w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121-300x195.png 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121-768x499.png 768w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121-696x452.png 696w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/121-647x420.png 647w\" sizes=\"(max-width: 844px) 100vw, 844px\" \/><figcaption class=\"wp-element-caption\"><a rel=\"noreferrer noopener\" aria-label=\"source (opens in a new tab)\" href=\"https:\/\/github.com\/tensorflow\/models\/blob\/master\/research\/object_detection\/g3doc\/tf1_detection_zoo.md\" target=\"_blank\">source<\/a>: Various model available in Tensorflow 1 model zoo<\/figcaption><\/figure>\n\n\n\n<p>Here mAP (mean average precision) is the product of precision and recall on detecting bounding boxes. It\u2019s a good combined measure for how sensitive the network is to objects of interest and how well it avoids false alarms. The higher the mAP score, the more accurate the network is but that comes at the cost of execution speed which we want to avoid here.<br><\/p>\n\n\n\n<p>As my PC is a low-end machine with not much processing power, I am using the model ssd_mobilenet_v1_coco which is trained on COCO dataset. This model has decent mAP score and less execution time. Also, the COCO is a dataset of 300k images of 90 most commonly found objects so the model can recognise 90 objects<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"object-detection-using-tensorflow\"><strong>Object Detection Using Tensorflow<\/strong><\/h2>\n\n\n\n<p>As mentioned above the knowledge of neural network and machine learning is not mandatory for using this API as we are mostly going to use the files provided in the API. All we need is some knowledge of python and passion for completing this project. Also, I assume Anaconda is already installed in your PC.So let us start by downloading some files:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"download-tensorflow-api-from-github-repository\"><strong>Download Tensorflow API from Github Repository<\/strong><\/h4>\n\n\n\n<p>There are two ways of doing this, one is by using git and another by manually downloading it :<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Using gi<\/strong>t: This is the easiest way of downloading the Tensorflow Object detection API from the repository but you need to have git installed in the system. Open the command prompt and type this command\n<ol class=\"wp-block-list\">\n<li>git clone <a href=\"https:\/\/github.com\/tensorflow\/models\">https:\/\/github.com\/tensorflow\/models<\/a><\/li>\n<\/ol>\n<\/li>\n\n\n\n<li><strong>Downloading Manually<\/strong>: To manually download the API, go to this<a href=\"https:\/\/github.com\/tensorflow\/models\"> link<\/a> and click on the code button(in green colour). You can see the download zip option, click on that you will have a compressed file. Now you need to extract the files.<\/li>\n<\/ol>\n\n\n\n<p>After getting this API in your PC, rename the folder from models-master to models<\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Setting up a virtual environment<\/strong><\/li>\n<\/ol>\n\n\n\n<p>Next, we are going to do is to create a separate virtual environment. The main purpose of Python virtual environments is to create an isolated environment for Python projects. This means that each project can have its own dependencies, regardless of what dependencies every other project has. I am naming my virtual environment as obj_detection but you can name it anything else. Now open the Anaconda prompt and type<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To set up the virtual environment:<\/li>\n<\/ul>\n\n\n\n<p>conda create -n obj_detection<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To activate it the above created virtual environment:<\/li>\n<\/ul>\n\n\n\n<p>conda activate obj_detection<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"installing-dependencies\"><strong>Installing dependencies<\/strong><\/h4>\n\n\n\n<p>The next step is to install all the dependencies needed for this API to work on your local PC. Type this command after activating your virtual environment.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>pip install tensorflow<\/li>\n<\/ul>\n\n\n\n<p><strong>If you have a GPU in your PC, use this instead. You will have a better performance<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>pip install tensorflow-gpu<\/li>\n<\/ul>\n\n\n\n<p><strong>Next, use this command to install the rest of dependencies<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>pip install pillow Cython lxml jupyter matplotlib contextlib2 tf_slim<\/li>\n<\/ul>\n\n\n\n<p>Now we need to download Protocol Buffers (Protobuf) which are Google\u2019s language-neutral, platform-neutral, extensible mechanism for serializing structured data, \u2013 think of it as XML, but smaller, faster, and simpler. Download the appropriate version of Protobuf from<a href=\"https:\/\/github.com\/google\/protobuf\/releases\" target=\"_blank\" rel=\"noreferrer noopener\"> here<\/a> and extract it. After extracting it copy it to the \u2018research\u2019 sub-folder in the \u2018models\u2019 folders we downloaded earlier.<\/p>\n\n\n\n<p><strong>Now in the anaconda prompt, navigate to the folder containing the protoc file using the cd \u2018path of folder\u2019 and run this command<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>protoc object_detection\/protos\/*.proto --python_out=.<\/li>\n<\/ul>\n\n\n\n<p>To check whether this worked or not, you can go to the protos folder inside models&gt;object_detection&gt;protos and there you can see that for every proto file there\u2019s one python file created.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"object-detection-code\"><strong>Object detection Code<\/strong><\/h4>\n\n\n\n<p>Now you need to go to the \u201cobject_detection\u201d directory inside research subfolder and then create a new python file and paste this code. You can use Spyder or Jupyter to write your code. I would recommend using the Jupyter notebook.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy as np\nimport os\nimport six.moves.urllib as urllib\nimport sys\nimport tarfile\nimport tensorflow as tf\nimport zipfile\nimport pathlib\nfrom collections import defaultdict\nfrom io import StringIO\nfrom matplotlib import pyplot as plt\nfrom PIL import Image\nfrom IPython.display import display\nfrom object_detection.utils import ops as utils_ops\nfrom object_detection.utils import label_map_util\nfrom object_detection.utils import visualization_utils as vis_util\n\nwhile &quot;models&quot; in pathlib.Path.cwd().parts:\n    os.chdir(&#039;..&#039;)\n\ndef load_model(model_name):\n  base_url = &#039;http:\/\/download.tensorflow.org\/models\/object_detection\/&#039;\n  model_file = model_name + &#039;.tar.gz&#039;\n  model_dir = tf.keras.utils.get_file(\n    fname=model_name, \n    origin=base_url + model_file,\n    untar=True)\n\n  model_dir = pathlib.Path(model_dir)\/&quot;saved_model&quot;\n\n  model = tf.saved_model.load(str(model_dir))\n\n  return model\n\nPATH_TO_LABELS = &#039;models\/research\/object_detection\/data\/mscoco_label_map.pbtxt&#039;\ncategory_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=True)\n\nmodel_name = &#039;ssd_inception_v2_coco_2017_11_17&#039;\ndetection_model = load_model(model_name)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-code\"><code>def run_inference_for_single_image(model, image):\n  image = np.asarray(image)\n  # The input needs to be a tensor, convert it using `tf.convert_to_tensor`.\n  input_tensor = tf.convert_to_tensor(image)\n  # The model expects a batch of images, so add an axis with `tf.newaxis`.\n  input_tensor = input_tensor&#091;tf.newaxis,...]\n\n  # Run inference\n  model_fn = model.signatures&#091;'serving_default']\n  output_dict = model_fn(input_tensor)\n\n  # All outputs are batches tensors.\n  # Convert to numpy arrays, and take index &#091;0] to remove the batch dimension.\n  # We're only interested in the first num_detections.\n  num_detections = int(output_dict.pop('num_detections'))\n  output_dict = {key:value&#091;0, :num_detections].numpy() \n                 for key,value in output_dict.items()}\n  output_dict&#091;'num_detections'] = num_detections\n\n  # detection_classes should be ints.\n  output_dict&#091;'detection_classes'] = output_dict&#091;'detection_classes'].astype(np.int64)\n   \n  # Handle models with masks:\n  if 'detection_masks' in output_dict:\n    # Reframe the the bbox mask to the image size.\n    detection_masks_reframed = utils_ops.reframe_box_masks_to_image_masks(\n              output_dict&#091;'detection_masks'], output_dict&#091;'detection_boxes'],\n               image.shape&#091;0], image.shape&#091;1])      \n    detection_masks_reframed = tf.cast(detection_masks_reframed &gt; 0.5,\n                                       tf.uint8)\n    output_dict&#091;'detection_masks_reframed'] = detection_masks_reframed.numpy()\n    \n  return output_dict\n\ndef show_inference(model, image_path):\n  # the array based representation of the image will be used later in order to prepare the\n  # result image with boxes and labels on it.\n  image_np = np.array(Image.open(image_path))\n\n\n  # Actual detection.\n    \n  output_dict = run_inference_for_single_image(model, image_np)\n  # Visualization of the results of a detection.\n  vis_util.visualize_boxes_and_labels_on_image_array(\n      image_np,\n      output_dict&#091;'detection_boxes'],\n      output_dict&#091;'detection_classes'],\n      output_dict&#091;'detection_scores'],\n      category_index,\n      instance_masks=output_dict.get('detection_masks_reframed', None),\n      use_normalized_coordinates=True,\n      line_thickness=8)\n\n  display(Image.fromarray(image_np))<\/code><\/pre>\n\n\n\n<p>Inside the object detection folder, we have a folder named as test_images. There are two images already in that folder that will be used to test the model. We can put our Images also for which we want to located objects and run the below cells to get the results.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nPATH_TO_TEST_IMAGES_DIR = pathlib.Path(&#039;models\/research\/object_detection\/test_images&#039;)\nTEST_IMAGE_PATHS = sorted(list(PATH_TO_TEST_IMAGES_DIR.glob(&quot;*.jpg&quot;)))\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfor image_path in TEST_IMAGE_PATHS:\n    print(image_path)\n    show_inference(detection_model, image_path)\n<\/pre><\/div>\n\n\n<p>Here are some of the predictions on some random pictures I took from Google.<\/p>\n\n\n<figure class=\"wp-block-image size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-1.png\"><img decoding=\"async\" width=\"474\" height=\"266\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-1.png\" alt=\"\" class=\"wp-image-18075\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-1.png 474w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/2-1-300x168.png 300w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/figure>\n\n\n<figure class=\"wp-block-image size-large zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3.png\"><img decoding=\"async\" width=\"474\" height=\"315\" src=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3.png\" alt=\"\" class=\"wp-image-18076\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3.png 474w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/3-300x199.png 300w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/figure>\n\n\n\n<p> <strong><em><a rel=\"noreferrer noopener\" href=\"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/\" target=\"_blank\">Object Detection using YOLO algorithm<\/a><\/em><\/strong> <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"real-time-object-detection-using-tensorflow\"><strong>Real-Time Object detection using Tensorflow<\/strong><\/h2>\n\n\n\n<p>The steps in detecting objects in real-time are quite similar to what we saw above. All we need is an extra dependency and that is OpenCV. So to install OpenCV run this command in our virtual environment.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> pip install opencv-python <\/pre>\n\n\n\n<p>Now just copy and paste this code and you are good to go<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy as np\nimport os\nimport six.moves.urllib as urllib\nimport sys\nimport tarfile\nimport tensorflow as tf\nimport zipfile\nimport pathlib\nfrom collections import defaultdict\nfrom io import StringIO\nfrom matplotlib import pyplot as plt\nfrom PIL import Image\nfrom IPython.display import display\nfrom object_detection.utils import ops as utils_ops\nfrom object_detection.utils import label_map_util\nfrom object_detection.utils import visualization_utils as vis_util\n\nwhile &quot;models&quot; in pathlib.Path.cwd().parts:\n    os.chdir(&#039;..&#039;)\n\ndef load_model(model_name):\n  base_url = &#039;http:\/\/download.tensorflow.org\/models\/object_detection\/&#039;\n  model_file = model_name + &#039;.tar.gz&#039;\n  model_dir = tf.keras.utils.get_file(\n    fname=model_name, \n    origin=base_url + model_file,\n    untar=True)\n\n  model_dir = pathlib.Path(model_dir)\/&quot;saved_model&quot;\n  model = tf.saved_model.load(str(model_dir))\n  return model\n\nPATH_TO_LABELS = &#039;models\/research\/object_detection\/data\/mscoco_label_map.pbtxt&#039;\ncategory_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=True)\n\nmodel_name = &#039;ssd_inception_v2_coco_2017_11_17&#039;\ndetection_model = load_model(model_name)\n\ndef run_inference_for_single_image(model, image):\n  image = np.asarray(image)\n  # The input needs to be a tensor, convert it using `tf.convert_to_tensor`.\n  input_tensor = tf.convert_to_tensor(image)\n  # The model expects a batch of images, so add an axis with `tf.newaxis`.\n  input_tensor = input_tensor&#x5B;tf.newaxis,...]\n\n  # Run inference\n  model_fn = model.signatures&#x5B;&#039;serving_default&#039;]\n  output_dict = model_fn(input_tensor)\n\n  # All outputs are batches tensors.\n  # Convert to numpy arrays, and take index &#x5B;0] to remove the batch dimension.\n  # We&#039;re only interested in the first num_detections.\n  num_detections = int(output_dict.pop(&#039;num_detections&#039;))\n  output_dict = {key:value&#x5B;0, :num_detections].numpy() \n                 for key,value in output_dict.items()}\n  output_dict&#x5B;&#039;num_detections&#039;] = num_detections\n\n  # detection_classes should be ints.\n  output_dict&#x5B;&#039;detection_classes&#039;] = output_dict&#x5B;&#039;detection_classes&#039;].astype(np.int64)\n   \n  # Handle models with masks:\n  if &#039;detection_masks&#039; in output_dict:\n    # Reframe the the bbox mask to the image size.\n    detection_masks_reframed = utils_ops.reframe_box_masks_to_image_masks(\n              output_dict&#x5B;&#039;detection_masks&#039;], output_dict&#x5B;&#039;detection_boxes&#039;],\n               image.shape&#x5B;0], image.shape&#x5B;1])      \n    detection_masks_reframed = tf.cast(detection_masks_reframed &gt; 0.5,\n                                       tf.uint8)\n    output_dict&#x5B;&#039;detection_masks_reframed&#039;] = detection_masks_reframed.numpy()\n    \n  return output_dict\n<\/pre><\/div>\n\n\n<p>Till here everything was the same as the previous section, but now you can see some minor changes. All we do is to get frames from the webcam feed and convert them to Numpy arrays.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\ndef show_inference(model, frame):\n  #take the frame from webcam feed and convert that to array\n  image_np = np.array(frame)\n  # Actual detection.\n    \n  output_dict = run_inference_for_single_image(model, image_np)\n  # Visualization of the results of a detection.\n  vis_util.visualize_boxes_and_labels_on_image_array(\n      image_np,\n      output_dict&#x5B;&#039;detection_boxes&#039;],\n      output_dict&#x5B;&#039;detection_classes&#039;],\n      output_dict&#x5B;&#039;detection_scores&#039;],\n      category_index,\n      instance_masks=output_dict.get(&#039;detection_masks_reframed&#039;, None),\n      use_normalized_coordinates=True,\n      line_thickness=5)\n\n  return(image_np)\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n#Now we open the webcam and start detecting objects\nimport cv2\nvideo_capture = cv2.VideoCapture(0)\nwhile True:\n    # Capture frame-by-frame\n    re,frame = video_capture.read()\n    Imagenp=show_inference(detection_model, frame)\n    cv2.imshow(&#039;object detection&#039;, cv2.resize(Imagenp, (800,600)))\n    if cv2.waitKey(1) &amp; 0xFF == ord(&#039;q&#039;):\n        break\nvideo_capture.release()\ncv2.destroyAllWindows()\n<\/pre><\/div>\n\n\n<p><strong>Here is the output of the code:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/youtu.be\/tejSwCIuE74\n<\/div><\/figure>\n\n\n\n<p>This brings us to the end of this article where we learned how to use Tensorflow object detection API to detect objects in images as well as in webcam feed too. <\/p>\n\n\n\n<p>Looking to get started with TensorFlow? Check out our <a href=\"https:\/\/www.mygreatlearning.com\/tensorflow\/free-courses\" target=\"_blank\" rel=\"noreferrer noopener\">free tensorflow courses<\/a> and learn how to build effective machine learning models!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"further-reading\">Further Reading<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/yolo-object-detection-using-opencv\/\" target=\"_blank\" rel=\"noreferrer noopener\">YOLO object detection using OpenCV<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/real-time-face-detection\/\" target=\"_blank\" rel=\"noreferrer noopener\">Real-time Face detection | Face Mask Detection using OpenCV<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/object-detection-in-pytorch\/\" target=\"_blank\" rel=\"noreferrer noopener\">Object Detection in Pytorch | What is Object Detection?<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/viola-jones-algorithm\/\" target=\"_blank\" rel=\"noreferrer noopener\">Face Detection using Viola Jones Algorithm<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/face-recognition\/\" target=\"_blank\" rel=\"noreferrer noopener\">Face Recognition Using Python and OpenCV<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Object Detection using Tensorflow is a computer vision technique to detect objects in an image or a video in real time. As the name suggests, it helps us in locating, understanding and tracing an object from an image or a video. Let us gain a deeper understanding about how object detection works, what Tensorflow is, [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":18082,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[2],"tags":[],"content_type":[],"class_list":["post-18067","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-artificial-intelligence"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Real-Time Object Detection Using TensorFlow<\/title>\n<meta name=\"description\" content=\"Object detection using TensorFlow API makes it easy to perform to complex computer vision tasks and we do not need to train any models at all.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Real-Time Object Detection Using TensorFlow\" \/>\n<meta property=\"og:description\" content=\"Object detection using TensorFlow API makes it easy to perform to complex computer vision tasks and we do not need to train any models at all.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-24T20:44:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-02T11:31:46+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"667\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/object-detection-using-tensorflow\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/object-detection-using-tensorflow\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Real-Time Object Detection Using TensorFlow\",\"datePublished\":\"2021-12-24T20:44:00+00:00\",\"dateModified\":\"2024-09-02T11:31:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/object-detection-using-tensorflow\\\/\"},\"wordCount\":1661,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/object-detection-using-tensorflow\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/shutterstock_668209624.jpg\",\"articleSection\":[\"AI and Machine Learning\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/object-detection-using-tensorflow\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/object-detection-using-tensorflow\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/object-detection-using-tensorflow\\\/\",\"name\":\"Real-Time Object Detection Using TensorFlow\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/object-detection-using-tensorflow\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/object-detection-using-tensorflow\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/shutterstock_668209624.jpg\",\"datePublished\":\"2021-12-24T20:44:00+00:00\",\"dateModified\":\"2024-09-02T11:31:46+00:00\",\"description\":\"Object detection using TensorFlow API makes it easy to perform to complex computer vision tasks and we do not need to train any models at all.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/object-detection-using-tensorflow\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/object-detection-using-tensorflow\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/object-detection-using-tensorflow\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/shutterstock_668209624.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/shutterstock_668209624.jpg\",\"width\":1000,\"height\":667,\"caption\":\"object detection using TensorFlow\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/object-detection-using-tensorflow\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AI and Machine Learning\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/artificial-intelligence\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Real-Time Object Detection Using TensorFlow\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Real-Time Object Detection Using TensorFlow","description":"Object detection using TensorFlow API makes it easy to perform to complex computer vision tasks and we do not need to train any models at all.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/","og_locale":"en_US","og_type":"article","og_title":"Real-Time Object Detection Using TensorFlow","og_description":"Object detection using TensorFlow API makes it easy to perform to complex computer vision tasks and we do not need to train any models at all.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2021-12-24T20:44:00+00:00","article_modified_time":"2024-09-02T11:31:46+00:00","og_image":[{"width":1000,"height":667,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624.jpg","type":"image\/jpeg"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Real-Time Object Detection Using TensorFlow","datePublished":"2021-12-24T20:44:00+00:00","dateModified":"2024-09-02T11:31:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/"},"wordCount":1661,"commentCount":1,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624.jpg","articleSection":["AI and Machine Learning"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/","url":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/","name":"Real-Time Object Detection Using TensorFlow","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624.jpg","datePublished":"2021-12-24T20:44:00+00:00","dateModified":"2024-09-02T11:31:46+00:00","description":"Object detection using TensorFlow API makes it easy to perform to complex computer vision tasks and we do not need to train any models at all.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624.jpg","width":1000,"height":667,"caption":"object detection using TensorFlow"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/object-detection-using-tensorflow\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"AI and Machine Learning","item":"https:\/\/www.mygreatlearning.com\/blog\/artificial-intelligence\/"},{"@type":"ListItem","position":3,"name":"Real-Time Object Detection Using TensorFlow"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624.jpg",1000,667,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624-150x150.jpg",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624-300x200.jpg",300,200,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624-768x512.jpg",768,512,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624.jpg",1000,667,false],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624.jpg",1000,667,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624.jpg",1000,667,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624.jpg",640,427,false],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624.jpg",96,64,false],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/07\/shutterstock_668209624.jpg",150,100,false]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":1,"uagb_excerpt":"Object Detection using Tensorflow is a computer vision technique to detect objects in an image or a video in real time. As the name suggests, it helps us in locating, understanding and tracing an object from an image or a video. Let us gain a deeper understanding about how object detection works, what Tensorflow is,&hellip;","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/18067","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=18067"}],"version-history":[{"count":36,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/18067\/revisions"}],"predecessor-version":[{"id":111110,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/18067\/revisions\/111110"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/18082"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=18067"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=18067"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=18067"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=18067"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}