Hi!
In this tutorial I’m going to show you how I made the bAIwatch. This device is capable of being connected to the webcam located in a beache where I usually go surfing, while it evaluates the state of the waves and lets me know, thanks to the vibration of a solenoid, when the conditions are good to leave everything, take the board and go surfing!
Step 1: Downloading Images.This project is based on an image classifier. The first step was collecting a good amount of pictures of the spot, with the aim of gathering images of every possible conditions: sunny days, cloudy days, heavy rain days, soft rain days...
For this, I used the notebook below (pictureDownloader on Code section) on Google Colab (I’ve changed the target webcam url of the script). In this case, I'm using urllib to download the.jpg files directly to Google Drive -for other webcam configurations you may have to use Selenium-.
Step 2: Preparing the DataAfter collecting data, I made another script (imageClassificator on Code section) to make a manual classification for preparing the dataset.
I made three categories:
1- Good waves, with all the images with acceptable waves.
2- Bad waves, with both photos of calm and shattered seas impossible to surf for me.
3- Discards, with all the photos that don't point to the place of the beach that I'm trying to analyze (because they point to another place on the beach, the parking lot... whatever).
Once I had all the downloaded images on those 3 categories I started training the AI. For this, I used this notebook as a guide:
https://www.kaggle.com/vincee/intel-image-classification-cnn-keras
The result was quite good, with 84% accuracy. Here you have the confusion matrix, where you can see the result in a more graphic way:
After that, I just put it inside a raspberry pi 3. Here you can find a guide to install tensorflow 2.2 on it.
https://github.com/sagarrabanana/Install-OpenCV-and-TF-2.2.0-on-RPi-3
Remember that you must downgrade the version of tensorflow on Google Colab before training the AI.
Here you have the adapted code I made for the raspberry (mainScript on Code section). You must configure the RP to run this script automatically when the RP is turned on.
I also made a cool box and assembled everything inside.
Here you have the schema.
I hope you like the project! This may not be the best documentation, but I think it can be very handy if you are trying to replicate it.
Of course, you can contact me for further information!
Comments