Monday, November 19, 2012

UGM Library for Undirected Graphical Models

I was in search for  suitable library for CRF implementation for my segmentation work and found the UGM library useful, since it has some demos and nice explanations for different functionalities. It also seems to be up-to-date with different inference techniques.

Here is the link for the directory:

They have clearly explained the download and setup process. However, I found that bit scattered across different pages, so here are the steps that I went through:

1. Download the tgz from the homepage .
The 2011 version is available in

2. There are also some updates in 2012. Download them as well.

3.Download the mex-wrapper for maxflow from the link and place it under the directory UGM/

4.Download from and place it inside UGM/maxflow/  under the name maxflow-v.3.0 (since the different files refer to it in the same name.)  Note: there is a  Readme.txt in UGM/maxflow/ to guide us too.

5.In matlab command window,
 >> cd UGM/
 >> addpath(genpath(pwd))
>> mex -setup
>> mexAll

In case you find errors like the following while running mexAll, sort it out using help from the other blogpost :  matlab-error-of-type-usrbinld

: /usr/bin/ld: matlab/sys/os/glnx86/ version `GLIBCXX_3.4.10' not found (required by /usr/bin/ld) 


 5. >> cd maxflow/
      >> make
     >> test1 
     >> test2   % to test the functionality
      >> cd ..

In case you are in a 64-bit system, you will face an error like this:

>> make     
>> test1

??? Error using ==> maxflowmex
Function "mxGetIr_700" is obsolete in file "compat32.cpp", line 282.
(64-bit mex files using sparse matrices must be rebuilt with the "-largeArrayDims" option.  See the R2006b release notes for
more details.)

Error in ==> maxflow at 35
[flow,labels] = maxflowmex(A,T);

Error in ==> test1 at 32
[flow,labels] = maxflow(A,T)

The solution is, 

edit the file maxflow/make.m as follows:

mex -O -largeArrayDims maxflowmex.cpp maxflow-v3.0/graph.cpp maxflow-v3.0/maxflow.cpp

>> make
>> test1 
>> test2   % to test the functionality
>> cd ..

6.  Run any demo present in UGM/examples/. For example,
  >> example_UGM_AlphaBeta 

No comments:

Post a Comment