How to load caffe models in pytorch

(Kirk86) #1

Hi everyone, with torch we had loadcaffe which was extremely useful. Is there any way to achieve the same functionality in pytorch? Simply how can we load caffe models in pytorch?

Thanks a lot!

(Adam Paszke) #2

One way would be to use loadcaffe to load weights in Lua, save them, and use torch.utils.serialization.load_lua to load them in PyTorch. Unfortunately we don’t have a ready solution for that yet.

(Kirk86) #3

Thanks Adam,
hope there is some plan for future solution?

(Adam Paszke) #4

Not anytime soon I’m afraid. There are a lot of high priority tasks.

(Adam Paszke) #5

But it should be quite simple for someone to add that. You just need to read protobufs and translate graphs into modules.

(Kirk86) #6

gotcha ya. Thanks a lot for the suggestions.

(Xiaoxing Zeng) #7

@apaszke,you means that I can load caffe models in Pytorch using torch?

(Adam Paszke) #8

Yes it should be possible. But these will only be torch.legacy.nn models, not torch.nn networks.

(Sunitha Kanuri) #9

Hello, I am not familiar with the caffe framework.
I want to convert this code into pytorch… I am using arch linux. Would that be possible?

(Neo Li) #10

I have finally fixed my problem
Thanks to everyone, and I integrate it into my project