Search code examples
caffepycaffematcaffe

How do you export .caffemodels to other applications?


Is it possible to translate the info in a .caffemodel file such that it could be read by (for example) Matlab. That is, is there a way to write your model using something else that prototxt and import the weights trained using Caffe?

If the answer is "Nope, it's a binary file and will always remain that way", is there some documentation regarding the structure of the file so that one could extract the important information somehow?


Solution

  • As you know, .caffemodel consists of weights and biases. A simple way to read weights and biases for a caffemodel given the prototxt would be to just load the network in Python and read the weights.

    You can use:

    import caffe
    net = caffe.Net(<prototxt-file>,<model-file>,<phase>);
    

    and access the params from net.params

    source