Smart Bird Feeder
Project intro
Project summary
The Smart Bird Feeder identifies birds and animals that visit the feeder, records their visits, and deters squirrels from stealing bird seed.
The bird feeder runs the camera feed through a MobileNet model that is quantized and thus compatible with the Dev Board's Edge TPU. Since it runs the model locally on the Dev Board the system does not require an internet connection. The Smart Bird Feeder is therefore ideal for remote applications—such as being in a birdhouse up on a tree.
This project describes how to mount the bird feeder in a custom birdhouse, and install the electronics in a custom enclosure attached to the birdhouse. If you do not have access to a 3D printer or laser cutting equipment, you can still follow the assembly instructions below to mount the electronics in an alternative enclosure.
How it works
The camera in the Smart Bird Feeder system runs continuously, providing the Dev Board with a video feed of the feed bottle, entrances, and sides of the birdhouse.
The clear acrylic structure of the birdhouse provides natural light to ensure a clear camera image. If you use an alternative enclosure, you will need to make certain the camera’s field of view (indicated with a gray triangle in the diagram on the left) has enough illumination.
The Dev Board receives images from the attached camera and uses the Edge TPU Python API to identify birds with machine learning inference. The video feed is processed through a MobileNet model, which identifies many different animals that come within the field of view, and the species of any detected birds. The system then outputs top inference results to a text file along with a timestamp. Still frames from the camera feed are saved to the onboard microSD card.
If the Smart Bird Feeder identifies a squirrel, it plays a loud sound through the system
speaker. The system logs time-stamped entries with the identifying information and stating deterrent sounded
. The log looks like this:
The system initially bases its identification of the animals frequenting the feeder on pre-built models processed using a Python script running on the Dev Board. However, these pre-built models have only generalized training. In our example script, the board can specifically identify a fox squirrel (an eastern fox squirrel or Sciurus niger). However, a native Douglas squirrel may also be mistakenly identified as a member of the previous species, simply because that is what the model predicts as the closest match. This identification will still trigger the deterrent sound, but may not necessarily be accurate enough for detailed species identification.
To address these inaccuracies, you can put the model through on-device training using photos of the local birds and animals to provide a more accurate model inference. This is described later in this document.
What you'll do in this tutorial
- Gather materials for, and then prepare and set up, the birdhouse, the electronics, and the software for the project.
- Assemble and install the bird feeder.
- Collect data.
- Improve the feeder’s accuracy by retraining the machine-learning model and testing it.
- Learn some troubleshooting tips.
- Get some suggestions on how to take things further by upgrading the electronics, modifying the model, and engaging with a community of developers using Coral products.
What you'll need
Required electronics
To identify the birds and animals visiting the bird feeder, you will need the Coral Dev Board and the Coral Camera, along with a power supply. The table below provides you with example part numbers and links for obtaining the parts, which are available from several sellers.
Description | Example Part Number | Product/purchase information |
---|---|---|
Coral Dev Board | 212-193575000077 | Product page |
Coral Camera | 212-193575000442 | Product page |
5 V 2-3 A USB C Power Supply | 358-1101001000045 | Example part |
Recommended electronics
To enable deterrent sounds for your Smart Bird Feeder or to store a large number of images, we recommend the parts listed in the table below.
Description | Example part |
---|---|
4 Ω, 3 W speaker | Adafruit 1314 (You could repurpose the speaker from the AIY Voice Kit) |
32 GB microSD card | Mouser 467-SDSDQAF3-032G-XI |
Electronics enclosure
To create the electronics enclosure we are going to use below, you will need a 3D printer.
If you do not have access to a 3D printer, you can use your own custom enclosure. However, you will need to ensure that the enclosure has vent holes to regulate the temperature of the board, and that the birdhouse allows enough light and an unobstructed view of the feed bottle for the camera.
The parts necessary for building the electronics enclosure are listed in the table below, with links to example parts and the relevant CAD file.
Description | Dimensions/example part |
---|---|
Enclosure top | 148×97×11 mm, 120,000 mm³ (3D printed) |
Enclosure bottom | 148×97×45 mm, 46,000 mm³ (3D printed) |
14x Self-threading M2X6 screws | McMaster-Carr 96817A844 |
4x M3 nuts | McMaster-Carr 91828A211 |
1x 1/4-20 nuts | McMaster-Carr 91845A029 |
Acrylic birdhouse (optional)
To fabricate the birdhouse, you will need a laser cutter and a 3D printer. The CAD data files are available online as mentioned above. The acrylic birdhouse described here is just one option for a container to hold the bird feeder and electronics. Alternative designs and materials can also be used, including any existing birdhouses you may already have. You will just need to make certain that the camera has a clear field of view with enough illumination as mentioned above.
The parts necessary for building the acrylic birdhouse are listed in the table below, with links to example parts and the relevant CAD files.
Description | Dimensions/example part |
---|---|
Birdhouse front | 6 mm acrylic, 396×304 mm (Laser cut) |
Birdhouse back | 6 mm acrylic, 396×304 mm (Laser cut) |
Birdhouse left | 6 mm acrylic, 200×231 mm (Laser cut) |
Birdhouse right | 6 mm acrylic, 200×231 mm (Laser cut) |
Birdhouse bottom | 6 mm acrylic, 400×200 mm (Laser cut) |
Birdhouse roof, left | 6 mm acrylic, 230×227 mm (Laser cut) |
Birdhouse roof, right | 6 mm acrylic, 230×227 mm (Laser cut) |
Feed holder bottle | 106×170×59 mm, 101,000 mm³ (3D printed) |
54x M3 nuts | McMaster-Carr 91828A211 |
2x Hinges | McMaster-Carr 1603A27 |
62x Truss head M3x16 screws | McMaster-Carr 92467A433 |
6x Long corner brackets | 20×20×190mm, 49,000 mm³ (3D printed) |
2x Short corner brackets | 20×20×70mm, 17,000 mm³ (3D printed) |
Zip ties | McMaster-Carr 7130K41 |
Mount plate | 195×180×35mm, 163,000 mm³ (3D printed) |
3x Mount option 1: #8 to #10 screw, 1½” length | Lowe’s #9×1½” lattice screws |
5x Mount option 2: #8 to #10 screw, 1½” length | Lowe’s #9×1½” lattice screws |
Files
Description | Download location |
---|---|
MobileNet V2 (iNAT Birds) model & labels file | Coral Models |
Bird feeder code & optional CAD (STP) files | Coral Smart Bird Feeder on GitHub |
Deterrent sound (optional) | Example: Royalty-free sounds from Sound Bible |
Recommended tools
- 1.5 mm flathead screwdriver
- T6 Torx® driver
- 5.5 mm nut driver
- #1 Phillips screwdriver
- #2 square drive bit
- Power drill
- 9/64” straight drill bit
- Diagonal cutters
How to build it
Time required
- Software set up: 30 minutes
- Assembly: 2 hours
- Acrylic cutting: 60 minutes (Optional. You can use alternative enclosures.)
- Birdhouse 3D prints: 36.5 hours (Optional. You can use alternative enclosures.)
Skills required
You will need some familiarity with working on the command line on Linux; with 3D printing & laser cutting (if you choose to use the acrylic birdhouse mentioned above); and with basic mechanical assembly. The code is written in Python and uses the TensorFlow machine learning platform, but you should not need to do much programming beyond the files we provide.
Step 1: Prepare birdhouse materials
1.1 Fabricate the 3D-printed parts
The first step towards building the birdhouse is to fabricate the 3D-printed parts (listed above) using the CAD files provided and a 3D printer.
Keep in mind that the system will attempt to identify anything within view of your camera. To avoid the birdseed bottle or brackets from triggering false identifications, you should use print material that is a different color from the birds in your area.
The following table lists the 3D-printed parts and the CAD files you will need for the parts pictured here. The process for 3D printing will depend on your specific printer. We recommend consulting the manufacturer documents for your printer if you don't already have enough experience with the process. Results should look similar to the parts shown in the picture here, depending on what material you use.
Part | CAD (STP) File |
---|---|
6x Long corner brackets | Link |
2x Short corner brackets | Link |
Enclosure parts (top and bottom) | Link |
Feed holder bottle | Link |
Mount plate | Link |
1.2 Laser cut the acrylic parts
As mentioned above, you will also need a laser cutter to fabricate parts of the birdhouse.
Use the laser cutter to fabricate each of the panels listed below. The Birdhouse laser.DXF CAD file includes specifications for each of the panels.
Cut the bottom panel.
Laser cut the right side panel.
Laser cut the left side panel.
Laser cut the front panel.
Laser cut the back panel.
Laser cut the left roof panel.
Laser cut the right roof panel.
Step 2: Assemble the electronics
2.1 Connect the camera to the Dev Board
Follow the official directions on how to connect a camera to the Dev Board.
2.2 Connect the speaker to the Dev Board
Use a 2 mm flathead screwdriver to secure the speaker wires to the Dev Board stereo terminal.
Insert the red wire into the right speaker positive (port 3), and the black wire into the right speaker negative (port 4).
You will need to check and ensure that the screw terminal is open prior to inserting the speaker wires.
Once the wires are inserted, clamp them into place by screwing down the terminal. Be sure to not overtighten these, as that can damage the terminal.
See the 4-pin stereo terminal section of the Dev Board datasheet if you need more information.
2.3 Insert the microSD card into the Dev Board
Make sure to push the card in far enough to have it click into place.
Step 3: Set up the software
Because you'll be installing the electronics into an assembled enclosure, you should verify that your electronics function the way you want them to before you install them in the enclosure. If necessary, you can change the code remotely later, but troubleshooting hardware connections will require disassembling parts of the installation.
3.1 Set up the Dev Board & hardware peripherals
1. Flash the board and connect to the board over SSH:
To get started, follow the steps listed in the official guide for getting started with the Dev Board.
Before proceeding further, make sure you have connected to your network successfully, as you will need to download files to your board.
2. Verify that the camera is functioning:
Test the camera setup by following the instructions in the Dev Board documentatiion for how to run a demo with the camera.
3. Verify that the speaker is functioning:
Verify that the speaker produces your selected sound clearly, by entering the following at the command prompt:
speaker-test -t wav -w /usr/share/sounds/alsa/Front_Center.wav -s 1
You should hear a demo voice state “Front center”. If you don't hear any sound, or if the sound is crackling, verify that the wires are seated securely within the screw terminals.
3.2 Configure the SD card for storage
1. Determine your SD card path:
You will need to verify that your SD card is recognized by the Dev Board, and determine the device path for the SD card. Use this command:
sudo fdisk -l
You should see output listing all the disks and devices available on your board, similar to the
example below. In this following example, the SD card inserted has a FAT32 format and is located at
/dev/mmcblk1p1
:
Disk /dev/mmcblk0: 7.3 GiB, 7818182656 bytes, 15269888 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 85B83F23-51C4-4403-8BAC-906FF5800F4E
Device Start End Sectors Size Type
/dev/mmcblk0p1 16384 278527 262144 128M unknown
/dev/mmcblk0p2 278528 280575 2048 1M unknown
/dev/mmcblk0p3 294912 15253503 14958592 7.1G unknown
Disk /dev/mmcblk0boot1: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mmcblk0boot0: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mmcblk1: 7.4 GiB, 7901020160 bytes, 15431680 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7a7c732a
Device Boot Start End Sectors Size Id Type
/dev/mmcblk1p1 2048 15431679 15429632 7.4G b W95 FAT32
Make sure you identify the correct drive. If you are unsure which drive is the card, remove the card, run the command again and see which drive disappears.
2. Create a mapping directory:
Create a directory to map your SD card to. For example, you can use this command:
sudo mkdir sdcard
You can name this directory whatever you prefer.
3. Mount the SD card:
Once you have a directory to map the storage device to, mount the SD card to that directory. In the example above, you would enter the command:
sudo mount /dev/mmcblk1p1 sdcard/
4. Update file permissions for the SD card:
Check that the card is mounted and read/write accessible. For the example above, you can enter this command:
sudo chmod 775 sdcard/
Changing the permissions as shown above enables users other than root to read and write to the SD card.
5. Edit fstab
to mount the SD card automatically:
In order to have the SD card mount automatically when the board powers up, you must add the SD card
mount instructions to the fstab
file. Open the file using your preferred editor. For our example,
and using the Nano text editor:
sudo nano /etc/fstab
Add the following line to the end of the file, save, and exit. Remember to use your own paths for the SD mount directory and partition.
/dev/mmcblk1p1 /home/mendel/sdcard vfat uid=1000,gid=1000,nofail 0 0
6. Reboot the Dev Board:
In order to apply the changes to fstab
, you must reboot your board. For example:
sudo reboot
Reconnect to your board once it boots back up.
7. Verify that card permissions have been updated:
Check that the card is mounted and read/write accessible. For example:
cd sdcard/
ls -al
You should see the read/write permissions present:
total 8
drwxr-xr-x 7 mendel mendel 188416 Jan 1 1970 .
drwxr-xr-x 7 mendel mendel 4096 Apr 29 18:47 ..
You should now be able to read and write to your sd card. You can test this by writing to a new text file, and removing it. For example:
echo "hello world" >> test.txt
cat test.txt
rm test.txt
3.3 Set up the bird feeder code
1. Download the code:
Run the command shown in this example to download the code bundle:
wget https://github.com/google-coral/project-birdfeeder/archive/master.zip &&
unzip master.zip && cd project-birdfeeder-master
You should see the following in the project-birdfeeder-master/
directory:
bird_classify.py
Birdfeeder.sh
Gstreamer.py
cad/
CONTRIBUTING.md
LICENSE
README.md
2. Download the demo model and labels files:
If you did not download the MobileNet V2 model and the corresponding labels file when setting up your Dev Board, run the command shown in this example:
wget https://dl.google.com/coral/canned_models/mobilenet_v2_1.0_224_quant_edgetpu.tflite && \
wget https://dl.google.com/coral/canned_models/imagenet_labels.txt
3. Source a deterrent sound:
If you don't already have a preferred deterrent sound, we recommend downloading a short 1-2 second
sample sound file. Push the file to
your device using mdt
from your host machine as shown here or download it directly onto the board:
mdt push sample_file.wav /devboard/path/to/project
4. Install the necessary libraries:
You will need to install the playsound
and svgwrite
libraries on the Dev Board using pip
. For example:
pip3 install playsound svgwrite
5. Verify that your file paths are correct:
Open the bash script file with a text editor and ensure that your file paths are updated to match your system's configuration. Thus, for example, using the Nano text editor:
nano birdfeeder.sh
If necessary, update the following paths:
--model <path/to/mobilenet/model>
--labels <path/to/imagenet/labels>
--storage <path/to/mounted/sd/card>
--sound <path/to/deterrent/sound>
The --print
flag enables detailed output to the terminal to help with debugging. We recommend
leaving this set to True
for initial testing and verification.
6. Make the script file executable:
The downloaded script permissions must be updated in order to run properly. To make the file executable, run the following:
sudo chmod +x birdfeeder.sh
7. Verify that the script will run:
Run the bash script:
./birdfeeder.sh
This script should produce output such as that shown below (assuming you have kept the --print
flag in the script):
W0422 20:57:54.034146 13493 package_registry.cc:65] Minimum runtime version required by package (5) is lower than expected (10).
v4l2src device=/dev/video0 ! video/x-raw,height=720,format=YUY2,width=1280,framerate=30/1 ! glupload ! glfilterbin filter=glcolorscale ! video/x-raw,height=125,format=RGBA,width=224 ! videoconvert ! video/x-raw,height=125,format=RGB,width=224 ! videobox autocrop=True ! video/x-raw,height=224,width=224 ! appsink name=appsink sync=False max-buffers=1 drop=True emit-signals=True
Frame saved as "img-0341599115.png"
Frame saved as "img-0341599211.png"
Frame saved as "img-0341599236.png"
3.4 Power down the board
Once you've verified that everything works, power down the board and unplug the power cable so you
can mount the board in the enclosure. Run the poweroff
command as shown below:
sudo systemctl poweroff
Step 4: Assemble the bird feeder
4.1 Prepare for preassembly
1. Insert nuts into the enclosure bottom:
The M3 nuts are for mounting the enclosure to the birdhouse. Seat them in the spots provided in the enclosure. Make sure they are fully seated.
The ¼-20 nut is for mounting the enclosure on a tripod.
2. Insert nuts into the short brackets:
The two short brackets hold the bottom to the front and back pieces.
3. Insert nuts into long brackets:
These two brackets take four nuts each. They hold the right roof piece to the front and back pieces.
4. Insert nuts into the long brackets:
These two brackets take seven nuts each. They hold the walls to the bottom piece.
5. Insert nuts into the feed bottle:
These four nuts help hold the bottle to the back of the birdhouse.
4.2 Build the electronics enclosure
1. Remove the SD card from the board:
The following assembly steps may risk damaging the SD card if it sticks out. Remove it for now.
2. Align the board on the enclosure bottom:
Orient the board with the heatsink nested on the enclosure base, and the ports lined up with the external holes.
Make sure to tuck the speaker wires where they won't sit on the heatsink, or be damaged by the lid.
Ensure the ports are aligned to the enclosure openings.
3. Install the speaker:
Align the four pins on the enclosure bottom with the four slots on the speaker flange (the frame holding the speaker). Push the speaker down into place by pressing only on the flange.
4. Fasten down the board:
Using four M2 self tapping screws, fasten the board to the enclosure.
5. Install the camera to the enclosure top:
Align the camera with the lens pointed through the enclosure front. Using four M2 self tapping screws, secure the camera in place.
6. Close the lid:
Tuck the camera cable under the speaker to avoid crimping it between the lid and the speaker.
Put the enclosure top over the bottom and fasten the six M2 screws around the perimeter.
4.3 Assemble the birdhouse
1. First corner:
Dry fit the left wall and the back to the bottom. Place a 7-nut bracket in place as shown and ensure the holes on the walls line up with the holes on the bracket.
Using six M3 screws, fasten the walls to the bracket.
2. Second corner:
Repeat the process you carried out for the first corner to attach the right wall to the back.
3. Third and fourth corners:
Repeat the process you carried out for the first corner to attach the front wall to the subassembly.
4. Reinforce the subassembly:
Align and fasten the two short brackets as shown here.
5. Fasten the bottom:
Flip the subassembly over, being careful to prevent the bottom from falling out.
Using eight M3 screws, fasten the bottom piece to the four corner brackets and the two short brackets.
Screw the short brackets to the base.
Screw the long bracket corner to the base.
Check the completed base to make sure it is firmly put together.
6. Plug in the SD card:
Before you put the roof on the birdhouse, install the electronics enclosure into the birdhouse.
Start by inserting the SD card on the board.
7. Connect the power supply:
Run the power supply cord through the hole in the housing bottom, and plug it in to the Dev Board.
8. Mount the electronics enclosure:
Using four M3 screws, secure the electronics box to the four slots on the right wall.
You can adjust the box upwards or downwards in the slots to adjust the camera view.
9. Secure the power cable:
Once you have finalized the position of the electronics box, you need to add strain relief to the power supply cable. To do this, make a loop with the cord and secure this to the second hold in the base with a zip tie. This will help prevent any animals from disconnecting the power supply.
Use diagonal cutters to trim the excess off of the zip tie, taking care to avoid the power cord.
10. Install the bird feed bottle:
Secure the bottle inside the back panel of the house using six M3 screws.
11. Connect the roof:
Connect the slotted roof piece to the house using two long brackets and eight M3 screws.
Using the hinges, secure the remaining roof piece to the slotted roof piece.
If you are concerned about rain/snow getting into the birdhouse, add a piece of tape over the roof seam.
Step 5: Install the bird feeder
Now that you have your birdhouse completed, it's time to install it where the birds can reach it. Keep in mind that you should install this in a location away from predators (such as at ground level, or near hiding spots for outdoor cats) in order to encourage birds to use the feeder.
5.1 Mount the birdhouse
We describe two options below for mounting the birdhouse fabricated above.
Option 1: Attach to a tree or wall using the mount plate
Measure and mark the surface where you want to mount the birdhouse:
Measure out the surface and space where you want to mount the birdhouse, ensuring that there is enough space for the completed birdhouse to fit. A spirit or laser level is useful in this regard, as shown in the figure.
Mark the 3 points for the screws using the mount plate as your template.
Drill pilot holes at the marked locations:
Use the 9/64” drill bit. Try to drill as straight as you can.
Screw in the mount plate:
Use the wood screws to install the mount plate. (If you are mounting on another kind of surface, you might need different screws.)
Line up and place the birdhouse on the mount plate:
Align the three nubs on the mount plate to the larger holes on the back of the birdhouse. Once aligned, allow the birdhouse to slide down until it rests fully on the plate.
Verify that the birdhouse is attached securely:
Make sure the birdhouse does not shake or wiggle in place. Animals may knock it around as they fly, jump, and climb in and out of the birdhouse.
If the birdhouse does wiggle, double check how the birdhouse is seated on the 3 nubs of the mount plate and ensure that it is secure.
Option 2: Attach to a stump or post
First find a suitable location:
The bottom of the birdhouse has five holes. These are meant for mounting to a 4x4 or equivalent wood post. A tall stump in the middle of a clearing would be a good choice.
Place the birdhouse on the post or stump you have chosen and secure it using the wood screws.
Drill pilot holes on the post or stump.
Install the birdhouse:
Screw the base of the birdhouse to a post.
The birdhouse is now mounted on the post.
5.2 Connect power to the system
1. Plug the power supply in to a suitable power source:
You may need to run an extension cable.
Keep in mind that squirrels and other animals sometimes chew on cables, so provide protection for the cable and minimize access to it by using cable covers or other means.
2. Verify that the board is powered up:
You should see the power indicator LED light up on the board through the enclosure.
3. Verify that the bird feeder is attached securely:
It doesn’t hurt to check that everything is still secure.
5.3 Add seed to the feeder
Different birds need different types of seed. Check online to see what types of seeds or dried fruit you should include to attract a variety of birds in your local area.
Keep in mind that if squirrels do get to the feeder, they may still eat quite a bit of the seed. Add enough food to ensure there is something for any hungry birds that may stop by after a visit from squirrels or other small animals.
Pour birdseed into the feeder as shown in the figure.
How to use the birdfeeder
Collecting data
Let the feeder run for several days
You will need to keep away from the feeder in order for animals to feel safe enough to approach it. Check on it occasionally to ensure that there is still enough seed, and that the feed is still dry.
Review logged data
Check on the feeder to review the data collected. The SD card will contain the captured snapshots from the camera, along with a results.log file. This file has entries each providing a time stamp; an associated image ID; the model identified; and the confidence of the model results.
2019-04-15 12:56:00,713 -Image: 0012338723 Results: [('Corvus cornix (Hooded Crow)', 1.6796875), ('background', 0.9453125)]
2019-04-11 19:07:15,075 - Image: 0087713445 Results: [('fox squirrel, eastern fox squirrel, Sciurus niger', 6.7578125)]
2019-04-11 19:07:21,964 - Deterrent sounded
If your model results do not accurately reflect what is in the associated camera image, you need to train your own custom model on-device, as described in the next section.
Captured image of a crow.
Captured image of a squirrel
Improving the feeder's accuracy
A common issue you may see with running the generic models provided is that items in the background are occasionally misidentified as animals. For example:
Captured image showing black feeder bottle that was repeatedly identified as a hooded crow (Corvis cornix) when using the precompiled MobileNet V2 (iNAT birds) model, as you can see in the results shown below. The model scores the identified object as more likely being a crow than part of the overall background.
To address this, we need to create a model more 'tuned' to our application. We can do this by retraining an existing model. The process for doing this is as follows.
Step 1: Retrain a model
1. Create a dataset from your captured photos:
Group the photos you have already collected into directories with appropriate identifying labels.
For example, if you have several photos of a bluejay and several of a robin, place all of the photos
of bluejays into a directory named bluejay/
, and the photos of robins into a directory labeled
robin/
.
The more varying photos of each label you can provide, the more accurate your model will be.
2. Create the custom model:
To create your new custom model, follow the process for how to retrain an image classification model on-device described in the documentation section of our website.
3. Update the birdfeeder.sh
script:
Update the birdfeeder.sh
script to use the .tflite
and labels.txt
file output from the last
step. Remember to remove the --training
flag as well.
Step 2: Test the new model
Run the new model for a few days and see if the accuracy of your collected results changes. If the accuracy does not improve, try creating a new model with a different dataset of photographs, or use a different embedding extractor to retrain the model.
Troubleshooting
If your bird feeder is not working as expected, try some of the recommendations below.
Data/photos are not being logged
- Verify that your SD card is fully inserted into the slot, and has not accidentally been ejected. It might help to remove it and then listen for the click when you reinsert it.
- Verify that the power connector is properly connected and not loose. SSH into the board to verify
that the script is not returning any error messages when running. You can also set the
--print
flag toTrue
in thebirdfeeder.sh
script to verify that the script is running as expected. - Ensure that there is still space available to store the data. Run
df <path_to_sd_card>
to verify disk usage.
No animals are coming to the feeder
- Keep in mind it may take some time for the birds to get used to the feeder, or to discover it. If it is installed near a place where there is a lot of human activity (or which is potentially accessible to predators like house cats), they may not try to access the food. Adjusting the location of the feeder may help.
- Try switching the bird feed. Not all species can eat the same types of seeds, and certain foods are not safe for wild birds to consume. For more information, check out some additional resources on feeding backyard birds.
Extending the project
Now that you've built a bird feeder that can classify birds in your area, consider additional upgrades and changes you could make.
Modify the functionality
To avoid scaring off birds along with the squirrels, consider replacing the deterrent horn with a motor controlled food dispenser that can be shut when a bird is not present. Squirrels are smart and will quickly learn to either ignore or avoid the deterrent sound.
Keep in mind that you may also need to take into consideration how much the deterrent bothers others (such as rabbits, prairie dogs, outdoor pets, yourself, or your neighbors). You could modify the code to only trigger the horn between certain hours, or add a light sensor that enables the system to only work during the daytime.
Alternatively, If you have several different types of birds present in your area, you could add multiple feeders to the birdhouse and use a custom model to dispense the appropriate species-specific food when a particular bird is identified.
Modify your model
If you are more interested in aquatic or land-dwelling creatures, you could build a waterproof enclosure to detect different types of fish in a local water supply, or identify various lizards and reptiles that wander by in a desert.
By changing what dataset your model has been trained on, you can identify different creatures. Using the MobileNet V2 (iNat insects) model and labels file, you could identify what bugs are frequenting your garden or, assuming you have a waterproof enclosure, you could build a fish identifier for your local streams or ponds.
Engage with the community
If you have more questions or would like to see what other developers are doing with their Coral products, check out the Stack Overflow community. You can also find additional example code for the Coral product line on GitHub.
About the creators
Toni Klopfenstein has been involved with open-source hardware for several years, and believes in empowering others in making and hacking. She is a Developer Advocate who currently focuses on Smart Home Actions at Google in Boulder, Colorado.
Minh-Nhat Le is a Mechanical Engineer and semi-amateur maker of things. In his spare time, he likes to think about what to eat next. Nhat currently works on Coral products at Google in Mountain View, California.
Is this content helpful?