Monkey Detector web service!

The monkey detector is temporarily live as a web service (I’m using the free version of Roboflow for image recognition – to save on server resources – so it will run out at some point)

Try it out! Send an image via curl like so*:

curl -X POST -F "file=@image.jpg" http://detect.devsoft.co.za/vision

For example if your filename is monkey.jpg then it’s “file=@monkey.jpg” You should see True or False as a response in the terminal.

Successful monkeys detected will be displayed on this web page: detect.devsoft.co.za – just re-fresh the page after your POST request.

This service will eventually be part of the Monkey Squirter project.

*please be nice and don’t spam my service, right now the server is pretty overloaded and running low on resources!

Goodbye Fritz.ai, goodbye proprietary online services

Fritz.ai “sunsetting services”:

Fritz.ai is (was) a cool service for, in particular, making machine learning apps easily. The marketing hype was slick, and they roped in a lot of developers to help them push their service to many devs, particularly in the Android space, with paid articles on medium, and on their website.

First of all, I have to say, I take full responsibility for this, and I don’t blame anyone at Fritz.ai for my problems, it’s their service, they can do what they want – but I wasted a lot of time learning how to use their api, publishing my own (unpaid, no affiliation) posts about the service, and using it in apps published to the play store. Their business model seemed clear – free to use but once you reach a threshold you have to pay for the service. Seems legit, probably was legit.

My Android apps didn’t take off, so I never reached that threshold, never ended up paying for anything at all – but I did waste a lot of time making apps using a service which is getting switched off at the end of the month (August 2021). In other words, my apps are going to be switched off, for the (very) few users who did install them. If I want to continue with these apps, they will need a substantial re-write. In many ways I’m lucky that the apps were not successful!

So I have learned a valuable lesson here:

The lesson is: don’t trust your work to “flashy” or “new” products and services. I could have spent a week back then just learning the ins and outs of tensorflow on android, and done it myself. Just because I’m lazy doesn’t mean I’m stupid. Lesson learned.

*here is the full unedited email for those who are interested – I still don’t see any mention of this on their site or blog:

We’re Sunsetting Fritz AI


Service will end August 30, 2021


Hello,

This email is to let you know that we will be sunsetting the Fritz AI mobile machine learning platform, effective August 30, 2021.

What does this mean for my account?

As always, any custom trained models, datasets and annotations are exportable. Please see this documentation for how to export datasets and models.

After the sunsetting date, access to the Fritz AI SDK, webapp, API, and hosted services will be discontinued. All models, datasets, and resources stored in Fritz AI will be removed.

For mobile apps, the Fritz SDK will lose API connectivity, but on-device model inference should continue to function. Regardless, we advise you to update your apps, removing the Fritz SDK and models.

Snapchat lenses do not depend on the Fritz SDK nor API, and lenses should continue to function as before.

Why are we doing this?

Fritz AI’s mission has been to make the power of machine learning solutions available to mobile developers. When we started in 2017 there were few options available. In the following years there have been many great entries to the market such as ML Kit, Create ML, MediaPipe, Lobe.ai, MakeML, Firebase ML, and more. Now there is a mature ecosystem of tools, including free and open source options.

We understand that this decision will have significant consequences for our community, but we truly believe the wide range of incredible tools and resources out there will empower you to continue on without Fritz AI.


Sincerely,

Dan & Jameson
Founders, Fritz AI

Monkey Detector Circuit and App

It’s been a while since I was so excited about a project. After much struggle (to do with a very hot voltage regulator) I have come up with a working circuit for the hosepipe tap trigger.

I was hoping to power the whole thing from 12 volts but the voltage regulator was getting a bit hot, and my main directive for this whole project is to not spend any money (otherwise I would have a relay shield like this one instead of the bare 5v relay which I had to trigger with a transistor)…

The other exciting thing was the Android app. I decided to create a stand-alone app which recognizes monkeys to put on the play store. Right now it plays a loud siren sound when a monkey – or baboon – is detected. I can’t even count how many times it would have been useful to have a simple alert which would warn me about vervets attempting to break in on the other side of the house.

Don’t get me wrong, I love the monkeys. They are really interesting to watch, their kids play in our yard, they do tight-rope on the telephone wires, and the troupes have all-out warfare sometimes on the road. The other day we found out that our neighbor’s dog has a pact with the monkeys: they open the bin for him and he helps them eat the contents. Just some monkeys and a dog getting along just fine!

So the Android app is pending review, it’s called Monkey Detector, I will add a link to it when available. My third play store app!

Update: Monkey Detector on Google Play Store – unfortunately some devices are having a problem where the app isn’t playing the alert sound. I am looking into this (it works on my phone…)

Monkey Detector – image for app icon

Mobile Monkey Detector

It’s amazing how machine learning has improved over the last few years. I was dabbling with TensorFlow for a while, then moved on to look at pyCharm, but ultimately I was going to go with the easy-to-use Google image recognition API for the mobile version of my monkey detector.

Then a few days ago I stumbled upon fritz.ai and their even easier-to-use pre-trained mobile classifier. Unfortunately the example was written in Kotlin, but anyone developing an Android app today should know that, so I gave it a go. Here is the tutorial on Medium (with link to Kotlin code on GitHub) https://heartbeat.fritz.ai/image-labeling-on-android-in-kotlin-using-fritz-ai-and-camerax-1466089b2e34

The current version of the app (detects monkeys but doesn’t send a signal to my WiFi connected sprinkler system yet) is here: circusscientist.com/seeMonkey.apk – now available on the Google Play Store!
In order to use it you need to give camera permissions before first run, otherwise the app will force close. Just point it at a monkey and get alerted* (pictures of monkeys work fine)

*If you are wondering what happens, my 6 year old son shouts “Hey you, get away from my lunch!” when a monkey is detected.

The next step is to adapt my Arduino controlled tap valve (more on this to come soon) to receive WiFi (using ESP8266 of course) and then send the signal from the app (in Kotlin…!)

I can’t wait to make the demo video, those monkeys are trying to get into the bin (and our house) every day, and they hate getting squirted.

Progress with Monkey Detector

So I have been working on the vervet monkey detector idea for a little while now. So far I have had some success with the back end. Here is an update on how it works so far. (tldr I used Google Cloud Vision api and some bash scripts)

  • 1. I take a photo of the monkey (I still need to automate this, with motion detection)
  • 2. Upload to my server using scp
  • 3. Some moving around on the server to make the image public for Google Cloud Vision to see it – using inotifywait and mv
  • 4. Google cloud vision api call with image url using curl
  • 5. To do: parse json response from google to check if a monkey is actually there.
  • 6. Send a signal to wireless valve (switches on the sprinkler and hopefully gives the monkeys a fright) – I have built one already, just need to modify the code slightly for wireless. Thinking of using esp8266 for this, since I have so many lying around, and a 12v battery since the tap valve solenoid runs off of 12v. I have a nice circuit board I built for my wireless poi which incorporates an ESP-01 and a voltage regulator. Add in a relay to switch 12v and it’s done.

So there is much to do. There is also the question of accuracy, obviously I don’t want any false positives wetting any unwary visitors, so I need to test this a lot before using it. The first version will trigger an alarm only, which in itself could be useful as a phone app, for example. We might be able to leave the windows open on occasion, with a monkey detector to alert us when one tries to get in and steal our food (this happened twice in the last week)

At some point I will have to make my own machine learning classifier for monkey images, as Google charges $1.50 currently per 1000 images classified. The first 1000 are free, but they have a habit of changing the pricing on their products without notice.

Security and Monkey Business

Just wanted to mention a couple of projects in the pipeline for 2019.

I recently moved house and it’s a great opportunity to look at home security. In South Africa this is quite an important topic. Most homes here have burglar guards but while these may go some way to delaying an intruder they are by no means fool proof. An alarm provides an added layer of protection, especially if you are asleep, or not at home. The cheapest alarm I could find cost R2000 (around $150) but all it does is blare a siren. For a proper system which will alert you it’s significantly more pricey.

Of course I have so many microcontrollers around so I have started looking at the options of making my own super secure system. A friend has made his using an Arduino Uno connected to magnetic switches on the doors and windows. A GSM module provides connectivity, so both he and his security company receive SMS alerts if an intruder gains access. The whole thing is one long circuit with wires connecting every switch (this is true of many commercial home alarm setups as well) and each “zone” can be bypassed or set by sending an SMS code.

I made him an Android application to send the codes so that he doesn’t have to type them in manually any more but with my system I am hoping to eliminate the wires entirely as well. Not sure yet about the GSM module, SMS cost more and you need a dedicated SIM card (also I don’t have one and would have to order).

So it’s wireless, ESP8266 to be exact. I have been looking at mesh networks (the wifi doesn’t quite extend to every corner of the house) and have settled on painlessMesh as the best one. Each node in the network will consist of one ESP-01 connected to a battery and some sort of spring switch (or possibly a tilt switch) which will be turned on by the opening of a door or window. As soon as it is turned on, the node will send a message, alerting the main (always on) node that something has happened, possibly triggering the alarm (and sending me an SMS, email or some other notification). This way the battery is not draining all day, only when it is needed.

The other problem at my new place is a bit more novel, we have a monkey problem. Situated near a nature reserve the birds and butterflies are prolific but Vervet Monkeys come in and poke through our trash on a daily basis. I found a manual method at https://www.wikihow.com/Repel-Monkeys-from-Residential-Areas – just tie your bin shut with slinky cables but the monkeys are so brazen, they steal our bananas from inside the kitchen as well. Basically as soon as you hear them it’s total lockdown, shut all the doors and windows and with the heat here that’s not great.

Image below: Monkeys on my car. One of them took a dump up there, which was the last straw for me.

My plan is to leverage Google’s Cloud Vision API to assist here. The image recognition works great for monkey detection (try it yourself here: https://cloud.google.com/vision/) – I upload a still from a webcam if motion is detected and then Google will tell me if a monkey is present. If one is, on come the sprinklers. The garden gets watered and the monkey runs away. Vervets hate getting wet, we have water squirters stationed at each entrance.

The only issue is Google’s pricing, it’s $1.50 per 1000 images scanned (after the first 1000 per month free). Ideally I would be creating my own recognizer with Tensorflow and using that but my CPU can’t handle this currently. Not to mention the time it takes. So Google it is. For now.

So.. lots to do, much code to write. Let me know what you think, if you have anything similar to share, or ideas for me to try.