The first thing you will do is train a Machine Learning model so that Lobe can recognize your cat or cats. If you only have a single cat, you will want to train it for Cat and No Cats and the code should work fine without any changes.
Take Some Photos
First, you will want to capture some photos of your cat in the place it shouldn't be. Cat treats work well for enticing the cat to hold still while taking photos. You will want to get as much variety as possible in the photo content, so that Lobe is able to more accurately detect if a cat is there or not in a variety of different conditions.
You can vary it by moving around different dishes and taking it from different angles. You will want to take photos from where you are planning on keeping the setup for better accuracy. You may also want to have your cat facing various angles.
Collect your images in Lobe
Once you are happy with your photo set, download and install Lobe from the link below:
Open Lobe and create a new project.
From the top right, select Import and choose Images in the drop-down menu.
In the Bottom Left corner, add a label such as Cat
, No Cats
, or Multiple Cats
. If you use different names, you can always change them in the code to reflect the labels you chose.
Go ahead and add at least 10 photos per label and try and keep it to 2-3 labels. The more photos that you use to train each label, the more accurate the predictions will be. Remember that you will need a diverse set of pictures without cats as well because the items on the counter tend to change over time, so a pot that it doesn't recognize could be confused for a cat.
Test your model
In Lobe, switch to the Use tab in the left menu and select either Images to test new images or Camera to test what the camera is seeing.
Click the green button when your model predicts the correct label. This will add the image with the correct label to your dataset.
Click the red button when your model predicts the wrong label. You can then provide the correct label and the image will get added to your dataset.
If you find that one of the images is consistently confusing the model, try collecting more images for the corresponding label.
Export your Model
Next, export your Lobe model to use on the Raspberry Pi. We'll use TensorFlow Lite which is a format that is optimized for mobile and edge devices, like the Pi.
In Lobe, navigate to the Use tab and click Export.
Select TensorFlow Lite and select a location to save the model. We'll transfer the model to our Raspberry Pi later in the next step.
Text editor powered by tinymce.