<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.2">Jekyll</generator><link href="https://ankit1khare.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://ankit1khare.github.io/" rel="alternate" type="text/html" /><updated>2022-12-26T20:09:43+00:00</updated><id>https://ankit1khare.github.io/feed.xml</id><title type="html">Ankit Khare</title><subtitle>Head of Content and Developer Relations at Abacus.AI</subtitle><entry><title type="html">Street Parking using Deep Learning and Computer Vision</title><link href="https://ankit1khare.github.io/Street-Parking-using-Deep-Learning-and-Computer-Vision/" rel="alternate" type="text/html" title="Street Parking using Deep Learning and Computer Vision" /><published>2019-01-29T14:20:00+00:00</published><updated>2019-01-29T14:20:00+00:00</updated><id>https://ankit1khare.github.io/Street-Parking-using-Deep-Learning-and-Computer-Vision</id><content type="html" xml:base="https://ankit1khare.github.io/Street-Parking-using-Deep-Learning-and-Computer-Vision/">&lt;p&gt;Pre-trained Mask-RCNN from Matterport can be easily used to detect cars in a parking. In order to utilize it I recorded a video of the parking near my apartment. Even with my hands shaking due to cold, the overall prototype successfully detect an available parking space vacancy.&lt;/p&gt;

&lt;p&gt;
    &lt;img src=&quot;https://github.com/ankit1khare/ankit1khare.github.io/blob/master/_posts/gifs/test_vid.gif?raw=true&quot; style=&quot;max-width:100%;display: block;margin-left: auto;margin-right: auto;&quot; alt=&quot;&quot; /&gt;
    &lt;center&gt;
      &lt;em&gt;Pardon me for shaking hands. It was cold outside&lt;/em&gt;
    &lt;/center&gt;
&lt;/p&gt;

&lt;p&gt;Observe the change of color in the other parking spots. It is primarily due to moving camera while recording, the car parked in the area gets out from the marked spot. Using Twilio API, we can easy generate a number and use it to send a custom message to our own cell phone whenever there’s a vacancy available to park. There’s a great medium post here which describes the process flow. The underlying assumption is that, the first frame will determine the parking spots and no car in the first frame should be a moving one.&lt;/p&gt;

&lt;p&gt;
    &lt;img src=&quot;https://github.com/ankit1khare/ankit1khare.github.io/blob/master/_posts/gifs/assumption_test1.gif?raw=true&quot; style=&quot;max-width:100%;display: block;margin-left: auto;margin-right: auto;&quot; alt=&quot;&quot; /&gt;
    &lt;center&gt;
      &lt;em&gt;Assumption: The first frame will determine the parking spots and no car in the first frame should be in motion&lt;/em&gt;
    &lt;/center&gt;
&lt;/p&gt;

&lt;p&gt;This is very inconvenient. We can’t expect to take our cell phone out and get bluffed by a moving car just because it was in the first frame. So, we need to think of something better. What about identifying the static cars by observing them for 5 seconds and assuming that they are parked in the authorized parking area only. This way, no moving cars would hamper our system.&lt;/p&gt;

&lt;p&gt;
    &lt;img src=&quot;https://github.com/ankit1khare/ankit1khare.github.io/blob/master/_posts/gifs/better_test1.gif?raw=true&quot; style=&quot;max-width:100%;display: block;margin-left: auto;margin-right: auto;&quot; alt=&quot;&quot; /&gt;
    &lt;center&gt;
      &lt;em&gt;Observe the passing by car at the beginning of the video. Our new method is working great!&lt;/em&gt;
    &lt;/center&gt;
&lt;/p&gt;

&lt;p&gt;The approach is pretty simple. I just took two frames and compared them for a possible motion using frame subtraction. Next I eroded the area occupied by the moving vehicle so that MASK-RCNN would not capture it.&lt;/p&gt;
&lt;p&gt;
    &lt;img src=&quot;https://github.com/ankit1khare/ankit1khare.github.io/blob/master/_posts/gifs/1_x6wTWuWlwlnic30Mj61S0g.png?raw=true&quot; style=&quot;max-width:100%;display: block;margin-left: auto;margin-right: auto;&quot; alt=&quot;&quot; /&gt;
    &lt;center&gt;
      &lt;em&gt;This frame makes the operations performed in the above code very intuitive I guess&lt;/em&gt;
    &lt;/center&gt;
&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;video_capture&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;isOpened&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;frame&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;video_capture&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;couldn't read video&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
          &lt;span class=&quot;c1&quot;&gt;#create another video reader object to compare the two frames   and verify the possibility of motion
&lt;/span&gt;          &lt;span class=&quot;n&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;frame2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;video_capture&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
          &lt;span class=&quot;n&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;absdiff&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;frame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;frame2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  
          &lt;span class=&quot;n&quot;&gt;grey&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cvtColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;COLOR_BGR2GRAY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
          &lt;span class=&quot;n&quot;&gt;blur&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GaussianBlur&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;grey&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
          &lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;th&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;threshold&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blur&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;THRESH_BINARY&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

          &lt;span class=&quot;c1&quot;&gt;#perform these morphological transformations to erode the car which is moving so that it is not detected by MASKRCNN. Take the erosion levels to be high. 
&lt;/span&gt;          &lt;span class=&quot;n&quot;&gt;dilated&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dilate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;th&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ones&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uint8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;iterations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
          &lt;span class=&quot;n&quot;&gt;eroded&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;erode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dilated&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ones&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uint8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;iterations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

          &lt;span class=&quot;c1&quot;&gt;#fill the contours for even a better morphing of the vehicle
&lt;/span&gt;          &lt;span class=&quot;n&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;h&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;findContours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eroded&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RETR_TREE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CHAIN_APPROX_SIMPLE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
          &lt;span class=&quot;n&quot;&gt;frame2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;drawContours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;frame2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FILLED&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For full code, check park_clever.ipynb by visiting the Git repo hereThis frame makes the operations performed in the above code very intuitive I guess&lt;/p&gt;

&lt;p&gt;Let’s check how well our system performs in night, just for the fun :)&lt;/p&gt;

&lt;p&gt;
    &lt;img src=&quot;https://github.com/ankit1khare/ankit1khare.github.io/blob/master/_posts/gifs/night_blur_test.gif?raw=true&quot; style=&quot;max-width:100%;display: block;margin-left: auto;margin-right: auto;&quot; alt=&quot;&quot; /&gt;
    &lt;center&gt;
      &lt;em&gt;Credits to Mask RCNN, works pretty well even at night with a bad quality input video&lt;/em&gt;
    &lt;/center&gt;
&lt;/p&gt;

&lt;p&gt;What if we use IPhone 7 plus ? let’s see:&lt;/p&gt;
&lt;p&gt;
    &lt;img src=&quot;https://github.com/ankit1khare/ankit1khare.github.io/blob/master/_posts/gifs/night_better_test.gif?raw=true&quot; style=&quot;max-width:100%;display: block;margin-left: auto;margin-right: auto;&quot; alt=&quot;&quot; /&gt;
    &lt;center&gt;
    &lt;em&gt;Far better! It's funny how the leftmost car gets identified by MASK-RCNN with full confidence as soon as the headlights of the 'Camry' focus on it&lt;/em&gt;
    &lt;/center&gt;
&lt;/p&gt;

&lt;p&gt;Easy, right! Now all I have for you guys is to check my other Yolo repository to see how we can speed up the process using batch-processing. Essentially, I am asking you to read multiple frames, keep them in buffer and then send them for processing to GPU at once to maximize GPU utilization. This way you might be able to take advantage of colab’s 12 GB of free K80.
Have fun and do let me know if you come up with any further cool ideas! You can find the code on my Git. The code is runnable on Google Colab.&lt;/p&gt;</content><author><name></name></author><summary type="html">Detects vacant and occupied parking space on a street and sends a text whenever a space is available to park</summary></entry><entry><title type="html">Intro to CNN</title><link href="https://ankit1khare.github.io/Introduction-to-Convolution-Neural-Networks/" rel="alternate" type="text/html" title="Intro to CNN" /><published>2018-04-11T11:20:00+00:00</published><updated>2018-04-11T11:20:00+00:00</updated><id>https://ankit1khare.github.io/Introduction-to-Convolution-Neural-Networks</id><content type="html" xml:base="https://ankit1khare.github.io/Introduction-to-Convolution-Neural-Networks/">&lt;p&gt;&lt;img src=&quot;/assets/Cover.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Convolutional Neural Networks, the three words together sounds like a weird combination of biology and math with a little flavor of computer science sprinkled in, but these networks have been some of the most influential inventions in the field of Computer Vision. The year 2012 was the first year that neural nets grew to prominence. Alex Krizhevsky used them to win that year’s ImageNet competition (the annual Olympics of computer vision in simple terms), dropping the classification error record from 26% to 15%, an astounding improvement at the time. Ever since, a plethora of companies have been using deep learning at the core of their services. The classic, and arguably most popular, use case of these networks is for image processing. Within image processing, let’s take a look at how to use these CNNs for image classification.&lt;/p&gt;

&lt;h2 id=&quot;the-problem-space&quot;&gt;&lt;strong&gt;The Problem Space&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Image classification is the task of taking an input image and outputting a class (cat, dog, etc.) or a probability of classes that best describe the image. For humans, this task of recognition is one of the first skills that we acquire from the moment we are born and is something that comes as adults naturally and without effort. Without even thinking twice, we’re able to identify the environment we’re in, quickly and seamlessly. When we see an image or just look at the world around us, most of the time we can immediately characterize the scene and give each object a label, all without even noticing it consciously. These skills of being able to recognize patterns quickly, generalize from previous knowledge, and adapt to various image environments are those we do not share with our fellow machines.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/Corgi3.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;inputs-and-outputs-to-the-network&quot;&gt;&lt;strong&gt;Inputs and Outputs to the network&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;When a computer views an image (takes an image as input), an array of pixel values will appear. Depending on the image resolution and size, an array of numbers 32 x 32 x 3 (the 3 refers to RGB values) will appear. Just to drive the point home, let’s say we have a JPG-form color image and its size is 480 x 480. The representational array is set to be 480 x 480 x 3. Each of these numbers is given a value from 0 to 255 that describes the intensity of the pixels at that point. These numbers are the only inputs available to the computer, though they are meaningless to us when we perform image classification. The idea is to give this array of numbers to the computer and output numbers will describe the likelihood of the image being a certain class (.70 for cat,.25 for dog,.05 for bird, etc.).&lt;/p&gt;

&lt;h2 id=&quot;what-we-want-our-computer-to-do&quot;&gt;&lt;strong&gt;What We Want our Computer to Do&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Now that we know the issue and the inputs and outputs, let’s think about how to approach it. What we want the computer to do is to be able to distinguish between all the images it is given and to figure out the unique characteristics that make a dog,  a dog or cat, a cat. That is the process that also goes on subconsciously in our minds. Looking at a dog’s picture we can classify it as such if the picture has identifiable features like paws or 4 legs. Similarly, by searching for low-level features such as edges and curves, the computer is able to perform image classification, and then build up to more abstract concepts through a series of convolutional layers. This was a general overview of what CNN does. Now, let’s get into the specifics.&lt;/p&gt;

&lt;h2 id=&quot;biological-connection&quot;&gt;&lt;strong&gt;Biological Connection&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;But first, let’s take some history lessons. It’s not going to be boring at all, I promise. You may have been thinking about something related to neuroscience or biology when you first heard of the term Convolutional Neural Networks, and guess what? You would be right. CNNs borrow their structural construct from the visual cortex which we would call as an inspiration coming from biology. The visual cortex has tiny regions of cells that are sensitive to specific visual field regions. A fascinating experiment by Hubel and Wiesel in 1962 (Video) expanded this idea, where they showed that some individual neuronal cells in the brain responded (or fired) only in the presence of edges of a certain orientation. Hubel and Wiesel found that all of these neurons were arranged in a columnar architecture and were able to generate visual perception together. This concept of specialized components inside a system with different tasks (neuronal cells in the visual cortex looking for similar characteristics) is often used by machines and is the basis behind CNNs.&lt;/p&gt;

&lt;h2 id=&quot;structure&quot;&gt;&lt;strong&gt;Structure&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Back to the particulars. A more detailed overview of what CNNs are doing would be taking the image, passing it through a series of convs, nonlinear, pooling (downsampling), and fully connected layers, and getting an output. As we said earlier, the output can be either a single class, or a class probability that best describes the image. The hard part now is the understanding of what each of these layers is doing. So let’s start with the most significant one.&lt;/p&gt;

&lt;h2 id=&quot;first-layer--math-part&quot;&gt;&lt;strong&gt;First Layer – Math Part&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;In a CNN the first layer is always a Convolutional layer. First thing to make sure is that you remember what the layer of input to this conv (I will use that abbreviation a lot) is. As we already mentioned, the input is a pixel value array of 32 x 32 x 3. Now, the best way to explain a conv layer is to imagine a flashlight that shines above the image at the top left. Let’s say the light which this flashlight shines covers an area of 5 x 5. And now, let’s imagine this sliding flashlight across all areas of the input image. In terms of machine learning, this flashlight is called a filter (or sometimes referred to as a neuron or kernel), and the region it shines over, is called the receptive field. Now this filter is an array of numbers as well (these numbers are called weights or parameters). A very important note is that the depth of this filter must be the same as the depth of the input (this ensures the math works out), so this filter’s dimensions are 5 x 5 x 3. Now let’s take, for example, the first position the filter is in. That would be the left corner at the top. Since the filter slides over the input image, the values in the filter are multiplied by the original pixel values of the image (aka computing element wise multiplications). These multiplications are all summed up (in mathematical terms, that would be a total of 75 multiplications). So, you got a single number now. Remember, that number only represents when the filter is at the top left of the image. Now, for every location on the volume of input we repeat this process. (The next step would be to move the filter in 1 unit to the right, then in 1 again to the right and so on). Every single location produces a number on the input volume. After sliding the filter across all the locations, you’ll find out that what you’re left with is, an array of 28 x 28 x 1 that we call an activation map or feature map. The reason you get a 28 x 28 array is that a 5 x 5 filter can fit on a 32 x 32 input image with 784 different locations. Those 784 numbers are mapped to an array of 28 x 28.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/ActivationMap.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;(Quick Note: Some of the images, including the one above I used, came from this awesome book, Michael Nielsen’s “Neural Networks and Deep Learning.” Strongly recommended by the way.) Let’s say now that we’re using two 5 x 5 x 3 filters instead of one. Our volume of output would then be 28 x 28 x 2. We are able to preserve the spatial dimensions better by using more filters. This is mathematically what happens in a convolutional layer.&lt;/p&gt;

&lt;h2 id=&quot;first-layer--high-level-perspective&quot;&gt;&lt;strong&gt;First Layer – High Level Perspective&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Let’s talk about what this convolution actually does on a high level. One can think of each of these filters as feature identifiers. I’m talking about things like straight edges, simple colours, and curves when I say features. Think about the simplest features all the images have in common. Let’s say that our first filter is 7 x 7 x 3, and will be a detector of curves. (In this section, let’s overlook the fact that the filter is 3 units deep and only consider the filter’s top depth slice and the image, for simplicity.) The filter will have a pixel structure as a curve detector in which there will be higher numerical values along the area that is a curve shape.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/Filter.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now let’s get back to mathematically visualizing this. When we have this filter at the top left corner of the input volume, multiplications are computed between the values of the filter and the pixel in that region. Now let’s take an example of an image we’d like to classify, and put our filter in the top left corner.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/OriginalAndFilter.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Remember, what we need to do is multiply the values in the filter by the image’s original pixel values.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/FirstPixelMulitiplication.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Basically, if there is a shape in the input image that generally resembles the curve this filter represents, then all of the multiplications summed up together will result in a large value! Now let’s see what happens with our filter when it moves.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/SecondMultiplication.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The value is a lot smaller! This is because the image section contained nothing that responded to the curve detector filter. Remember, an activation map is the output of this conv layer. So, in the simple case of a one-filter convolution (and if that filter is a curve detector), the activation map shows the areas where curves in the picture are most likely to occur. In this example the top left of our activation map 26 x 26 x 1 (26 due to the 7x7 filter instead of 5x5) will be 6600. This high value means that there is probably some kind of curve in the volume of the input which caused the filter to activate. In our activation map, the top right value will be 0 because there was nothing in the input volume that caused the filter to activate (or, more simply, there was no curve in that area of the original image). Remember, this is for one filter only. This is just a filter that will detect lines curving outwards and to the right. For lines curving to the left or for straight edges we may have other filters. The more filters, the greater the activation map depth and the more information we have about the volume of inputs.&lt;/p&gt;

&lt;p&gt;Disclaimer: The filter I described in this section was simplistic to describe the math that is going on during a convolution. In the image below, you will see some examples of actual visualizations of the filters of a trained network’s first conv layer. The main argument remains the same, nonetheless. The filters on the first layer converge around the input image and “activate” (or calculate high values) when input volume is the specific feature it is looking for.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/FirstLayers.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;(Quick Note: The above image was taken from Stanford’s CS 231N course taught by Andrej Karpathy and Justin Johnson. Recommend to anyone seeking a deeper understanding of CNNs.)&lt;/p&gt;

&lt;h2 id=&quot;going-deeper-through-the-network&quot;&gt;&lt;strong&gt;Going Deeper Through the Network&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Now, there are other layers in a traditional convolutionary neural network architecture that are interspersed between these layers. I would strongly encourage those interested to read about them and understand their function and effects, but in general, they do provide nonlinearities and dimensional preservation that help improve network robustness and control overfitting. So would look like a classic CNN architecture.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/Table.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;However, the last layer is an important one which we will go into later. Just take a step back and review what we have learned up to now. We have talked about what the filters are designed to detect in the first conv layer. They detect features of low levels, such as edges and curves. As one would imagine, we need the network to be able to recognize higher-level features such as hands or paws or ears to predict whether an image is a type of object. So let’s ponder what the network output is after the first conv layer. It would be a volume of 28 x 28 x 3 (assuming we will use three 5 x 5 x 3 filters). The output of the first conver layer becomes the input of the 2nd conv layer when we go through another conv layer. Now, that’s a bit more difficult to visualize. When we spoke of the first layer, the input was simply the original image.When we talk about the 2nd conv layer, though, the input is the activation map(s) that result from the first layer. Thus each input layer basically describes the locations in the original image for which certain features of the low level appear. Now, if you apply a set of filters on top of that (pass it through the 2nd conv layer), the output will be activations representing features of higher levels. Types of these features might be semicircles (combining a curve and a straight edge) or squares (combining several straight edges). As you pass through the network and more conv layers, you get activation maps that represent increasingly complex features. You may have some filters at the end of the network that activate when handwriting occurs in the image, filters that activate when viewing pink objects etc. If you want more information about filter visualization in ConvNets, Matt Zeiler and Rob Fergus had an excellent research paper on the topic. Jason Yosinski also has a YouTube video which gives a great visual representation.Another interesting thing to note is that as you go deeper into the network, the filters start to have a larger and larger receptive field which means they can consider information from a larger area of the original input volume (another way to put it is that they are more responsive to a larger area of pixel space).&lt;/p&gt;

&lt;h2 id=&quot;fully-connected-layer&quot;&gt;&lt;strong&gt;Fully Connected Layer&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Now that we can detect these high-level features, a fully connected layer is attached to the network end by the icing on the cake. This layer basically takes an input volume (whatever the output is of the preceding conv or ReLU or pool layer) and outputs a N dimensional vector where N is the number of classes from which the program must choose. For example, if you wanted a program for digit classification, N would be 10, because there are 10 digits. Each number in this N dimension vector represents the likelihood of some class. For example, if the resulting vector for a digit classification program is [0 .1.1.75.0 0 0 0 0 0.05], then this represents a 10 percent probability of the image being a 1, a 10 percent probability of the image being a 2, a 75 percent probability of the image being a 3, and a 5 percent probability of the image being a 9 (Side note: there are other ways you can represent the output, but I’m a 3) The way this fully connected layer works is by looking at the output of the previous layer (which, as we remember, should represent the high-level activation maps) and determining which features are most correlated to a particular class.For example, if the program predicts that some image is a dog, the activation maps will have high values that represent high-level features like a paw or 4 legs etc. Similarly, if the program predicts that some image is a bird, the activation maps will contain high values that represent high-level features like wings or a beak, etc. Basically, an FC layer looks at what high-level features most closely correlate with a particular class and has particular weights so you get the right probabilities for the different classes when you calculate the products between the weights and the previous layer.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/LeNet.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;training-akawhat-makes-this-stuff-work&quot;&gt;&lt;strong&gt;Training (AKA:What Makes this Stuff Work)&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Now, this is the one aspect of the neural networks that I have not yet deliberately mentioned and that is probably the most important part. You may have had lots of questions while reading. How do the filters know to look for edges and curves in the first conv layer? How does the layer that is fully connected know which activation maps to view? How do the filters know what values to have in every layer? The way the computer can adjust its filter values (or weights) is through a process called backpropagation training.&lt;/p&gt;

&lt;p&gt;Before we get into backpropagation, first we have to take a step back and talk about what a neural network needs to work with. Our minds were fresh at the moment we were all born. We didn’t know what it was that cat or dog or bird. In a similar way, the weights or filter values are randomized before the CNN starts. The filters are unfamiliar with looking for edges and curves. In the higher layers the filters don’t know how to look for paws and beaks. However, as we grew older our parents and teachers showed us various images and pictures and gave us a corresponding label. This idea of being given an image and a label is the process of training CNNs undergo. Before we get into it too, let’s just say we have a training set with thousands of pictures of dogs, cats and birds and each of the pictures has a label of what that picture is like. Return to Backprop.&lt;/p&gt;

&lt;p&gt;Thus backpropagation can be divided into 4 separate sections, forward pass, loss function, backward pass and weight update. You take a training image during the forward pass which, as we recall, is a 32 x 32 x 3 array of numbers and passes it through the entire network. In our first example of training, since all the weights or filter values have been initialized randomly, the output is likely to be something like [.1.1.1.1.1.1.1.1.1], basically an output that does not give preference to any number in particular.With its current weights, the network is unable to search for those low-level features or is therefore unable to draw any reasonable conclusion as to what the classification might be. This relates to the backpropagation part of loss function. Remember that Training data is what we are using right now. That data has an image as well as a label. For example, let’s say the first training image you input was a 3. The image label would be set to [0 0 0 1 0 0 0 0 0]. A loss function can be defined in many different ways, but MSE (mean squared error) is a common one, which is squared 1⁄2 times (actual-predicted).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/Equation.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Let’s say this value is equal to the variable L. As you can imagine, the loss for the first pair of training images will be extremely high. Now, let’s just think intuitively on this. We want to get to a point where the predicted label (ConvNet output) is the same as the training label (this means our network got its prediction right).We want to minimize the amount of loss we have to get there. Visualizing this as a simple problem of optimization in calculus, we want to find out which inputs (weights in our case) contributed most directly to the network’s loss (or error).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/Loss.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is the mathematical equivalent of a dL / dW in which W is the weights at a given layer. What we want to do now is to carry out a backward pass through the network, which determines which weights have contributed the most to the loss and find ways to adjust it so that the loss decreases. Once we calculate this derivative, we proceed to the final step, which is the weight update. This is where we take all of the filters’ weights and update them so they change the gradient in the opposite direction.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/Weight.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The learning rate is a parameter selected by the programmer. A high learning rate means that the weight updates take bigger steps and therefore, it may take less time for the model to converge on an optimal set of weights. However, an overly high learning rate could result in jumps that are too large and not accurate enough to reach the optimum point.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/HighLR.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;One training iteration is the process of forward pass, loss function, backward passage, and parameter update. For each set of training images the program will repeat this process for a fixed number of iterations (commonly called a batch).Once you finish updating the parameter on the last example of the training, hopefully the network should be trained well enough so that the layers’ weights are correctly tuned.&lt;/p&gt;

&lt;h2 id=&quot;testing&quot;&gt;&lt;strong&gt;Testing&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Finally, to see if our CNN works or not, we have a different set of images and labels (can’t double dip between training and testing!) and the images are passed through the CNN. We compare the outputs with the reality on the ground and see if our network is working!&lt;/p&gt;

&lt;h2 id=&quot;how-companies-use-cnns&quot;&gt;&lt;strong&gt;How Companies Use CNNs&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Data, figures, data. The firms that have lots of that magic 4 letter word are those that have an inherent advantage over the rest of the competition. The more training data you can give to a network, the more training iterations you can make, the more weight updates you can make, and when it goes to production, the better the network tuned. Facebook (and Instagram) can use all the pictures of the billion users it currently has, Pinterest can use information of the 50 billion pins on its website, Google can use search data and Amazon can use data from the millions of products that are purchased daily. And now you are aware of the magic behind how they use it.&lt;/p&gt;

&lt;p&gt;Disclaimer: Although this post should be a good beginning to understand CNNs, it is by no means a comprehensive overview. Things that are not discussed in this post include the nonlinear and pooling layers as well as network hyperparameters such as filter sizes, steps, and padding. Topics such as network architecture, batch standardization, fading gradients, dropout, initialization techniques, non-convex optimization, bases, loss function choices, data increase, regulation methods, computational considerations, backpropagation modifications, and more were also not discussed (still).&lt;/p&gt;</content><author><name></name></author><summary type="html">Don't worry, it's easier than it sounds</summary></entry><entry><title type="html">Collection of Material to understand BackProp</title><link href="https://ankit1khare.github.io/Backprop-Useful-links/" rel="alternate" type="text/html" title="Collection of Material to understand BackProp" /><published>2017-10-10T15:55:52+00:00</published><updated>2017-10-10T15:55:52+00:00</updated><id>https://ankit1khare.github.io/Backprop-Useful%20links</id><content type="html" xml:base="https://ankit1khare.github.io/Backprop-Useful-links/">&lt;p&gt;I went through all of the links which I’ve given below and find them to be a comprehensive guide to understanding backpropagation. Please consider going through below mentioned awesome tutorials and articles for getting a solid grip on backprop as it is the backbone of neural networks.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://cs231n.stanford.edu/handouts/linear-backprop.pdf&quot; target=&quot;_blank&quot;&gt;http://cs231n.stanford.edu/handouts/linear-backprop.pdf&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://cs231n.github.io/optimization-2/&quot; target=&quot;_blank&quot;&gt;http://cs231n.github.io/optimization-2/&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://neuralnetworksanddeeplearning.com/chap2.html&quot; target=&quot;_blank&quot;&gt;http://neuralnetworksanddeeplearning.com/chap2.html&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://github.com/dennybritz/nn-from-scratch/blob/master/nn-from-scratch.ipynb&quot; target=&quot;_blank&quot;&gt;https://github.com/dennybritz/nn-from-scratch/blob/master/nn-from-scratch.ipynb&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://www.wildml.com/2015/10/recurrent-neural-networks-tutorial-part-3-backpropagation-through-time-and-vanishing-gradients/&quot; target=&quot;_blank&quot;&gt;http://www.wildml.com/2015/10/recurrent-neural-networks-tutorial-part-3-backpropagation-through-time-and-vanishing-gradients/&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://www.analyticsvidhya.com/blog/2017/05/neural-network-from-scratch-in-python-and-r/&quot; target=&quot;_blank&quot;&gt;https://www.analyticsvidhya.com/blog/2017/05/neural-network-from-scratch-in-python-and-r/&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;</content><author><name></name></author><summary type="html">I went through all of the links which I’ve given below and find them to be a comprehensive guide to understanding backpropagation. Please consider going through below mentioned awesome tutorials and articles for getting a solid grip on backprop as it is the backbone of neural networks.</summary></entry><entry><title type="html">My notes on GitHub!</title><link href="https://ankit1khare.github.io/my-notes-on-github/" rel="alternate" type="text/html" title="My notes on GitHub!" /><published>2017-09-28T12:55:52+00:00</published><updated>2017-09-28T12:55:52+00:00</updated><id>https://ankit1khare.github.io/my-notes-on-github</id><content type="html" xml:base="https://ankit1khare.github.io/my-notes-on-github/">&lt;p&gt;&lt;strong&gt;Here are a few interesting videos which would help you get started with GitHub:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=SWYqp7iY_Tc&quot; target=&quot;_blank&quot;&gt; https://www.youtube.com/watch?v=SWYqp7iY_Tc&lt;/a&gt; - Intro&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=HVsySz-h9r4&quot; target=&quot;_blank&quot;&gt; https://www.youtube.com/watch?v=HVsySz-h9r4&lt;/a&gt; - Intro&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=xuB1Id2Wxak&quot; target=&quot;_blank&quot;&gt; https://www.youtube.com/watch?v=xuB1Id2Wxak&lt;/a&gt; - Intro + few details&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.youtube.com/playlist?list=PL-osiE80TeTuRUfjRe54Eea17-YfnOOAx&quot; target=&quot;_blank&quot;&gt; Playlist &lt;/a&gt;- Intro + a lot of details&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Let’s start with some one-liners:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Git is a version control tool&lt;/li&gt;
  &lt;li&gt;Github Inc is a organization that provides web-based hosting services for distributed version control&lt;/li&gt;
  &lt;li&gt;Github Inc. is git based and they have their own features as well&lt;/li&gt;
  &lt;li&gt;Git is open source&lt;/li&gt;
  &lt;li&gt;Git is  written in C and hence it is fast&lt;/li&gt;
  &lt;li&gt;Git is lightweight (it doesn’t use a lot of space or processing power of your computer)&lt;/li&gt;
  &lt;li&gt;Git does lossless compression of files to store them on local repository or central repository&lt;/li&gt;
  &lt;li&gt;Git is secure and it follows SHAI encryption&lt;/li&gt;
  &lt;li&gt;Git is follows a non-linear structure called Directed Acyclic Graph (DAG)
&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Setup:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;ssh-keygen&lt;/li&gt;
  &lt;li&gt;cat {path of ssh key}
&lt;br /&gt; Add the key to your github settings. After this, you will be able to push or pull from your central repo.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common commands and their use:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;git clone {url} {folder where to clone}&lt;/li&gt;
  &lt;li&gt;git init&lt;/li&gt;
  &lt;li&gt;git status&lt;/li&gt;
  &lt;li&gt;git remote add origin {git url}&lt;/li&gt;
  &lt;li&gt;git remote -v&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;git add -A&lt;/li&gt;
  &lt;li&gt;git commit -m “msg”&lt;/li&gt;
  &lt;li&gt;git commit -a -m “msg”
adds the files to the staging area and then commits them.&lt;/li&gt;
  &lt;li&gt;git checkout &amp;lt;last 8 digit of your commit hash id&amp;gt; &lt;filename to=&quot;&quot; revert=&quot;&quot;&gt;&lt;/filename&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;git log&lt;/li&gt;
  &lt;li&gt;git diff
&lt;br /&gt;check the difference between working tree (your files in the project folder) and the local repository&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;git pull origin master&lt;/li&gt;
  &lt;li&gt;git push -u origin master&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Branching commands:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;git Branch&lt;/li&gt;
  &lt;li&gt;git branch {brname}
The branch will contain everything in the master branch&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;git checkout {brname}
move to the branch specified&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;git checkout -b[ branch_name]
&lt;br /&gt;This command will create a new branch and checkout the new branch at the same time.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;git push -u origin {brname}
&lt;br /&gt;push branch to central repo. Be on the branch which you are pushing. 
&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Few other useful commands:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;git remote get-url origin&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;git remote set-url origin  &amp;lt;git@github.com:ankit1khare/Img-Cap.git&amp;gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;git reset HEAD –
A little tricky. I’ll have to explain this in another post&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;git rm –cached &lt;file_name&gt; 
&lt;br /&gt;Suppose you added a file to staging area. But now you want to remove it since it is not needed anymore but might be needed later on. Use this command to remove a file from index before commit. You have files indexed before commit but you want to remove one of them from index so that you don't commit it accidentally. Changes to the file remain intact. This doesn't apply to &quot;untracked&quot; files.&lt;/file_name&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;git merge &lt;branch_name&gt;
&lt;br /&gt;Suppose you want to merge your new branch with master. Then you must be on master branch and the branch name in above command must be your new branch. So, be on destination branch where merging is happening.&lt;/branch_name&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;git branch –merged
&lt;br /&gt; Displays all the merges occured so far.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;git rebase &lt;branch-name&gt;
&lt;br /&gt; You are on master. And you have a branch ahead of master. Now, when you rebase the branch it will copy all the new content from your branch to master and set the head of your branch to the tip of your master linearly. So, master will have everything that was extra in new branch but it would seem like you developed all this linearly.&lt;/branch-name&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;git branch -d &lt;branch_name&gt;&lt;/branch_name&gt;&lt;/li&gt;
  &lt;li&gt;git push origin –delete &lt;branch_name&gt;&lt;/branch_name&gt;&lt;/li&gt;
  &lt;li&gt;git branch -a
&lt;br /&gt; display names of all branches with their locations (remote or local)&lt;/li&gt;
&lt;/ul&gt;</content><author><name></name></author><summary type="html">Quick intro to GitHub and easy reference to frequently used commands</summary></entry><entry><title type="html">Getting started with Jekyll on Windows platform</title><link href="https://ankit1khare.github.io/Getting-started-with-Jekyll-on-Windows-platform/" rel="alternate" type="text/html" title="Getting started with Jekyll on Windows platform" /><published>2017-09-07T16:20:00+00:00</published><updated>2017-09-07T16:20:00+00:00</updated><id>https://ankit1khare.github.io/Getting-started-with-Jekyll-on-Windows-platform</id><content type="html" xml:base="https://ankit1khare.github.io/Getting-started-with-Jekyll-on-Windows-platform/">&lt;p&gt;There are many blogs and videos on how to set up Jekyll on Windows, but it can be confusing and complex, especially for those who are unfamiliar with Linux and Jekyll. This is due to version incompatibility and the fact that Jekyll is not officially supported on the Windows platform. A lot of the relevant material is also more than a year old. When using templates and themes, it can be difficult to deal with gems and bundles, especially if you are not familiar with Ruby and Rails. This post aims to help you use this powerful static website development tool and set it up on Windows without any hassle.&lt;/p&gt;

&lt;p&gt;To start, I recommend following this simple video tutorial: &lt;a href=&quot;https://www.youtube.com/watch?v=BTX_uh_v99I&quot; target=&quot;_blank&quot;&gt;https://www.youtube.com/watch?v=BTX_uh_v99I&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are also many templates available that you can use to develop a beautiful website with powerful functionality. Check them out here: &lt;a href=&quot;http://themes.jekyllrc.org/&quot; target=&quot;_blank&quot;&gt;http://themes.jekyllrc.org/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are some tips for saving time during the setup process:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Follow all the steps carefully, and remember to restart PowerShell as an administrator every time it is mentioned.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2.If the bundle is not the latest version and you try to use the already existing templates (may be from &lt;a href=&quot;http://themes.jekyllrc.org/&quot; target=&quot;_blank&quot;&gt;http://themes.jekyllrc.org/&lt;/a&gt;) you may get a “gem not found” error. In this case, force the bundle to switch to the latest version.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Here’s another useful video if you are having problems setting up templates: 
&lt;a href=&quot;https://www.youtube.com/watch?v=bty7LHm14CA&quot; target=&quot;_blank&quot;&gt;https://www.youtube.com/watch?v=bty7LHm14CA&lt;/a&gt;
The most common problems that I have noticed are related to relative path and slash ‘/’.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;It’s worth understanding the basic functionality of Jekyll and how it is used with GitHub, especially if you are a developer or even if you just want to create a basic portfolio: 
&lt;a href=&quot;https://www.youtube.com/watch?v=SWVjQsvQocA&quot; target=&quot;_blank&quot;&gt;https://www.youtube.com/watch?v=SWVjQsvQocA&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;If your localhost (which is 4000 by default with Jekyll) shows a blank page, try clearing the cache and restarting your computer before attempting to reinstall Ruby or gems.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;If you encounter an error with the ‘jekyll serve’ command due to version mismatch, try using ‘bundle exec jekyll serve’ instead.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I hope this helps!&lt;/p&gt;</content><author><name></name></author><summary type="html">There are many blogs and videos on how to set up Jekyll on Windows, but it can be confusing and complex, especially for those who are unfamiliar with Linux and Jekyll. This is due to version incompatibility and the fact that Jekyll is not officially supported on the Windows platform.</summary></entry></feed>