pageauc
Posts: 229
Joined: Fri Jan 04, 2013 10:52 pm

How to Install and Run Deep Learning DeepBeliefSDK on a RPI

Thu Feb 26, 2015 10:22 pm

How to Install and Run Deep Learning DeepBeliefSDK on a Raspberry Pi
NOTE
The DeepBeliefSDK developer GitHub has instructions for running on a RPI B2. See detailed instructions in posts below FYI
I have previously successfully installed and run deepbelief examples on a B+ from https://github.com/jetpacapp/DeepBeliefSDK This uses the GPU to do analysis of images.
memory was set to 128 and the example deepbelief compiled and I was able to successfully run many examples using various photos and downloaded google images.
I have a new B2 and went through the same install procedure that is pretty basic. Compile was successful but when I tried to run the example, the RPI B2 locks up and needed a hard reboot to recover.
Tried reinstalling several times with No Luck.
Change gpu Settings

Code: Select all

sudo nano /boot/config.txt
# in nano add gpu line below to bottom of file
# gpu_mem=128
sudo reboot
How to Install Deep Learning DeepBeliefSDK on a RPI model B or B+ (Not B2)
make sure you have previously installed build-essentials packages

Code: Select all

git clone https://github.com/jetpacapp/DeepBeliefSDK.git
cd DeepBeliefSDK/RaspberryPiLibrary
sudo ./install.sh
cd ../examples/SimpleLinux/
make
sudo ./deepbelief 
I am trying to integrate this into a robotics openCV project and the B2 quadcore is giving me better openCV performance so I would like to move forward using the B2

The developer now has a B2 install that no longer uses the GPU for analysis. I have include instructions below.
Thanks
Last edited by pageauc on Wed Jul 08, 2015 7:12 pm, edited 13 times in total.
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp

pageauc
Posts: 229
Joined: Fri Jan 04, 2013 10:52 pm

Re: B2 problem running deepbeliefSDK

Thu Mar 12, 2015 9:12 pm

FYI
Got a Github message back from the developer. It looks like different ARM architecture might be causing the problem. Developer has ordered a B2 and will do some investigation into the problem.
Last edited by pageauc on Wed Jul 08, 2015 12:25 pm, edited 1 time in total.
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp

pageauc
Posts: 229
Joined: Fri Jan 04, 2013 10:52 pm

Re: B2 problem running deepbeliefSDK

Wed Jul 08, 2015 11:46 am

How to Install and Run Deep Learning DeepBeliefSDK on a RPI B2

DeepBeliefSDK is now running on the B2. It does not use the GPU but still runs stable. This setup works well because the camera can be used at the same time as DeepBelief jpcnn. I have been using the camera on the robot to take images and analyze them using two different ntwk files using a bash script that filters the results. The recognition quality is not very good probably due to the objects I am using and the varied backgrounds but still interesting to work with. I will look at doing this in a python script and implement actions depending on results. In the mean time this is a very basic demo script fyi.

Here are the install instructions for the B2
https://github.com/jetpacapp/DeepBelief ... berry-pi-2

Since this will install the complete eigen and DeepBeliefSDK in your /home/pi/projects folder, I decided to install the essential files in a separate folder called b2_learn per these commands

Code: Select all

sudo cp /home/pi//projects/DeepBeliefSDK/source/libjpcnn.so /usr/lib/
sudo cp /home/pi//projects/DeepBeliefSDK/source/src/include/libjpcnn.h /usr/include/
mkdir /home/pi/b2_learn
mkdir /home/pi/b2_learn/data
cp /home/pi//projects/DeepBeliefSDK/networks/data/*  /home/pi/b2_learn/data
# copies dog.jpg and lena.jpg files that can be used for testing purposes.
mkdir /home/pi/b2_learn/networks
cp /home/pi//projects/DeepBeliefSDK/networks/* /home/pi/b2_learn/networks
cp /home/pi//projects/DeepBeliefSDK/source/jpcnn /usr/local/bin
Do a Test to ensure everything is working OK

Code: Select all

cd ~/b2_learn
echo "testing data/dog.jpg"
jpcnn -i data/dog.jpg -n networks/jetpac.ntwk -m s
echo "Sort list highest to lowest percent values"
jpcnn -i data/dog.jpg -n networks/jetpac.ntwk -m s | sort -nrk 1
I then created a demo script called deep_look.sh that uses the pi camera module. This analyses the camera image using more than one ntwk file and filters the results using awk. I currently filter results to display anything above 5 percent.. Also you don't need to specify /usr/local/bin/jpcnn since /usr//local/bin folder should be on the path but I have included it for clarity. This also does not save unique image names but overwrites the previous image. Like I said it is a quick demo.

Code: Select all

#!/bin/bash
# deep_look.sh written by Claude Pageau
image_name=./deep_look.jpg
while true
do
  echo "Take photo ......" $image_name
  raspistill -w 800 -h 600 -n -t 1 -o $image_name
# /usr/local/bin/jpcnn -i $1 -n ./networks/jetpac.ntwk -m s | awk 'int($1*100)>=50' | sort -nrk 1
  echo "jeppack.ntwk"
# change the awk >=  value to filter results for higher percentage value.  I have set value to 5 percent.
# A higher value will eliminate results with a lower percentage than specified.
  /usr/local/bin/jpcnn -i $image_name -n ./networks/jetpac.ntwk -m s | awk 'int($1*100)>=5' | sort -nrk 1
  echo "ccv2012.ntwk"
  /usr/local/bin/jpcnn -i $image_name -n ./networks/ccv2012.ntwk -m s | awk 'int($1*100)>=5' | sort -nrk 1
done

Here is another script that analyses a specific image passed as a parameter

Code: Select all

#!/bin/bash
# learn.sh written by Claude Pageau
if [ $# -eq 0 ]
then
  echo "Error - Missing parameter"
  echo "Usage $0 imagepath"
  echo "eg $0 ./data/imagename.jpg"
  exit 1
else
  if [ -f $1 ]
  then
#    /usr/local/bin/jpcnn -i $1 -n ./networks/jetpac.ntwk -m s | awk 'int($1*100)>=50' | sort -nrk 1
    echo "jetpack.ntwk"
    /usr/local/bin/jpcnn -i $1 -n ./networks/jetpac.ntwk -m s | awk 'int($1*100)>=5' | sort -nrk 1
    echo "ccv2012.ntwk"
    /usr/local/bin/jpcnn -i $1 -n ./networks/ccv2012.ntwk -m s | awk 'int($1*100)>=5' | sort -nrk 1
  else
    echo "Error - Image file $1 Not Found."
    exit 1
  fi
fi
You can Modify the script or create your own to perform actions based on the results of the analysis.
Let me know if you do anything interesting. I am still playing with this technology.
Note some of the results you get can sometimes be pretty funny.

Regards
Claude ...
GitHub - https://github.com/pageauc
YouTube - https://www.youtube.com/user/pageaucp

Return to “Advanced users”