[Alexandrina]
to take inventory of wildlife populations
and ultimately measure the health of biodiversity
in a non-invasive way using motion-sensor cameras.
These cameras take care of automatically snapping photos
when movement is detected.
But, the tricky part after is reviewing
each of the millions of photos and counting each species
as well as bad actors such as poachers.
[camera clicks]
This is where machine learning is of great help.
And so in this episode, we will share
how to build an image classification app for camera traps.
So let's dive in.
♪ [music] ♪
Thanks to data,
today, we can understand our natural world
with far greater richness than ever before
by orders of magnitude.
This now empowers us to build amazing apps
that can help us solve complex social and environmental challenges.
And so in this series, let's build an app together.
Meet Tanya from Google, where her and a team of volunteers
have done an amazing job at partnering with multiple organizations
to launch a successful image classifier for camera traps
along with a web app that lets anyone upload camera trap data
since it's fundamental in machine learning to use a lot of data.
And so sharing with as many organizations
is essential to research as many species as possible.
You can check out the website at
Wildlife Insights is a project that's a collaboration
between leading conservation organizations and Google.
And the bigger picture challenge that we're facing
is we've lost 68% of wildlife populations on average
since the 1970s.
Biologists, for a number of years,
about beyond several decades or even further,
have been using these things called camera traps.
This is a motion-triggered camera.
The animal walks by, and the camera takes a series of images.
[camera clicks]
So one of the challenges-- the data is siloed.
Oftentimes, it's housed in universities or research institutions.
And there isn't an easy way to share that data.
The second problem is it's really hard to process.
Like I said, you can be drowning in all of this data,
millions and millions of images,
and what you really need is the species of your interest.
So we have been working with the Google Cloud platform
to upload, to manage, and share, and store
all of this camera trap data, millions and millions of images
on the Google Cloud.
And then, we've been applying artificial intelligence models
to understand, make predictions upon what species is in what image.
This project is quite amazing.
And now, I will walk you through how to build a simple version.
Let's start with the main ingredients
for the hardware and the software.
From a hardware standpoint, we need a camera trap
taking photos that's connected to a microcontroller,
like a Raspberry Pi or Arduino.
This basically serves as a small Linux computer,
and will have an ML model we install
that labels images of species and omits blank images.
If it is able to connect to the internet via a cellular network,
it can send labeled photos automatically.
But in remote areas, you can carry the microcontroller
to a Wi-Fi-enabled area periodically to do this transfer.
As a friendly tip,
when managing a large fleet of microcontrollers,
it's handy to write a script that uses Cloud IoT core
in order to update all of your devices simultaneously,
rather than updating each device manually,
especially as the classification model is updated
with new data from the field.
Next is the software, which we will be using
cloud computing resources from Google Cloud.
I think one of the biggest challenges for this project
is building it upon a robust enough platform that it can scale,
and also that can handle the kind of inference
that we'll be doing when you have biologists
from all over the world that are uploading their data
and using cloud AI Platform predictions.
For this project, specifically,
the estimated cost per month is less than $30,
as of the making of this video,
and includes three gigabytes of images.
There are two main workflows in the solution--
one is a training model, and the other is classifying images.
And the two products that perform most of the heavy lifting
is Dataflow and AI Platform.
Let's start with Dataflow,
which is a serverless data-processing service
that can process very large amounts of data
needed for machine learning activities.
In this scenario, we use it to run two jobs.
The first job creates a database in BigQuery
by uploading two columns of the metadata
from the camera trap data set from
This is a one-time setup.
Those two columns contain the category of the label of the species.
The other is the file's name or the path where the image is located.
It also omits rows that do not contain relevant information,
which is an essential data preprocessing step.
The second Dataflow job makes a list of images
that would be great for creating a balanced data set.
This is informed by our requirements for selecting images
that have a minimum and a maximum amount of species per category,
to ensure that we train a bias-free model
that doesn't include a species it has too little information about
and is later unable to classify it correctly.
When this assessment is complete,
Dataflow proceeds to download the actual images
into Cloud Storage from that
This enables us to only store and process
the images that are relevant and not the entire data set.
This keeps computational time and cost down.
Next, we build a model with AI Platform,
which uses AutoML and the images we store in Cloud Storage.
Once the model is deployed, we can classify images.
Let's see what the model thinks about some of these images.
♪ [music] ♪
This is fantastic!
We have a model working.
Now, the next step is to upload it to each microcontroller
so that it classifies images locally.
Next time you want to upload these classified images from the field,
we can save them as JPEG files directly into Cloud Storage
and their metadata into BigQuery.
Note that you can optionally collect more metadata information
such as the camera trap's location, the date, etc.,
and build a simple dashboard
that you can report aggregated insights of species.
To recap,
And today, we took apart this case study
in order to inspire you to try to replicate the solution
for your own use case.
So what's next?
Well, I have appended in this video's description
several helpful links, including a link to a notebook
that contains all the code we used for this example,
which means you don't have to write any of it.
All you have to do is click
And finally, you can hit
if you found this content helpful,
and share what other AI for Good use cases you have in mind.
Thank you so much for watching, friends.
I'll leave you with Tanya's fun fact about this project.
Cheers.
A fun fact about working on this project
has been putting a camera trap in my very own backyard.
Yeah, we've caught all sorts of animals.
We've caught mountain lions, bobcats, foxes, deer,
of course, opossums.
And, yeah, it's really great to be able to teach my kids
about the wildlife in our backyard.
♪ [music] ♪