0

I want to use vlfeat library on Octave but the vlfeat.org does not have instructions for installing it on Octave. Any help/pointers would be appreciated.

IKavanagh
  • 6,089
  • 11
  • 42
  • 47

1 Answers1

0

I needed to apply a patch to the octave makefile. Here is a complete script to make vlfeat run on a fresh install of Ubuntu 13.04:

# install required packages
sudo apt-get install octave octave-pkg-dev build-essential octave-image transfig

# get vlfeat
wget http://www.vlfeat.org/download/vlfeat-0.9.16.tar.gz
tar xzvf vlfeat-0.9.16.tar.gz

# apply patch
cd vlfeat-0.9.16
sed -i 's/mex $(OCTAVE_MEX_FLAGS)/mex $(OCTAVE_MEX_FLAGS) $(OCTAVE_MEX_LDFLAGS)/' make/octave.mak

# compile
MKOCTFILE=mkoctfile make

# run demo
mkdir -p doc/demo
cd toolbox
octave --persist --eval "vl_setup; vl_demo"

On my system the demo executes until it hits a point where the current architecture is need. It seems like octave is not recognized at this step and the demo stops. But nevertheless it is able to produce some plots which shows it is generally working. But I don't know to which extent since I have not done any further tests.

Update:

To run phow_caltech101 I first had to install liblinear since the provided SVM usese some matlab function not provided by octave:

cd 
wget "http://www.csie.ntu.edu.tw/~cjlin/cgi-bin/liblinear.cgi?+http://www.csie.ntu.edu.tw/~cjlin/liblinear+tar.gz" -O liblinear.tar.gz
tar xzvf liblinear.tar.gz
cd liblinear-1.93/matlab
sed -i 's/include\/octave/include\/octave-3.6.4\/octave/' Makefile
make octave

Than I had to patch some vlfeat files:

cd
cd vlfeat-0.9.16
patch -p0 << EOF
--- apps/phow_caltech101.m    2012-10-04 11:57:08.000000000 +0200
+++ apps/phow_caltech101.m    2013-06-07 12:37:29.413434382 +0200
@@ -56,7 +56,7 @@
 conf.numSpatialY = [2 4] ;
 conf.quantizer = 'kdtree' ;
 conf.svm.C = 10 ;
-conf.svm.solver = 'pegasos' ;
+conf.svm.solver = 'liblinear' ;
 conf.svm.biasMultiplier = 1 ;
 conf.phowOpts = {'Step', 3} ;
 conf.clobber = false ;
@@ -218,6 +218,8 @@
                           conf.svm.biasMultiplier, conf.svm.C), ...
                   'col') ;
       w = svm.w' ;
+      b = w(end,:);
+      w = w(1:(end-1),:);
   end
 
   model.b = conf.svm.biasMultiplier * b ;
@@ -259,7 +261,7 @@
 % -------------------------------------------------------------------------
 
 im = im2single(im) ;
-if size(im,1) > 480, im = imresize(im, [480 NaN]) ; end
+if size(im,1) > 480, im = imresize(im, [480 round(480*size(im,2)/size(im,1))]) ; end
 
 % -------------------------------------------------------------------------
 function hist = getImageDescriptor(model, im)
EOF


patch -p0 << EOF
--- toolbox/sift/vl_phow.m    2012-10-04 11:57:08.000000000 +0200
+++ toolbox/sift/vl_phow.m    2013-06-07 12:08:43.653416992 +0200
@@ -135,6 +135,8 @@
     sigma = opts.sizes(si) / opts.magnif ;
     ims = vl_imsmooth(im, sigma) ;
 
+    ims = im2single(ims);
+
     % extract dense SIFT features from all channels
     for k = 1:numChannels
       [f{k}, d{k}] = vl_dsift(...
EOF

Then I was able to successfully run it:

octave --eval "addpath('~/liblinear-1.93/matlab'); cd toolbox; vl_setup; cd ../apps; phow_caltech101" --persist
Community
  • 1
  • 1
sietschie
  • 7,425
  • 3
  • 33
  • 54
  • `vl_demo_print: wrote file '/home/ankit/vlfeat-0.9.16/doc/demo/sift_edge_3.eps' vl_demo_print: wrote file '/home/ankit/vlfeat-0.9.16/doc/demo/sift_edge_4.eps' error: 'arch' undefined near line 27 column 30 error: evaluating argument list element number 3 error: called from: error: /home/ankit/vlfeat-0.9.16/toolbox/demo/vl_demo_cmd.m at line 27, column 5 error: /home/ankit/vlfeat-0.9.16/toolbox/demo/vl_demo_sift_cmd.m at line 20, column 12 error: /home/ankit/vlfeat-0.9.16/toolbox/vl_demo.m at line 24, column 1 octave:1> ` These are the final lines of the log generated. –  Jun 07 '13 at 03:38
  • My system is running Ubuntu 13.04 64bit and the above error log resembles to what you said. –  Jun 07 '13 at 03:39
  • Good. So do you have any further questions? You now should be able to use the vlfeat library functions. – sietschie Jun 07 '13 at 09:16
  • Can you check whether the two applications in the apps directory of the library are working on your system? –  Jun 07 '13 at 09:17
  • No. Because of incompatibilities between matlab and octave. But with some modifications I was able run the phow_caltech101 example. Since the original developers do not really support octave, you are likely to encounter more problems and inconsistencies. – sietschie Jun 07 '13 at 10:44
  • Is it possible for you to share with me(via github or dropbox) the modified version of the package which can successfully run the phow_caltech101 example? –  Jun 07 '13 at 11:32
  • I don't have any more questions as of now. I will ping you if I have some queries. Thanks a lot for your help. –  Jun 09 '13 at 04:06
  • When run on a custom data-set, phow_caltech101.py gives the following error error: `phow_caltech101: A(I): index out of bounds; value 4 out of bound 2 error: called from: error: /home/ankit/vlfeat-0.9.16/apps/phow_caltech101.m at line 113, column 9`. This corresponds to the line :classes = {classes(3:conf.numClasses+2).name}. The default code for Matlab works on the custom data-set successfully. Is this error because of the above (Octave related)modifications? –  Jun 10 '13 at 08:16
  • It seems that `length(classes)` is less than `conf.numClasses + 2`. You should have a look at the values of `classes` and `conf.numClasses` to confirm they have the expected values. – sietschie Jun 10 '13 at 10:01