clcarwin / convert_torch_to_pytorch

Convert torch t7 model to pytorch model and source.
MIT License
540 stars 161 forks source link

DepthConcat problem in FaceNet model #5

Closed TwoBranchDracaena closed 7 years ago

TwoBranchDracaena commented 7 years ago

Hi, clcarwin,

Have you tried convert FaceNet's model? It is used in OpenFace project, and you can download the model here It requires dpnn package to load the model in lua.

Since it's a bit of old, I load and save it with the newest lua torch.

When I convert this model to PyTorch, this error occurs: File "/home/xiaolush/.pyenv/python3.5/lib/python3.5/site-packages/torch/utils/serialization/read_lua_file.py", line 357, in storage_to_size value = getattr(obj, attr) AttributeError: 'DepthConcat' object has no attribute 'outputSize'

Do you have a hint where could be the problem?

Thanks!

clcarwin commented 7 years ago

This is a bug in read_lua_file.py. Re-saving the model with this lua script can pass the error.

m = torch.load('nn4.small2.v1.t7')
m:replace(function(mm)
    if torch.typename(mm)=='nn.DepthConcat' then
        mm.outputSize=torch.LongStorage()
    end
    return mm
end)
torch.save('nn4.small2.v1.t7',m) 

However convert_torch.py can not support dpnn package. The openface model still can not be converted.

Not Implement nn.SpatialConvolutionMM
Not Implement nn.SpatialConvolutionMM
Not Implement nn.SpatialConvolutionMM
Not Implement nn.Inception
Not Implement nn.Inception
Not Implement nn.Inception
Not Implement nn.Inception
Not Implement nn.Inception
Not Implement nn.Inception
TwoBranchDracaena commented 7 years ago

Thanks clcarwin! It's quite odd that lua torch creates outputSize during updateOutput() in DepthConcat :p

Looking forward to more update!

pkmandke commented 5 years ago

@clcarwin Hi! Has dpnn support been included yet or is it in the pipeline? Would save me a lot of boilerplate code if your repo could convert the openface model to pytorch. Thanks