It took 4 minutes for 911 to be called, let’s fix that with AI


Over the past year, the pandemic has had a massive toll on small businesses, my parents being affected by that. Running PurePages, a hotel-based Internet Service Provider (ISP), they were forced into laying off most of their staff. With that being said, my Dad stayed at work late at night wearing multiple hats from tech support to server maintenance. On the daily I would help my father out with the business and work on an IoT project with him (app-controlled vending machine)

My Custom Dataset
My Response

The AI 🤖

The creation process

Being completely new to Artificial Intelligence (AI), I had no idea where to even start. After some research, I found that TensorFlow would be the best language to use, combined with an algorithm called You Only Look Once (YOLO). Getting this to work is surprisingly simple! After a couple of days, I had trained my custom dataset to detect guns. As of now, it isn’t 100% accurate due to a lack of resources, but this will be fixed as I upgrade my PC.


I chose TensorFlow over other libraries like PyTorch for several reasons, with the main being compatibility with YOLO. Tensorflow is less object-oriented but has several more options, not to mention it’s fast training time. TensorFlow has also enabled me to future-proof my code, in the coming months, I aim to create a full computer vision software for hospitality, commercial, and restaurants with features including people count per store, mask detectors and anti-shoplifting measure. While TensorFlow is harder to learn, it is effortless to scale, which is necessary for my long-term success.


We all know computers don't think the same way people do, we need to first enable our machine to parse the images used, this is also referred to as Computer Vision.

The IoT 🌐

Starting the code

As mentioned earlier, down to the last day with my dad, we worked on a project to control a vintage vending machine from your phone. In light of my intentions for this project, I tried to use what we worked on together in this script. My last week with him was by far the most significant and memorable as I finally surpassed his knowledge in coding (for Arduino and APIs at least 😉), making myself genuinely useful in the process.


This part is completely from scratch since there haven’t been any proper projects utilizing an API with YOLO. By creating a fairly straightforward python script running Flask, I sent an image from my laptop to my desktop and received back the confidence score. Then I booted up an IP camera and did a GET command to quickly get real-time images and feed them through my custom dataset.



While adapting the code, I instantly felt the frustration of my dad’s old school PHP work. I ended up doing all my API calls locally on the same computer and feeding the response directly to an Arduino turning on and off an LED. This is easy to replace with a calling module to notify 911, but I'm sure they wouldn’t appreciate all my tests :)

How you can do the same 🤯

Using Google Colab, we can take advantage of cloud GPUs and a Linux based Virtual Machine (VM).

My next steps ➡️

The very first thing I will do is retrain the model. The resources I need won’t come for several weeks, but upon arrival, I will retrain my custom dataset to pick up on a gun being pulled out much quicker.

Connect With Me!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store