-
11. Overview of instructions for building the Elephant AI System
-- First of all we will build Elephant Detector software using TensorFlow’s Object Detector API. This elephant detector will examine images which are sent to it and report if they are elephants, and if so which type of elephant they are (e.g. male elephant, baby elephant)
-- Next we need to build hardware and software that can acquire images when motion is detected, both in daytime and nighttime conditions, and pass these images to our elephant detector. This component of the system is the elephant detection device. There are two elephant detection devices: a dayPi to acquire images during conditions with natural light, and a nightPi to acquire images in the dark. The dayPi has an IR filtered camera, whilst the nightPi has a NoIR (no IR filtering) camera, and thus relies on infrared LEDs to illuminate the scene.
-- At this stage we have a system that can detect whether or not images it acquires in daytime and nighttime conditions contain elephants.
-- Now we need to make an addition to the elephant detection device. We need to allow it to communicate its findings to local people! We do this by adding mobile phone network connectivity to the device. Now the device can alert local people by sending them an SMS that contains information pertaining to the location at which elephants have been sighted!
-- Next we need to provide a battery and solar charging circuit to these elephant detection devices so they can operate without people having to change their batteries every day!
-- At this stage we have a system that can detect if elephants are present, alert local people as to their location, and function independently per power.
-- Next we need to build an elephant deter device. This device will attempt to repel elephants by playing audio of animals they dislike! For example, bees! We need to build hardware and software for this device. It will communicate with the elephant detection device using bluetooth. It may require its own battery and solar charging circuit in some scenarios, in others it can share these with the elephant detection device that is physically close (e.g. <50m)
-- At this stage we have a system that can detect if elephants are present, alert local people as to their location, repel elephants using sounds they dislike, and function independently per power.
-- Finally we need to provide multiple housing solutions for each component of the system. These need to be waterproof.
-
22. Elephant Detector
Elephant detector software
What are some of the approaches we can use to make an elephant detector with CNs?
Elephant Detector Approaches using CNs https://hackaday.io/project/20448-elephant-ai/log/68344-elephant-detector-approaches-using-cns
#software elephant detector: transfer learning off-shelf model with TensorFlow https://hackaday.io/project/20448-elephant-ai/log/68436-software-elephant-detector-transfer-learning-off-shelf-model-with-tensorflow
Here we just detect elephants with an off-shelf model, without doing any training:
#software installing on Rasp Pi, and detection w TensorFlow & Keras (off-shelf) https://hackaday.io/project/20448-elephant-ai/log/68401-software-installing-on-rasp-pi-and-detection-w-tensorflow-keras-off-shelf
Image classification with TensorFlow using Inception trained on ImageNet 2012 dataset https://hackaday.io/project/20448-elephant-ai/log/58958-image-classification-with-tensorflow-using-inception-trained-on-imagenet-2012-dataset
Here are some of the classical machine vision approaches we tried!
Summary of python code for Object Detector using Histogram of Oriented Gradients (HOG) and Linear Support Vector Machines (SVM) https://hackaday.io/project/20448-elephant-ai/log/58448-summary-of-python-code-for-object-detector-using-histogram-of-oriented-gradients-hog-and-linear-support-vector-machines-svm
#5 result for object detector using Histogram of Oriented Gradients (HOG) and Linear Support Vector Machines (SVM) https://hackaday.io/project/20448-elephant-ai/log/58816-5-result-for-object-detector-using-histogram-of-oriented-gradients-hog-and-linear-support-vector-machines-svm
1. So let's get started by performing transfer learning on an off-shelf model just using TensorFlow. We'll be doing this using an Amazon EC2 virtual machine. You can go ahead and SSH to to it from a Raspberry Pi if you want, or use another kind of computer. I used a laptop running Ubuntu. We detail what to do in this guide: https://hackaday.io/project/20448-elephant-ai/log/68436-software-elephant-detector-transfer-learning-off-shelf-model-with-tensorflow
Remember you are adding some new elephant classes to the off-shelf model! So you will need to obtain as many images of the new elephant classes as you can! I had around 1000 for elephant herd and lone elephant class. It however, was difficult to obtain sufficient images for classes such as elephant calf, lone male, lone female, and night elephants! I'm working on this at the moment.
2. Ok, now you have performed transfer learning on an off-shelf model, and have got back your graph file, and labels.txt, you will need to move these files to the elephant detection devices. Probably easiest using a USB storage device, but you could SSH them too.
3. Now we need to install TensorFlow on the dayPi and nightPi detection devices! Ok, so the pre-built binary is for a Raspberry Pi 3 running Raspbian 8.0 ("Jessie"). So make sure you are running that OS or else there may be problems! This is for Python 2.7.x
4. Download the wheel file with the command:
wget https://github.com/samjabrahams/tensorflow-on-raspberry-pi/releases/download/v1.1.0/tensorflow-1.1.0-cp27-none-linux_armv7l.whl
Note, this is from https://github.com/samjabrahams/tensorflow-on-raspberry-pi | and there are several issues regarding installing TensorFlow on a Pi which I should mention e.g. https://www.bountysource.com/issues/28311275-tensorflow-on-raspberry-pi ; issue with bazel build here: https://github.com/samjabrahams/tensorflow-on-raspberry-pi/issues/85
** this is from TensorFlow for MakeFile so to build on a Pi:
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/makefile
5. Now you can use pip to install it with the following command:
sudo pip install tensorflow-1.1.0-cp27-none-linux_armv7l.whl
6. Uninstall and reinstall mock
sudo pip uninstall mock
sudo pip install mock7. Ok, TensorFlow should be installed now! Now we just need to get out code ready for a modified version of label_image.py - I mentioned this at the end of the following guide: https://hackaday.io/project/20448-elephant-ai/log/68436-software-elephant-detector-transfer-learning-off-shelf-model-with-tensorflow so you can work from there! Plus take a look at the original code here: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/image_retraining/label_image.py
8. Well that should have us setup to detect our new elephant classes! There are many ways to approach this, as I went through in https://hackaday.io/project/20448-elephant-ai/log/68344-elephant-detector-approaches-using-cns but this is probably the easiest!
-
33. Elephant Detection Devices
Let's get started with how to build these!
Elephant Detection Devices: software overview https://hackaday.io/project/20448-elephant-ai/log/68968-elephant-detection-devices-software-overview
Now, as I mentioned, there are two detection devices: the dayPi for daytime detection, and the nightPi for night-time detection. After much deliberation, it was decided they will both share a light sensor. This is a digital sensor, so sends HIGH for day and LOW for night. The sharing of the light sensor eliminates the need for Ethernet communication between the dayPi and nightPi regarding light levels. They will additionally both share a PIR, so we don't need two PIRs and again, we don't need Ethernet communication between them regarding state of PIR!
So let's start with the dayPi
dayPi (the elephant detection device that is used in daylight)
1. First of all, let's build the circuit required for PIR and camera, and test it. The full instructions are here: https://hackaday.io/project/20448-elephant-ai/log/67655-buildinstructions-for-hardware-pir-and-camera PIR and Camera for daytime detection (dayPi)
2. Now we did build a safe shutdown switch. But I have decided not to use it - at this stage. You might wish to, and if so, the full build instructions are here: https://hackaday.io/project/20448-elephant-ai/log/68015-buildinstructions-for-hardware-safe-shutdown-switch
3. Next, let's add mobile connectivity using a USB 2G/3G dongle! I have used the Huawei E3531. In this build guide, I've explained how to set this up both for PPP over 2G/3G, or in serial modem mode for sending out SMS to alert system users of elephants: https://hackaday.io/project/20448-elephant-ai/log/68798-software-mobile-connectivity-huawei-e3531
4. Let's add our light sensor!
Here we go, this is how to set one up: #buildinstructions: light-sensor https://hackaday.io/project/20448-elephant-ai/log/69405-buildinstructions-light-sensor
Now, remember at this point. Only the dayPi has direct access to the mobile connectivity through the USB dongle. So the nightPi does need to communicate with the dayPi via Ethernet so it can get the dayPi to alert system users via the mobile connectivity component! The background, a build guide, and demo, for connecting via Ethernet between the dayPi and nightPi in server/client scenarios is here: https://hackaday.io/project/20448-elephant-ai/log/68501-software-switching-between-raspberry-pi-depending-on-daynight . But remember we are not communicating regarding day and night anymore since we are going to share a light sensor between dayPi and nightPi! Skip to step 5 to do this. But it's best if you test the light-sensor on its own first!
5. Great! So at this point, we can acquire images when the PIR is HIGH, we may have a safe shutdown switch, and we have mobile connectivity via either PPP or serial modem, and we have a light sensor!
Next, I want to move onto the nightPi:
nightPi (the elephant detection device that is used in darkness i.e. at night)
5. So now it is time to alter our light sensor and PIR circuits a bit - so both the dayPi and nightPi can share these components. Here's how to do this: https://hackaday.io/project/20448-elephant-ai/log/69399-buildinstructions-allowing-daypi-and-nightpi-to-share-pir-and-light-sensor . And let's install our NoIR camera too. I don't think you'll need a guide for that at this stage!
6. Subsequently, we can add a safe shutdown switch for the nightPi if we wish! In the same manner as for the dayPi: https://hackaday.io/project/20448-elephant-ai/log/68015-buildinstructions-for-hardware-safe-shutdown-switch
7. Ok, now let's add an IR illumination device for the nightPi. And get the nightPi to switch it on! Remember, we are using a NoIR camera (no IR filtering) for the nightPi. So it can only see anything if it has infrared LEDs to illuminate the scene! Because the IR illumination devices are 12v, and the raspberry pi device is 5v, we need to optically isolate the circuits for each of these devices. Let's build and test that circuit now: https://hackaday.io/project/20448-elephant-ai/log/69144-buildinstructions-for-hardware-an-optically-isolated-circuit-for-ir-illuminator
8. So great! We've built all the circuits and hardware for both the dayPi and nightPi now! If you haven't already, it would be a good time to test out Ethernet communications between the two! Since we are going to be communicating using Ethernet in our final software! So all the code is here for that: https://hackaday.io/project/20448-elephant-ai/log/68501-software-switching-between-raspberry-pi-depending-on-daynight
At this point, we have built the dayPi and nightPi! They both can acquire images when the shared PIR detected something. They can both stay in a while loop when the shared light sensor is giving either LIGHT or DARK. The dayPi has mobile connectivity. We have a optically isolated circuit on the nightPi that can turn on a 12v IR illumination device when we require. We may have safe shutdown switches for both. And they can both communicate via Ethernet!
9. Now I would say is a good time to jump to section 5 of the instructions and setup your battery and solar-recharging circuit!
10. After getting that setup done, I would go ahead and jump to section 6 of the instructions and build your elephant deter device! I know I didn't state it this way in the overview!
Ok, so we are almost there now! Let's incorporate all the prior steps and get our final code for the detection devices done!
11. So here's the code we are going to use for the nightPi: https://hackaday.io/project/20448-elephant-ai/log/68943-buildinstructions-for-hardware-and-software-nightpi
12. And here's the code we are going to use for the dayPi: https://hackaday.io/project/20448-elephant-ai/log/68942-buildinstructions-for-hardware-and-software-daypi
13. Let's go ahead and test this out now. Here we go: https://hackaday.io/project/20448-elephant-ai/log/69321-testing-of-elephantai
Great! We just completed our build and testing of the elephantAI system!
-
44. Mobile connectivity
dayPi will have mobile connectivity. nightPi will communicate with dayPi via Ethernet so giving it indirect mobile connectivity via the dayPi.
-- USB dongle software and hardware build
How can we use USB dongles to enable mobile connectivity for the elephant detection devices? We can use these to provide PPP via 2G/3G bound to Ethernet. Or we can use them as serial modems and send AT commands in order to alert local people via SMS in lower connectivity scenarios.
#software mobile connectivity: Huawei E3531 https://hackaday.io/project/20448-elephant-ai/log/68798-software-mobile-connectivity-huawei-e3531
#software mobile connectivity: Huawei E303 https://hackaday.io/project/20448-elephant-ai/log/68220-software-mobile-connectivity-huawei-e303 [not complete. refer to E3531 instead. It's the same thing]
-- HAT software and hardware build [these are too expensive or hard to get hold of, the libraries are not good either for the low-cost ones. You can add them I guess]
-- Alternative solution of wifi hotspot with a mobile phone [lowest cost would be more than a dongle so not going to bother - maybe add later]
-- multiplex using HAT [interesting to do it I guess]
-- multiplex using USB dongle [I'm not sure there is any point - on to-do list I guess]
-
55. Battery and solar-charging circuit
https://hackaday.io/project/20448-elephant-ai/log/67879-buildinstructions-for-hardware-solar-charging-circuit #buildinstructions for hardware: solar charging circuit including video demos
-
66. Elephant Deter Device
https://hackaday.io/project/20448-elephant-ai/log/67720-buildinstructions-for-hardware-elephant-deter-devices #buildinstructions for hardware: elephant deter devices including software for bluetooth comms and software for playing sounds of bees/scare_sounds including video demos
-
77. Housing solutions
Some of my earlier thoughts regarding housing:
Mounting for the detection devices https://hackaday.io/project/20448-elephant-ai/log/67276-mounting-for-the-detection-devices
Unfortunately, we have not been able to complete the housing in time! Hopefully, if you are building the system, you will be able to go ahead with the housing!
-
88. Field testing
Unfortunately, we have not been able to complete this testing in time for close of Hackaday Prize! But I'm sure once housing is completed, we can go ahead and do it! Some of the WWF researchers have offered to field test the prototypes, so I'm going to proceed with that in the next month or so.
Field testing of ElephantAI: with elephants https://hackaday.io/project/20448-elephant-ai/log/68950-field-testing-of-elephantai-with-elephants [not completed]
Field testing of ElephantAI: with horses https://hackaday.io/project/20448-elephant-ai/log/68949-field-testing-of-elephantai-with-horses [not completed]
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.