<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Suraj Krishnamurthy on Medium]]></title>
        <description><![CDATA[Stories by Suraj Krishnamurthy on Medium]]></description>
        <link>https://medium.com/@mailto-surajk?source=rss-8c2e7b519d7b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MDyQ0Dsx6mbcnkj4K7Jffw.jpeg</url>
            <title>Stories by Suraj Krishnamurthy on Medium</title>
            <link>https://medium.com/@mailto-surajk?source=rss-8c2e7b519d7b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 00:47:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mailto-surajk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Welcome!]]></title>
            <link>https://medium.com/computer-vision-concepts/welcome-b89492473f33?source=rss-8c2e7b519d7b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b89492473f33</guid>
            <dc:creator><![CDATA[Suraj Krishnamurthy]]></dc:creator>
            <pubDate>Sat, 21 Dec 2024 17:31:29 GMT</pubDate>
            <atom:updated>2024-12-21T17:31:29.761Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to this publication “Computer Vision Concepts”. If you are reading this article (or any article in this publication), it means you are a busy professional interested to learn more on various topics of computer vision.</p><p>I have started this publication to convert all my personal notes into an organized digital form which can be accessed by everyone.</p><p>The goal of the articles posted here will be to disseminate the knowledge of the fundamentals of computer vision to a larger audience who may not have the resources to go through the academic literature, or who don’t have enough time to peruse the vast resource pool available on the Internet.</p><p>I wouldn’t be using ChatGPT or any other tools to create the articles that are posted on this publication as I believe blindly copying and pasting from an AI text generator tool wouldn’t help much in increasing a human’s knowledge. Hence, the articles may look a little unpolished, but please keep in mind that there would be as fewer errors and mistakes as possible since I would’ve written, edited and reviewed each article multiple times.</p><p>If you are interested in a particular topic, please feel free to drop a comment or even send a mail to computervisionconcepts@gmail.com so I can write an article on the suggested topic.</p><p>Wishing you a warm welcome again, and hoping you’d enjoy the articles and learn from them!</p><p>Ciao, till the next article…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b89492473f33" width="1" height="1" alt=""><hr><p><a href="https://medium.com/computer-vision-concepts/welcome-b89492473f33">Welcome!</a> was originally published in <a href="https://medium.com/computer-vision-concepts">Computer Vision Concepts</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Quick Introduction to Orthonormal Matrices]]></title>
            <link>https://mailto-surajk.medium.com/a-quick-introduction-to-orthonormal-matrices-15bb54682572?source=rss-8c2e7b519d7b------2</link>
            <guid isPermaLink="false">https://medium.com/p/15bb54682572</guid>
            <category><![CDATA[linear-algebra]]></category>
            <dc:creator><![CDATA[Suraj Krishnamurthy]]></dc:creator>
            <pubDate>Sun, 06 Dec 2020 10:44:15 GMT</pubDate>
            <atom:updated>2020-12-06T10:44:15.879Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_c3lwyf7QdYhA_x6" /><figcaption>Photo by <a href="https://unsplash.com/@possessedphotography?utm_source=medium&amp;utm_medium=referral">Possessed Photography</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Setting the stage</h3><p>Before dwelling into “orthonormal”, we must first understand what “orthogonal” means.</p><p>In simple terms, two vectors <strong><em>x</em></strong> and <strong><em>y</em></strong> are said to be “orthogonal” if they make an angle of 90 degrees with each other.</p><h4>So how do we find if two vectors are orthogonal?</h4><p>Well, that’s really simple! The vectors <strong><em>x</em></strong> and <strong><em>y</em></strong> are orthogonal if their dot product is equal to 0.</p><p>Consider two vectors of length <strong><em>n</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*J0ImvepD2XpC30oBUUtnTw.png" /></figure><p>Their dot product (also called inner product) is defined as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*xHOsInaw06LEbVFwejRYww.png" /></figure><p>Mathematically, the vectors <strong><em>x</em></strong> and <strong><em>y</em></strong> are orthogonal if</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/138/1*tTnvmXn08dDsoamBc2Ty5w.png" /></figure><h4>Now, what about “orthonormal”?</h4><p>The vectors <strong><em>x</em></strong> and <strong><em>y</em></strong> are now orthonormal if they both are of unit length as well as orthogonal. Mathematically,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/161/1*bqy-6E8IzmsGv7uVUL-6Lg.png" /></figure><p>It is important to note that while both “orthogonal” and “orthonormal” pairs of vectors are perpendicular to each other, the “orthogonal” vectors need not be of length 1. Hence, any pair of orthonormal vectors are also orthogonal (but the vice versa isn’t true).</p><h3>Moving from vector to matrix</h3><p>An orthogonal matrix <strong><em>Q</em></strong> is a square matrix whose columns are all orthonormal i.e., orthogonal unit vectors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*3iMtS2IBmE5H1GoxMIv0jg.png" /></figure><p>Mathematically, <strong><em>Q</em></strong> is orthonormal if the following conditions are satisfied:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*H2prPYLKwrZBXiSG1LCkow.png" /></figure><p>In simpler words, the magnitude of every column of the orthonormal matrix is 1, and each column is perpendicular to the other.</p><h3>Examples of orthonormal matrices</h3><p>→ An identity matrix is the simplest orthonormal matrix</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/1*BCRYnXErympOiYedH-Tfbg.png" /></figure><p>→ The permutation of an identity matrix</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/233/1*aZbGhJV5BZ7-TmtTuY4QwA.png" /></figure><p>→ Any rotation matrix is an orthonormal matrix. For example, the 3x3 rotation along Z-axis as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*DO8UO6q_hAUEX-M37tBaRg.png" /></figure><h3>Visual example of rotation matrices:</h3><p>In three dimensions, rotation can be applied in three directions i.e., X, Y and Z directions.</p><p>The following matrices are used in order to apply rotation in the corresponding directions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*OqMWIDOobMTLY9n3k-DXaA.png" /></figure><p>The figure below consists of the following plots:</p><ol><li>Basis vectors in X, Y and Z directions</li><li>Basis vectors rotated along X direction by 45 degrees</li><li>Basis vectors rotated along Y direction by -15 degrees</li><li>Basis vectors rotated along Z direction by 30 degrees</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nvno5myQD_Fcnv5ogDRNNw.png" /></figure><p>While it may not be visibly obvious from the plots, the three colored lines are indeed perpendicular to each other. Also, the length of each of the colored lines in the rotated axes are still 1. Hence, the property that orthonormal matrix preserves the length of a vector is experimentally proved.</p><p>The Octave code used to generate the above figure is provided below for any further exploration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/caf6bebace0b4161d06698c8047b617e/href">https://medium.com/media/caf6bebace0b4161d06698c8047b617e/href</a></iframe><h3>Few properties of orthonormal matrices:</h3><p>Some of the properties of orthonormal matrices are listed below, along with the proofs. It is important to know that this list is non-exhaustive, and the goal here is to give</p><h4>The inverse of an orthonormal matrix is its transpose</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*lWqVCsDrlpZCYBHmeNTTZA.png" /></figure><p>As can be seen above, multiplying the orthonormal matrix <strong><em>Q</em></strong> with its transpose yielded the identity matrix, thereby proving that the transposed matrix is indeed the inverse of the original matrix <strong><em>Q</em></strong>.</p><h4>The transpose of the orthonormal matrix is also orthonormal</h4><p>Given that <strong><em>Q</em></strong> is orthonormal,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*WlJAgnCK7z50VSbuWje-xg.png" /></figure><h4>The columns of the matrix are orthonormal</h4><p>This directly follows the definition.</p><h4>The rows of the matrix are orthonormal</h4><p>Since the transpose of the matrix <strong><em>Q</em></strong> is orthonormal, the columns of <strong><em>Q</em>^T</strong> are orthonormal. However, these columns form the rows in <strong><em>Q</em></strong>, thereby proving that the rows of <strong><em>Q</em></strong> are orthonormal.</p><h4>An orthonormal matrix is non-singular</h4><p>It is already established that for any orthonormal matrix, the inverse exists and is the transpose of the matrix itself.</p><p>This proves the following properties:</p><ol><li>The orthonormal matrix is non-singular</li><li>Determinant of an orthonormal matrix is NOT equal to 0</li><li>0 is NOT an eigen values of the orthonormal matrix</li></ol><h4>Transforming a vector by an orthonormal matrix does not change the magnitude of the vector</h4><p>Mathematically,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/226/1*YYujQKnbOGPlL7FDmHT_kg.png" /></figure><p>Proof:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*ysXE8lHEM07K4wu8Mcu8Pg.png" /></figure><h4>The product of two orthonormal matrix is also orthonormal</h4><p>Given two orthonormal matrices <strong><em>A</em></strong> and <strong><em>B</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*TRbAFAzW14UveEd3e2EGpA.png" /></figure><h4>The determinant of an orthonormal matrix is +1 or -1</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*TyvUIXlmzQouWuTZr7hfAw.png" /></figure><h4>The eigenvalues of an orthonormal matrix are always +1 or -1</h4><p>If <strong><em>Q</em></strong> is an orthonormal matrix,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/235/1*JWGjAKP-CJMPzVsaFrUHDQ.png" /></figure><h3>Extending from real to complex matrices</h3><p>So far so good. But what happens when <strong><em>Q</em></strong> is a complex matrix consisting of one or more complex numbers?</p><p>A complex matrix whose columns are orthonormal is called a <strong>Unitary </strong>matrix. Unitary matrix also satisfies the above-mentioned properties, albeit with a minor change as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/125/1*bn9SEyfkxLht3WUTLZDsAQ.png" /></figure><p>i.e., the inverse of a unitary matrix is the <strong>conjugate transpose</strong> or <strong>Hermitian transpose</strong> of the same (One may recall that the inverse of a real orthonormal matrix is only the transpose).</p><p>The conjugate transpose or Hermitian transpose of a matrix is obtained by first transposing the matrix and then taking the complex conjugate of every element of the matrix. An example is shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*vcJ9oZeY6rpI7928RWWSrw.png" /></figure><p><strong>Note:</strong> In literature, one may also come across the following notation for the conjugate transpose:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/122/1*M5n1KuMRro2g24MNtJrx1A.png" /></figure><h3>Conclusion:</h3><p>For a novice reader, any rotation matrix is the most obvious example or orthonormal matrix. However, orthonormal and unitary matrices find applications in various aspects of linear algebra such as eigenvalue decomposition, spectral decomposition, Principal Component Analysis (PCA) etc. which form the basis for several real-world applications.</p><h3>References and Further Reading:</h3><ol><li>David W Lewis, “<strong>Matrix Theory</strong>”</li><li>R A Horn &amp; C R Johnson, “<strong>Matrix Analysis</strong>”</li><li>Wikipedia article on orthonormal matrix: <a href="https://en.wikipedia.org/wiki/Orthogonal_matrix">https://en.wikipedia.org/wiki/Orthogonal_matrix</a></li><li>Wikipedia article on rotation matrix: <a href="https://en.wikipedia.org/wiki/Rotation_matrix">https://en.wikipedia.org/wiki/Rotation_matrix</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15bb54682572" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Tutorial on Traffic Sign Classification using PyTorch]]></title>
            <link>https://mailto-surajk.medium.com/a-tutorial-on-traffic-sign-classification-using-pytorch-dabc428909d7?source=rss-8c2e7b519d7b------2</link>
            <guid isPermaLink="false">https://medium.com/p/dabc428909d7</guid>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[image-classification]]></category>
            <category><![CDATA[traffic-sign-recognition]]></category>
            <dc:creator><![CDATA[Suraj Krishnamurthy]]></dc:creator>
            <pubDate>Sun, 18 Oct 2020 15:33:54 GMT</pubDate>
            <atom:updated>2021-01-30T15:48:31.809Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wVJb1RHwrqwagqOj" /><figcaption>Photo by <a href="https://unsplash.com/@will0629?utm_source=medium&amp;utm_medium=referral">Will Porada</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Traffic Sign Recognition (TSR) is undoubtedly one of the most important problems in the field of driverless cars and advanced driver assistance systems (ADAS). TSR enables the front-facing smart cameras mounted on the car to recognize the signboards so that the car can act accordingly. Some examples include recognizing stop signs, speed limit, turn signs etc.</p><p>More formally, TSR is expected to perform two tasks:<br>1. <strong>Traffic Sign Detection</strong>: Detect all the signs from a given video frame<br>2. <strong>Traffic Sign Recognition</strong>: Recognize all the detected signs</p><p>The focus of this blogpost is to introduce the second step alone i.e., the recognition part. I assume that the signboards are all detected and the sign part alone is cropped and stored as a separate image. However, detection and classification can be solved as a single problem, which will be addressed in a separate blogpost.</p><p>In this blogpost, I provide a step-by-step guide to train a deep neural network model for traffic sign classification.</p><p>If you’re someone who likes to directly dive into the code, here’s the link for the Github repo: <a href="https://github.com/surajmurthy/TSR_PyTorch">https://github.com/surajmurthy/TSR_PyTorch</a></p><p>I use the <strong>German Traffic Sign Recognition Benchmark (GTSRB) </strong>dataset for demostrating TSR.</p><p>The GTSRB dataset consists of 39209 training images corresponding to 43 classes. An example image corresponding to each class of the dataset is shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mWK70K4agwvlwR-JBiT-aw.png" /><figcaption>Sample images and the class labels of GTSRB dataset</figcaption></figure><p>It is important to note that these example images are not a part of the training data. The training data, in fact, is quite challenging — with varying sizes, contrast, noisy and blurred. A montage of training samples of all classes of the GTSRB dataset is provided in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PzxgtgcTTZFkg6egXcJW6Q.png" /><figcaption>Examples of training data of GTSRB dataset</figcaption></figure><p><strong>Preparing data for training</strong></p><p>I defined a simple transformation that performs only two operations i.e., resize the images to 112 x 112 and convert them to PyTorch tensor.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0d5f4f6b3ba5e5400d14c886abaf8f1/href">https://medium.com/media/e0d5f4f6b3ba5e5400d14c886abaf8f1/href</a></iframe><p>As mentioned earlier, The GTSRB dataset consists of 39209 training images corresponding to 43 classes.</p><p>I initially split the training dataset into two: training and validation, with ratio 80:20. So I used 31367 images for training and the remaining 7842 images as validation. Then data loaders for both training and validation datasets were created.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a784605607e27c6463fc771bc4b5eb8/href">https://medium.com/media/6a784605607e27c6463fc771bc4b5eb8/href</a></iframe><p>The distribution plot of both training and validation examples is shown in the figure below. As can be observed, the distribution of validation examples closely follows that of the training set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*irSdB9ROOu7Fxqv926WWag.png" /><figcaption>Distribution plot of training and validation examples</figcaption></figure><p><strong>Implementing a Convolutional Neural Network</strong></p><p>To perform TSR, I built a CNN whose architecture is similar to that of the original AlexNet network used for image classification on ImageNet by Alex Krizhevsky et. al. [3]. I call this model AlexNetTS.</p><p>The code that describes AlexNetTS is provided in the gist below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/02feafb5ea289f7cff95a260a28dfa4b/href">https://medium.com/media/02feafb5ea289f7cff95a260a28dfa4b/href</a></iframe><p>Once the architecture is defined, I created the network. I also printed the details of the network. In addition, to generate a summary of the model, I used this wonderful package <strong>torchsummary</strong> package [2]. Please check the Github link provided in the reference for more details. The “torchsummary” package requires the input size to make a forward pass through the network and print the output shape and number of parameters at each layer.</p><p>The code to create the model and print the summary is provided below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b488fd788c84211abefab25e54f077c8/href">https://medium.com/media/b488fd788c84211abefab25e54f077c8/href</a></iframe><p>Our model has 15,063,891 trainable parameters. The details of the model as printed by Line-10 of the above gist is provided below.</p><pre>AlexnetTS(<br>  (features): Sequential(<br>    (0): Conv2d(3, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))<br>    (1): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)<br>    (2): ReLU(inplace=True)<br>    (3): Conv2d(64, 192, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>    (4): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)<br>    (5): ReLU(inplace=True)<br>    (6): Conv2d(192, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>    (7): ReLU(inplace=True)<br>    (8): Conv2d(384, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>    (9): ReLU(inplace=True)<br>    (10): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))<br>    (11): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)<br>    (12): ReLU(inplace=True)<br>  )<br>  (classifier): Sequential(<br>    (0): Dropout(p=0.5, inplace=False)<br>    (1): Linear(in_features=12544, out_features=1000, bias=True)<br>    (2): ReLU(inplace=True)<br>    (3): Dropout(p=0.5, inplace=False)<br>    (4): Linear(in_features=1000, out_features=256, bias=True)<br>    (5): ReLU(inplace=True)<br>    (6): Linear(in_features=256, out_features=43, bias=True)<br>  )<br>)</pre><p>Since I’m providing RGB images of size 112x112 to the network for training, I use the input size (3, 112, 112) to print the summary, which is provided below. The summary contains the following information:</p><ol><li>Output shape and parameter at each layer</li><li>Estimated total size of the network</li><li>Total number of parameters in the network, both trainable and non-trainable</li></ol><pre>----------------------------------------------------------------<br>        Layer (type)               Output Shape         Param #<br>================================================================<br>            Conv2d-1           [-1, 64, 56, 56]           1,792<br>         MaxPool2d-2           [-1, 64, 28, 28]               0<br>              ReLU-3           [-1, 64, 28, 28]               0<br>            Conv2d-4          [-1, 192, 28, 28]         110,784<br>         MaxPool2d-5          [-1, 192, 14, 14]               0<br>              ReLU-6          [-1, 192, 14, 14]               0<br>            Conv2d-7          [-1, 384, 14, 14]         663,936<br>              ReLU-8          [-1, 384, 14, 14]               0<br>            Conv2d-9          [-1, 256, 14, 14]         884,992<br>             ReLU-10          [-1, 256, 14, 14]               0<br>           Conv2d-11          [-1, 256, 14, 14]         590,080<br>        MaxPool2d-12            [-1, 256, 7, 7]               0<br>             ReLU-13            [-1, 256, 7, 7]               0<br>          Dropout-14                [-1, 12544]               0<br>           Linear-15                 [-1, 1000]      12,545,000<br>             ReLU-16                 [-1, 1000]               0<br>          Dropout-17                 [-1, 1000]               0<br>           Linear-18                  [-1, 256]         256,256<br>             ReLU-19                  [-1, 256]               0<br>           Linear-20                   [-1, 43]          11,051<br>================================================================<br>Total params: 15,063,891<br>Trainable params: 15,063,891<br>Non-trainable params: 0<br>----------------------------------------------------------------<br>Input size (MB): 0.14<br>Forward/backward pass size (MB): 6.63<br>Params size (MB): 57.46<br>Estimated Total Size (MB): 64.24<br>----------------------------------------------------------------</pre><p><strong>Training the network</strong></p><p>The network was trained for 15 epochs. Adam optimizer with a learning rate of 0.001 was used. The loss function used was Cross Entropy Loss.</p><p>The code to perform training and validation is provided below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3f5a606dfdb909c6f3bfbdd1d03610c/href">https://medium.com/media/f3f5a606dfdb909c6f3bfbdd1d03610c/href</a></iframe><p>The plots of loss and accuracy for both the sets are shown in the figure below. It can be noticed that though the network was trained for 15 epochs, the loss curve flattens after around 6 epochs. At the end of 15 epochs, both training and validation accuracy achieved above 99%.</p><p>The training time for each epoch was approximately less than a minute on a Windows 10 machine having RTX 2060 GPU. Evaluation on the validation set took slightly more than 8 seconds only i.e., evaluating each sample in the validation set took only 1 millisecond!</p><pre>Epoch-14: <br>Training: Loss = 0.0233, Accuracy = 0.9925, Time = 41.47 seconds<br>Validation: Loss = 0.0160, Accuracy = 0.9966, Time = 7.88 seconds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*LMpFxrlHF5RyDBp5jxm-uw.png" /><figcaption>Plots of loss and accuracy of both training and validation sets</figcaption></figure><p><strong>Inferencing on the Test Set</strong></p><p>The GTSRB dataset also consists of 12630 test images on which inference was performed. These images were NOT a part of either training and validation sets.</p><p>Using the model trained earlier, I was able to achieve an accuracy of around 95%. Impressive, but there’s still plenty of room for improvement!</p><pre>Number of correctly classified images = 12028<br>Number of incorrectly classified images = 602<br>Final accuracy = 0.952336</pre><p>It is also important to note that the TSR problem I’m addressing here is a multi-class classification problem with an imbalanced training set. Hence relying only on accuracy for measuring the performance of the model isn’t the right thing to do.</p><p>Hence I generated the classification report using the scikit-learn package, and also plotted the confusion matrix for a better analysis. The classification report consists of Precision, Recall and their harmonic means i.e., the F1 score. More details about these measures can be found in the following Wikipedia article: <a href="https://en.wikipedia.org/wiki/Precision_and_recall">https://en.wikipedia.org/wiki/Precision_and_recall</a></p><pre>                precision    recall  f1-score   support<br><br>           0       0.97      0.95      0.96        60<br>           1       0.97      0.95      0.96       720<br>           2       0.94      0.98      0.96       750<br>           3       0.98      0.96      0.97       450<br>           4       0.95      0.95      0.95       660<br>           5       0.95      0.92      0.93       630<br>           6       0.99      0.89      0.94       150<br>           7       0.97      0.94      0.95       450<br>           8       0.87      0.98      0.92       450<br>           9       1.00      1.00      1.00       480<br>          10       1.00      0.98      0.99       660<br>          11       0.97      0.90      0.93       420<br>          12       0.96      0.92      0.94       690<br>          13       0.99      0.99      0.99       720<br>          14       1.00      1.00      1.00       270<br>          15       0.96      0.97      0.97       210<br>          16       1.00      0.99      0.99       150<br>          17       0.99      0.98      0.99       360<br>          18       0.96      0.87      0.91       390<br>          19       0.69      0.95      0.80        60<br>          20       0.89      0.97      0.93        90<br>          21       0.98      0.99      0.98        90<br>          22       0.94      0.90      0.92       120<br>          23       1.00      0.80      0.89       150<br>          24       0.85      0.94      0.89        90<br>          25       0.95      0.93      0.94       480<br>          26       0.76      0.90      0.82       180<br>          27       0.54      0.63      0.58        60<br>          28       0.99      0.90      0.94       150<br>          29       0.90      0.83      0.87        90<br>          30       0.88      0.79      0.83       150<br>          31       0.87      0.99      0.93       270<br>          32       0.91      1.00      0.95        60<br>          33       0.99      0.99      0.99       210<br>          34       0.94      0.99      0.96       120<br>          35       1.00      0.99      0.99       390<br>          36       0.98      1.00      0.99       120<br>          37       0.95      1.00      0.98        60<br>          38       1.00      0.99      0.99       690<br>          39       0.98      0.98      0.98        90<br>          40       0.70      1.00      0.83        90<br>          41       0.97      1.00      0.98        60<br>          42       0.92      0.93      0.93        90<br><br>    accuracy                           0.95     12630<br>   macro avg       0.93      0.94      0.93     12630<br>weighted avg       0.96      0.95      0.95     12630</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6fU3Qp_6NEXXIdCfKLIog.png" /><figcaption>Confusion matrix for the test data for TSR</figcaption></figure><p>From the confusion matrix, it is quite evident that the model is performing reasonably well. However, there are few non-zero entries in the non-diagonal locations of the matrix which needs to be further reduced.</p><p>For better understanding, the predicted v/s actual labels for the first 30 images in the test set are provided below. Despite few test images are of poor quality, the model is still able to classify them correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5rhDZEF5A17S-ugfvVKV_g.png" /><figcaption>Predicted v/s Actual labels for 30 images of test set</figcaption></figure><p><strong>Conclusion and tips for improvement</strong></p><p>In this tutorial, we looked at building a Convolutional Neural Network model to perform traffic sign recognition. A modification of the popular AlexNet architecture was used for performing the task, and the network was trained on the GTSRB dataset.</p><p>While we were able to achieve around 99% accuracy on both training and validation sets, an accuracy of around 95% was achieved on the test set. By employing other metrics such as Precision, Recall, F1-Score and the Confusion Matrix, we could notice that the model is indeed performing well on the test set.</p><p>Listed below are few points that provide directions for further improvements:</p><ol><li>Since we are dealing with an imbalanced training data, we can perform oversampling on the minority class during training. Synthetic Minority Oversampling Technique (SMOTE) can be used for the same [4]</li><li>Data augmentation techniques can be used to improve the performance. Currently, I haven’t used any augmentation in this tutorial</li><li>Weighted cross entropy loss can be applied during the training, where the weights are inversely related to the proportion of the number of examples of a particular class</li><li>Focal loss can be employed to penalized “hard” examples</li><li>Adrian Roseblock suggests improving image contrast by applying an algorithm called <a href="https://en.wikipedia.org/wiki/Adaptive_histogram_equalization#CLAHE">Contrast Limited Adaptive Histogram Equalization</a> (CLAHE)</li><li>A combination of some or all the above-mentioned methods can be applied</li><li>A technique called <strong>Curriculum Learning</strong> in which the training examples are fed to the model in a meaningful order is an active area of research. Works such as dynamic curriculum learning [5] are very powerful tools to combat imbalanced data classification.</li></ol><p><strong>References</strong></p><p>[1] Adrian Roseblock’s tutorial on Traffic Sign Recognition. URL: <a href="https://www.pyimagesearch.com/2019/11/04/traffic-sign-classification-with-keras-and-deep-learning/">https://www.pyimagesearch.com/2019/11/04/traffic-sign-classification-with-keras-and-deep-learning/</a></p><p>[2] Keras style model.summary() in PyTorch. URL: <a href="https://github.com/sksq96/pytorch-summary">https://github.com/sksq96/pytorch-summary</a></p><p>[3] Krizhevsky, Alex, Ilya Sutskever, and Geoffrey E. Hinton. “Imagenet classification with deep convolutional neural networks.” <em>Advances in Neural Information Processing Systems</em>. 2012</p><p>[4] <a href="https://machinelearningmastery.com/smote-oversampling-for-imbalanced-classification/">https://machinelearningmastery.com/smote-oversampling-for-imbalanced-classification/</a></p><p>[5] Wang, Yiru, et al. “Dynamic curriculum learning for imbalanced data classification.” <em>Proceedings of the IEEE international conference on computer vision </em>(ICCV). 2019. URL: <a href="https://openaccess.thecvf.com/content_ICCV_2019/html/Wang_Dynamic_Curriculum_Learning_for_Imbalanced_Data_Classification_ICCV_2019_paper.html">https://openaccess.thecvf.com/content_ICCV_2019/html/Wang_Dynamic_Curriculum_Learning_for_Imbalanced_Data_Classification_ICCV_2019_paper.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dabc428909d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>