ML-based Bird and Squirrel Detector
By Nicola King. Posted
New York-based Mike Sadowski had been interested in machine learning (ML) for some time and wanted some original images that he could feed into an ML algorithm: “I was interested in the challenge of trying ML with real data, not a canned data set,” he explains.
Advertisement
Get started with Raspberry Pi – everything you need to know to start your journey!
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.”
Eagle eye
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.”
Winging it
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.”
Subscribe to Raspberry Pi Official Magazine
Save up to 37% off the cover price and get a FREE Raspberry Pi Pico 2 W with a subscription to Raspberry Pi Official Magazine.
More articles
Get started with Raspberry Pi in Raspberry Pi Official Magazine 161
There’s loads going on in this issue: first of all, how about using a capacitive touch board and Raspberry Pi 5 to turn a quilt into an input device? Nicola King shows you how. If you’re more into sawing and drilling than needlework, Jo Hinchliffe has built an underwater rover out of plastic piping and […]
Read more →
Win one of three DreamHAT+ radars!
That’s right, an actual working radar for your Raspberry Pi. We reviewed it a few months ago and have since been amazed at some of the projects that have used it, like last month’s motion sensor from the movie Aliens. Sound good? Well we have a few to give away, and you can enter below. […]
Read more →
RP2350 Pico W5 review
It’s Raspberry Pi Pico 2, but with a lot more memory
Read more →