2

Basically I am using using caffe for deep learning. Now I finetuned a network for my own dataset and saved my model in hdf5 format which is .h5 extension.

Now I want to classify images using matcaffe. matcaffe understands only .caffemodel format for trained model.
So is there any way to convert hdf5 file to caffemodel?

Shai
  • 111,146
  • 38
  • 238
  • 371
Rafay Zia Mir
  • 2,116
  • 6
  • 23
  • 49

1 Answers1

3

You can set the preferred format for the caffemodel file in your solver.prototxt. Simply set

snapshot_format: BINARYPROTO

See caffe.proto for more information.


Alternatively, you can use python interface (which is by far better than the matlab interface for caffe, IMHO):

import caffe
net = caffe.Net('/path/to/deploy.prototxt', '/path/to/caffemodel.h5', caffe.TEST)
net.save('/path/to/just.caffemodel')
Community
  • 1
  • 1
Shai
  • 111,146
  • 38
  • 238
  • 371
  • Shai thanks for your answer, actually in start i did not know that there are different snapshot formats so i saved in hdf5 format. I ran 1lakh iterations so it was not possible for me to run it again. – Rafay Zia Mir Jun 28 '16 at 10:38
  • But i found a way around for this and it worked for me. – Rafay Zia Mir Jun 28 '16 at 10:39
  • @RafayZiaMir can you elaborate on the workaround you found? would you post it as an answer? – Shai Jun 28 '16 at 10:43
  • 1
    Shai, i think that way around should not be an answer, because what i did that after 1lakh iterations i had an hdf5 format model. Then i changed the snapshot format in solver file. Then i loaded my trained model and then started finetuning on it but now this time it saved the model in caffemodel format. So basically its what you are saying but i just again finetuned my network and saved in caffemodel format. – Rafay Zia Mir Jun 28 '16 at 10:55