Skip to content

mesadowski/RaspberryPi-Bird-Image-Recognition

Repository files navigation

RaspberryPi-Bird-Image-Recogition

Image Recognition using Raspberry Pi and AWS Rekognition. See my blog at mikesml.com for further details.

s3_send_bird_pic_crop.py is a Python program that runs in an infinite loop on a Raspberry Pi. It looks for new photos placed in a designated folder by PI_TIMOLO, and sends them to an S3 bucket. It also crops the files so that Rekognition works better. You need boto (the AWS Python SDK) installed, and also need AWS credentials stored in the credentials file in your .aws folder on the Pi. The Raspbery Pi should have a camera connected and also have PI-TIMOLO running. See https://github.com/pageauc/pi-timolo. There are constants for the path where PI-TIMOLO places photos, and also where we store cropped images, and where we place archived (processed) images. You may need to modify these for your situation.

BirdLambda.py is a Python AWS Lambda function that uses Amazon Rekognition, for image recognition. To set up the Lambda in AWS follow the instruction on the blog www.mikesml.com. This Lambda is triggered when a new picture is placed in an AWS S3 bucket by the Raspberry Pi code. Then, the Lambda calls AWS Rekognition to see what's in the photo. We filter our various uninteresting objects based on a list (you can add to this), and if the picture still seems to be interesting, we publish a message to an SNS topic so you can receive an email or text about it. There are different topics for birds and squirrels. You'll need to create your own SNS topics and enter their identifiers (ARNs) in the Lamdba as constants. The Lamdba function puts the interesting pictures in a different bucket, which is used for a static S3 website. You'll need to enter the name of the website bucket as a constant in the Lamdba if you want to do this.

BirdLambda_Rekognition_Custom_Labels.py is a Python AWS Lambda function that uses AWS Rekognition Custom Labels, which is a custom-trained model (BirdLambda.py uses standard Rekognition, which is not a custom model). You'd need to supply Rekognition Custom Labels with a collection of bird pictures (of birds common in your area), train the model, and then configure this Lambda to call your model when it gets a bird pictures in S3. I suggest starting with BirdLambda.py, using standard Rekognition.

Bird_ID_fastai_model.ipynb is a Python notebook for training a custom image recognition model, using the fast.ai library. This should provide more accurate bird species identification, although I'm not using it yet with my bird feeder. The results look promising (above 90% accuracy) but I'll have to work out how to deploy it at a reasonable cost.

config.py is a sample PI-TIMOLO config file. Yours will probably need to be adjusted for your situation, but you can start with this.

You can use the following approach to view the photos on a 'static' website in an AWS S3 bucket: https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-photos-view.html. The website is static in Amazon's sense of the word--it's a simple web site and in this case you just need an index.html file and a Javascript file. However the site isn't totally static because the Lamdbda function adds new pictures to the the website bucket if they are deemed interesting, and the new pictures show up on the web site. Getting this working with Amazon Cognito (a tool for providing temporary credentials so users can list and view the files in the website bucket) might take some fiddling if you're not that familiar with it, so follow Amazon's instructions carefully.

About

Image Recognition using Raspberry Pi and AWS Rekognition

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages