<?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 Ann Mohan Kunnath on Medium]]></title>
        <description><![CDATA[Stories by Ann Mohan Kunnath on Medium]]></description>
        <link>https://medium.com/@annmohankunnath?source=rss-d283f1e9e8e3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*F-zmDvNFQf9Q-C7uE8YjSw.jpeg</url>
            <title>Stories by Ann Mohan Kunnath on Medium</title>
            <link>https://medium.com/@annmohankunnath?source=rss-d283f1e9e8e3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 10:36:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@annmohankunnath/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[An introduction to implementing the YOLO algorithm for multi object detection in images]]></title>
            <link>https://medium.com/@annmohankunnath/an-introduction-to-implementing-the-yolo-algorithm-for-multi-object-detection-in-images-3011dfc10a05?source=rss-d283f1e9e8e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/3011dfc10a05</guid>
            <category><![CDATA[yolo]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Ann Mohan Kunnath]]></dc:creator>
            <pubDate>Tue, 04 Aug 2020 01:11:58 GMT</pubDate>
            <atom:updated>2020-08-04T01:11:58.408Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JCqgJ2JDDyQeBA2IGKxlJQ.png" /></figure><h3>An introduction to implementing the YOLO algorithm for multi object detection in images</h3><p>YOLO is an extremely fast real time multi object detection algorithm. YOLO stands for “You Only Look Once”. This is the link to the original paper : <a href="https://pjreddie.com/media/files/papers/YOLOv3.pdf">https://pjreddie.com/media/files/papers/YOLOv3.pdf</a>.</p><p>The algorithm applies a neural network to an entire image. The network divides the image into an S x S grid and comes up with bounding boxes, which are boxes drawn around images and predicted probabilities for each of these regions.</p><p>The method used to come up with these probabilities is logistic regression. The bounding boxes are weighted by the associated probabilities. For class prediction, independent logistic classifiers are used.</p><p>In this article, I am going to demonstrate how to implement the YOLO algorithm with a pre trained model.</p><p>First, we would need to install DarkNet. DarkNet is a neural network framework that is open source. You can find more information about DarkNet in this link: <a href="https://pjreddie.com/darknet/">https://pjreddie.com/darknet/</a></p><p>Step 1: We import the necessary libraries</p><pre>import cv2 # computer vision library<br>import matplotlib.pyplot as plt # to plot<br>from darknet import Darknet # to use DarkNet</pre><p>Step 2: We load the configuration file and pre trained weights into variables</p><pre>config_file = &#39;./cfg/yolov3.cfg&#39;<br>pretrained_weights = &#39;./weights/yolov3.weights&#39;</pre><p>Step 3: We instantiate an object of the DarkNet class</p><pre>net = Darknet(config_file)</pre><p>Step 4: We load the pre trained weights</p><pre>net.load_weights(pretrained_weights)</pre><p>Step 5: We display the network and see how it looks</p><pre>net.print_network()</pre><p>A small part of the output is shown below:</p><pre>layer     filters    size              input                output<br>   0 conv     32  3 x 3 / 1   416 x 416 x   3   -&gt;   416 x 416 x  32<br>   1 conv     64  3 x 3 / 2   416 x 416 x  32   -&gt;   208 x 208 x  64<br>   2 conv     32  1 x 1 / 1   208 x 208 x  64   -&gt;   208 x 208 x  32<br>   3 conv     64  3 x 3 / 1   208 x 208 x  32   -&gt;   208 x 208 x  64</pre><p>In the full output,we can see that the network has 106 layers including the classification / detection layers.</p><p>Step 6 : Next, we read in and image and display it. This is the image we are going to apply the YOLO algorithm on.</p><pre>plt.rcParams[&#39;figure.figsize&#39;] = (15.0, 15.0)<br>img = cv2.imread(&#39;./images/city_scene.jpg&#39;)<br>img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)<br>plt.imshow(img)</pre><p>The output is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*jaKxrkOlACuxbaocy4EAMw.png" /></figure><p>Step 7: Next we load the names that the pre trained model was trained on.</p><pre>class_names_file = &#39;data/coco.names&#39;<br>class_names = load_class_names(class_names_file)</pre><p>Now, the variable class_names holds all the class names that the model was trained on. Let us display the values in class_names to get a better idea of what it contains</p><p>Step 8: Display the class names</p><pre>print(class_names)</pre><p>The output is as follows:</p><pre>[&#39;person&#39;, &#39;bicycle&#39;, &#39;car&#39;, &#39;motorbike&#39;, &#39;aeroplane&#39;, &#39;bus&#39;, &#39;train&#39;, &#39;truck&#39;, &#39;boat&#39;, &#39;traffic light&#39;, &#39;fire hydrant&#39;, &#39;stop sign&#39;, &#39;parking meter&#39;, &#39;bench&#39;,&#39;bird&#39;, &#39;cat&#39;, &#39;dog&#39;, &#39;horse&#39;, &#39;sheep&#39;, &#39;cow&#39;, &#39;elephant&#39;, &#39;bear&#39;, &#39;zebra&#39;, &#39;giraffe&#39;, &#39;backpack&#39;, &#39;umbrella&#39;, &#39;handbag&#39;, &#39;tie&#39;, &#39;suitcase&#39;, &#39;frisbee&#39;, &#39;skis&#39;, &#39;snowboard&#39;, &#39;sports ball&#39;, &#39;kite&#39;, &#39;baseball bat&#39;, &#39;baseball glove&#39;, &#39;skateboard&#39;, &#39;surfboard&#39;, &#39;tennis racket&#39;, &#39;bottle&#39;, &#39;wine glass&#39;, &#39;cup&#39;, &#39;fork&#39;, &#39;knife&#39;, &#39;spoon&#39;, &#39;bowl&#39;, &#39;banana&#39;, &#39;apple&#39;, &#39;sandwich&#39;, &#39;orange&#39;, &#39;broccoli&#39;, &#39;carrot&#39;, &#39;hot dog&#39;, &#39;pizza&#39;, &#39;donut&#39;, &#39;cake&#39;, &#39;chair&#39;, &#39;sofa&#39;, &#39;pottedplant&#39;, &#39;bed&#39;, &#39;diningtable&#39;, &#39;toilet&#39;, &#39;tvmonitor&#39;, &#39;laptop&#39;, &#39;mouse&#39;, &#39;remote&#39;, &#39;keyboard&#39;, &#39;cell phone&#39;, &#39;microwave&#39;, &#39;oven&#39;, &#39;toaster&#39;, &#39;sink&#39;, &#39;refrigerator&#39;, &#39;book&#39;, &#39;clock&#39;, &#39;vase&#39;, &#39;scissors&#39;, &#39;teddy bear&#39;, &#39;hair drier&#39;, &#39;toothbrush&#39;]</pre><p>Step 9: The image is resized to have the same width and height as the first layer of the neural network</p><p>resized_image = cv2.resize(img, (net.width, net.height))</p><pre>resized_image = cv2.resize(img, (net.width, net.height))</pre><p>Step 10: We set the Intersection Over Union (IOU) threshold. IOU is defined as Area Of Overlap / Area Of Union of the ground truth bounding box and the predicted bounding box.</p><pre>iou_threshold = 0.4</pre><p>This means that a detection with a IOU greater than .4 is a true positive.</p><p>Step 11: We set the Non-Maximal Suppression (NMS) threshold. NMS suppresses overlapping bounding boxes and only retains the bounding box that has the maximum probability of object detection associated with it.</p><pre>nms_threshold = 0.6</pre><p>Step 12: Next, we detect the objects and display them with their probabilities.</p><pre>boxes = detect_objects(net, resized_image, iou_threshold, nms_threshold)<br>print_objects(boxes, class_names)<br>plot_boxes(img, boxes, class_names, plot_labels = True)</pre><p>The output is as follows:</p><pre>It took 3.684 seconds to detect the objects in the image.</pre><pre>Number of Objects Detected: 28 </pre><pre>Objects Found and Confidence Level:</pre><pre>1. person: 0.999996<br>2. person: 1.000000<br>3. car: 0.707237<br>4. truck: 0.933031<br>5. car: 0.658086<br>6. truck: 0.666982<br>7. person: 1.000000<br>8. traffic light: 1.000000<br>9. person: 1.000000<br>10. car: 0.997369<br>11. bus: 0.998023<br>12. person: 1.000000<br>13. person: 1.000000<br>14. person: 1.000000<br>15. person: 1.000000<br>16. person: 1.000000<br>17. traffic light: 1.000000<br>18. traffic light: 1.000000<br>19. umbrella: 0.997282<br>20. traffic light: 1.000000<br>21. car: 0.989741<br>22. traffic light: 1.000000<br>23. traffic light: 0.999999<br>24. person: 0.999999<br>25. truck: 0.715035<br>26. traffic light: 1.000000<br>27. person: 0.999993<br>28. person: 0.999996</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1I9FxY4-LFrivEakgxR7lA.png" /></figure><p>We can see the objects that have been detected along with their probabilities in the output above.</p><p>References:</p><ol><li>The Original Paper on YOLOv3, <a href="https://pjreddie.com/media/files/papers/YOLOv3.pdf">https://pjreddie.com/media/files/papers/YOLOv3.pdf</a></li><li>Udacity Computer Vision Nanodegree, <a href="https://www.udacity.com/course/computer-vision-nanodegree--nd891">https://www.udacity.com/course/computer-vision-nanodegree--nd891</a></li><li>Real Time Object Detection with YOLO, YOLOv2 and now YOLOv3, <a href="https://medium.com/@jonathan_hui/real-time-object-detection-with-yolo-yolov2-28b1b93e2088">https://medium.com/@jonathan_hui/real-time-object-detection-with-yolo-yolov2-28b1b93e2088</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3011dfc10a05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Introduction to Web Scraping with Python]]></title>
            <link>https://medium.com/@annmohankunnath/an-introduction-to-web-scraping-with-python-bc9563fe8860?source=rss-d283f1e9e8e3------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc9563fe8860</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ann Mohan Kunnath]]></dc:creator>
            <pubDate>Thu, 09 Aug 2018 04:29:08 GMT</pubDate>
            <atom:updated>2018-08-09T23:14:24.469Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*ajVHV3l_8ezVivCTBomPtw.gif" /></figure><p>A lot of unstructured data is available on the internet. Once gathered and put into a structured &amp; meaningful format, this data can be used to perform analytics and derive meaningful insights. In this tutorial, I am going to demonstrate how we can collect such data from the internet and process it to get it to be in a structured format. This process is known as Web Scraping. It is also called Screen Scraping, Web Harvesting or Web Data Extraction.</p><p>Web Scraping has many applications in business.A few examples are Market Sentiment Analysis, Customer Sentiment Analysis and Competitive Pricing.</p><p>In this post, I am going to demonstrate web scraping apartments.com using Python.</p><p><strong>Step 1</strong>: Before we scrape a website, we need to take a look at their robots.txt. This file tells us if the website allows scraping or if they do not. To find the robots.txt, type in the base url and add “/robots.txt”. For eg, if we want to crawl apartments.com, type in <a href="https://www.apartments.com/robots.txt">https://www.apartments.com/robots.txt</a> at the url box.</p><p>If the robots.txt allows full access it says as follows:</p><p><em>User-agent: *</em></p><p><em>Disallow:</em></p><p>If the robots.txt blocks all access, it contains the following:</p><p><em>User-agent: *</em></p><p><em>Disallow: /</em></p><p>And if the robots.txt gives partial access, it contains the following, where section stands for the sections that are not to be crawled:</p><p><em>User-agent: *</em></p><p><em>Disallow: /section/</em></p><p>In the case of apartments.com, the robots.txt contains the following , as of today:</p><pre># Ensure UTF-8 WITHOUT SIGNATURE- no BOM <br><br>User-agent: *<br>Disallow: /services/<br><br>Sitemap: https://www.apartments.com/sitemapindex.xml.gz</pre><p>This means we can crawl all the sections on the site except for the ones with apartments.com/services/ in the url.</p><p><strong>Step 2:</strong> Import the necessary libraries:</p><pre><strong>import</strong> <strong>requests </strong><br><strong>from</strong> <strong>bs4</strong> <strong>import</strong> BeautifulSoup<br><strong>import</strong> <strong>pandas</strong></pre><p>Requests is used in this example to get the html content, BeautifulSoup to parse the html, and pandas to make a dataframe and write to a csv.</p><p><strong>Step 3: </strong>Store the url you want to scrape to a variable. In this example, I go to apartments.com and type in Cincinnati, OH in the search box and press Go as in the screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*osVIebT6ArAPRjZAxPbsEw.png" /></figure><p>This makes my url change to <a href="https://www.apartments.com/cincinnati-oh/">https://www.apartments.com/cincinnati-oh/</a> as in the screenshot below and this is going to be my base url.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EqVCLB1jDhk4eAaZJLvvFQ.png" /></figure><pre>base_url = &quot;https://www.apartments.com/cincinnati-oh/&quot;</pre><p><strong>Step 4: </strong>Get the html contents from the page. This is done using the requests library</p><pre>r = requests.get(base_url)<br>c = r.content</pre><p><strong>Step 5: </strong>Parse the html. This is done with BeautifulSoup.</p><pre><br>soup = BeautifulSoup(c,&quot;html.parser&quot;)<br></pre><p><strong>Step 6: </strong>Extract the first and last page numbers. We need to be able to find the first and the last page numbers in order to be able to crawl through all of the pages on the website dynamically. To do this click on the paging section at the end of the page as shown in the screen shot below and right click to inspect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mLxWDzvc3j4rOxs53Q1LXA.png" /></figure><p>On clicking inspect, we get to see that the page numbers are inside a div id “paging” which is inside the div id “placardContainer” as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kt6SlnkJBVRed_PwTs7cRg.png" /></figure><p>The code below extracts the starting page number and the ending page number using these tags.</p><pre># To extract the first and last page numbers<br>paging = soup.find(&quot;div&quot;,{&quot;id&quot;:&quot;placardContainer&quot;}).find(&quot;div&quot;,{&quot;id&quot;:&quot;paging&quot;}).find_all(&quot;a&quot;)<br>start_page = paging[1].text<br>last_page = paging[len(paging)-2].text</pre><p><strong>Step 7: </strong>Make an empty list to append all the content that we get later on</p><pre>web_content_list = []</pre><p><strong>Step 8: </strong>Make page links from the page numbers ,crawl through the pages and extract the contents from the corresponding tags. We start a for loop to iterate through each of the pages.</p><pre><strong>for</strong> page_number <strong>in</strong> range(int(start_page),int(last_page) + 1):<br>    <br>    <em># To form the url based on page numbers</em><br>    url = base_url+str(page_number)+&quot;/.html&quot;<br>    r = requests.get(base_url+str(page_number)+&quot;/&quot;)<br>    c = r.content<br>    soup = BeautifulSoup(c,&quot;html.parser&quot;)</pre><p><strong>Step 9</strong>: Extract the header class for title and the location.Right click on the title and inspect. Below is a screenshot of the same. We can see that for the title of the property, for eg “Williamsburg Of Cincinnati”,the header class is “placardHeader”. We can see that the location is under the same header class further below.The tags in the rectangles in blue will be used later on to extract the exact values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BaIQxGx29oF_VqDrZ5P55Q.png" /></figure><pre><em># To extract the Title and the Location</em><br>    placard_header = soup.find_all(&quot;header&quot;, {&quot;class&quot;:&quot;placardHeader&quot;})</pre><p><strong>Step 10</strong>: Extract the section class for rent, no of beds and phone number. By inspecting the elements, we can see that they come under the section class “placardContent” as shown in the screenshot below.The tags in the rectangles in blue will be used later on to extract the exact values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SjJmNIidkYc0GrleRP_HHg.png" /></figure><pre><em># To extract the Rent, No of Beds and Phone Number</em><br>    placard_content = soup.find_all(&quot;section&quot;,{&quot;class&quot; :&quot;placardContent&quot;})</pre><p><strong>Step 11</strong>: Start a for loop to process property by property and extract the values of Title, Address, Price, Beds and Phone from the header classes and section classes. We extract the individual values by accessing into the inner most tag with the value. These inner most tags are shown in blue rectangles in the screenshots in Step 9 &amp; Step 10.</p><pre><em># To process property by property by looping</em><br>    <strong>for</strong> item_header,item_content <strong>in</strong> zip(placard_header,placard_content):<br>      <br>      <em># To store the information to a dictionary</em><br>      web_content_dict = {}<br>      web_content_dict[&quot;Title&quot;]=item_header.find(&quot;a&quot;,{&quot;class&quot;:&quot;placardTitle js-placardTitle &quot;}).text.replace(&quot;<strong>\r</strong>&quot;,&quot;&quot;).replace(&quot;<strong>\n</strong>&quot;,&quot;&quot;)<br>      web_content_dict[&quot;Address&quot;] = item_header.find(&quot;div&quot;,{&quot;class&quot;:&quot;location&quot;}).text<br>      web_content_dict[&quot;Price&quot;] = item_content.find(&quot;span&quot;,{&quot;class&quot;:&quot;altRentDisplay&quot;}).text<br>      web_content_dict[&quot;Beds&quot;] = item_content.find(&quot;span&quot;,{&quot;class&quot;:&quot;unitLabel&quot;}).text<br>      web_content_dict[&quot;Phone&quot;] = item_content.find(&quot;div&quot;,{&quot;class&quot;:&quot;phone&quot;}).find(&quot;span&quot;).text<br>      <br>      <em># To store the dictionary to into a list</em><br>      web_content_list.append(web_content_dict)</pre><p><strong>Step 12</strong>:Make a dataframe with the list and write the list to a csv file</p><pre><em># To make a dataframe with the list</em><br>df = pandas.DataFrame(web_content_list)<br><br><em># To write the dataframe to a csv file</em><br>df.to_csv(&quot;Output.csv&quot;)</pre><p><strong>Step 13</strong>: Now, we can find the Output.csv file in the working directory and it will have all the info in a structured manner. A screenshot of the first 5 rows from this csv is below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*7AROLlYvWaPt4jOlfkpDJw.png" /></figure><p>And we are done !</p><p>Github Link for the code:</p><p><a href="https://github.com/annmohankunnath/Webscraping/blob/master/Webscraping.ipynb">https://github.com/annmohankunnath/Webscraping/blob/master/Webscraping.ipynb</a></p><p>Happy Webscraping :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc9563fe8860" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>