How to enable MatCaffe wrapper for Caffe

1. Go to caffe root directory, for me it is :

 $cd /home/naved/Desktop/caffe-master 

2. Make Matcaffe binaries:

 $ make all matcaffe 

3. Test matcaffe installation:

 $make mattest 

4. Now open ~/.bashrc and check if the following lines are there, otherwise find them in your (it can be different for your case) system and modify accordingly:

export PATH=$PATH:/usr/local/cuda/bin
export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/

# Caffe Root
export CAFFE_ROOT=/home/guo/Desktop/caffe-master

5. Now open matlab FROM TERMINAL ,(NOT using launcher icon! This is important!) e.g.:


6. Run a test code to makes sure it is running properly. Before running the code make sure to add path to the caffe/matlab directory as shown in the example code below:


addpath('/home/guo/Desktop/caffe-master/matlab'); % MAKE SURE TO ADD THIS!

img = imread('ak.png');
img = single(img);

averageImage = [129.1863,104.7624,93.5940] ;

img = cat(3,img(:,:,1)-averageImage(1),...

img = img(:, :, [3, 2, 1]); % convert from RGB to BGR
img = permute(img, [2, 1, 3]); % permute width and height

model = 'VGG_FACE_16_deploy.prototxt';
weights = 'VGG_FACE.caffemodel';
net = caffe.Net(model, weights, 'test'); % create net and load weights

res = net.forward({img});
prob = res{1};

caffe_ft = net.blobs('fc7').get_data();