summaryrefslogtreecommitdiff
path: root/posts/2019-12-10-TensorFlow-Model-Prediction/index.html
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2020-09-08 12:43:11 +0530
committerNavan Chauhan <navanchauhan@gmail.com>2020-09-08 12:43:11 +0530
commit9c681eb127254dfd6a9b60aea35dd2e07cbdcac8 (patch)
tree1da58bb5902711444c8da2fd7ae46082bc17d66a /posts/2019-12-10-TensorFlow-Model-Prediction/index.html
parent5c712abef6b9fded9c3d0b7bb930cdfeb94981d1 (diff)
Publish deploy 2020-09-08 12:43
Diffstat (limited to 'posts/2019-12-10-TensorFlow-Model-Prediction/index.html')
-rw-r--r--posts/2019-12-10-TensorFlow-Model-Prediction/index.html2
1 files changed, 1 insertions, 1 deletions
diff --git a/posts/2019-12-10-TensorFlow-Model-Prediction/index.html b/posts/2019-12-10-TensorFlow-Model-Prediction/index.html
index e287303..b3b3d60 100644
--- a/posts/2019-12-10-TensorFlow-Model-Prediction/index.html
+++ b/posts/2019-12-10-TensorFlow-Model-Prediction/index.html
@@ -1,4 +1,4 @@
-<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"/><meta name="og:site_name" content="Navan Chauhan"/><link rel="canonical" href="https://navanchauhan.github.io/posts/2019-12-10-TensorFlow-Model-Prediction"/><meta name="twitter:url" content="https://navanchauhan.github.io/posts/2019-12-10-TensorFlow-Model-Prediction"/><meta name="og:url" content="https://navanchauhan.github.io/posts/2019-12-10-TensorFlow-Model-Prediction"/><title>Making Predictions using Image Classifier (TensorFlow) | Navan Chauhan</title><meta name="twitter:title" content="Making Predictions using Image Classifier (TensorFlow) | Navan Chauhan"/><meta name="og:title" content="Making Predictions using Image Classifier (TensorFlow) | Navan Chauhan"/><meta name="description" content="Making predictions for image classification models built using TensorFlow"/><meta name="twitter:description" content="Making predictions for image classification models built using TensorFlow"/><meta name="og:description" content="Making predictions for image classification models built using TensorFlow"/><meta name="twitter:card" content="summary"/><link rel="stylesheet" href="/styles.css" type="text/css"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link rel="shortcut icon" href="/images/favicon.png" type="image/png"/><link rel="alternate" href="/feed.rss" type="application/rss+xml" title="Subscribe to Navan Chauhan"/><meta name="twitter:image" content="https://navanchauhan.github.io/images/logo.png"/><meta name="og:image" content="https://navanchauhan.github.io/images/logo.png"/></head><head><script>var _paq=window._paq=window._paq||[];_paq.push(["trackPageView"]),_paq.push(["enableLinkTracking"]),function(){_paq.push(["setTrackerUrl","https://navanchauhan.matomo.cloud/matomo.php"]),_paq.push(["setSiteId","1"]);var a=document,t=a.createElement("script"),e=a.getElementsByTagName("script")[0];t.type="text/javascript",t.async=!0,t.src="//cdn.matomo.cloud/navanchauhan.matomo.cloud/matomo.js",e.parentNode.insertBefore(t,e)}();</script></head><head><script src="https://www.googletagmanager.com/gtag/js?id=UA-108635191-1v"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'UA-108635191-1');</script></head><body class="item-page"><header><div class="wrapper"><a class="site-name" href="/">Navan Chauhan</a><nav><ul><li><a href="/about">About Me</a></li><li><a class="selected" href="/posts">Posts</a></li><li><a href="/publications">Publications</a></li><li><a href="/assets/résumé.pdf">Résumé</a></li><li><a href="https://navanchauhan.github.io/repo">Repo</a></li></ul></nav></div></header><div class="wrapper"><article><div class="content"><span class="reading-time">1 minute read</span><span class="reading-time">Created on December 10, 2019</span><span class="reading-time">Last modified on June 1, 2020</span><h1>Making Predictions using Image Classifier (TensorFlow)</h1><p><em>This was tested on TF 2.x and works as of 2019-12-10</em></p><p>If you want to understand how to make your own custom image classifier, please refer to my previous post.</p><p>If you followed my last post, then you created a model which took an image of dimensions 50x50 as an input.</p><p>First we import the following if we have not imported these before</p><pre><code><div class="highlight"><span></span><span class="kn">import</span> <span class="nn">cv2</span>
+<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"/><meta name="og:site_name" content="Navan Chauhan"/><link rel="canonical" href="https://navanchauhan.github.io/posts/2019-12-10-TensorFlow-Model-Prediction"/><meta name="twitter:url" content="https://navanchauhan.github.io/posts/2019-12-10-TensorFlow-Model-Prediction"/><meta name="og:url" content="https://navanchauhan.github.io/posts/2019-12-10-TensorFlow-Model-Prediction"/><title>Making Predictions using Image Classifier (TensorFlow) | Navan Chauhan</title><meta name="twitter:title" content="Making Predictions using Image Classifier (TensorFlow) | Navan Chauhan"/><meta name="og:title" content="Making Predictions using Image Classifier (TensorFlow) | Navan Chauhan"/><meta name="description" content="Making predictions for image classification models built using TensorFlow"/><meta name="twitter:description" content="Making predictions for image classification models built using TensorFlow"/><meta name="og:description" content="Making predictions for image classification models built using TensorFlow"/><meta name="twitter:card" content="summary"/><link rel="stylesheet" href="/styles.css" type="text/css"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link rel="shortcut icon" href="/images/favicon.png" type="image/png"/><link rel="alternate" href="/feed.rss" type="application/rss+xml" title="Subscribe to Navan Chauhan"/><meta name="twitter:image" content="https://navanchauhan.github.io/images/logo.png"/><meta name="og:image" content="https://navanchauhan.github.io/images/logo.png"/></head><head><script>var _paq=window._paq=window._paq||[];_paq.push(['trackPageView']),_paq.push(['enableLinkTracking']),function(){var a='http://navanspi.duckdns.org:6969/analytics/';_paq.push(['setTrackerUrl',a+'matomo.php']),_paq.push(['setSiteId','1']);var e=document,t=e.createElement('script'),p=e.getElementsByTagName('script')[0];t.type='text/javascript',t.async=!0,t.src=a+'matomo.js',p.parentNode.insertBefore(t,p)}();</script></head><head><script src="https://www.googletagmanager.com/gtag/js?id=UA-108635191-1v"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'UA-108635191-1');</script></head><body class="item-page"><header><div class="wrapper"><a class="site-name" href="/">Navan Chauhan</a><nav><ul><li><a href="/about">About Me</a></li><li><a class="selected" href="/posts">Posts</a></li><li><a href="/publications">Publications</a></li><li><a href="/assets/résumé.pdf">Résumé</a></li><li><a href="https://navanchauhan.github.io/repo">Repo</a></li></ul></nav></div></header><div class="wrapper"><article><div class="content"><span class="reading-time">1 minute read</span><span class="reading-time">Created on December 10, 2019</span><span class="reading-time">Last modified on June 1, 2020</span><h1>Making Predictions using Image Classifier (TensorFlow)</h1><p><em>This was tested on TF 2.x and works as of 2019-12-10</em></p><p>If you want to understand how to make your own custom image classifier, please refer to my previous post.</p><p>If you followed my last post, then you created a model which took an image of dimensions 50x50 as an input.</p><p>First we import the following if we have not imported these before</p><pre><code><div class="highlight"><span></span><span class="kn">import</span> <span class="nn">cv2</span>
<span class="kn">import</span> <span class="nn">os</span>
</div></code></pre><p>Then we read the file using OpenCV.</p><pre><code><div class="highlight"><span></span><span class="n">image</span><span class="o">=</span><span class="n">cv2</span><span class="o">.</span><span class="n">imread</span><span class="p">(</span><span class="n">imagePath</span><span class="p">)</span>
</div></code></pre><p>The cv2. imread() function returns a NumPy array representing the image. Therefore, we need to convert it before we can use it.</p><pre><code><div class="highlight"><span></span><span class="n">image_from_array</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">fromarray</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="s1">&#39;RGB&#39;</span><span class="p">)</span>