One day, while looking out of his window, a flash of inspiration came to him. “You really want a lot of data for machine learning – the more the better. I was looking out the window at my bird feeder and I realised that there were probably hundreds of birds visiting it daily, so that would be perfect! I added squirrels to the mix because they are always hanging around the feeder, hoping they can figure out how to break in.”
And so, Mike began work on his Bird and Squirrel Detector, a marvellous make that utilises a Raspberry Pi, a High Quality Camera, some clever code, and Amazon Web Services image recognition (aka AWS Rekognition). Mike set his Raspberry Pi up to run PI-TIMOLO, a downloadable software module that watches for motion and takes a snap when it detects any.
“I have a Python program that runs on the Raspberry Pi that watches a folder for new photos. If it sees one, it makes an API call to AWS to send the photo to an AWS ‘bucket’,” Mike tells us. In AWS, he has a Python Lambda function (a cost-effective way of running code) that watches the bucket, waiting for photos. His Lambda takes the photo that just arrived and then sends it to Amazon Rekognition, which then uses its ML-based image recognition capabilities to try to assess what the photo contains.
“Amazon Rekognition replies with a list of ‘labels’ (that’s a machine learning term that describes what an ML algorithm thinks is in the picture),” explains Mike. “Then my Lambda code looks at the labels and decides if the image contains a bird or squirrel. Based on this, it sends a message to an AWS service called Simple Notification Service (SNS). You can subscribe to an SNS ‘topic’ and ask it to send you emails or texts. So I have one SNS topic for birds and another for squirrels, so I know what’s in each photo.”
Mike needed to tweak some of software parameters in order that the trigger to take the photo was just how he needed it. He wanted images of the birds and squirrels and not anything else. “You want to make sure you don’t miss good photos, but you don’t want to snap a picture every time a tree branch moves in the background, or you’ll end up with thousands of photos per day.”
In addition, he says, “The other bit of fine-tuning that took some time was filtering out all of the uninteresting labels Amazon Rekognition returned. It tells you everything it thinks it sees in the picture. So it won’t just identify animals, it will also tell you it sees a bird feeder, or a chair. Or it might tell you it sees trees and grass, which may be accurate, but you don’t care about that.” So, he built up a list of ‘uninteresting’ labels over time, and filtered them out so he was only informed of bird and squirrel sightings.
Mike describes the feedback he’s had from other makers as “amazing”, and is glad to share his insight into both the possibilities and limitations of AI. He’s also discovered the fantastic Raspberry Pi team spirit: “A cool thing about the Raspberry Pi community is that you can reach out to people and they will really help you.”