<?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 Rohan Sharma on Medium]]></title>
        <description><![CDATA[Stories by Rohan Sharma on Medium]]></description>
        <link>https://medium.com/@rohan.engmech?source=rss-ac6124944ad5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*y5h6JxL6Jy0d387g</url>
            <title>Stories by Rohan Sharma on Medium</title>
            <link>https://medium.com/@rohan.engmech?source=rss-ac6124944ad5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 10:17:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rohan.engmech/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[Indian Food Identifier]]></title>
            <link>https://medium.com/@rohan.engmech/indian-food-identifier-366b87ae5b4e?source=rss-ac6124944ad5------2</link>
            <guid isPermaLink="false">https://medium.com/p/366b87ae5b4e</guid>
            <dc:creator><![CDATA[Rohan Sharma]]></dc:creator>
            <pubDate>Tue, 30 Jun 2020 00:11:48 GMT</pubDate>
            <atom:updated>2020-06-30T00:11:48.855Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*_ixYTW5Q3Gn_ajcv4rCXHA.png" /></figure><p>The first impression about INDIA, when asked from a person of any non INDIAN origin person, is the diversity of culture and too much spicy food. Yes, so the project that I have worked on is somewhat related to the above argument. India not only shares diversity in culture but also the food that is associated with that culture. From North to down south and from west to far east, Indian food changes shape color and taste.</p><p>But a machine is unable to taste the food, it can analyze it only using the shape and color. The classifier can distinguish with an accuracy of 79% (because of low data).</p><p>The classes that we used are</p><ol><li>BIRYANI</li><li>BISIBELEBATH</li><li>BUTTER NAAN</li><li>CHAAT</li><li>CHAPPATI</li><li>DHOKLA</li><li>DOSA</li><li>GULAB JAMUN</li><li>HALWA</li><li>IDLY</li><li>KATHI ROLL</li><li>MEDUVADAI</li><li>NOODLES</li><li>PANIYARAM</li><li>POORI</li><li>SAMOSA</li><li>TANDOORI CHICKEN</li><li>UPMA</li><li>VADA PAV</li><li>VEN PONGAL</li></ol><p>Each class has an approximate dataset of 100 images approximately. These images are then fed to the data.</p><p>Let&#39;s go step by step</p><p>The initial step is importing the essential libraries</p><pre>import os</pre><pre>import zipfile<br>import tarfile</pre><pre>from torchvision.datasets.utils import download_url</pre><pre>from torch.utils.data import random_split</pre><pre>import os</pre><pre>import torch</pre><pre>import torch.nn as nn</pre><pre>import numpy as np</pre><pre>import torch.nn.functional as F</pre><pre>from torchvision.datasets.utils import download_url</pre><pre>from torchvision.datasets import ImageFolder</pre><pre>from torch.utils.data import DataLoader</pre><pre>import torchvision.transforms as tt</pre><pre>from torch.utils.data import random_split</pre><pre>from torchvision.utils import make_grid</pre><pre>import matplotlib.pyplo</pre><p>first let&#39;s unzip the zip file and separate the test and the training data</p><pre>import zipfile<br>with zipfile.ZipFile(&#39;food_data (2).zip&#39;, &#39;r&#39;) as zip_ref:<br>    zip_ref.extractall(&#39;./new_food&#39;)<br>data_dir = &#39;/content/new_food/food_data/food20dataset&#39;<br>print(os.listdir(data_dir))<br>classes = os.listdir(data_dir + &quot;/train_set&quot;)<br>print(len(classes))</pre><p>Now the data consist of different sized images which should be bought to the normalized size, (an approximate of average and standard deviation is considered) and this is done for both training and testing dataset</p><pre>train_tfms = tt.Compose([tt.Resize(256),tt.RandomCrop(256),</pre><pre>tt.RandomHorizontalFlip(),</pre><pre>tt.ToTensor(),</pre><pre>tt.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))</pre><pre>])</pre><pre>valid_tfms = tt.Compose([tt.Resize(256),tt.CenterCrop(256),tt.ToTensor(), tt.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])</pre><p>The next step is to prepare to be fed to the network with a batch. I selected a batch size of 16. Remember to switch on the shuffle so that networks learn to classify the network properly</p><pre>batch_size = 16<br>train_dl = DataLoader(train_ds, batch_size, shuffle=True, num_workers=3, pin_memory=True)<br>valid_dl = DataLoader(valid_ds, batch_size*2, num_workers=3, pin_memory=True)<br>def <strong>show_batch</strong>(dl):<br>    for images, labels in dl:<br>        fig, ax = plt.subplots(figsize=(12, 12))<br>        ax.set_xticks([]); ax.set_yticks([])<br>        ax.imshow(make_grid(images[:64], nrow=8).permute(1, 2, 0))<br>        break<br>show_batch(train_dl)</pre><p>The output of this was</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m6AcNsh6XjKs0dNwsElnNg.png" /></figure><p>(don&#39;t get distracted, we still haven’t prepared the model for the execution)</p><p>The neural network architecture that I am using is ResNet and I have updated it to accommodated 12 layers (8192 NEURONS), I know that sounds unnecessary usage of the GPU space but Thanks to Google for providing COLAB. And it&#39;s free not a big headache.</p><p>( I am attaching the link to my notebook and you can use the code Given there</p><p>Next step is to load the model GPU and training to 100 epochs using ADAM optimizer and train the model</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*DkgzlJb8x-llabYOyTY8xA.png" /></figure><p>Which shows that maximum accuracy obtained by the model is around 0.79 which is around 79 %</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*ij6bbVR18ZVEhmpUiukHmw.png" /></figure><p>Not only this, but the validation loss vs the training loss is also compatible less. Still, I assume that because of lower data, the model is underfitting or biased but that can be changed with adding more data</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fjovian.ml%2Fembed%3Furl%3Dhttps%3A%2F%2Fjovian.ml%2Frohan-engmech%2Fmy-project-1&amp;dntp=1&amp;display_name=Jovian&amp;url=https%3A%2F%2Fjovian.ml%2Frohan-engmech%2Fmy-project-1&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=jovian" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d731e936d0d628f8d015f7d95e420b5/href">https://medium.com/media/7d731e936d0d628f8d015f7d95e420b5/href</a></iframe><p>Lastly, I would like to thank Jovian.ml for putting out his wonderful course</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=366b87ae5b4e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>