Did you know you can make machine learning models with Wolfram Mathmatica which is bundled into the full version of RaspberryOS (raspbian)? Well you can.
To give you some background I have been implementing a security camera system using imagenode, imagehub, and imagezmq developed by Jeff Bass which in my humble opinion is just awesome. Jeff has written a very good installation guide so go have a look.
Once you have the nodes and the hub setup what you get is a detailed activity log on both the nodes and hub that is easy to parse and is rotated daily. Another feature is that the image folders are rotated daily also. And that's it the Desktop app or Web front end is on you. I chose the web frontend and developed a quick and dirty page using Svelte to show the last 25 pics along with some activity stats.
Now this setup does a wonderful job of detecting motion and responding to events. I have one monitoring my drive way and garage door but what I needed was a way to tell if the garage door was open or closed. I looked at pre-built models that google offers but found them lacking and would need to be retrained.
So while sifting through the mountains of Machine Learning tutorials out there I decided to take a break. I have recently started using the RPI 4 as my primary desktop so I decided to take a break and mess with this Wolfram Mathmatica. I have seen it bundled with the RPI for years but never messed with it. I noticed their project page and found this Facial recognition how to. Whaaaaaat is is really that easy. Just so happens I already had about 500 photos of garage door opened and closed. So I separated them into different folders and followed the tutorial. About an hour later it spit out a model that I can put up on imagehub to classify images. But how to do that?
Wolfram provides python bindings to the Wolfram engine,
pip3 install wolframclient
so running your new model on your RPI is really easy.
from wolframclient.evaluation import WolframLanguageSession from wolframclient.language import wl session = WolframLanguageSession('/usr/bin/wolfram') gdstatus = wl.Import("/path/to/model.wls) status = "" for gdpic in gdpiclist: picimport = wl.Import("/path/to/pic/to/classify.jpg") status = session.evaluate(gdstatus(picimport)) session.terminate()
As this is not the most optimal option to machine learning it is an easy, low install way of creating trivial machine learning models. Everything you need is already installed except for one package that is pip installable. I hope this helps someone.