Tag Archives: Lambda

All Your Face Are Belong To Us: DeepLens Challenge Day 5

Keep Hope Alive

This is Day 5 (for me) of the DeepLens Challenge, which I talked about starting in my post here.  I have to submit my project by February 12th or 13th.  I’m making progress toward my project goal, which right now is simply to recognize a face in an image cache from a live video feed using the stock face detection model on the DeepLens device.  Face and image recognition is pretty common place today, I guess, but I’m stoked to get something similar working myself.  I’d also love to integrate Alexa into the mix somehow as well, but I need to start making bigger strides with less messing about with the fiddly things!

Coding Challenges And Solutions

Some of the challenges I’ve faced, and (mostly) overcome, so far include:

  • Cropping a detected face out of the DeepLens video feed in the Lambda Python script.  Turns out this is very simple, but it took me a while to figure out.
  • How to convert the cropped face image to a jpg and write it to disk.  Also very simple in retrospect, but I’m a moron.
  • I thought it would be easy to write the resulting face jpg to AWS S3 from the DeepLens edge device, but this one I just could not figure out due to permission issues.  I can write to S3 using the aws cli as the aws_cam user, but so far I’ve not been able to extend those same permissions to the ggc_user account, which seems is what runs the awscam software.  I even hard-coded credentials in the creation of my S3 client in the lambda code, but still had permission problems.  I had to back-off from hacking on the device out of fear of really screwing something up, however.  Best to stay off the DeepLens as much as possible in retrospect.
  • The only way I was able to get a face image off the DeepLens and into the cloud so far is by converting it to a base64 String, putting into a JSON object, and putting it on the IoT Topic.  I worry that all this data transfer is going to cost me an arm-and-a-leg by the end of this thing…
  • When creating a lambda function to read from the IoT Topic, I kept getting a random error when trying to save it, which made no sense as I was following an AWS Blog Post for how to do the same.  Then I found this: https://forums.aws.amazon.com/thread.jspa?messageID=825417&tstart=0.  And this is what makes hackathons using new technology so fun!  Writing software is really just lots of Google Searches.

And speaking of the Internet of Things (IoT), to-date I’ve thought this was just another marketing buzz word that wasn’t going to pan-out, so to speak.  I used to think the same about ‘cloud’ (and still think this about Bitcoin and its ilk).  But this DeepLens development challenge is giving me a greater appreciation for IoT and edge computing.  In fact, we’ve been talking about the proliferation of internet connected things and the resulting possibilities since Java Jini, and probably before that, but I suspect Python will be its great enabler instead of Java at this point.  But I digress…

Baby Steps, But Machine Learning Learning No Where In Sight

So as of today, I am able to leverage the stock face detection model to detect and crop a face out of a live video feed from DeepLens, send it up to the AWS Cloud Lambda IOT Topic Listener, and put it into an S3 Bucket.  Next step is to try to figure out how to use the AWS Rekognition service to recognize face images in an image cache.

The Flow Zone

I’ve found listening to music particularly distracting these last few days.  However, I find this Horn Solo in Tchaikovsky’s 5th Symphony really soothing and not distracting (but too short).  I played this solo in Solo and Ensemble in High School.  I’ve been told that french horn players are better kissers…

AWS Serveless Computing Example: Wild Rydes Part I

I’ve been working through a tutorial I started in a session I took at AWS re:Invent 2016.  I did not finish the tutorial in class so I started working on it again after getting home from the conference.  The tutorial is on GitHub if you care to follow along.

Admittedly, I’m not the sharpest knife in the drawer(but I am made of the hardest, most persistent steel…they call me, ‘Blue Steel’ – said in my best Ben Stiller voice).  It took me a while to figure out why I could not get the AWS Javascript SDK to allow unauthorized users, vis-a-vis AWS Cognito, to access my DynamoDB Email Table.  Here are some errors and things I learned troubleshooting this:

The latest Firefox browser seems to give better clues about why things are not working in the Developer Console than Google Chrome.  Using Google Chrome, I kept seeing an error like, “Missing Credentials In Config”, and was really confused what exactly that meant.  I was following the tutorial exactly, as far as I could tell, so I could not discern whether this error was from a code change I made or an AWS configuration problem?  Then I looked at my website in Firefox, using the Firefox Developer Console, and could see a little bit better what was going on.

Here’s my main error as seen in the Google Chrome Developer Console:

And here’s the same error as reported by Firefox Developer Console:

Ahh!  So a ‘ResourceNotFoundException’ is being thrown.  Now I could see that my Javascript code probably wasn’t the problem and that my Cognito/IAM Role Configuration might be the culprit.

After further investigation..a day (or so) later…I discovered a simple typo in my DynamoDB Table Name:

The table name should have been ‘Wildrydes_Emails’.  Seriously?!?!  Yes, I’m an idiot (but one made of ‘Blue Steel’…).  Once that was corrected, I was finally able to get my unauthenticated Cognito Role to access my DynamoDB Table.

There is still work to be done in this tutorial, and I’ll blog about any issues I overcome as I encounter them.  My work is being hosted in my AWS account on Cloudfront, so feel free to check it out and submit your email to my DynamoDB database.  Let’s get this startup rolling!