<?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 Prudhvi Gnv on Medium]]></title>
        <description><![CDATA[Stories by Prudhvi Gnv on Medium]]></description>
        <link>https://medium.com/@prudhvi.gnv?source=rss-526fdf4315b7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZFu4uTQFyF1fpsjwzf6vLA.png</url>
            <title>Stories by Prudhvi Gnv on Medium</title>
            <link>https://medium.com/@prudhvi.gnv?source=rss-526fdf4315b7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 13:19:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prudhvi.gnv/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[How to publish your own Python Package in pypi]]></title>
            <link>https://medium.com/@prudhvi.gnv/how-to-publish-your-own-python-package-in-pypi-5037ca21dd82?source=rss-526fdf4315b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5037ca21dd82</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[package]]></category>
            <category><![CDATA[twiline]]></category>
            <category><![CDATA[pypi]]></category>
            <dc:creator><![CDATA[Prudhvi Gnv]]></dc:creator>
            <pubDate>Tue, 08 Sep 2020 09:54:30 GMT</pubDate>
            <atom:updated>2020-09-08T09:54:30.204Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*FFcPiLLv_vAntalM" /></figure><p>Python is famous for coming with <a href="https://docs.python.org/tutorial/stdlib.html#batteries-included">batteries included</a>. Sophisticated capabilities are available in the standard library. You can find modules for working with <a href="https://realpython.com/python-sockets/">sockets</a>, parsing <a href="https://realpython.com/python-csv/">CSV</a>, <a href="https://realpython.com/python-json/">JSON</a>, and <a href="https://docs.python.org/library/xml.html">XML</a> files, and <a href="https://realpython.com/working-with-files-in-python/">working with files</a> and <a href="https://realpython.com/python-pathlib/">file paths</a>.</p><p>The PyPi package index is one of the properties that makes python so powerfull: With just a simple command, you get access to thousands of cool libraries, ready for you to use.</p><p>However great the <a href="https://realpython.com/python-modules-packages">packages</a> instead. included with Python are, there are many fantastic projects available outside the standard library. These are most often hosted at the <a href="https://pypi.org/">Python Packaging Index</a> (PyPI), historically known as the <a href="https://www.youtube.com/watch?v=Hz1JWzyvv8A">Cheese Shop</a>. At PyPI, you can find everything from <a href="https://pypi.org/search/?q=helloworld">Hello World</a> to advanced <a href="https://pypi.org/project/Keras/">deep learning libraries</a>.</p><h3>But what is PyPi?</h3><p>Well, according to their <a href="https://pypi.org/">Website</a>:</p><blockquote><em>The Python Package Index (PyPI) is a repository of software for the Python programming language. PyPI helps you find and install software developed and shared by the Python community.</em></blockquote><h3><strong>Overview:</strong></h3><ul><li>Pre-requisites</li><li>Make your code publish-ready</li><li>Create a python package</li><li>Create the files PyPi needs</li><li>Create a PyPi account</li><li>Upload your package to github.com</li><li>Upload your package to PyPi</li><li>Install your own package using pip</li><li>Change your package</li></ul><h3>SOME PRE-REQUISITES BEFORE WE START IT…</h3><ol><li>You should have Python3 installed on your machine.</li><li>Make sure you have the latest version of pip. Be sure by typing it on your terminal or command prompt</li></ol><pre>python -m pip <strong>install</strong> -<strong>upgrade</strong> pip</pre><p>3. You should have installed wheel and twine library. If not then they can be easily installed by the following commands,</p><pre>pip <strong>install</strong> wheel</pre><pre>pip install twine</pre><p>4. You should have a working GitHub account.</p><h3>Make your code publish-ready</h3><p>Let’s prepare your code for the uploading. First, you should remove all “print” statements from your code. It’s annoying when you work with a library and your command promt is flooded with print messages that are not yours — therefore remove all of them. If you want to inform the user about certain activities, use <a href="https://docs.python.org/3/library/logging.html">logging</a>.</p><p>wrap it into the “__main__” function.</p><pre>if __name__ == &quot;__main__&quot;:    <br>your example code goes here</pre><h3>Create a python package</h3><p>To create a package, create a folder that is named exactly how you want your package to be named. Place all the files and classes that you want to ship into this folder.</p><p>Now, create a file called __init__.py (again two underscores).</p><pre>from packagename.Filename import Classname</pre><h3>Create a PyPi account</h3><p>You can register yourself for a PyPi account <a href="https://pypi.org/account/register/">here</a>.</p><h3>Upload your package to github.com</h3><p>Create a github repo including all the files we are going to create in a second, as well as your package folder. Name the repo exactly as the package. You find an example of such a repo <a href="http://www.github.com/PrudhviGNV/py-automl">here</a>.</p><h3>Create the files PyPi needs</h3><p>PyPi needs three files in order to work:</p><ul><li>setup.py</li><li>setup.cfg</li><li>LICENSE.txt</li><li>README.md <em>(optinal but highly recommended)</em></li></ul><h3>setup.py</h3><p>The setup.py file contains information about your package that PyPi needs, like its name, a description, the current version etc. Copy and Paste the following Code and replace the Strings with your matching content:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6f3a6a7d253dc96c58792058b32636b/href">https://medium.com/media/d6f3a6a7d253dc96c58792058b32636b/href</a></iframe><p>Let me explain the download_url and the install_requires a bit further.</p><h3>download_url</h3><p>You have previously uploaded your project to your github repository. Now, we create a new release version of your project on github. This release will then be downloaded by anyone that runs the “pip install YourPackage” command.</p><p>First, go to github.com and navigate to your repository. Next, click on the tab “releases” and then on “Create a new release”. Now, define a Tag verion (it is best to use the same number as you used in your setup.py version-field: <em>v_01</em>. Add a release title and a description (not that important), then click on “publish release”. Now you see a new release and under <strong>Assets</strong>, there is a link to <strong>Source Code (tar.gz)</strong>. Right-click on this link and chose <em>Copy Link Address</em>. Paste this link-address into the <em>download_url</em> field in the setup.py file. Every time you want to update your package later on, upload a new version to github, create a new release as we just discussed, specify a new release tag and copy-paste the link to Source into the setup.py file (do not forget to also increment the version number).</p><h3>Install_requires</h3><p>Here, you define all the dependencies your package has — all the pip packages that you are importing.</p><pre>import keras as k<br>import numpy as np</pre><p>The resulting <em>install_requires</em> field would look like this:</p><pre>install_requires=[       <br>   &#39;numpy&#39;,        <br>  &#39;keras&#39;,     <br> ],</pre><h3>setup.cfg</h3><p>This is a short one. Create a new file called “setup.cfg”. If you have a description file (and you definitely should!), you can specify it here:</p><pre># Inside of setup.cfg<br>[metadata]<br>description-file = README.md</pre><h3>LICENSE.txt</h3><p>Use this file to define all license details. Most propably, just copy-paste the license text from <a href="https://opensource.org/licenses/">this</a> website into the LICENSE.txt file. I always use the MIT license for my projects, but feel free to use your own.</p><h3>README.md (Optional)</h3><p>Create a markdown file with <a href="https://dillinger.io/">this</a> beautiful website, then download it and place it into your directory.</p><h3>Upload your package to PyPi</h3><p>Now, the final step has come: uploading your project to PyPi. First, open the command prompt and navigate into your the folder where you have all your files and your package located:</p><pre>cd &quot;C://PATH//TO//YOUR//FOLDER&quot;</pre><p>Now, we create a source distribution with the following command</p><pre>python setup.py sdist</pre><p>You might get a warning stating “Unknown distribution option: ‘install_requires’. Just ignore it.</p><p>We will need <em>twine</em> for the upload process, so first install twine via pip:</p><pre>pip install twine</pre><p>Then, run the following command:</p><pre>twine upload dist/*</pre><p>You will be asked to provide your username and password. Provide the credentials you used to register to PyPi earlier.</p><p><strong><em>notes:</em></strong></p><p>Twine → used to uploading project builds to pypi</p><p>sdist → is used to make a source code artifact that can be uploaded to pypi. it will place this artifact in ./build/ directory as <em>project-name-version.tar.gz</em></p><p><strong>Congratulations, your package is now uploaded!</strong> Visit <a href="https://pypi.org/project/YOURPACKAGENAME/"><em>https://pypi.org/project/YOURPACKAGENAME/</em></a> to see your package online!</p><h3>Install your own package using pip</h3><p>Okay, now let’s test this out. Open your console and type the following command:</p><pre>pip install YOURPACKAGENAME</pre><p>It works! Now open the python SHELL/IDLE and import your package.</p><h3>Update your package</h3><p>If you maintain your package well, you will need to change the source code form time to time.</p><pre>python setup.py sdist<br>twine upload dist/*</pre><p>Finally, update your package via pip</p><pre>pip install YOURPACKAGE --upgrade</pre><p>I published a python package called Py-AutoML,</p><p>checkout :</p><p>source code here: <a href="http://www.github.com/PrudhviGNV/py-automl">www.github.com/PrudhviGNV/py-automl</a></p><p>and pypi: <a href="https://pypi.org/project/py-automl/">https://pypi.org/project/py-automl/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5037ca21dd82" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ImageNet Challenge: Advancement in deep learning and computer vision]]></title>
            <link>https://medium.com/@prudhvi.gnv/imagenet-challenge-advancement-in-deep-learning-and-computer-vision-124fd33cb948?source=rss-526fdf4315b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/124fd33cb948</guid>
            <dc:creator><![CDATA[Prudhvi Gnv]]></dc:creator>
            <pubDate>Tue, 08 Sep 2020 08:26:16 GMT</pubDate>
            <atom:updated>2020-09-08T08:44:45.285Z</atom:updated>
            <content:encoded><![CDATA[<p>A few years back, we still used small datasets like CIFAR and NORB consisting of tens of thousands of images. These datasets were sufficient for machine learning models to learn basic recognition tasks. However, real life is never simple and has many more variables than are captured in these small datasets. The recent availability of large datasets like ImageNet, which consist of hundreds of thousands to millions of labeled images, have pushed the need for an extremely capable deep learning model. Then came different CNN architectures to change the game.</p><h3><strong>ImageNet Challenge:</strong></h3><p><a href="http://image-net.org/"><strong>ImageNet</strong></a> is formally a project aimed at (manually) labeling and categorizing images into almost 22,000 separate object categories for the purpose of computer vision research.</p><p>However, when we hear the term <em>“ImageNet”</em> in the context of deep learning and Convolutional Neural Networks, we are likely referring to the <a href="http://www.image-net.org/challenges/LSVRC/"><strong><em>ImageNet Large Scale Visual Recognition Challenge</em></strong></a>, or ILSVRC for short.</p><p>The goal of this image classification challenge is to train a model that can correctly classify an input image into 1,000 separate object categories.</p><p><strong>The Dataset</strong>. ImageNet: a dataset made of more than 15 million high-resolution images labeled with 22 thousand classes. The key: web-scraping images and crowd-sourcing human labelers. ImageNet even has its own competition: the ImageNet Large-Scale Visual Recognition Challenge (ILSVRC). This competition uses a subset of ImageNet’s images and challenges researchers to achieve the lowest top-1 and top-5 error rates <strong>(top-5 error rate would be the percent of images where the correct label is not one of the model’s five most likely labels).</strong> In this competition, data is not a problem; there are about 1.2 million training images, 50 thousand validation images, and 150 thousand testing images. The authors enforced a fixed resolution of 256x256 pixels for their images by cropping out the center 256x256 patch of each image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*CBmNcivG9WLtKOVP.png" /></figure><p>When it comes to image classification, the ImageNet challenge is the <em>de facto</em> benchmark for computer vision classification algorithms — and the leaderboard for this challenge has been <strong><em>dominated</em></strong> by Convolutional Neural Networks and deep learning techniques since 2012.</p><p>The general challenge tasks for most years are as follows:</p><ul><li><strong>Image classification</strong>: Predict the classes of objects present in an image.</li><li><strong>Single-object localization</strong>: Image classification + draw a bounding box around one example of each object present.</li><li><strong>Object detection</strong>: Image classification + draw a bounding box around each object present.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*7r50bYoY9AnW0IG_.png" /></figure><p>The datasets comprised approximately 1 million images and 1,000 object classes. The datasets used in challenge tasks are sometimes varied (depending on the task) and were released publicly to promote widespread participation from academia and industry.</p><h3>Deep Learning Milestones From ILSVRC</h3><p>Researchers working on ILSVRC tasks have pushed back the frontier of computer vision research and the methods and papers that describe them are milestones in the fields of computer vision, deep learning, and more broadly in artificial intelligence.</p><p>The pace of improvement in the first five years of the ILSVRC was dramatic, perhaps even shocking to the field of computer vision. Success has primarily been achieved by large (deep) convolutional neural networks (CNNs) on graphical processing unit (GPU) hardware, which sparked an interest in deep learning that extended beyond the field out into the mainstream.</p><p>State-of-the-art CNN architectures changes the game. below is the popular cnn architectures with top 5% error .</p><blockquote><em>State-of-the-art accuracy has improved significantly from ILSVRC2010 to ILSVRC2014, showcasing the massive progress that has been made in large-scale object recognition over the past five years</em></blockquote><h3>ILSVRC-2012</h3><h3>AlexNet (SuperVision)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/0*nuhkboBXvTG5LHuD.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/0*PitRUq1z1ZcrQpMg.png" /></figure><p>AlexNet is considered to be the break-through paper which rose the interest in CNNs when it won the ImageNet challenge of 2012. AlexNet is a deep CNN trained on ImageNet and outperformed all the entries that year. It was a major improvement with the next best entry getting only 26.2% top 5 test error rate.</p><p>The simple network was made up of 5 conv layers, max-pooling layers, dropout layers, and 3 fully connected layers at the end. AlexNet used ReLU for the nonlinearity functions, which they found to decrease training time because ReLUs are much faster than using tanh functions. They also did image translations, horizontal reflections, and patch extractions as a way of augmenting the data before using it to train their network. They also used dropout layers to prevent over-fitting to the training data. They used a batch stochastic gradient descent optimization. Their implementation was trained on GPUs for five to six days.</p><h3>ILSVRC-2013</h3><h3>ZFNet (Clarifai)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*dM8k_DWGjQBRJ6hH.png" /></figure><p>ZF Net used 1.3 million images for training, compared to 15 million images used by AlexNet. One major difference in the approaches was that ZF Net used 7x7 sized filters whereas AlexNet used 11x11 filters. The intuition behind this is that by using bigger filters we were losing a lot of pixel information, which we can retain by having smaller filter sizes in the earlier conv layers. The number of filters increase as we go deeper. This network also used ReLUs for their activation and trained using batch stochastic gradient descent. It trained on a GPU for twelve days. Another interesting approach from the paper was this idea of a DeConvNet which can be used to see which image pixels excite each filter and provides great intuition in how CNNs work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*qS5yiOWELCf9q0W7igfz6g.png" /></figure><h3>ILSVRC-2014</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*smaJBYed3MSsqDodgnJnXw.png" /></figure><h3>Inception (GoogLeNet)</h3><p>With submissions like VGG Net ImageNet Challenge 2014 had many great submissions, but the winner of them all was Google’s GoogLeNet (The name ‘GooLeNet’ is a tribute to the works of Yann LeCun in his LeNet , widely considered to be the first use of modern CNNs). The GoogLeNet architecture is visually represented as follow</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*jrmaj7xFOmcacQ5U.png" /></figure><p>GoogLeNet uses 9 inception module and it eliminates all fully connected layers using average pooling to go from 7x7x1024 to 1x1x1024. This saves a lot of parameters. As a form of data augmentation, multiple crops of the same image were created and the network was trained on it. Training took less than a week with few high-end GPUs.</p><h3>VGG</h3><p>VGG Net was a technique proposed for the ImageNet challenge of 2013. VGG Net didn’t win the ImageNet 2013 challenge but it is still used by many people because it was a simple architecture based on the AlexNet type architecture.</p><p>VGG Net used 3x3 filters compared to 11x11 filters in AlexNet and 7x7 in ZF Net. The authors give the intuition behind this that having two consecutive 2 consecutive 3x3 filters gives an effective receptive field of 5x5, and 3–3x3 filters give a receptive field of 7x7 filters, but using this we can use a far less number of hyper-parameters to be trained in the network. As you may notice from the architecture the number of filters double after every max-pooling operation. As a data augmentation technique scale jittering was used. Trained with batch gradient descent and used RelUs. Trained on 4 GPUs for two to three weeks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*TfLKUNANtcXBfl6B.png" /></figure><h3>ILSVRC-2015</h3><h3>ResNet (MSRA)</h3><p>The Microsoft ResNet (residual network) won the 2015 ImageNet challenge</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*LNAZDaOBPE-6zMqm.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*pAbdM8_qeHe8j5s8.png" /></figure><p>There are 152 layers in the Microsoft ResNet. The authors showed empirically that if you keep on adding layers the error rate should keep on decreasing in contrast to “plain nets” where adding a few layers resulted in higher training and test errors. It took two to three weeks to train it on an 8 GPU machine. One intuitive reason why residual blocks improve classification is the direct step from one layer to the next and intuitively using all these skip steps form a gradient highway where the gradients computed can directly affect the weights in the first layer making updates have more effect.</p><h3>ILSVRC-2016</h3><h3>ResNeXt</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*kVg0LyHlGqmplQlt.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/0*UyY9fAQXU6i6FudG.png" /></figure><p>The model name, ResNeXt, contains Next. It means the next dimension, on top of the ResNet. This next dimension is called the “cardinality” dimension. And ResNeXt becomes the 1st Runner Up of ILSVRC classification task.</p><h3>ILSVRC-2017</h3><h3>SENet</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*k4w3s8k6qGYmiszN.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*NWjLJ5muzAGqRqls.png" /></figure><p>With “Squeeze-and-Excitation” (SE) block that adaptively recalibrates channel-wise feature responses by explicitly modelling interdependencies between channels, SENet is constructed. And it won the first place in ILSVRC 2017 classification challenge with top-5 error to 2.251% which has about 25% relative improvement over the winning entry of 2016. And this is a paper in 2018 CVPR with more than 600 citations.</p><p>I think I document almost everything that related to the imageNet</p><p>Hope you all love this. If you have any queries feel free to comment below.</p><p>For more projects, please</p><p><a href="http://prudhvignv.github.io/"><strong><em>prudhvignv.github.io</em></strong></a></p><p><strong>Thank you!!..</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=124fd33cb948" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Py-AutoML (pyAutoML) : A minimalistic low code machine learning package in python]]></title>
            <link>https://medium.com/@prudhvi.gnv/py-automl-pyautoml-a-minimalistic-low-code-machine-learning-package-in-python-1f78bb990b5f?source=rss-526fdf4315b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f78bb990b5f</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[pypi]]></category>
            <category><![CDATA[py-automl]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Prudhvi Gnv]]></dc:creator>
            <pubDate>Tue, 01 Sep 2020 07:52:48 GMT</pubDate>
            <atom:updated>2020-09-01T07:55:05.627Z</atom:updated>
            <content:encoded><![CDATA[<h3>Py-AutoML : A minimalistic low code machine learning package in python</h3><h3># Introduction</h3><h3>What is Py-AutoML?</h3><p><em>Py-AutoML is an open source `low-code` machine learning library in Python that aims to reduce the hypothesis to insights cycle time in a ML experiment. It mainly helps to do our pet projects quickly and efficiently. In comparison with the other open source machine learning libraries, Py-AutoML is an alternative low-code library that can be used to perform complex machine learning tasks with only few lines of code. Py-AutoML is essentially a Python wrapper around several machine learning libraries and frameworks such as `scikit-learn`, ‘tensorflow’,’keras’ and many more.</em></p><p><em>The design and simplicity of Py-AutoML is inspired by the two principles KISS (keep it simple and sweet) and DRY (Don’t Repeat Yourself) . We as engineers have to find a way effective way to mitigate this gap and address data related challenges in business setting.</em></p><p># <strong>Modules</strong><br>Py-AutoML is a minimalistic library which not simplifies the machine learning tasks and also makes our work easier.</p><p>Py-AutoML consists of so many functionalities. such as : <br> — — — — — — — — -</p><ul><li><strong>model.py </strong>- implementing popular neural networks such as googlenet , vgg16, simple cnn ,basic cnn, lenet5, alexnet, lstm, mlp etc..</li><li><strong>checkpoint.py</strong> — consists of callbacks function which is used to store metrics</li><li><strong>utils.py</strong> — consists of some functionalities used to preprocess test images, spliting the data.</li><li><strong>preprocess.py</strong> — used to preprocess image dataset such as resize, reshape, convert to greyscale, normalisation etc..</li><li><strong>ml.py</strong> — allow us to implement and check metrics of popular classical machine learning models such as random forest, decision tree, svm , logistic regression and also displays metric reports of every model.</li></ul><p><strong>visualize.py</strong> — allow us to visualize neural networks in pictorial and graphs form.</p><h3># ml.py → Implemented algorithms</h3><p>— — — — — —</p><ul><li>Logistic Regression</li><li>Support Vector Machine</li><li>Decision Tree Classifier</li><li>Random Forest Classifier</li><li>K-Nearest Neighbors<br> — — — — — — — — — — — — —</li></ul><h3><strong>model.py → Implemented popular neural network architectures</strong></h3><p>— — — — — —</p><ul><li><strong>GoogleNet</strong></li><li><strong>VGG16</strong></li><li><strong>AlexNet</strong></li><li><strong>Lenet5</strong></li><li><strong>Inception</strong></li><li><strong>simple &amp; basic cnn</strong></li><li><strong>basic_mlp &amp; deep_mlp</strong></li><li><strong>lstm</strong></li></ul><h4>with predefined configurations<br> — — — — — — — — — — — — — <br># Getting started</h4><p>— — — — — — — — -</p><h3>### Install the package</h3><pre>pip install py-automl</pre><p>Navigate to folder and install requirements:</p><pre><br>pip install -r requirements.txt</pre><p>## <strong>Usage</strong><br>Importing the package</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe8475c6647fb59e67d960917cc330f3/href">https://medium.com/media/fe8475c6647fb59e67d960917cc330f3/href</a></iframe><p>Assign the variables X and Y to the desired columns and assign the variable size to the desired test_size.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e72e6664808ec2a5061234d99004055/href">https://medium.com/media/5e72e6664808ec2a5061234d99004055/href</a></iframe><p>Encoding Categorical Data <br>Encode target variable if non-numerical:</p><pre><br>from pyAutoML import *<br>Y = EncodeCategorical(Y)<br>```<br>## Running py-automl</pre><p>Running Py-automl — ml function</p><p>signature is as follows : ML(X, Y, size=0.25, *args);</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d896211f9e680646316d6d28fe59ac5/href">https://medium.com/media/8d896211f9e680646316d6d28fe59ac5/href</a></iframe><p><strong>output:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c903f704de052ad77009d4c73a0345fb/href">https://medium.com/media/c903f704de052ad77009d4c73a0345fb/href</a></iframe><blockquote>you can also write as follows<br>ML(X,Y)</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe5923bcf7bf55dcbfcfab7f2b2d8bef/href">https://medium.com/media/fe5923bcf7bf55dcbfcfab7f2b2d8bef/href</a></iframe><h3><strong>Defining popular neural networks:</strong></h3><p><strong><em>implementing alexNet may looks like this</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9365f96a74afe23cc834b3a4dbbe9b97/href">https://medium.com/media/9365f96a74afe23cc834b3a4dbbe9b97/href</a></iframe><p>But we implement this in a single line of code like below using this package.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df396ebeacc49d888ba6167b816e436b/href">https://medium.com/media/df396ebeacc49d888ba6167b816e436b/href</a></iframe><p>For more generalization , let’s observe following code.</p><p>let’s define every available model architecture using this package</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1911a6390c11178b4ee7df7eb6149ad/href">https://medium.com/media/f1911a6390c11178b4ee7df7eb6149ad/href</a></iframe><h3>Visualization</h3><p>we can visualize neural networks architecture in different forms with ease.<br>Let’s observe the following code for better understanding</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7338098009611ceac8c2d0818824989d/href">https://medium.com/media/7338098009611ceac8c2d0818824989d/href</a></iframe><p>By default , it returns keras visualization object<br><strong>output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*wacvwGHINudmaj0RMr3Krw.png" /></figure><p>Now , visualize in graphical way using graphviz backend</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5543ff1d72e8bdc891fc3e9544f72cba/href">https://medium.com/media/5543ff1d72e8bdc891fc3e9544f72cba/href</a></iframe><p><strong>output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*DxBVxikxS704RohUO8O-YQ.jpeg" /></figure><p>This library is so developer friendly that even we declare type with starting letters.</p><pre><br>from pyAutoML.model import *<br>model2 = model(arch=”alexNet”)</pre><blockquote>nn_visualize(model2,type=”k”)</blockquote><p><strong>output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*Gch1nkH-qR99gjBssPrCbQ.png" /></figure><p>This is a minimal documentation about the package.</p><p>For more information and understanding, see examples</p><p>[HERE]</p><p><a href="https://github.com/PrudhviGNV/py-automl/edit/master/examples">PrudhviGNV/py-automl</a></p><p>and source code:</p><p><a href="https://github.com/PrudhviGNV/py-automl">GITHUB</a></p><h3><strong>Author: Prudhvi GNV</strong></h3><p><a href="https://prudhvignv.githib.io/">https://prudhvignv.githib.io</a></p><h3>Contact:</h3><p>Hope, we understand everything in this story…</p><p>You can contact me through ……</p><p><a href="https://linkedin.com/in/prudhvignv/">LinkedIn</a></p><p><a href="https://github.com/PrudhviGNV">Github</a></p><p><a href="https://instagram.com/prudhvi-gnv">Instagram</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f78bb990b5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[As human beings speech is amongst the most natural way to express ourselves.As]]></title>
            <link>https://medium.com/@prudhvi.gnv/as-human-beings-speech-is-amongst-the-most-natural-way-to-express-ourselves-as-8fc38ebe1c44?source=rss-526fdf4315b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fc38ebe1c44</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[keras]]></category>
            <category><![CDATA[speech-recognition]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Prudhvi Gnv]]></dc:creator>
            <pubDate>Wed, 19 Aug 2020 09:25:37 GMT</pubDate>
            <atom:updated>2020-08-19T09:28:10.497Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Guide for Speech Emotion Recognition using Deep learning.</strong></h3><p>As human beings speech is amongst the most natural way to express ourselves.As emotions play a vital role in communication, the detection and analysis of the same is of vital importance in today’s digital world of remote communication. Emotion detection is a challenging task, because emotions are subjective. There is no common consensus on how to measure or categorize them.</p><p>There are three classes of features in a speech namely, the lexical features (the vocabulary used), the visual features (the expressions the speaker makes) and the acoustic features (sound properties like pitch, tone, jitter, etc.).</p><h3>Data Sources — Ravdass:</h3><p>2452 audio files, with 12 male speakers and 12 Female speakers, the lexical features (vocabulary) of the utterances are kept constant by speaking only 2 statements of equal lengths in 8 different emotions by all speakers.</p><p>This dataset was chosen because it consists of speech and song files classified by 247 untrained Americans to eight different emotions at two intensity levels: Calm, Happy, Sad, Angry, Fearful, Disgust, and Surprise, along with a baseline of Neutral for each actor.</p><p><strong>Tools:</strong></p><p>The Python library libROSA provided the main tools for processing and extracting features from the audio files utilized in this project.</p><p>The foundation of modeling began with feature selection. After extracting MFCCs, Chroma, and Mel spectrograms from the audio files we began training machine learning algorithms</p><h3><strong>Data preprocessing — Extracting features</strong></h3><p><strong>Extract feature from audio file</strong></p><p>Features supported:</p><p>- MFCC (mfcc)</p><p>- Chroma (chroma)</p><p>- MEL Spectrogram Frequency (mel)</p><p>- Contrast (contrast)</p><p>- Tonnetz (tonnetz)</p><p>Before going into pre-processing and data exploration we will explain some of the concepts that allowed us to select our features.</p><ul><li><strong>Mel scale</strong> — deals with human perception of frequency, it is a scale of pitches judged by listeners to be equal distance from each other</li><li><strong>Pitch </strong>— how high or low a sound is. It depends on frequency, higher pitch is high frequency</li><li><strong>Frequency </strong>— speed of vibration of sound, measures wave cycles per second</li><li><strong>Chroma </strong>— Representation for audio where spectrum is projected onto 12 bins representing the 12 distinct semitones (or chroma). Computed by summing the log frequency magnitude spectrum across octaves.</li></ul><p><strong>MFCC </strong>— Mel Frequency Cepstral Coefficients:</p><ul><li>Voice is dependent on the shape of vocal tract including tongue, teeth, etc.</li><li>Representation of short-time power spectrum of sound, essentially a representation of the vocal tract</li></ul><p>Below is the code snippet to extract features from each file.</p><p>Here we use soundfile → used to read and write audio files</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c4ff7ee9f44a5348f20d555e22629ef/href">https://medium.com/media/5c4ff7ee9f44a5348f20d555e22629ef/href</a></iframe><p>below load_data() is used to traverse every file in a directory and we extract features from them and we prepare input and output data for mapping and feed to machine learning algorithms.</p><p>and finally, we split the dataset into 80% training and 20% testing.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e61d9837a35a615780d1634e63ad3f5/href">https://medium.com/media/0e61d9837a35a615780d1634e63ad3f5/href</a></iframe><h3><strong>Training and Analysis:</strong></h3><p><strong>Traditional Machine Learning Models:</strong></p><ul><li>Simple models:</li><li>Performs different traditional algorithms such as -Decision Tree, SVM, Random forest .</li><li>Finds that these algorithms don’t give satisfactory results. So Deep Learning comes into action.</li></ul><p><strong>Deep Learning:</strong></p><ul><li>Deep learning algorithms like mlp tends to overfit to the data. So the preferred neural network is CNN which is a game changer in many fields and applications.</li><li>Wants to perform some analysis to find the best CNN architecture for available dataset.</li><li>Here CNN with different architectures is trained against the dataset and the accuracy is recorded.</li><li>Here every architecture has same configuration and is trained to 500 epochs.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbd87b0d7886004d69f51841a95456e1/href">https://medium.com/media/dbd87b0d7886004d69f51841a95456e1/href</a></iframe><p>Let&#39;s compare the results.</p><p><strong>Architecture -I</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5296a11aaedb59d90fe46e8b72691b2f/href">https://medium.com/media/5296a11aaedb59d90fe46e8b72691b2f/href</a></iframe><p>Accuracy is 82.9%</p><p>Below is the other metrics</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*qt1ByEslMDqy_Ih-C1yPUA.png" /></figure><p><strong>Architecture-II</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ff4ad96b993ebf7ff1024c2bc7701c8/href">https://medium.com/media/1ff4ad96b993ebf7ff1024c2bc7701c8/href</a></iframe><p>Accuracy is 75.68%</p><p>Below is the other metrics</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*PMjb_I0I4N1fgCrztsXBxg.png" /></figure><p><strong>Architecture-III</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42bc02fc45df5382084ffc39aaad3ca7/href">https://medium.com/media/42bc02fc45df5382084ffc39aaad3ca7/href</a></iframe><p>Accuracy is 80.24%</p><p>Below is the other metrics</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*BuRYzJ2NeedDFnHPGor5JA.png" /></figure><p><strong>Architecture -IV:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4514072f577e91dfe730376635b48565/href">https://medium.com/media/4514072f577e91dfe730376635b48565/href</a></iframe><p>Accuracy: 81.9%</p><p>Here is the other metrics</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*PZxkZCkuuOru0fngKIQRZQ.png" /></figure><p><strong>Conclusion:</strong></p><p>Deep learning models mainly CNN architecture always overperforms traditional machine learning algorithms.</p><p>|The total source code available here. You can get code in both .py and notebook formats here.</p><p><a href="https://github.com/PrudhviGNV/SpeechEmotionRecognization">PrudhviGNV/SpeechEmotionRecognization</a></p><p>This is the overall explanation of this project . Hope you all love this. If you have any queries feel free to comment below.</p><p>For more projects, please visit,</p><p><a href="http://prudhvignv.github.io/"><strong><em>prudhvignv.github.io</em></strong></a></p><p><strong>Thank you!!..</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fc38ebe1c44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Path finding visualizer using React — from creating to building and deploying]]></title>
            <link>https://medium.com/@prudhvi.gnv/path-finding-visualizer-using-react-from-creating-to-building-and-deploying-bd1e2bc64696?source=rss-526fdf4315b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd1e2bc64696</guid>
            <category><![CDATA[pathfinder]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Prudhvi Gnv]]></dc:creator>
            <pubDate>Wed, 19 Aug 2020 06:46:28 GMT</pubDate>
            <atom:updated>2020-08-19T06:46:28.965Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://gist.github.com/PrudhviGNV/6377fee5c4d174d1603837d4075d845d"><strong>Path finding visualizer</strong></a><strong> using React — from creating to building and deploying</strong></p><p>I’ve done a fun project on visualizing path finding algorithms i.e BFS, DFS, Dikstra’s , A* algorithm.</p><p>I built this app in react and below is the interface</p><p>Green box is the starting node and Red box is the end node.</p><p>You can see the various algorithms below to visualize.</p><p>Here we design a grid using tables and set first node and second node colors using CSS properties.</p><p>Then we write algorithms to find the path between two nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*8sWL5BLI_ZtnGTk03b_0PA.png" /></figure><h3><a href="https://hurna.io/academy/algorithms/maze_pathfinder/bfs.html">Breadth First Search</a></h3><blockquote><em>Breadth First Search explores equally in all directions.</em></blockquote><blockquote><em>This is an incredibly useful algorithm, not only for regular traversal, but also for procedural map generation, flow field pathfinding, distance maps, and other types of map analysis.</em></blockquote><blockquote><em>This may be the algorithm of choice to identify nearby places of interest in GPS.</em></blockquote><blockquote><em>BFS guarantees the shortest path.</em></blockquote><p>Below is the demo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*7BE47OjxjpoOE-vVRWD8Rw.png" /></figure><h3><a href="https://hurna.io/academy/algorithms/maze_pathfinder/dfs.html">Depth First Search</a></h3><blockquote><em>Traverses by exploring as far as possible down each path before backtracking.</em></blockquote><blockquote><em>As useful as the BFS: DFS can be used to generate a topological ordering, to </em><a href="https://hurna.io/academy/algorithms/maze_generator/dfs.html"><em>generate mazes</em></a><em>, to traverse trees, to build decision trees, to discover a solution path with hierarchical choices…</em></blockquote><blockquote><em>DFS does not guarantee the shortest path.</em></blockquote><p>Below is the demo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*aEf-4sAcZ6vqSfUB4FEEoA.png" /></figure><h3><a href="https://hurna.io/academy/algorithms/maze_pathfinder/dijkstra.html">Dijkstra</a></h3><blockquote><em>Dijkstra’s Algorithm lets us prioritize which paths to explore. Instead of exploring all possible paths equally, it favors lower cost paths.</em></blockquote><blockquote><em>We can assign lower cost to encourage moving on roads while assigning high cost on highway to avoid them.</em></blockquote><blockquote><em>It is the algorithm of choice for finding the shortest path paths with multiple destinations.</em></blockquote><p>Below is the demo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*TouVtXUG3wLdBRqkM-6iVA.png" /></figure><h3><a href="https://hurna.io/academy/algorithms/maze_pathfinder/a_star.html">A* (A-Star)</a></h3><blockquote><em>A* is a modification of Dijkstra’s Algorithm that is optimized for a single destination.</em></blockquote><blockquote><em>Dijkstra’s Algorithm can find paths to all locations; A* finds paths to one location. It prioritizes paths that seem to be leading closer to a goal.</em></blockquote><blockquote><em>In a game, we could set costs to be attracted or discouraged in going near some objects : how useful it is for an AI.</em></blockquote><blockquote><em>It is more or less the </em><strong><em>golden ticket</em></strong><em> or </em><strong><em>industry standard</em></strong><em> algorithm for all applications finding directions between two locations.</em></blockquote><p>Below is the demo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*MCEvL3nwaz_zASOc_B-P0A.png" /></figure><p><strong>The main thing in the project is to let</strong>:</p><p>Users able to establish a relation between a property and a table simply by clicking on a row and dragging it over the target table. Tables are rendered in HTML inside of a div. An SVG HTML element is placed behind the tables div. This is where we’ll draw the relations. When table positions change, our lines need to be redrawn.</p><h3><strong>Get Started …</strong></h3><p><strong>First install node.js </strong>which comes with a bundle(npm+npx) to run javascript in local system.</p><p>type following commands in the shell to create a react app</p><pre>npx create-react-app my-app</pre><pre>cd my-app</pre><pre>npm start</pre><p>Basically, react app structure looks like below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*L406fTdyw83gXLfxu25l-A.png" /></figure><h3>npm start</h3><p>Runs the app in the development mode.<br>Open <a href="http://localhost:3000/">http://localhost:3000</a> to view it in the browser.</p><p>The page will reload if you make edits.<br>You will also see any lint errors in the console.</p><p>Below is the App.js component which is the root component for the react applications.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dccf413dc1aa414979a08a9b8868d18e/href">https://medium.com/media/dccf413dc1aa414979a08a9b8868d18e/href</a></iframe><p>I write everything related to the project in the pathfindingVisualizer component.</p><p><strong>pathfindingVisualizer:</strong></p><p>Here we jammed everything we need into this component such as GUI logic, animations logic , node objects structure and its properties, Some boolean values (isRunning, isStartNode, isFinishNode, isWallNode ), css properties , walls logic, implementing algorithms, mousehandlers</p><p>Then the pathfinding algorithms are written in another folder and is imported into pathfindingVisualizer component.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f54f234016b13fc84ed8338ecc26acc/href">https://medium.com/media/9f54f234016b13fc84ed8338ecc26acc/href</a></iframe><p>This pathVisualizer component mainly handle with 3 mouse events:</p><pre>this.handleMouseDown = this.handleMouseDown.bind(this);    this.handleMouseLeave = this.handleMouseLeave.bind(this);    this.toggleIsRunning = this.toggleIsRunning.bind(this);</pre><p>Basically ,here we use predefined reusable react components to handle events such as</p><p>componentDidMount()</p><p>toggleIsRunning()</p><p>toggleView()</p><p>Created a initial grid by using a list:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be6012ca7d95c53335bd46397fda9391/href">https://medium.com/media/be6012ca7d95c53335bd46397fda9391/href</a></iframe><p>Then a created createNode function with some properties</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a565ef2d7ed688f49fba28b94d0ea9f/href">https://medium.com/media/4a565ef2d7ed688f49fba28b94d0ea9f/href</a></iframe><p>Then write a logic to clear walls using node-visited property</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6ced483df19e1ed4dfb21205a0bbd81/href">https://medium.com/media/f6ced483df19e1ed4dfb21205a0bbd81/href</a></iframe><p>logic to clear grid ..except node-start, node-finish and node-wall it clears all grid by setting isVisited=false</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c34496b22df4512a1ca607d5e7d76c9/href">https://medium.com/media/7c34496b22df4512a1ca607d5e7d76c9/href</a></iframe><p>logic to clear walls by selecting node-wall className nodes and setting its isWall = false</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7bea5b46e9fec9fa8d1e43c24bd928b1/href">https://medium.com/media/7bea5b46e9fec9fa8d1e43c24bd928b1/href</a></iframe><p>Below is the driver code to implement algorithm</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5ff51c70db27cd3f45a23c8fa0d8980/href">https://medium.com/media/a5ff51c70db27cd3f45a23c8fa0d8980/href</a></iframe><p>And we can also add animations logics and styling properties of grid,walls and nodes of the component in a css file.</p><h3>npm run build</h3><p>Builds the app for production to the build folder.<br>It correctly bundles React in production mode and optimizes the build for the best performance.</p><pre>npm run build</pre><p>The build is minified and the filenames include the hashes.<br>Your app is ready to be deployed!</p><p><strong>Deployment:</strong></p><p>we can deploy in various platforms. here I deploy this app in github pages.</p><p>since it is easy and effective.</p><p>Check out here: <a href="https://prudhvignv.github.io/pathFinderVisualizer/"><strong><em>https://prudhvignv.github.io/pathFinderVisualizer/</em></strong></a></p><p>for source code :</p><p><a href="https://github.com/PrudhviGNV/pathFinderVisualizer">PrudhviGNV/pathFinderVisualizer</a></p><p>Thank you,</p><p>Hope you like my work.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd1e2bc64696" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ultimate Guide for Facial Emotion Recognition Using A CNN.]]></title>
            <link>https://medium.com/@prudhvi.gnv/ultimate-guide-for-facial-emotion-recognition-using-a-cnn-f9239fdc63ad?source=rss-526fdf4315b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9239fdc63ad</guid>
            <category><![CDATA[keras]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[convolutional-neural-net]]></category>
            <dc:creator><![CDATA[Prudhvi Gnv]]></dc:creator>
            <pubDate>Mon, 17 Aug 2020 13:20:23 GMT</pubDate>
            <atom:updated>2020-08-17T14:21:16.584Z</atom:updated>
            <content:encoded><![CDATA[<h3>A comprehensive guide for image preprocessing and to implement CNN using Keras</h3><p><strong><em>Note: This is a long post to read to coverup everything. So don’t get frustrated :)</em></strong></p><p>Hello Folks,</p><p>As we know, emotions play a vital role in our life. We need a system that customizes its actions based on our behavior and emotions.</p><p>Major tech giant companies like Google, Microsoft, Apple are trying to make their virtual assistants like Siri, Google Assistant, Alexa appear more like humans. These companies are doing great research and development to humanize their AI functionality of their virtual assistants. The idea is to incorporate digital assistants with a psychological machine learning model that is capable of detecting human facial emotions and acts accordingly.</p><p>So It inspires me to do this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*asxy3fJja7gIURLq10W2PQ.png" /></figure><h3>Getting started…</h3><h3>Step 1: DataSet Preparation</h3><p>Download the data set from the official Kaggle website from the link below :</p><p><a href="https://www.kaggle.com/c/challenges-in-representation-learning-facial-expression-recognition-challenge/data">Challenges in Representation Learning: Facial Expression Recognition Challenge</a></p><ul><li>The data consists of 48*48 pixel grayscale images of faces.</li><li>The task is to categorize each face based on the emotion shown in the facial expression into one of seven categories (0=Angry, 1=Disgust, 2=Fear, 3=Happy, 4=Sad, 5=Surprise, 6=Neutral).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*rua4aFvhQki4vCNx_P7SQw.png" /></figure><ul><li>The data set contains two columns, “emotion” and “pixels”.</li><li>The “emotion” column contains a numeric code ranging from 0 to 6, inclusive, for the emotion that is present in the image.</li><li>The “pixels” column contains a string surrounded in quotes for each image. The contents of this string a space-separated pixel values in row-major order. test.csv contains only the “pixels” column and your task is to predict the emotion column.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*okKanNIDlOnafxO0iibEGw.png" /></figure><h3>Step 2: Data preprocessing</h3><p>Data preprocessing is one of the important steps in the machine learning pipeline.</p><p>load the pixels CSV of the file into a data frame.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c8dd654f4a24862d581b3aaa0619147/href">https://medium.com/media/3c8dd654f4a24862d581b3aaa0619147/href</a></iframe><p>Apply image preprocessing techniques such as resize, reshape, convert into greyscale, and normalization.</p><p>Use the power of vectorization by converting images into NumPy arrays and pandas data frame whenever it’s necessary.</p><p>Convert the images into NumPy arrays using OpenCV and make the output as categorical using pandas.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/72c856c1cc656d4a2872815605b09efa/href">https://medium.com/media/72c856c1cc656d4a2872815605b09efa/href</a></iframe><p>applying normalization to speedup convergence</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7fb14df334ccba524400e6f5e445782f/href">https://medium.com/media/7fb14df334ccba524400e6f5e445782f/href</a></iframe><h3>Step 3: Splitting dataset</h3><p>Split the data set into the train and validation set. So that we can check whether the model is overfitted to the training dataset or not using the validation dataset.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc6f9ff173a39d45149c52ffa0654451/href">https://medium.com/media/cc6f9ff173a39d45149c52ffa0654451/href</a></iframe><h3>Step 4: Build the model using Convolutional Neural Networks(CNN):</h3><p>A <strong>Convolutional Neural Network (ConvNet/CNN)</strong> is a Deep Learning algorithm that can take in an input image, assign importance (learnable weights and biases) to various aspects/objects in the image, and be able to differentiate one from the other. The pre-processing required in a ConvNet is much lower as compared to other classification algorithms. While in primitive methods filters are hand-engineered, with enough training, ConvNets can learn these filters/characteristics.</p><p>Right now, all you need to know that a Convolution Neural Network or CNN as it is popularly called is a collection of mainly two types of layers-</p><ol><li>The hidden layers / Feature Extraction Part</li></ol><ul><li>convolutions</li><li>pooling</li></ul><p>2. The classifier part</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*dl6UEr4JYUbQcbVm2vzvNA.png" /></figure><p>Here I am using Keras with TensorFlow as the back-end for building Neural Networks. Further generalization, We have following layers in the keras to be added are</p><ol><li>Convolution layer</li><li>Pooling layer</li><li>Batch normalization</li><li>Activation Layer</li><li>Dropout Layer</li><li>Flatten Layer</li><li>Dense layer</li></ol><p><strong>First import all dependencies</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3cc44ead60414130ea21e100e20daa1a/href">https://medium.com/media/3cc44ead60414130ea21e100e20daa1a/href</a></iframe><p>Keras is a powerful deep learning library that is a high-level API for TensorFlow and acts as a wrapper for simplifications and abstract representations of neural networks.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e13c475521e61d22727c8a4a03273827/href">https://medium.com/media/e13c475521e61d22727c8a4a03273827/href</a></iframe><p>Implementing Convolutional neural network using Keras may involve following intuitions, insights and back scenes</p><p><strong>Convolution</strong> : A matrix multiplication with filter -&gt; feature detector</p><p>It involves the following components</p><ul><li>Convolution2d : used for filtering windows of 2 dimensional input-&gt; if 1st layer = input_shape</li><li>filters | windows; 2 dim filter | sliding window</li><li>the sliding window slides over each channel and summarising the features.</li></ul><p><strong>batch normalization:</strong></p><p>It is used to stabilize perhaps accelerate the learning process by standardizing layer inputs.</p><p>It is done by applying transformation that maintains mean activation close to 0 and activation standard deviation(square root of variance — -&gt; how far) close to 1</p><p>Below are the intuitive points and insights related to batch normalization</p><ol><li>normalization =&gt; process tends to follow bell shape curve known as a normal distribution</li><li>backpropagation =&gt; updated layer by layer backward from output to the input using an estimate of error that assumes weights in the layer before the current layer is fixed.</li><li>the gradient tells how to update each parameter under the assumption that other layers do not change.</li><li>all layers change during an update → this update procedure leads to forever chasing a moving target.</li><li>batch normalization =&gt; technique to coordinate the update of multiple layers in the model =&gt; reparametrization of network</li><li>Its all about standardize the mean and variance of each unit in normal dist</li><li>it’s all about standardizing inputs to layers for each mini-batch</li></ol><p><strong>Activation(ReLu)</strong>: activation layer( non linear layer)</p><ol><li>a convention is to apply after conv layer</li><li>to introduce non-linearity to a system that has computed linear operations in Conv</li><li>The rectified linear unit is widely used than non-linear functions(sigmoid, tanh) for its fast training without accuracy.</li><li>Relu : max(0,x)</li><li>Relu also alleviates the vanishing gradient (lower layers of network trains very slowly because the gradient decreases slowly through layers.)</li><li>without these non-linear functions(activation functions), the network would be a large linear classifier that could be simplified by multiplying weight matrices(accounting for bais). It wouldn’t do anything interesting such as image classification etc..</li></ol><p><strong>Pooling: </strong>involves following types — max, avg ,global max, globalavg</p><ol><li>order : conv &gt; activation &gt; pooling</li><li>To reduce dimensions of feature map by reducing parameters to learn and amount of computations</li><li>it further summarizes the feature map instead of precisely positioned features generated by conv layer. This makes the model more robust to variations in the position of features in image</li><li>when network wants to detect higher-level features from low-level building blocks (detecting corners from edges). we don’t need to be rigid about the exact position . we need translational invariance at the feature level . so insert pooling</li><li>It overcomes the problem of sensitivity to the location of the features.</li><li>local translation invariance</li></ol><p><strong>Dropout</strong>: is a regularization technique</p><ol><li>neurons are randomly dropped while training</li><li>this effect makes the network less sensitive to the specific weights of neurons</li><li>better generalization — less overfit</li></ol><p><strong>model.summary()</strong>: gives the information about the architecture and configuration of the neural network.</p><p><strong>Data Augmentation:</strong></p><p>Neural networks are data hunger. It’s best practice to use a large dataset since it reduces overfit and more chance to generalization.</p><p>So we use data augmentation using ImageDataGenerator() in keras</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c4fec697a06994cead2462637c58d80/href">https://medium.com/media/3c4fec697a06994cead2462637c58d80/href</a></iframe><p>Here is a brief summary of ImageDataGenerator() and it’s parameters and usage.</p><p><strong>horizontal and vertical shift</strong>:</p><p>for moving all pixels of an image in one direction either vertically or horizontally</p><ol><li>width_shift_range ( horizontal shift)</li><li>height_shift_range (vertical shift)</li><li>floating num [0- 1] → % of shift</li></ol><p><strong>horizontal and vertical flips augmentation</strong>:for reversing rows or cols of pixels → True or False</p><p><strong>Random rotation</strong> → from 0–360 degrees</p><p>if rotation_range = 90 ==&gt; means random rotation to image is between 0 and 90 degrees</p><p><strong>random brightness</strong>:it randomly darkens or brightens images. if brightness_range =[0.2,1.0] → means darkens or brightens if pixel is between 0.2 and 1</p><p><strong>random zoom</strong> : either adds pixel or subtract pixels in image.</p><ol><li>[1-value, 1+value]</li><li>for example , if zoom_range = .3 → means range [0.7, 1.3] or between 70%(zoom in) and 130% (zoom out)</li></ol><blockquote>when an object is created using following arguments. an iterator can be created for an image dataset.</blockquote><ul><li>it iterates through all images in memory → use obj.flow(X,y)</li><li>to iterates images through subdirectories → use obj.flow_from_directory(X,y,..)</li><li>for training ==&gt; fit_generator()</li></ul><p>It’s time to set the configuration for our neural network :)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8b9fe0899e2d61078b219a1af18f221/href">https://medium.com/media/a8b9fe0899e2d61078b219a1af18f221/href</a></iframe><h3>Step 5: Training the model</h3><p>Now its time to train our model. Training is nothing but a learning loop. here we define hyperparameters such as the number of epochs, batch size, learning rate etc..The only way to find the best parameters is by trying.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/312c3aa931c4c1f81893a4ad91fdb59c/href">https://medium.com/media/312c3aa931c4c1f81893a4ad91fdb59c/href</a></iframe><p>we use callbacks to record model performance while the model is learning.</p><p>Here I want to explain everything in the code and also want to mention some of the insights briefly.</p><p><strong>callback</strong> is an object that can perform actions at various stages of training</p><pre>1. write tensorflowboard logs after every batch<br>2. periodically save model to disk<br>3. do early stopping <br>4. view on internal states and statistics during training<br>* used in fit() loop</pre><p><strong>CSVLogger(filename, separator=”,’) :</strong></p><ul><li><strong>is used </strong>to save epoch results to a csv file</li><li>create obj and use that obj in fit(callbacks=[csv_logger_obj])</li></ul><p><strong>EarlyStopping()</strong> :</p><ul><li>is used to stop training when a monitored metric has stopped improving</li><li>Below are the parameters used</li></ul><ol><li>monitor = “val_loss” → loss function to be monitored</li><li>min_delta → minimum change to count(threshold)</li><li>patience → no of epochs with no improvement to stop training</li></ol><p><strong>ReduceLROnPlateau()</strong></p><ul><li><strong>is used</strong> reduce learning rate when metric has stopped improving</li><li>Below are the parameters</li></ul><ol><li>monitor, patience, min_delta</li><li>factor = 0.1 ==&gt; learning rate reduced to 10% (lr*0.1)</li><li>verbose ==&gt; 0: quiet , 1: update msgs</li></ol><p><strong>ModelCheckpoint()</strong> :</p><ul><li><strong>to save</strong> keras model or model weights at some frequency</li><li>Below are the parameters used</li></ul><ol><li>filepath</li><li>monitor → val_acc or val_loss</li><li>save_best_only = True</li></ol><h3>Step 6: Evaluating the model.</h3><p>Its time to check how well the model learn the patterns from the training dataset.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/318422e3b7775707044d22f9515ae8be/href">https://medium.com/media/318422e3b7775707044d22f9515ae8be/href</a></iframe><p><strong>Let’s see how the accuracy changes with epochs:- using history object:</strong></p><p><strong>History</strong> is default callbacks that is registered when training</p><ol><li>Records training metrics for each epoch</li><li>The history object is returned from calls to the fit() function used to train the model</li><li>Metrics are stored in a dictionary in the history member of the object returned.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/870c7f74913f828d08c61f4efe5c3946/href">https://medium.com/media/870c7f74913f828d08c61f4efe5c3946/href</a></iframe><p>For demo purpose, below i use accuracy record for 20 epochs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*EmAe3VVPmpJTJPCpdPBJbQ.png" /></figure><p><strong>Visualizing model training history:</strong></p><p>Using matplotlib , let’svisualise the learning curve of the model.</p><p>Below is the code snippet, to plot loss vs number of epochs ..</p><p>to visualize how the loss decreases as the number of epochs increases.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7c8944327a644c2b459a7bd2cae8521/href">https://medium.com/media/e7c8944327a644c2b459a7bd2cae8521/href</a></iframe><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*98Wdf1sXD9t-WFsu5wHD6w.png" /></figure><p>Below is the code snippet, to plot accuracy vs number of epochs ..</p><p>To visualize how the accuracy increases as the number of epochs increases</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86d641cb5aba0866dd66443125eb31bb/href">https://medium.com/media/86d641cb5aba0866dd66443125eb31bb/href</a></iframe><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*GPfWp30jWCY7pcumpmp_aA.png" /></figure><p>To create a sense of feel, |I add emojis to the results.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3033903c2664c6b3493f72b3705bbe7f/href">https://medium.com/media/3033903c2664c6b3493f72b3705bbe7f/href</a></iframe><p>I define all relevant emoji’s to the emotions in a dictionary . You can see the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*J9bByTtKHJhl3zJ-T2znRg.png" /></figure><h3>Step 7: Testing the model</h3><p>Now its time for predictions . Lets test the model with some images.</p><p>Before testing , we need to preprocess the testing image.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ba5ad594dd6f18575db8e1b17ec963b/href">https://medium.com/media/8ba5ad594dd6f18575db8e1b17ec963b/href</a></iframe><p>I want add some things related to <strong>OpenCV</strong> here for better understanding.</p><p>With the help of OpenCV, we can easily preprocess images.</p><h4>cv2 has so many functionalities:</h4><ol><li>imread() →reading image throught its path</li><li>cvtColor() → can convert image color . Some of the parameters are: img , cv2.COLOR_BGR2GRAY</li><li>cascadeClassifier() → consists of function detectMultiScale() →it is used to detect multiple faces in an image</li><li>rectangle() → used to draw box in an image .some important parameters are →img, startpoint, endpoint, color,thickness</li><li>putText() →used to write text in an image . Parameters →img, text, coordinates, font, fontScale, color, thickness, lineType</li></ol><p><strong>Things that need to be observe in the above code for better intuition are</strong>:</p><ul><li>np.argmax(predictions) →to get the maximum confidence prediction</li><li>croping of image → use the power of slicing</li></ul><p><strong>cascade classifier </strong>→ensemble learning based on concatenation of several classifiers</p><ul><li>not multiexpert but multistage</li><li>combinatorial nature of the classification</li><li>haar cascade classifier ==&gt; highly pretrained models stored in XML files</li></ul><p>Here are some of the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*QG8yPywx8IDclL2eShdsbA.png" /><figcaption>predictions</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*saaFbCvTiNqkkcy51pbuCA.png" /><figcaption>predictions</figcaption></figure><h3>Step 8: Saving the model</h3><p>Now let us save the model. It involves both weights and architecture.</p><p>We don’t need to save the architecture but every time when we load model, we have to again define model architecture before we use it.</p><p>So I prefer to save both (model into .h5 file and architecture into json file.)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8cb20f896eb35a1c303ec9a95637162/href">https://medium.com/media/f8cb20f896eb35a1c303ec9a95637162/href</a></iframe><p>I write function to load model. so we can load the model with ease.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93f67844aedb0f69d87d8f8d1d06cdd3/href">https://medium.com/media/93f67844aedb0f69d87d8f8d1d06cdd3/href</a></iframe><p>I think I document almost everything that needs to this project</p><p>The total source code with explanation is available at</p><p><a href="https://github.com/PrudhviGNV/FacialEmotionRecognition-usingCNN">PrudhviGNV/FacialEmotionRecognition-usingCNN</a></p><p>This is the overall explanation of the project . Hope you all love this. If you have any queries feel free to comment below.</p><p>For more projects, please</p><p><a href="http://prudhvignv.github.io/"><strong><em>prudhvignv.github.io</em></strong></a></p><p><strong>Thank you!!..</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9239fdc63ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>