<?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 Samruddhi Chitnis on Medium]]></title>
        <description><![CDATA[Stories by Samruddhi Chitnis on Medium]]></description>
        <link>https://medium.com/@samruddhichitnis02?source=rss-82bbe2715c22------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*G2Sf2Ao1sqmx5X2OoLYC8w.jpeg</url>
            <title>Stories by Samruddhi Chitnis on Medium</title>
            <link>https://medium.com/@samruddhichitnis02?source=rss-82bbe2715c22------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 00:24:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@samruddhichitnis02/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[I Let Code Llama Write My Data Analysis Code. Here’s the Honest Truth]]></title>
            <link>https://samruddhichitnis02.medium.com/i-let-code-llama-write-my-data-analysis-code-heres-the-honest-truth-c576523c3ceb?source=rss-82bbe2715c22------2</link>
            <guid isPermaLink="false">https://medium.com/p/c576523c3ceb</guid>
            <dc:creator><![CDATA[Samruddhi Chitnis]]></dc:creator>
            <pubDate>Thu, 12 Feb 2026 15:46:32 GMT</pubDate>
            <atom:updated>2026-02-12T15:46:32.974Z</atom:updated>
            <content:encoded><![CDATA[<p>AI can now write Python code.</p><p>But can it write <em>good</em> Python code?</p><p>To test this, I used <strong>Code Llama</strong> to analyze an NBA player statistics dataset.</p><p>I gave it a simple instruction:</p><blockquote><em>“Write Python code to load NBA stats, clean the data, find top scorers, create visualizations, compute correlations, and export the cleaned dataset.”</em></blockquote><p>It generated around 60 lines of code in seconds.</p><p>At first glance? Impressive.</p><p>But then I ran it.</p><h3>😅 The First Errors</h3><p>Immediately, I saw:</p><ul><li>Deprecated library imports</li><li>Assumed column names like “Points” and “Assists” (which didn’t exist)</li><li>Mean calculations applied to text columns</li><li>Visualization syntax errors</li></ul><p>Classic AI confidence.</p><p>It looked correct , but it wasn’t runnable.</p><h3>🧪 Where It Actually Did Well</h3><p>To be fair, Code Llama:</p><p>✔ Structured the workflow logically<br> ✔ Chose appropriate libraries (pandas, seaborn, matplotlib)<br> ✔ Implemented grouping and sorting correctly<br> ✔ Generated correlation calculations</p><p>The <em>structure</em> was solid.</p><p>The <em>details</em> needed fixing.</p><h3>🔍 The Biggest Lesson: Specific Prompts Matter</h3><p>When I wrote:</p><blockquote><em>“Analyze NBA data.”</em></blockquote><p>The result was generic and wrong.</p><p>When I wrote:</p><blockquote><em>“Use columns ws, per, bpm, and team to analyze performance.”</em></blockquote><p>The result improved dramatically.</p><p>The more context I gave, the better it performed.</p><p>AI doesn’t struggle with logic.</p><p>It struggles with missing context.</p><h3>🛠 After Debugging</h3><p>I refined the code by:</p><ul><li>Separating numeric and categorical columns</li><li>Using modern pandas instead of deprecated sklearn tools</li><li>Fixing visualization formatting</li><li>Adding correlation heatmaps</li><li>Adding data validation checks</li></ul><p>Once cleaned up, the pipeline worked beautifully.</p><p>But it required human judgment.</p><h3>🤖 Can Code Llama Replace Analysts?</h3><p>Short answer: No.</p><p>Long answer: It can significantly speed up your work, if you know what you’re doing.</p><p>It’s like having a junior developer who works fast but needs supervision.</p><p>If you understand debugging and data structures, it’s powerful.</p><p>If you don’t, you may not even realize the code is wrong.</p><h3>💡 What This Experiment Taught Me</h3><p>AI tools are not replacements.</p><p>They are amplifiers.</p><ul><li>PandasAI amplified curiosity.</li><li>Code Llama amplified productivity.</li><li>But human reasoning amplified correctness.</li></ul><p>And that combination is where real power lies.</p><h3>Final Reflection</h3><p>These two experiments showed me something important:</p><p>The future of data science isn’t humans vs. AI.</p><p>It’s humans working with AI.</p><p>The real skill isn’t just coding anymore.</p><p>It’s knowing:</p><ul><li>What to ask</li><li>What to trust</li><li>What to verify</li><li>And how to interpret</li></ul><p>That’s where we still matter most.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c576523c3ceb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Tried Talking to My Dataset—Here’s What Happened (PandasAI + Movie Data)]]></title>
            <link>https://samruddhichitnis02.medium.com/i-tried-talking-to-my-dataset-heres-what-happened-pandasai-movie-data-22db02105f0a?source=rss-82bbe2715c22------2</link>
            <guid isPermaLink="false">https://medium.com/p/22db02105f0a</guid>
            <category><![CDATA[pandas-ai]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Samruddhi Chitnis]]></dc:creator>
            <pubDate>Thu, 12 Feb 2026 15:40:43 GMT</pubDate>
            <atom:updated>2026-02-12T15:40:43.738Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever wished you could just <em>ask</em> your dataset questions like</p><blockquote><em>“Why do some movies make billions while others flop?”<br> “Does spending more money really mean earning more?”<br> “Do longer movies get better ratings?”</em></blockquote><p>That’s exactly what I tried to do using <strong>PandasAI: </strong>a tool that lets you interact with your data in plain English.</p><p>Instead of writing 100 lines of pandas code, I had a conversation with my dataset.</p><p>And honestly? It was fascinating.</p><h3>🎬 The Dataset: 45,000+ Movies</h3><p>For this experiment, I used the <strong>Kaggle Movie Ratings and Reviews dataset</strong>, which includes:</p><ul><li>45,000+ movies</li><li>Budget and revenue data</li><li>26 million user ratings</li><li>Cast and crew details</li><li>Genres, runtime, release year</li></ul><p>Basically, a goldmine for asking interesting questions.</p><h3>🤔 My Big Questions</h3><p>I didn’t want to just compute averages. I wanted insights.</p><p>So I focused on two questions:</p><ol><li><strong>What determines movie financial success?</strong></li><li><strong>What influences audience ratings?</strong></li></ol><p>Then I let PandasAI help me explore.</p><h3>💰 Does Spending More Money Actually Make More Money?</h3><p>One of the first questions I asked was:</p><blockquote><em>“Is budget correlated with revenue?”</em></blockquote><p>The answer? <strong>Yes, strongly.</strong></p><p>There was a clear positive relationship between budget and revenue. Bigger budgets often lead to bigger box office returns.</p><p>But here’s what made it interesting:</p><ul><li>Some low-budget movies made huge profits.</li><li>Some high-budget movies performed terribly.</li></ul><p>So while money helps, it doesn’t guarantee success.</p><p>That felt like a very “real-world” answer.</p><h3>🎭 Which Genres Make the Most Money?</h3><p>When I dug into genres, something clear emerged.</p><p>Genres like</p><ul><li><strong>Adventure</strong></li><li><strong>Animation</strong></li><li><strong>Fantasy</strong></li><li><strong>Science Fiction</strong></li></ul><p>tended to generate the highest average revenue.</p><p>Not surprising! These are big-production, global-audience movies.</p><p>But seeing the data confirm what we intuitively believe was satisfying.</p><h3>⭐ What About Ratings?</h3><p>Then I shifted focus:</p><blockquote><em>“Do bigger movies get better ratings?”</em></blockquote><p>Interestingly? not really.</p><p>Most movie ratings fell between <strong>5 and 7</strong>. A nice bell-shaped curve.</p><p>And when I compared runtime vs rating?</p><p>Very weak relationship.</p><p>Longer movies don’t necessarily mean better movies.</p><p>In fact, audience ratings seemed more connected to content and storytelling than budget or runtime.</p><p>That was a powerful insight.</p><h3>📈 What Surprised Me Most</h3><p>One thing I loved about using PandasAI was how conversational it felt.</p><p>I could ask:</p><ul><li>“Show me the most profitable movies under $10M budget.”</li><li>“Compare Action vs Drama revenue.”</li><li>“Has movie production increased over time?”</li></ul><p>And it would generate answers quickly.</p><p>I discovered:</p><ul><li>Movie production increased sharply after the 1990s.</li><li>Certain genres consistently outperform others.</li><li>Financial success and audience approval don’t always align.</li></ul><h3>🚧 Where PandasAI Struggled</h3><p>It wasn’t perfect.</p><ul><li>It struggled with nested genre data.</li><li>Some visualizations didn’t generate properly.</li><li>Occasionally it gave text summaries instead of charts.</li></ul><p>So yes , you still need to understand pandas.</p><p>But as an exploratory assistant? It was incredibly helpful.</p><h3>🧠 What I Learned</h3><p>This project made something very clear:</p><p>AI doesn’t replace analysis.<br>It accelerates curiosity.</p><p>PandasAI helped me:</p><ul><li>Ask better questions</li><li>Explore faster</li><li>Focus more on interpretation than syntax</li></ul><p>And honestly? That’s powerful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22db02105f0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to do image convolution from scratch using Numpy]]></title>
            <link>https://samruddhichitnis02.medium.com/how-to-do-image-convolution-from-scratch-using-numpy-902541f08a9a?source=rss-82bbe2715c22------2</link>
            <guid isPermaLink="false">https://medium.com/p/902541f08a9a</guid>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[numpy]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Samruddhi Chitnis]]></dc:creator>
            <pubDate>Sun, 14 Apr 2024 14:32:37 GMT</pubDate>
            <atom:updated>2024-04-14T14:32:37.001Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/860/0*xJq41pCMQ_iATvDQ" /><figcaption>Photo by <a href="https://imgs.search.brave.com/okRa__6PGWbzOOof6ebNQrOi1uM0OFM4BTGQ4MJJIs8/rs:fit:860:0:0/g:ce/aHR0cHM6Ly9tZWRp/YS5saWNkbi5jb20v/ZG1zL2ltYWdlL0Q0/RDEyQVFITXo1a1Rj/Q2E3ZVEvYXJ0aWNs/ZS1jb3Zlcl9pbWFn/ZS1zaHJpbmtfNzIw/XzEyODAvMC8xNjcz/OTQwODU2NTA2P2U9/MjE0NzQ4MzY0NyZ2/PWJldGEmdD1vTWE1/blU1RE1MdFZvczB5/MHhfSHBibk5LMUta/Q09MSjQ5elNzeGF3/WGJF">https://imgs.search.brave.com/okRa__6PGWbzOOof6ebNQrOi1uM0OFM4BTGQ4MJJIs8/rs:fit:860:0:0/g:ce/aHR0cHM6Ly9tZWRp/YS5saWNkbi5jb20v/ZG1zL2ltYWdlL0Q0/RDEyQVFITXo1a1Rj/Q2E3ZVEvYXJ0aWNs/ZS1jb3Zlcl9pbWFn/ZS1zaHJpbmtfNzIw/XzEyODAvMC8xNjcz/OTQwODU2NTA2P2U9/MjE0NzQ4MzY0NyZ2/PWJldGEmdD1vTWE1/blU1RE1MdFZvczB5/MHhfSHBibk5LMUta/Q09MSjQ5elNzeGF3/WGJF</a></figcaption></figure><p>Table of Contents:</p><ol><li>What is Image Convolution?</li><li>Why do we need Convolution?</li><li>What are the different types of Convolution?</li><li>How can we implement Convolution from scratch using Numpy on 2-Dimensional Image?</li><li>References</li></ol><p><strong>What is Image Convolution?</strong></p><p>Image convolution is a fundamental operation in image processing and computer vision. It involves applying a mathematical operation to each pixel in an image, typically using a small matrix called a kernel or filter. This process is used to achieve various effects such as blurring, sharpening, edge detection and more.</p><p>How convolution works?</p><p>During convolution, two components are engaged: the image undergoing the convolution operation and the sampling matrix/kernel, which aids in extracting essential information from the image and altering the provided image.</p><p>In very simple words, convolution is just an element-wise matrix multiplication of sampling matrix/kernel and image.</p><p>Step 1 : The kernel/sampling matrix is overlaid on the image</p><p>Step 2 : The values of the kernel/sampling matrix are multiplied element-wise with the corresponding pixel values in the image that the kernel/sampling matrix.</p><p>Step 3 : The resulting products in step 2 are summed up.</p><p>Step 4 : The kernel is then moved to the next pixel in the image based on the dilation rate, and the process is repeated until all pixels in the image have been processed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*ObZoNoz9XeQOepBt.gif" /><figcaption>Photo by <a href="https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fwww.geeksforgeeks.org%2Fapply-a-2d-convolution-operation-in-pytorch%2F&amp;psig=AOvVaw3pmBdwM-dh5fBSmq2EScpn&amp;ust=1713161162651000&amp;source=images&amp;cd=vfe&amp;opi=89978449&amp;ved=0CBEQjRxqFwoTCPi5w-eEwYUDFQAAAAAdAAAAABAJ">https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fwww.geeksforgeeks.org%2Fapply-a-2d-convolution-operation-in-pytorch%2F&amp;psig=AOvVaw3pmBdwM-dh5fBSmq2EScpn&amp;ust=1713161162651000&amp;source=images&amp;cd=vfe&amp;opi=89978449&amp;ved=0CBEQjRxqFwoTCPi5w-eEwYUDFQAAAAAdAAAAABAJ</a></figcaption></figure><p><strong>Why do we need convolution?</strong></p><p>Convolution is a fundamental technique in image processing and computer vision, playing a crucial role in various tasks ranging from basic image enhancement to advanced deep learning-based image analysis.</p><p>One of the main purpose of convolution is it extracts useful features from images. By applying different kernels, we can emphasize certain patterns, edges, textures or other features present in the image. These features are essential for tasks such as object detection, recognition, classification, segmentation, etc.</p><p>Other uses of convolution are it can be used for filtering, for ex to remove noise, blur or sharpen images, etc. It can also be used for dimensionality reduction, convolution operations can reduce the dimensionality of an image while retaining important information useful for downsampling tasks. These are some of the reasons and areas where convolution plays an extremely crusial role.</p><h4>What are the different types of convolution?</h4><p>Various convolution types exist, each with its own specifications. Here, I’ll highlight a few of them.</p><ol><li><strong>Standard Convolution</strong> : These convolutions involve straightforward element-wise matrix multiplication, as demonstrated in the above explanation.</li><li><strong>Dilated Convolution</strong> : While performing convolutions we use sampling matrix/kernel along with the image array, when we add dilations or strides to the sampling matrix/kernel and use such sampling matrix/kernel for convolution then its called Dilated Convolution. Dilation rate is the spacing between each pixel in a sampling matrix/kernel. A 3x3 kernel/sampling matrix with a dilation rate of 2 will have the same view field of 5x5 kernel/sampling matrix. Dilated convolution allows to have larger receptive field with same computation memory and costs while also preserving resolution. Please refer the image below to get an idea of how a sampling matrix/kernel for Dilated Convolution looks like.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/0*sh00kOgysUUE7gWW.png" /><figcaption>Photo by <a href="https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Flink.springer.com%2Farticle%2F10.1007%2Fs10489-021-02537-6&amp;psig=AOvVaw0EwWoMVuBLvgtG3WLUmvLU&amp;ust=1713176389654000&amp;source=images&amp;cd=vfe&amp;opi=89978449&amp;ved=0CBIQjRxqFwoTCKChksa9wYUDFQAAAAAdAAAAABAJ">https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Flink.springer.com%2Farticle%2F10.1007%2Fs10489-021-02537-6&amp;psig=AOvVaw0EwWoMVuBLvgtG3WLUmvLU&amp;ust=1713176389654000&amp;source=images&amp;cd=vfe&amp;opi=89978449&amp;ved=0CBIQjRxqFwoTCKChksa9wYUDFQAAAAAdAAAAABAJ</a></figcaption></figure><p>3. <strong>Deformable Convolution </strong>: Using standard convolution, we cannot handle some of the geometric transformations which are unkown to us, to overcome this problem and to increase the capabilities of CNN deformable convolutions were introduced. The limitation of CNN to model geometric transformations arises from the fixed structure of the kernel/sampling matrix used. In deformable convolutions the size of the sampling matrix is not fixed and they are changing or they adapt different shapes according to the input provided to them. Offsets are added to the sampling matrix, and these offsets are the learning parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vcqUbhUwZEZQjPNA.png" /><figcaption>Photo by <a href="https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fleimao.github.io%2Fblog%2FDeformable-Convolution%2F&amp;psig=AOvVaw39Y70JotLVTOLtDGuYNVwt&amp;ust=1713185545072000&amp;source=images&amp;cd=vfe&amp;opi=89978449&amp;ved=0CBIQjRxqFwoTCKCX49HfwYUDFQAAAAAdAAAAABAJ">https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fleimao.github.io%2Fblog%2FDeformable-Convolution%2F&amp;psig=AOvVaw39Y70JotLVTOLtDGuYNVwt&amp;ust=1713185545072000&amp;source=images&amp;cd=vfe&amp;opi=89978449&amp;ved=0CBIQjRxqFwoTCKCX49HfwYUDFQAAAAAdAAAAABAJ</a></figcaption></figure><p>Deformable Convolution Kernels are kind off intelligent kernels, these are evry helpful when dealing with 3-dimensional data like point clouds.</p><p>4. <strong>Depthwise Separable Convolution</strong> : Depthwise separable convolution decomposes convolutions into two stages: depth-wise convolution, which applies a separate convolution to each input channel, and point-wise convolution, which merges the output channels. This technique significantly reduces computation and parameters compared to traditional convolutions, making it efficient for resource-limited devices like mobile phones, without sacrificing model performance in tasks like image classification and recognition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/0*2sq1bmqjthbFzyau.jpg" /><figcaption>photo by <a href="https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fwww.sciencedirect.com%2Fscience%2Farticle%2Fpii%2FS2214317322000026&amp;psig=AOvVaw0jfrl4xtK6Cdp6HECGRuUP&amp;ust=1713189959871000&amp;source=images&amp;cd=vfe&amp;opi=89978449&amp;ved=0CBIQjRxqFwoTCMDdkovwwYUDFQAAAAAdAAAAABAh">https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fwww.sciencedirect.com%2Fscience%2Farticle%2Fpii%2FS2214317322000026&amp;psig=AOvVaw0jfrl4xtK6Cdp6HECGRuUP&amp;ust=1713189959871000&amp;source=images&amp;cd=vfe&amp;opi=89978449&amp;ved=0CBIQjRxqFwoTCMDdkovwwYUDFQAAAAAdAAAAABAh</a></figcaption></figure><p>Depthwise Separable Convolution has a lot to cover and I will come up with a different post for depthwise separable convolution in future.</p><p>Now that we know how convolution works, what are the different types of convolutions let’s head to writing some code on convolving a 2-dimensional image from scratch using python libraries.</p><h4>Convolution from scratch using Numpy</h4><pre>import cv2<br>import numpy as np</pre><p>There are 2 steps involved in convolving an image with a filter/sampling matrix/kernel</p><p>Step 1: Calculate the target size/Output size for the convolved image</p><p>Step 2 : Convolving the image with the sampling matrix/kernel</p><pre># Step 1<br>def calculate_target_size(img, kernel, padding, stride):<br>    # There is a formula which tells what would be the output shape of the image when we give<br>    # it the original image shape, kernel size/convolution matrix size, padding and stide information<br>    # the formula is (W - K + 2P / S ) + 1<br>    # W -&gt; Image Size<br>    # K -&gt; Kernel Size or Convolution Image Size<br>    # P - &gt; Padding<br>    # S -&gt; Stride<br>    # here the image shape should be even that is a square shaped image<br><br>    # Here we will consider Stride = 1 and Padding = 0 for simplicity and kernel size = 3<br>    W = img.shape[0]<br>    Ot_shape = ((W - kernel + (2 * padding)) / stride) + 1<br>    return Ot_shape</pre><pre># Step 2<br>def convolve(img):<br>    k = 3<br><br>    # get the target size from calculate_target_size function<br>    target_size = int(calculate_target_size(img, kernel = k, padding = 0, stride = 1))<br>    print(target_size)<br><br>    # create another array which can hold the resulting convolutions<br>    convolved_img = np.zeros([target_size, target_size])<br><br>    # outline filter<br>    kernel = np.array([[-1, -1, -1],<br>                       [-1, 8, -1],<br>                       [-1, -1, -1]])<br><br>    for i in range(target_size):<br>        for j in range(target_size):<br>            mat = img[i : i + k, j : j + k]<br>            convolved_img[i, j] = np.sum(np.multiply(mat, kernel))<br>    <br>    return convolved_img</pre><pre>if __name__ == &#39;__main__&#39;:<br>    # reading a color image using cv2<br>    img = cv2.imread(&#39;dog.jpg&#39;)<br><br>    # converting the color image to gray scale image so as to pass it to convolve function<br>    gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)<br><br>    # reshaping the image to get even shape<br>    resized_image = cv2.resize(gray_img, (gray_img.shape[0], gray_img.shape[0])) <br><br>    convolved_image = convolve(resized_image)</pre><p>I have used an outline filter to convolve with an image, which will highlight the object in the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*qWpBpzvN6gDLUu9Hj2Tlug.png" /><figcaption>Original Image of a dog passed to the convolve function</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*McoMhpXJ7tAVTim1IBsXjA.png" /><figcaption>Output image after convolving the original image with the outline filter</figcaption></figure><p>Thank you to everyone who reached the end of this blog. Your feedback, comments, and support mean a lot to me. If you found this blog helpful, please consider leaving a comment, giving it a follow, or clapping. While you may not typically perform convolution from scratch, understanding the process can deepen your comprehension of how convolution operation is implemented in libraries.</p><p>I hope you found this explanation valuable! 😉</p><h4>Refernces :</h4><p><a href="https://www.youtube.com/watch?v=p6tG-dep8f4&amp;t=325s">https://www.youtube.com/watch?v=p6tG-dep8f4&amp;t=325s</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=902541f08a9a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to zero pad Images from scratch using Numpy]]></title>
            <link>https://samruddhichitnis02.medium.com/how-to-zero-pad-images-from-scratch-using-numpy-d8779abf44d5?source=rss-82bbe2715c22------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8779abf44d5</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[padding]]></category>
            <dc:creator><![CDATA[Samruddhi Chitnis]]></dc:creator>
            <pubDate>Thu, 11 Jan 2024 16:56:03 GMT</pubDate>
            <atom:updated>2024-01-11T16:56:03.980Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/949/0*sER7t5skUGdm1fw8.png" /><figcaption>Photo by <a href="https://www.baeldung.com/wp-content/uploads/sites/4/2023/02/padding.png">https://www.google.com/url?sa=i&amp;url=https%3A%2F%2Fwww.baeldung.com%2Fcs%2Fdeep-neural-networks-padding&amp;psig=AOvVaw0kzRezlJNaOuC1Iu845CsS&amp;ust=1704134910947000&amp;source=images&amp;cd=vfe&amp;opi=89978449&amp;ved=0CBIQjRxqFwoTCNCho7WruoMDFQAAAAAdAAAAABAI</a></figcaption></figure><p>Table of Contents:</p><ol><li>What is Image Padding?</li><li>Why is Image Padding needed?</li><li>How can we implement Image Padding from scratch using Numpy?</li><li>References</li></ol><h3><strong>What is Image Padding?</strong></h3><p>Image padding is a technique used in image processing and computer vision to add extra pixels around the edges of an image.In my journey of exploring Computer Vision and Image Processing I have come across two types of Image Padding —</p><p>Zero Padding : Adding zeros to the edge of the images</p><p>Constant Value Padding : Adding some constant values to the edge of the images</p><p>Obviously there might be many more types of padding, but I found zero padding as the best, because it does not add any information particularly any noise to the data plus it saves us from information loss.</p><h3><strong>Why is Image Padding needed?</strong></h3><p>Image padding is needed in image processing to prevent the loss of information at the image boundaries when applying operations like convolution. Padding ensures that the spatial dimensions of the output remain compatible with the input, enabling effective feature extraction and preserving relevant detials, especially at the edges and corners of the image.</p><h3><strong>How can we pad colorful images using numpy from scratch?</strong></h3><pre># Import required libraries<br>import cv2<br>import numpy as np<br>import matplotlib.pyplot as plt</pre><pre># Functions for Image Plotting<br>def plot_image(img : np.array):<br>    plt.figure(figsize = (6, 6))<br>    plt.imshow(img)<br>    <br>def plot_two_imgages(img1 : np.array, img2 : np.array):<br>    _, ax = plt.subplots(1, 2, figsize = (12, 6))<br>    ax[0].imshow(img1, cmap = &#39;gray&#39;)<br>    ax[1].imshow(img2, cmap = &#39;gray&#39;)</pre><pre># reading a color image using cv2<br>img = cv2.imread(&#39;dog.jpg&#39;)<br><br># converting the color image to gray scale image so as to pass it to convolve function<br># gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)<br>mat_img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)<br><br># reshaping the image to get even shape<br>resized_image = cv2.resize(mat_img, (500, 500)) <br><br>plot_image(img = resized_image)</pre><p>The unpaded image would look like the one below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*Fc6Ao7DkTPHobbD_LDgd6w.png" /><figcaption>Image before padding</figcaption></figure><pre>def get_padding_width_per_side(kernel_size : int):<br>    return kernel_size // 2</pre><pre>pad_5x5 = get_padding_width_per_side(5)<br>pad_5x5</pre><p>The above function get_padding_width_per_side will return the number of padding required for an image per side provided the kernel_size or convolution matrix size. Output of the above cell will be 2</p><pre>def add_padding_to_image(img, padding_width):<br>    img_with_padding = np.zeros([(img.shape[0] + padding_width * 2), (img.shape[0] + padding_width * 2), 3])<br>    <br>    r_pad = img_with_padding[:, :, 0]<br>    g_pad = img_with_padding[:, :, 1]<br>    b_pad = img_with_padding[:, :, 2]<br>    <br>    r_pad[padding_width : -padding_width, padding_width : -padding_width] = img[:, :, 0]<br>    g_pad[padding_width : -padding_width, padding_width : -padding_width] = img[:, :, 1]<br>    b_pad[padding_width : -padding_width, padding_width : -padding_width] = img[:, :, 2]<br>    <br>    fin_arr = np.dstack((r_pad, g_pad, b_pad))<br>    return fin_arr</pre><p>A color image contains 3 channels RGB, so we would have to pad all the 3 channels inorder to pad the entire image, the above function creates a numpy array with the shape of</p><p>width of image + padding_size(this padding size we get from get_padding_width_per_side) * 2</p><p>height of image + padding_size * 2</p><p>3 — This 3 is because we have 3 channels in colored image</p><p>Note here we multiply 2 with padding_size for height and width so that both the sides are covered</p><p>After, creating a numpy array with zeros, we extract numpy array of zeros separately in 3 variables such that</p><p>If the input image shape is 500x500x3 and the size of convolution matrix is 5x5 then r_pad, g_pad and b_pad has shape — 504x504x1 each with all zero values</p><p>The below step will</p><p>r_pad[padding_width : -padding_width, padding_width : -padding_width] = img[:, :, 0]</p><p>extract the R channel from the image and fill the r_pad with image pixels keeping 4 indexes(2 indexes on the left and 2 indexes on the right of the image width) with zeros and 4 indexes(2 indexes on the top and 2 indexes on the bottom of the image height) with zeros.</p><p>This will be done for B channel and G channel, and then dstack will be used to stack all of these channels as one, finally return the padded image.</p><pre>img_with_padding_5x5 = add_padding_to_image(resized_image, pad_5x5)<br>img_with_padding_5x5 = img_with_padding_5x5.astype(np.uint8)<br>print(img_with_padding_5x5.shape)<br><br>plot_image(img_with_padding_5x5)</pre><p>When you plot the padded image using above code, the image will have black color at the left, right, top and bottom of the image, refer the below image. Compare the “Image before padding” and “Image after padding” to have a closer look at the black color added at the boundaries of the padded image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*ORSFAAuTONTyr5Z_QyCnkA.png" /><figcaption>Image after padding</figcaption></figure><p>Thank you all who made it to the end of this blog. I would really appreciate you all if you comment out your views, follow or clap this blog if you like it. I hope I was able to explain you how to do padding, although you would almost not use this zero padding from scratch anywhere, but this might help you in understanding the process of zero padding which is done by libraries while performing convolution operation.</p><p>I hope this helps you!!! 😉</p><h3><strong>References</strong></h3><p><a href="https://www.youtube.com/watch?v=p6tG-dep8f4">https://www.youtube.com/watch?v=p6tG-dep8f4</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8779abf44d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Image Segmentation Transfer Learning Part 3]]></title>
            <link>https://samruddhichitnis02.medium.com/image-segmentation-transfer-learning-db40295abb58?source=rss-82bbe2715c22------2</link>
            <guid isPermaLink="false">https://medium.com/p/db40295abb58</guid>
            <category><![CDATA[transfer-learning]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Samruddhi Chitnis]]></dc:creator>
            <pubDate>Wed, 11 Oct 2023 18:09:43 GMT</pubDate>
            <atom:updated>2024-01-08T17:54:32.304Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*st2HNofLoYs8xA3s.jpg" /><figcaption>Photo by <a href="https://greenlogic.pl/blog/czym-jest-transfer-learning/">https://greenlogic.pl/blog/czym-jest-transfer-learning/</a></figcaption></figure><p>Table of Contents:</p><ol><li>What is Transfer Learning</li><li>How does Transfer Learning benefit</li><li>How can Transfer Learning be achieved</li></ol><p><strong>What is Transfer Learning?</strong></p><p>Formal Definition of a transfer learning can be defined as “ the ability of a learner to successfully apply the knowledge, behaviour and skills acquired in a learning event to a new situation or context with a resulting improvement in job performance. You might think how does this apply to a deep learning model? Yes I was shocked too when I first got to know about transfer learning. Basically the model is first trained on a determined task with a specific set of data which you’ll further get to know in this blog. Lets say the model was trained to classify a dog or a cat or any animal for that matter in an image. Now while training, the model at the low level will learn the features of the image like say the shape of the objects, edges in the image, pose and orientation of the animal, etc… This learning of the model can be utilized and used for another task for ex. image segmentation (ex you are trying to segment an animal from the background). Now while training the model for image segmentation, you do not need to train the model to understand these low level features instead you can use the already trained model for classification and retrain on top of it for your specific usecase. This is the basic idea of Transfer Learning, wheteher you use it in Image or NLP.</p><p><strong>How does Transfer Learning benefit?</strong></p><p>Transfer Learning saves time and data required for training. When you use the already learnt model for another task you don’t need to provide tons of data to train the transfer learning model, only some amount of data would suffice as the model has some information with it already. Secondly it would also reduce the training time, as we can keep some of the weights associated with the trained model and retrain only some layers of the model.</p><p><strong>How can Transfer Learning be achieved?</strong></p><p>Here I would explain how transfer learning can be achieved with perspective of Image and not NLP, because both the process are quite different.</p><p>In computer vision there are several different pre-trained models like for example VGG-16, VGG-19, Resnet50, etc., and all of these models are trained on Imagenet dataset.</p><p>What is an Imagenet dataset?</p><p>The imagenet dataset is a large collection of human annotated photographs designed for developing computer vision algorithms. It contains over 14 million high resolution images spanning thousands of object categories, organized according to the WordNet hierarchy. The dataset is widely used for training and evaluating deep learning models in various computer vision tasks, such as image classification, object detection, etc.</p><p>What is the architecture of the models mentioned in above?</p><p>The architecture for different models are different. You can click <a href="https://www.analyticsvidhya.com/blog/2020/08/top-4-pre-trained-models-for-image-classification-with-python-code/#h-very-deep-convolutional-networks-for-large-scale-image-recognition-vgg-16">here </a>to get a basic understanding of architecure of different models. Basically all of these models will have layers like CNN, Maxpooling, Dense, etc. Now based on your requirement you can decide on which layers you want to keep the weight as it is(pretrained weights) or which layer you want to train and which layer you want to remove totally</p><p>If you do not understand this now don’t worry at all as in the next series I’ll be explaining the code as well. The library which helped me achieve my goal is Keras in transfer learning.</p><p>Thank you all who made it to the end of this blog. I would really appreciate you all if you comment out your views, follow or clap this blog if you like it. I hope I was able to explain you what transfer learning in computer vision is. This is part 3 of Image Segmentation series. In the part 4 of Segmentation series I’ll explain in depth how to train a pre-trained model using Keras.</p><p>Until then you can visit/revisit part 1 and 2 of segmentation series here:<br>Part 1: <a href="https://medium.com/@samruddhichitnis02/image-segmentation-ba934d61f91c">https://medium.com/@samruddhichitnis02/image-segmentation-ba934d61f91c</a><br>Part 2: <a href="https://medium.com/@samruddhichitnis02/image-segmentation-code-implementation-8efa18163d1f">https://medium.com/@samruddhichitnis02/image-segmentation-code-implementation-8efa18163d1f</a> <br>I hope this helps you!!! 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db40295abb58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is NLP?]]></title>
            <link>https://samruddhichitnis02.medium.com/what-is-nlp-9e44387dce88?source=rss-82bbe2715c22------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e44387dce88</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[basic-concept]]></category>
            <category><![CDATA[natural-language-process]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Samruddhi Chitnis]]></dc:creator>
            <pubDate>Thu, 17 Aug 2023 17:59:46 GMT</pubDate>
            <atom:updated>2023-08-17T18:00:58.587Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*aRWhGDuHOgF1vIIyAWT33Q.jpeg" /><figcaption>Photo by <a href="https://st4.depositphotos.com/9233766/39686/i/600/depositphotos_396869716-stock-photo-nlp-natural-language-processing-cognitive.jpg">https://st4.depositphotos.com/9233766/39686/i/600/depositphotos_396869716-stock-photo-nlp-natural-language-processing-cognitive.jpg</a></figcaption></figure><p>Table of Contents:</p><ol><li>Introduction to NLP</li><li>Basic Concepts in NLP</li><li>Word Embeddings</li></ol><p>NLP is a branch of AI that focuses on enabling computers to understand, interpret &amp; interact with human language.It’s the technology behind chabots, language translation, voice assistants like Siri, chatGPT, etc. By teaching to grasp the nuances of written and spoken words, NLP bridges the gap between human communication &amp; digital processing.Through techniques like machine learning and linguistic analysis, NLP empowers computers to extract meaning from text, answer questions, and even hold conversations.</p><p>2. Basic Concepts in NLP</p><p>NLP is a vast area and recently there have been many advancements in NLP, but most of the research and advancement have these basic concepts like tokenization, stop words, stemming and lemmatization, part-of-speech tagging, etc.</p><p>Now you might be wondering what are these concepts and where are these exactly used, so let me give a brief about some of these concepts</p><p>Lets start with tokenization,</p><p><strong><em>What is tokenization?</em></strong></p><p>When you work with text data, that text data is many a times paragraph, or a text corpus which involves a couple of sentences. These text corpus cannot be directly fed to the model, so usually the text corpus/paragraph is either broken down in to sentences or words and then pre-processed further to feed to the model.</p><p><strong><em>What are stop words?</em></strong></p><p>There are some words like “it”, “and”, “the”, etc. you can refer to NLTK’s list of english stopwords from <a href="https://gist.github.com/sebleier/554280">here</a>. These words repeat more often in a text corpus and if we don’t remove them then they might get more attention or weightage rather than the words with context, hence we must remove stop words from the corpus.</p><p><strong><em>What is stemming/lemmatization?</em></strong></p><p>Both the techniques aim to reduce words to their base or root form. Stemming involves cutting off prefixes or suffixes, while lemmatization considers the words grammatical context to achieve the same result.We use stemming and lemmatization to normalize the text and prepare words and documents for further processing in Machine Learning. When to use stemming and when to use lemmatization is really a trick but here is a hint, if you are working on building a model for question and answering which requires understanding of the words then we must go ahead and use lemmatization, but if we are working on building a model for sentiment analysis then we may use stemming.</p><p>There are many more basic concepts which are helpful in data pre-processing of text, but the above mentioned concepts are the one’s which are most probably applied while working on any NLP tasks.</p><p>3. Word Embeddings</p><p>When we work on text data, they are strings and strings cannot be fed to the model, because model understands only numbers. Hence we convert strings to numbers and they are called embeddings or word embeddings.</p><p>There are different ways to create word embeddings and I have listed some of them below:</p><ul><li>Bag of words : The Bag of Words (BoW) is a fundamental and straightforward technique used in natural language processing (NLP) to convert text data into a numerical representation that machine learning models can understand. BoW treats a document as an unordered collection of words, disregarding grammar, word order, and context, and focuses solely on the presence and frequency of words. It’s a basic method but forms the foundation for more advanced techniques in text analysis.</li><li>TF-IDF : TF-IDF stands for “Term Frequency-Inverse Document Frequency.” Here’s a formula for TF-IDf</li></ul><blockquote>TF = (Number of times term appears in document) / (Total number of terms in the document)</blockquote><blockquote>IDF = log((Total number of documents) / (Number of documents containing the term))</blockquote><blockquote>TF-IDF = TF * IDF</blockquote><ul><li>Word2Vec: This is a popular technique that trains shallow neural networks to predict surrounding words given a target word (Skip-gram) or predict a target word given its context (Continuous Bag of Words, CBOW). The resulting word embeddings capture semantic relationships by placing words with similar contexts or meanings closer together in the vector space.</li><li>GloVe: GloVe creates word embeddings by factorizing the word co-occurrence matrix. It combines global statistics of word co-occurrences with local context window information to generate embeddings that capture both semantic and syntactic relationships.</li></ul><p>and many more</p><p>This blog will help you in having a basic idea of what NLP is and how things work in NLP.</p><p>Thank you all for reading this blog. I am just a begginer in writing blogs, so I request you all to please leave comments, feedbacks and suggestions if any.</p><p>I am planning to come up with more such blogs which explains concepts in NLP. If you like the blog don’t forget to leave a clap and a comment. Thanks once again for reaching here!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e44387dce88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Image Segmentation UNET Code Implementation part 2]]></title>
            <link>https://samruddhichitnis02.medium.com/image-segmentation-code-implementation-8efa18163d1f?source=rss-82bbe2715c22------2</link>
            <guid isPermaLink="false">https://medium.com/p/8efa18163d1f</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[image-segmentation]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[cnn]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Samruddhi Chitnis]]></dc:creator>
            <pubDate>Fri, 06 Jan 2023 14:51:42 GMT</pubDate>
            <atom:updated>2023-01-06T14:56:33.903Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This part is the continuation of Image Segmentation Part 1 </em><a href="https://medium.com/p/ba934d61f91c"><em>https://medium.com/p/ba934d61f91c</em></a></p><p>Table of Contents:</p><ul><li>A quick glance of what image segmentation is</li><li>Code to implement Unet Architecture from scratch</li><li>Explanation of the code</li><li>How is image segmentation different from image classification and object detection</li><li>References</li></ul><h4><strong>What is Image Segmentation?</strong></h4><p>I have explained what image segmentation is in the previous part but I would still discuss that here so that there is a continuity for the people reading the blog. Coming to what image segmentation is, the images we have are made up of multiple pixels, now using segmentation we try to classify the pixels of that image in to some classes. For ex. consider an image which has a tree, a lake(any water body), roads, and let us consider for now all the other objects present in the image are of no use to us. There can be 4 classes here and they are tree, water body, road and the other objects which are not useful to us can be classified as unwanted objects class. An ideal image segmentation model will predict each an every pixel from the image correctly in to their respective classes. So here along with the class of the object we also get an understanding of, from where to where the object is present in the given image, and this understanding can be very much helpful in applications like self driving cars.</p><h4><strong>Code to implement Unet architecture from scratch and explanation of the code —</strong></h4><p><strong>Encoder</strong></p><p>In this part I will try to implement Unet using Keras library from scratch. Unet architecture has 2 parts Encoder &amp; Decoder. The Encoder can be built either from scratch or we can use a transfer learning model. Here in this part that is part 2 of segmentation I would be explaining about how to code Unet from scratch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/0*CqeLWwSl7P-WMAPi" /><figcaption>Image Source: <a href="https://1329420134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LagOeJ2nL90MQERwhxy%2F-Lz43_f2D3C83OUVz_pr%2F-Lz8GIuxOgzYOCmTh6SW%2Fimage.png?alt=media&amp;token=3d8af2a4-6045-496c-8914-466e93f6bf87">https://1329420134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LagOeJ2nL90MQERwhxy%2F-Lz43_f2D3C83OUVz_pr%2F-Lz8GIuxOgzYOCmTh6SW%2Fimage.png?alt=media&amp;token=3d8af2a4-6045-496c-8914-466e93f6bf87</a></figcaption></figure><p>We will first start with the encoder part of the Unet. Please refer the above image for the Encoder part. Refer the code below for the encoder architecture using Keras.</p><p>First of all import all the required libraries as shown below</p><pre>from keras.layers import Conv2D, MaxPooling2D, UpSampling2D<br>from keras.layers import Input, add, concatenate<br>from keras.models import Model<br>from keras.optimizers import *</pre><p>Model architecture for Encoder from scratch</p><pre>skip_connections = []<br><br>input_img_shape = Input(shape = (512, 512))<br>en = Conv2D(filters = 8, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(input_img_shape)<br>en = Conv2D(filters = 8, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(en)<br>skip_connections.append(en)<br>en = MaxPooling2D(pool_size=(2, 2), strides=(2, 2))(en)<br><br>en = Conv2D(filters = 16, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(en)<br>en = Conv2D(filters = 16, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(en)<br>skip_connections.append(en)<br>en = MaxPooling2D(pool_size=(2, 2), strides=(2, 2))(en)<br><br>en = Conv2D(filters = 32, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(en)<br>en = Conv2D(filters = 32, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(en)<br>skip_connections.append(en)<br>en = MaxPooling2D(pool_size=(2, 2), strides=(2, 2))(en)<br><br>en = Conv2D(filters = 64, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(en)<br>en = Conv2D(filters = 64, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(en)<br>skip_connections.append(en)<br>en = MaxPooling2D(pool_size=(2, 2), strides=(2, 2))(en)</pre><p>The above code snippet is for encoder for Unet architecture, In encoder we use</p><ul><li><strong>Convulation layers</strong> to learn the features from the images like shape, objects, and other objects.</li><li>We use <strong>skip connections</strong> to store the information which can be remembered later while reconstructing the mask image in decoder stage, so skip connection basically acts like a memory.</li></ul><p>Also not that the shape in the Input layer is the shape of the input image we pass, and we can pass image of any shape to the model.</p><p><strong>Decoder</strong></p><p>Decoder in Unet always needs to be built from scratch, even if we try to use a pre trained model in encoder part, depending on the filters and the layers used in the encoder we try to build the decoder from scratch. Decoder basically tries to reconstruct a masked image from the features it had received using encoder. Now you might think what is a masked image so for this question I will attach an image of how a masked image or mask usually looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2xxxxcobDW7iIBKt" /><figcaption>Image Source: <a href="https://imgs.search.brave.com/taWHuk4tFJxPSMhVanc5Ok2KH2yZEQ6rsJHBwD9kQCk/rs:fit:1200:757:1/g:ce/aHR0cHM6Ly9taXJv/Lm1lZGl1bS5jb20v/bWF4LzEyODAvMSo3/TTNqUnVTUDZ2Sk1P/T2I0VWd3X3NRLnBu/Zw">https://imgs.search.brave.com/taWHuk4tFJxPSMhVanc5Ok2KH2yZEQ6rsJHBwD9kQCk/rs:fit:1200:757:1/g:ce/aHR0cHM6Ly9taXJv/Lm1lZGl1bS5jb20v/bWF4LzEyODAvMSo3/TTNqUnVTUDZ2Sk1P/T2I0VWd3X3NRLnBu/Zw</a></figcaption></figure><p><strong><em>Original Image</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/0*FnmvqS6MaxTfQ6Zo.png" /><figcaption>Image Source: <a href="https://miro.medium.com/max/524/1*qDTZb2PCoM-ZTzLZMqOrSQ.webp">https://miro.medium.com/max/524/1*qDTZb2PCoM-ZTzLZMqOrSQ.webp</a></figcaption></figure><p><strong><em>Image Mask</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/0*JjGwzS-cAvGJXet_.png" /><figcaption>Image Source : <a href="https://miro.medium.com/max/524/1*d8LA_ZJbeGfIAECjAGy5_A.webp">https://miro.medium.com/max/524/1*d8LA_ZJbeGfIAECjAGy5_A.webp</a></figcaption></figure><p>Model architecture for Decoder</p><pre>de = Upsampling2D(size = (2, 2))(en)<br>de = Conv2D(filters = 64, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(de)<br>de = concatenate([skip_connections[3], de])<br>de = Conv2D(filters = 64, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(de)<br>de = Conv2D(filters = 64, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(de)<br><br>de = Upsampling2D(size = (2, 2))(de)<br>de = Conv2D(filters = 32, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(de)<br>de = concatenate([skip_connections[2], de])<br>de = Conv2D(filters = 32, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(de)<br>de = Conv2D(filters = 32, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(de)<br><br>de = Upsampling2D(size = (2, 2))(de)<br>de = Conv2D(filters = 16, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(de)<br>de = concatenate([skip_connections[1], de])<br>de = Conv2D(filters = 16, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(de)<br>de = Conv2D(filters = 16, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(de)<br><br>de = Upsampling2D(size = (2, 2))(de)<br>de = Conv2D(filters = 8, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(de)<br>de = concatenate([skip_connections[0], de])<br>de = Conv2D(filters = 8, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(de)<br>de = Conv2D(filters = 8, kernel_size = (3, 3), activation = &#39;relu&#39;, padding = &#39;same&#39;)(de)</pre><p>The Decoder uses</p><ul><li><strong>Upsampling </strong>to scale the image to a higher resolution so that we get the mask of the same shape as the original image. Note that upsampling does not have any learning it just increases the resolution of the image.</li><li><strong>Concatenate </strong>to use the earlier memory of the encoder.</li><li><strong>Convolution </strong>to reconstruct the objects in the image.</li></ul><h4><strong>How is image segmentation different from image classification and object detection ?</strong></h4><ul><li>In Image Classification we just try to identify the object present in the image.</li><li>In Object Detection we try to classify the objects present in the image plus localize the objects in the image</li><li>In Image Segmentation we try to categorize each and every pixel present in the image.</li></ul><h4><strong>References</strong></h4><ol><li><a href="https://medium.com/@hanrelan/a-non-experts-guide-to-image-segmentation-using-deep-neural-nets-dda5022f6282">https://medium.com/@hanrelan/a-non-experts-guide-to-image-segmentation-using-deep-neural-nets-dda5022f6282</a></li><li><a href="https://github.com/petrosgk/Kaggle-Carvana-Image-Masking-Challenge/">https://github.com/petrosgk/Kaggle-Carvana-Image-Masking-Challenge/</a></li><li><a href="https://github.com/petrosgk/Kaggle-Carvana-Image-Masking-Challenge/blob/master/model/u_net.py">https://github.com/petrosgk/Kaggle-Carvana-Image-Masking-Challenge/blob/master/model/u_net.py</a></li></ol><p>Thank you all for reading this blog. I am just a begginer in writing blogs, so I request you all to please leave comments, feedbacks and suggestions if any, also do correct me in comments if you find any mistakes. Hope this blog helps you in getting an over all idea of what the unet architecture is about.</p><p>This is part 2 of Image Segmentation series, where in I have explained the code snippets of the model or more specifically unet model, in the upcoming parts of this series I would further explain on how to feed the input data to this model, how to create the input data and many more things so stay tuned ;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8efa18163d1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Image Segmentation Part 1]]></title>
            <link>https://samruddhichitnis02.medium.com/image-segmentation-ba934d61f91c?source=rss-82bbe2715c22------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba934d61f91c</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[cnn]]></category>
            <category><![CDATA[image-segmentation]]></category>
            <category><![CDATA[transfer-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Samruddhi Chitnis]]></dc:creator>
            <pubDate>Fri, 14 Jan 2022 19:23:59 GMT</pubDate>
            <atom:updated>2023-10-22T17:57:44.119Z</atom:updated>
            <content:encoded><![CDATA[<p>Image Segmentation</p><p>Table of Contents:</p><ol><li>What is Image Segmentation Segmentation?</li><li>Where is Image Segmentation used?</li><li>How can we implement Image Segmentation?</li><li>Unet Architecture</li><li>Conclusion</li><li>References</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*f6Uhb8MI4REGcYKkYM9OUQ.png" /><figcaption>Image Source: <a href="https://www.researchgate.net/figure/Example-of-2D-semantic-segmentation-Top-input-image-Bottom-prediction_fig3_326875064">https://www.researchgate.net/figure/Example-of-2D-semantic-segmentation-Top-input-image-Bottom-prediction_fig3_326875064</a></figcaption></figure><ol><li><strong>What is Image Segmentation/Semantic Segmentation?</strong></li></ol><p>Image Segmentation is also a kind of classification but in image segmentation each and every pixel of the image is classified in to some class. For instance refer the above image, the upper part is the actual image and the below part is the segmented image. We can clearly see that each and every pixel from the image is classified in to some class. Pixels which does not come under any class is often kept in to background class and labeled black .</p><p>2. <strong>Where is Image Segmentation used?</strong></p><p>There are various applications and domains where image segmentation is used. One of the domain where image segmentation is used mostly is medical domain.Other than medical domain image segmentation is also used in self driving cars, geo-sensing, agriculture, construction domain, etc.</p><p>3. <strong>How can we implement Image Segmentation?</strong></p><p>One of the most common and widely used architecture I came across while implementing image segmentation is Unet architecture. Unet architecture was basically developed for biomedical image segmentation. You can read about the original Unet Paper from <a href="https://arxiv.org/abs/1505.04597">here</a>.</p><p>4. <strong>Unet Architecture</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EaY7ImL1gy-KFWdBIfYi8g.png" /><figcaption>Image Source: <a href="https://miro.medium.com/max/1838/1*f7YOaE4TWubwaFF7Z1fzNw.png">https://miro.medium.com/max/1838/1*f7YOaE4TWubwaFF7Z1fzNw.png</a></figcaption></figure><p>As can be seen from the above image the Unet architecture resembles the U alphabet. There are two main components in Unet one is the Encoder and the other is the Decoder. Unet is made up of convolutional layers and max pooling layers in the Encoder part, convolutional layer and upsampling or transposed convolution layer in the Decoder part.Unet contains only convolutional layers and does not contain any Dense layer because of which it can accept image of any size.</p><p>What is an Encoder ?</p><p>Encoder is a stack of convolutional and maxpooling layers. Encoder is responsible for capturing the context or features from the image which is done using convolutional layer. We can either build encoder from scratch or we can use any of the transfer learning models like VGG16, Mobilenet, etc for building the encoder. I will explain how to implement both of them using Keras in the next part of Image Segmentation.</p><p>Skip Connections</p><p>While we capture the context or features from the images in Encoder, we save/store some of them in skip connections and then provide those skip connections to the Decoder, so that the Decoder remembers the features present at the early stages and use them for recreating the segmentated image.</p><p>What is a Decoder?</p><p>Decoder is basically responsible for constructing the segmentated image.If you have a look at the Decoder architecture which I would definitely walk you through in the next part, you will find out that there is no max pooling layer in the Decoder, instead it has an upsampling layer along with the convolutional layer or a transposed convolutional layer all of which upsamples the outputs received from the Encoder layer. Decoder receives the input from the Encoder layer as well as uses skip connections stored earlier from the Encoder layer to construct the final output image.</p><p>5. <strong>Conclusion</strong></p><p>This blog will help you in having a basic idea of what image segmentation is all about, it’s applications and a basic detail about what an image segmentation model architecture looks like.</p><p><strong>References:</strong></p><ol><li><a href="https://towardsdatascience.com/understanding-semantic-segmentation-with-unet-6be4f42d4b47">https://towardsdatascience.com/understanding-semantic-segmentation-with-unet-6be4f42d4b47</a></li></ol><p>Thank you all for reading this blog. I am just a begginer in writing blogs, so I request you all to please leave comments, feedbacks and suggestions if any.</p><p>This is just the part 1 of Image Segmentation series, in the upcoming blogs I would further explain in depth about image segmentation using unet with the code.</p><p>Also Find the next part of this series here</p><p>Part 2: <a href="https://medium.com/@samruddhichitnis02/image-segmentation-code-implementation-8efa18163d1f">https://medium.com/@samruddhichitnis02/image-segmentation-code-implementation-8efa18163d1f</a></p><p>Part 3: <a href="https://medium.com/@samruddhichitnis02/image-segmentation-transfer-learning-db40295abb58">https://medium.com/@samruddhichitnis02/image-segmentation-transfer-learning-db40295abb58</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba934d61f91c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Precision, Recall, F1 score]]></title>
            <link>https://samruddhichitnis02.medium.com/precision-recall-f1-score-afd2a6483da8?source=rss-82bbe2715c22------2</link>
            <guid isPermaLink="false">https://medium.com/p/afd2a6483da8</guid>
            <category><![CDATA[precision]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[f1-score]]></category>
            <category><![CDATA[metrics]]></category>
            <category><![CDATA[recall]]></category>
            <dc:creator><![CDATA[Samruddhi Chitnis]]></dc:creator>
            <pubDate>Sat, 28 Nov 2020 06:37:39 GMT</pubDate>
            <atom:updated>2020-11-28T06:37:39.154Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iHpmjvMA7iPEUulB" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>What are Precision, recall, f score?</p><p>They are the metrics used for classification tasks in simple language, but now you may think why is there a need for all these metrics to be used when we have a simple metric called accuracy to measure the correctness of the model!</p><p>The reason is accuracy cannot give us the correct estimate of how the model is going to work on unseen data all the time, <strong>especially when we have an imbalanced data</strong>. Consider a classification problem of whether an incoming email is a spam or not spam. Most of the time in real world scenario emails we get are not spam.</p><p>Consider another classification problem were a patient is classified as having cancer or not. Here also if we consider the real world scenario we can tell that majority of the patients will not be classified as having cancer. These are the examples of imbalanced datasets. When we train the model on such datasets our model becomes biased to one type of class(majority class) in the data. Hence it will give good accuracy for such biased datasets but what if we test the model on totally unseen data it will perform poorly on such data. Hence accuracy did not give us a good estimate of the model and cannot be used for validation.</p><p>To solve the problem we can use other metrics like precision, recall, f score, etc.</p><h3>What is precision?</h3><p><em>Precision tells us what proportion of positive identifications by the model are actually correct</em>.</p><p><strong><em>Formula for precision is:</em></strong></p><blockquote>Precision = (True Positive) / (True Positive + False Positive)</blockquote><h3>What is recall?</h3><p><em>Recall tells us what proportion of actual positives are identified correctly by the model.</em></p><p><strong><em>Formula for recall is:</em></strong></p><blockquote>Recall = (True Positive) / (True Positive + False Negative)</blockquote><p>Now this precision and recall have a trade off meaning both cannot be increased at the same time, so which one to increase depends on the type of problem we are having.</p><p>Lets take an example of the above spam, non spam mail classification, in such case there would be a problem if our model classifies non spam mails as spam mails that is we should focus more on reducing the <strong>false positives</strong> in this case and hence we should try to increase <strong>precision.</strong></p><p>Consider the second example of a patient being detected as having cancer or not, in this case it would be a problem if our model classifies a patient as having no cancer even when he is having cancer that is why we should focus more on reducing the <strong>false negative </strong>in<strong> </strong>this case and hence we should try to increase <strong>recall.</strong></p><h3>What is f1 score?</h3><p><em>F1 score is basically a harmonic mean of precision and recall</em></p><p><strong><em>Formula for f1 score is:</em></strong></p><blockquote><em>F1-score = 2 * (Precision * Recall) / (Precision + Recall)</em></blockquote><p>F1 score can be used when you want to maintain a balance between precision and recall or when you want to focus more on False Positive as well as False Negative.</p><h3>References</h3><ol><li><a href="https://www.youtube.com/watch?v=aWAnNHXIKww">https://www.youtube.com/watch?v=sJR-1yz7mnI</a></li><li><a href="https://developers.google.com/machine-learning/crash-course/classification/precision-and-recall">https://developers.google.com/machine-learning/crash-course/classification/precision-and-recall</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afd2a6483da8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>