Machine Learning With Raspberry Pi

Introduction: Machine Learning With Raspberry Pi

Hi,

This is my first Instructable and moreover my English is not good. So please don't mind if it is not well written.

Background:

Deep learning is a new hot topic in the area of Machine Learning, that shows promising results to achieve artificial intelligence. These days we hear a lot about Machine Learning algorithms from big companies like Google and facebook. But recently a startup called Jetpac brought an iphone app that makes even lay person to use Machine learning. Now the same startup has ported their Deep Learning algorithm called Deep Belief to Raspberry Pi. Although, Pete Warden, the CTO of Jetpac, has given instructions on Github, there are some small changes required to adopt to install it on Raspberry Pi. Therefore, I am writing this instructable.

Step 1: Allocating RAM to GPU

This deep belief software requires, at least 128 MB of RAM. In order to allocate that memory, edit the config file of Pi, by using the following command.

---------------------------------------------

sudo nano /boot/config.txt

----------------------------------------------

Add the following line at the end of the file

---------------------------------------------

gpu_mem=128

-----------------------------------------------

Now reboot the Pi.

------------------------------

sudo reboot

------------------------------

In case. if you did not install git before, install it

------------------------------

sudo apt-get install git

------------------------------

Step 2: Install Deep Belief Image Recognition SDK on Raspberry Pi

Now we can install the Deep Belief SDK, by following the below instructions

--------------------------------------------------------------------

git clone https://github.com/jetpacapp/DeepBeliefSDK.git

cd DeepBeliefSDK/RaspberryPiLibrary

sudo ./install.sh

---------------------------------------------------------------------------

Step 3:

Inorder to check whether it is installed correctly or not, follow the below instructions:

-----------------------------------------------------------

cd ../examples/SimpleLinux/

make

sudo ./deepbelief

---------------------------------------------------------------

That should give the following out put

--------------------------------------------------------

0.016994 wool

0.016418 cardigan

0.010924 kimono

0.010713 miniskirt

0.014307 crayfish

0.015663 brassiere

0.014216 harp

0.017052 sandal

0.024082 holster

0.013580 velvet

0.057286 bonnet

0.018848 stole

0.028298 maillot

0.010915 gown

0.073035 wig

0.012413 hand blower

0.031052 stage

0.027875 umbrella

0.012592 sarong

-----------------------------------

This is basically telling that the algorithm is analyzing the default image in the library and giving the probability of it being sarong and umbrella. This algorithm is very useful in robotics. I am trying to implement this on my Raspberry Pi Robot soon. You can find more details on my blog.


Credits:

Pete Warden

https://github.com/jetpacapp/DeepBeliefSDK/tree/ma...

Share

    Recommendations

    • Fix It! Contest

      Fix It! Contest
    • Water Contest

      Water Contest
    • Metalworking Contest

      Metalworking Contest

    6 Discussions

    in on raspberry pi3 / debian jessie / updated......

    Keep getting error. below is what i get when i use the make command.

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/examples/SimpleLinux $ make

    gcc -o deepbelief ./main.c -L/usr/lib -ljpcnn

    ./main.c:11:22: fatal error: libjpcnn.h: No such file or directory

    #include

    ^

    compilation terminated.

    Makefile:14: recipe for target 'deepbelief' failed

    make: *** [deepbelief] Error 1

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/examples/SimpleLinux $ ls

    jetpac.ntwk lena.png main.c Makefile

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/examples/SimpleLinux $ makefile

    bash: makefile: command not found

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/examples/SimpleLinux $ sudo make

    gcc -o deepbelief ./main.c -L/usr/lib -ljpcnn

    ./main.c:11:22: fatal error: libjpcnn.h: No such file or directory

    #include

    ^

    compilation terminated.

    Makefile:14: recipe for target 'deepbelief' failed

    make: *** [deepbelief] Error 1

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/examples/SimpleLinux $ (keep getting same error)

    1 reply

    ok so i got ahead of myself and skipped a section is why this error came out.

    but now im having this error and i know i did everythign right? it will not open

    $ Can't open device file: /var/lib/jpcnn/char_dev <------ the issue as below

    pi@raspiFlex:~/Desktop/DeepBeliefSDK $ cd RaspberryPiLibrary

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/RaspberryPiLibrary $ ls

    install.sh libjpcnn.h libjpcnn.so

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/RaspberryPiLibrary $ sudo ./install.sh

    libjpcnn installed

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/RaspberryPiLibrary $ cd ../examples/SimpleLinux/

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/examples/SimpleLinux $ make

    gcc -o deepbelief ./main.c -L/usr/lib -ljpcnn

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/examples/SimpleLinux $ sudo ./deepbelief

    Can't open device file: /var/lib/jpcnn/char_dev

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/examples/SimpleLinux $ ls

    deepbelief jetpac.ntwk lena.png main.c Makefile

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/examples/SimpleLinux $ ./deepbelief

    Can't open device file: /var/lib/jpcnn/char_dev

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/examples/SimpleLinux $ ./deepbelief

    Can't open device file: /var/lib/jpcnn/char_dev

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/examples/SimpleLinux $ sudo ./deepbelief

    Can't open device file: /var/lib/jpcnn/char_dev

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/examples/SimpleLinux $ leafpad /var/lib/jpcnn/char_dev

    pi@raspiFlex:~/Desktop/DeepBeliefSDK/examples/SimpleLinux $

    anyhelp would be great thanks

    Hi, great instructable !

    I followed all the instructions but when I entered “sudo ./deepbelief” for the last command it gave me the error,

    “Can’t open device file: /var/lib/jpcnn/char_dev”.

    Any assistance on how to fix it would be greatly appreciated!

    1 reply

    cd ~/DeepBeliefSDK/source/src/lib/pi/
    vi mailbox.cpp
    (change #define MAJOR_NUM 100 to #define MAJOR_NUM 249) / save
    sudo rm -rf /var/lib/jpcnn/
    cd ~/DeepBeliefSDK/source/
    make clean
    make TARGET=pi2
    sudo cp libjpcnn.so /usr/lib/
    sudo cp src/include/libjpcnn.h /usr/include/
    cd ~/DeepBeliefSDK/examples/SimpleLinux/
    make
    sudo ./deepbelief

    Hi, nice set of directions; I'm falling into a different hole; when making the SimpleLinux directory for the "deepbelief" executable, I get the error:

    /usr/lib/libjpcnn.so: file not recognized: File format not recognized

    Seems to be ELF 64-bit library, not the 32-bit for the other libraries. Any ideas??

    Thanks!

    I have the same issue as posted below/above. I'm using a fresh copy of Raspbian and a Pi 3. Please advise.