<?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 Steven Leung on Medium]]></title>
        <description><![CDATA[Stories by Steven Leung on Medium]]></description>
        <link>https://medium.com/@stevenleung_25613?source=rss-220ad5a8d099------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2RI9HwVPR-8f7g2j.</url>
            <title>Stories by Steven Leung on Medium</title>
            <link>https://medium.com/@stevenleung_25613?source=rss-220ad5a8d099------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 20:49:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stevenleung_25613/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[Build Your Own Computer Vision Powered Door Camera]]></title>
            <link>https://medium.com/@stevenleung_25613/build-your-own-computer-vision-powered-door-camera-42b3277509b7?source=rss-220ad5a8d099------2</link>
            <guid isPermaLink="false">https://medium.com/p/42b3277509b7</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[smart-home]]></category>
            <dc:creator><![CDATA[Steven Leung]]></dc:creator>
            <pubDate>Sat, 30 Apr 2022 16:25:37 GMT</pubDate>
            <atom:updated>2022-05-19T13:53:25.525Z</atom:updated>
            <content:encoded><![CDATA[<h4>A DIY guide to a deep learning secured home</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8VBX0PirRSCBvY-W9WDOVA.png" /><figcaption>Image by author</figcaption></figure><p><em>This project and article was a collaboration between </em><a href="https://www.linkedin.com/in/juan-a-ramirez/"><em>Juan Ramirez</em></a><em>, </em><a href="https://www.linkedin.com/in/jroshan/"><em>Javed Roshan</em></a><em> and </em><a href="https://www.linkedin.com/in/steven-leung/"><em>Steven Leung</em></a><em>.</em></p><p>The residential door camera market has grown steadily in the past decade and is <a href="https://www.grandviewresearch.com/press-release/global-doorbell-camera-market">expected to reach $2.8B by 2025</a>. The major players in the market like Ring (an Amazon subsidiary), Nest (a Google subsidiary), Arlo and Wyze recognize this opportunity and have been making their products more intelligent and capable with each new generation. AI-powered functionality such as <a href="https://www.cnet.com/home/security/best-facial-recognition-security-cameras/">face recognition</a> and <a href="https://www.theverge.com/2019/8/27/20834488/google-nest-hello-video-doorbell-detect-package-deliveries-amazon-key-ring">package recognition</a> have become commonplace in these door camera systems, promising homeowners greater security through automated monitoring of what is happening outside the home.</p><p>While the production systems have steadily improved in their capabilities and accuracy, they do not offer the flexibility of a DIY system in terms of hardware (camera and compute) and custom model training. And of course, it’s just way more fun to DIY it.</p><p>Our smart door camera will use two models- one that can recognize known individuals through facial recognition and another that can identify whether an individual is a delivery (USPS, UPS, Amazon) or non-delivery personnel through full-body recognition. To achieve this, we will:</p><ul><li>Build and annotate our dataset for training.</li><li>Fine-tune <a href="https://github.com/ultralytics/yolov5">Yolov5</a> on our dataset using Amazon Web Services (AWS) Elastic cloud compute (EC2).</li><li>Load both the Yolov5 fine-tuned model and <a href="http://dlib.net/face_recognition.py.html">dlib’s</a> one-shot facial recognition model onto our edge device, an Nvidia Jetson Xavier NX, connected to a standard webcam.</li><li>Set up an SMS notification system using <a href="https://www.twilio.com/">Twilio</a> to send out appropriate notifications as live streaming video is passed through the models.</li><li>Package everything in a kubernetes-docker framework for ease of use.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uLbQop9J05TdWpy_" /><figcaption>Image by author</figcaption></figure><p>While we had specific recognition objectives in this example, the beauty of a DIY solution is that you can teach your camera system to recognize whatever you would like by modifying the training data and objectives.</p><h3><strong>Training to Inference: Data Pipeline</strong></h3><p><strong>Delivery Non-Delivery (DND) Recognition</strong></p><p>As anyone who has worked on a new object detection problem knows, more than half the challenge is collecting and annotating enough images to allow a model to train effectively. To address this we leveraged youtube videos licensed under the creative commons license for training images. We identified these videos using two sets of search queries- the first set related to delivery personnel, for example, “Door Camera Delivery”, “Ring Delivery”, etc., and the second related to non-delivery personnel. By doing some further manual review and clean-up of the videos, we verified that individuals appearing in the first set of videos could be labeled as delivery personnel while individuals in the second set could be labeled non-delivery. Frames were extracted at a 1 frame per second (fps) rate from each video. These frames served as our training, validation, and test data.</p><p>To address the annotation challenge, we used <a href="https://arxiv.org/pdf/1606.00915.pdf">deeplab segmentation</a> to identify the pixel coordinates of personnel in each image. Through this method of annotation, we were able to annotate ~10k images in a semi-automated fashion.</p><p>We chose to use Yolo (You Only Look Once) v5 for this task as it is one of the most effective quick and easy pre-trained model solutions currently available. Yolov5 accepts annotations in a specific format so the coordinates from deeplab segmentation were converted for Yolov5 to accept in the model.</p><p><strong>Facial Recognition</strong></p><p>Dlib’s face-recognition python api provides one-shot capabilities for highly accurate face-recognition, performing at 99.38% accuracy on the <a href="http://vis-www.cs.umass.edu/lfw/">Labeled Faces in the Wild</a> dataset. We just had to load this library onto our edge device along with images of the faces we wanted the system to recognize.</p><h3><strong>Evaluation</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9YMyybfJnAPzPrCn" /><figcaption>Image by author</figcaption></figure><p>We trained the model twice for 250 epochs each, first on a limited dataset and finally on our full dataset. The mAP@0.5 was 0.582 on our first run and 0.607 on our second. Each training run took around 22 hours on an AWS g4dn.xlarge EC2 instance.</p><p>Mean average precision was slightly higher for the delivery class than for the non-delivery class. A review of a sample of the errors reveals that the model mislabels delivery vs non-delivery in cases where individuals are further from the camera or in adverse lighting conditions. Additionally, the model also fails to identify a person at all in some cases. These errors are often related to individuals in unconventional poses or at the edge of the image frame.</p><p>The takeaway? Your training data matters. Many real-world problems won’t have data served up to you ready to go. This means that taking more than half of your project time on collecting an adequate volume of domain-specific, robust data is not unreasonable.</p><p><strong>Measuring Success</strong></p><p>In testing the model, we sought to simulate what would be considered the criteria for success in the real world. Since each individual at the door would be captured in multiple frames and thus, classified multiple times by the model, we grouped test image frames from each individual’s visit to the door into what we called “events”. While some of the frames in each event may be classified incorrectly, as long as the majority of the classifications being used to form a notification to the user were correct, the notification sent to the user would still be correct. Because of this, the event accuracy is actually more forgiving than the frame-by-frame accuracy.</p><p>Out of 1181 image files in the test dataset, 924 were classified correctly, 26 classified wrong and 249 were not identified as a person for a frame accuracy of 78%. However, when these frames were grouped into events and the majority classification of each event was determined, the model was correct 94% of the time, meaning the user would receive the correct notification.</p><h3><strong>Edge Inference and User Notifications</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3hOXx-c8CEsYdU3O" /><figcaption>Image by author</figcaption></figure><p>Inference is done on the Nvidia Jetson Xavier NX. The entire process is designed to run within docker containers in a kubernetes cluster. The architecture accommodates the dual model system. First, the live video stream is processed into frames stored locally. We use <a href="https://mosquitto.org/">Eclipse Mosquitto</a> message broker to publish messages to “Image Topic” in the format shown above, with the key information being the file path of the latest stored image.</p><p>The facial recognition and DND models both subscribe to the “Image Topic”. Upon message receipt, the models concurrently run inference on the image identified in the message. If the models recognize a person in the image, the output is published to the “Model Output” topic in the format shown. If a person is not recognized, no message is published.</p><p>The notification container is subscribed to the “Model Output” topic. Upon receipt of a message the notification adds the classification in the message to the cache. The cache is read every 20 seconds with the majority classifications received being output. We use <a href="https://www.twilio.com/">Twilio</a> services to send SMS notifications to the registered user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NDGjoc6ZAhlarAZL" /><figcaption>Image by author</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/0*1XVQjLtcHWJSGprj" /><figcaption>Image by author</figcaption></figure><h3>Conclusion</h3><p>While we hope this framework can get you going with your own custom smart home security system, this is only the beginning compared to what is possible. Some ideas we would love to explore:</p><ul><li>Continuous training of the model to continually enhance its predictive ability based on user feedback. This would involve pushing new image frames to the cloud as they come in and soliciting user feedback on the quality of the classifications.</li><li>Transition the hardware of the system to devices more appropriate for the use case. Switch out the wired webcam for a wireless IP camera and the Xavier NX for a low-powered and cheaper GPU edge device.</li><li>Incorporate more advanced functionality, such as deep learning video summarization that could provide the user with a full synopsis of everything that had occurred at their door for a given period of time.</li></ul><p>To try Knock-knock and see all our code, <a href="https://github.com/stevendleung/w251-project-door-camera-public">head over to our public GitHub </a>and navigate to the “To Run” section.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42b3277509b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>