<?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 popoago on Medium]]></title>
        <description><![CDATA[Stories by popoago on Medium]]></description>
        <link>https://medium.com/@popoago?source=rss-d5d95bfff3ac------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Scx6-_U7Vatomx-kgLBGpg.jpeg</url>
            <title>Stories by popoago on Medium</title>
            <link>https://medium.com/@popoago?source=rss-d5d95bfff3ac------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 03:38:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@popoago/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[Detecting Fires using Tensorflow]]></title>
            <link>https://medium.com/analytics-vidhya/detecting-fires-using-tensorflow-b5b148952495?source=rss-d5d95bfff3ac------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5b148952495</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[google-cloud]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[popoago]]></dc:creator>
            <pubDate>Sun, 06 Oct 2019 14:40:37 GMT</pubDate>
            <atom:updated>2019-10-11T08:15:54.869Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*lyAKVTyRFqUhVPeOFVJaqw.png" /><figcaption>source: <a href="https://www.ft.com/content/1ba48b1a-cd69-11e9-b018-ca4456540ea6">https://www.ft.com/content/1ba48b1a-cd69-11e9-b018-ca4456540ea6</a></figcaption></figure><p>It goes without saying that taming fires was one of the greatest human achievements and brought us where we are today as a society. But despite its wondrous positives, unwanted fires are still a problem that we face everyday, and detecting them before they spread is absolutely necessary.</p><p>This article aims to use Machine learning to detect fires in videos, specifically talking about how to start on Computer Vision using Tensorflow’s object detection API and google cloud. Let’s get started.</p><p>PS: All the files relevant to this article are available in this github repository[<a href="https://github.com/popoago/Fire-Detection">here</a>].</p><h3>Background</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZeDQGWRoERxO9dW9Sqgc_w.jpeg" /><figcaption>source: <a href="https://github.com/tensorflow/models/tree/master/research/object_detection">https://github.com/tensorflow/models/tree/master/research/object_detection</a></figcaption></figure><p>Tensorflow’s <a href="https://github.com/tensorflow/models/tree/master/research/object_detection">object detection API</a> is an open source framework built on top of TensorFlow that makes it easy to construct, train and deploy object detection models. It has pretrained models available with easy to read documentation to help build and deploy powerful applications, and with support for <a href="https://www.tensorflow.org/lite/models/object_detection/overview">tensorflow lite</a> to help you run the model on your mobiles.</p><p>The API accepts images in either a png or jpeg format, along with the coordinates of the bounding boxes, specifically the xmin, ymin, xmax and ymax.</p><p>The dataset that I’ve used can be download from here:</p><p><a href="https://github.com/steffensbola/furg-fire-dataset">steffensbola/furg-fire-dataset</a></p><p>While the repository is no longer updated, it contains enough examples to get started. The first thing you’ll notice is there are multiple videos of both positive as well as negative examples along with corresponding xml files in the repository. The xml files contain the annotations(labels) associated with each frame in the video. Because the model expects data in the form of images and associated bounding box coordinates, we’ll have to convert above into <a href="https://www.tensorflow.org/tutorials/load_data/tfrecord">TFRecord file format</a>.</p><p>While there are files available to convert your data into the required format, such as <a href="https://github.com/tensorflow/models/blob/master/research/object_detection/create_pascal_tf_record.py"><strong>create_pascal_tf_record.py</strong></a><strong>, </strong>it might require modifications based on your dataset. Here, I’ve created my own script which reads each frame in the video and the corresponding annotation and stores them respectively in an image and xml folder, with every 20th image and xml being stored in separate folders for testing/validation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01895aa617218808ebfaa1501511d710/href">https://medium.com/media/01895aa617218808ebfaa1501511d710/href</a></iframe><p>The next step is to convert the xml files to a csv, which I have taken from this excellent <a href="https://github.com/datitran/raccoon_dataset">repository</a>, which is also the inspiration for this blog. Once the csv files have been generated for both the training and testing(validation) sets, we create TFRecords using <a href="https://github.com/popoago/Fire-Detection/blob/master/create_tf.py">this file</a>, giving us train.record and val.record files.</p><p>Along with the record files, we also need the label maps, which we define in fire_label_map.pbtxt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*8nAI3GW3TOhgtfY1Q4lY-Q.png" /><figcaption>It contains a single label</figcaption></figure><p>We also need to setup a project Google cloud to start the training. <a href="https://github.com/floydhub/object-detection-template/blob/master/object_detection/g3doc/running_pets.md">This repository</a> explains how to do it for <a href="http://www.robots.ox.ac.uk/~vgg/data/pets/">Oxford-IIIT Pets Dataset</a>, which I’ve edited accordingly for this particular problem. After following along the steps for creating the GCS bucket, we can upload the files that were created above to google cloud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*xwc0uCM4MITO8NjVKnF7pw.png" /><figcaption>upload tfrecord and .pbtxt files</figcaption></figure><h3>Training</h3><p>After setting up the input files, we can start with the training. The first thing we need to identify is the model that we’ll be using. There are excellent resources available explaining them, some of which I’ve mentioned at the end of this blog. The one that I’ve opted for is <a href="https://arxiv.org/pdf/1506.01497">Faster RCNN</a>, a widely used network architecture for object detection tasks. Even though <a href="https://arxiv.org/pdf/1512.02325">SSD</a> is relatively faster(ahem), the former offers better accuracy at the expense of speed. The first thing we have to do it edit the <strong>faster_rcnn_resnet101_coco.config </strong>file. Apart from changing the num_classes to 1 and editing the path for the checkpoint as well as the input and label paths. We can then upload this config file as above to out GCS bucket.</p><p>It’s always advisable to use pre-trained models for your problem. While detecting fire was clearly not one of the labels in <a href="https://tech.amikelive.com/node-718/what-object-categories-labels-are-in-coco-dataset/">COCO dataset</a>, the feature that the model learns and captures is almost always better than training from scratch. After downloading and untaring <a href="http://storage.googleapis.com/download.tensorflow.org/models/object_detection/faster_rcnn_resnet101_coco_11_06_2017.tar.gz">COCO-pretrained Faster R-CNN with Resnet-101 model</a>, we can upload these files to the cloud as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*2u-fG7pFGUYID_Pr-u1Qfg.png" /><figcaption>upload the weights and config files.</figcaption></figure><p>After following the remaining steps in the documentation, namely packaging the object detection code and writing a cluster configuration for our Google Cloud ML job, we can monitor the progress by running <a href="https://www.tensorflow.org/tutorials">Tensorboard</a> on our machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*MtQU6kYW0K4v4OeN2ukgJA.png" /><figcaption>starts training on Google cloud</figcaption></figure><h3>Exporting the model</h3><p>After the model has been trained, it needs to be exported to Tensorflow graph proto so that it can be used for inference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*NeVp5FFJ5oO0N8fPRot7jg.png" /><figcaption>replace the checkpoint number with wherever you stopped the training</figcaption></figure><h3>Next Steps</h3><p>While the model performed fairly accurately on the given dataset, because of the limited training images, it doesn’t give a great accuracy. Another factor that I missed here was the flickering that one will observe when working with videos, which I plan to take up in the future.</p><h3>References/ Resources</h3><ol><li><a href="https://towardsdatascience.com/deep-learning-for-object-detection-a-comprehensive-review-73930816d8d9">https://towardsdatascience.com/deep-learning-for-object-detection-a-comprehensive-review-73930816d8d9</a></li><li><a href="https://towardsdatascience.com/how-to-train-your-own-object-detector-with-tensorflows-object-detector-api-bec72ecfe1d9">https://towardsdatascience.com/how-to-train-your-own-object-detector-with-tensorflows-object-detector-api-bec72ecfe1d9</a></li><li><a href="https://machinelearningmastery.com/what-is-computer-vision/">https://machinelearningmastery.com/what-is-computer-vision/</a></li><li><a href="https://towardsdatascience.com/going-deep-into-object-detection-bed442d92b34">https://towardsdatascience.com/going-deep-into-object-detection-bed442d92b34</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5b148952495" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/detecting-fires-using-tensorflow-b5b148952495">Detecting Fires using Tensorflow</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>