Skip to content

asteinig4018/BirdWatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bird Watcher

The project was the result of experimenting with machine learning with the end goal of deploying something onto a Raspberry Pi. The reason for birds is just that it was the first and easiest to use free dataset that I could also realistically test with a camera.

Technologies Used and Explored

  • TensorFlow (and TFlite)
  • YOLOv5 (Pytorch)
  • Docker

Components

Data Prep and Training

The Jupyter notebook (makeMode.ipynb) contains all necessary commands to retrieve and prepare the Caltech 2011 Birds dataset for YOLOv5.

I originally created it in Google Colab and that is where many of the image producing and plotting functions work correctly, but the functionality works across a variety of Jupyter notebook platforms.

Docker

Due to the size of the dataset and time required to train the model, I first looked into training the model on my local computer using Docker. The docker system works and can be easily modified to run with a local Nvidia GPU, but I don't have one, and CPU training times are unusably long. However, VSCode's devcontainer features worked really well with this Docker.

One note about Docker: local systems often have issues with Yolov5's workers. Disable them with --workers 0. CPU training can be similarly configured with --device cpu.

Saturn Cloud

I chose Saturn cloud as an alternative to Colab for training my model. The 30 hours of free GPU time per month are more than enough to train with a couple hundred epochs.

Deployment

The deployment folder contains everything necessary for deploying this model on a Raspberry Pi with a USB webcam as I did. It contains some trained models as well. I run mine in a python virtual environment with

python3 bw-deploy.py -m best-fp16.tflite

To cleanly exit, hit q while on the window with the image. CTRL-C has a tendency to get the camera stuck.

Debugging

OpenCV requires a bunch of packages and will give you weird errors until you install them all with apt-get. I tested this on an older Pi running Python 3.5 and was able to get all the packages.

If you see VIDIOC_QBUF: Invalid argument, this is a weird webcamera/threading issue that comes up. I've just been restarting my Pi and it goes away.

Credits/Links

YOLOv5

Caltech-UCSD Birds-200-2011

TensorFLow Detection Example

EdjeElectronic's Detection Example

About

An experiment with ML using YOLOv5 and TFlite

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages