Monday, May 18, 2015

Read Matlab File Into LMDB/LevelDB

I found current Caffe lacking this functionality to read Matlab .mat file (of arbitrary channels, not restricted to RGB) into LMDB/LevelDB, and was motivated to write an extension for this:

convert_mat.cpp

To use it, put it under Caffe_directory/tools, and include proper Matlab headers and libraries in Caffe Makefile. I also included an example of the CMakeLists.txt:

CMakeLists.txt 

This works for Mac. Under linux, the matlab path would probably be

-I/opt/matlab/extern/include
-L/opt/matlab/bin/glnxa64

Hope this small piece of code would be helpful.

2 comments:

  1. Hi,
    Thanks for sharing. What is the efficiency? Before I am using convert_image_net, which is extremely slow.

    ReplyDelete
    Replies
    1. The time it takes is almost the same as the underlying mechanism is similar (convert image/mat to datum). Another option is to use matio library for reading .mat into C.

      Delete