I updated the code for my Graphical Models / Conditional Random Fields toolbox This is a Matlab toolbox, though almost all the real work is done in compiled C++ for efficiency. The main improvements are:
- Lots of bugfixes.
- Various small improvements in speed.
- A unified CRF training interface to make things easier for those not training on images
- Binaries are now provided for Linux as well as OS X.
- The code for inference and learning using TRW is now multithreaded, using openmp.
- Switched to using a newer version of Eigen
There is also far more detailed examples, including a full tutorial of how to train a CRF to do “semantic segmentation” on the Stanford Backgrounds dataset. Just using simple color, position, and Histogram of Gradient features, the error rates are 23%, which appear to be state of the art (and better than previous CRF based approaches.) It takes about 90 minutes to train on my 8-core machine, and processes new frames in a little over a second each.

For fun, I also ran this model on a video of someone driving from Alexandria into Georgetown. You can see that the results are far from perfect but are reasonably good. (Notice it successfully distinguishes trees and grass at 0:12)
I’m keen to have others use the code (what with the hundreds of hours spent writing it), so please send email if you have any issues.
January 5, 2012 at 10:45 am
Hi Justin, thank you for sharing your code.
Does it also work with Octave?
If you want your package to have more attention, add it to mloss.org, there are already a few other CRF implementations: http://mloss.org/software/search/?searchterm=CRF
January 5, 2012 at 1:26 pm
I’m eager to support Octave. I hadn’t done so thus far as I was under the impression that Octave couldn’t use mex files. I see now that isn’t true, but I have relied on matlab’s ability to pass arrays to C++ code by pointer. Since Octave makes copies beforehand, this means (I think!) it won’t work out of the box. The other reason I haven’t focused on Octave the lack of parfor. With multithreaded TRW, though, this is less of an issue.
Thanks for the pointer to mloss.org. I’ll add it there.