scnn_pytorch icon indicating copy to clipboard operation
scnn_pytorch copied to clipboard

can not convert from .t7

Open jjldr opened this issue 6 years ago • 4 comments

Thank you for sharing your code. But when i run the t7_to_pth.py with PyTorch 0.4.1, some error happens,the error is as follows: File "t7_to_pth.py", line 93, in model2[prefix+'conv_d.weight'] = model1.modules[42].modules[6].modules[0].modules[0].modules[2].modules[0].modules[1].modules[1].weight AttributeError: 'Sequential' object has no attribute 'weight'

please help me!

jjldr avatar Feb 22 '19 06:02 jjldr

The pretrained model provided by the author has been updated and it might be a little bit different from the original version. A feasible way is to insert .modules[0] before .weight in lines between 93 and 96.

model2[prefix+'conv_d.weight'] = model1.modules[42].modules[6].modules[0].modules[0].modules[2].modules[0].modules[1].modules[1].modules[0].weight
model2[prefix+'conv_u.weight'] = model1.modules[42].modules[6].modules[0].modules[0].modules[140].modules[1].modules[2].modules[0].modules[0].weight
model2[prefix+'conv_r.weight'] = model1.modules[42].modules[6].modules[1].modules[0].modules[2].modules[0].modules[1].modules[1].modules[0].weight
model2[prefix+'conv_l.weight'] = model1.modules[42].modules[6].modules[1].modules[0].modules[396].modules[1].modules[2].modules[0].modules[0].weight

jcdubron avatar Feb 23 '19 14:02 jcdubron

The pretrained model provided by the author has been updated and it might be a little bit different from the original version. A feasible way is to insert .modules[0] before .weight in lines between 93 and 96.

model2[prefix+'conv_d.weight'] = model1.modules[42].modules[6].modules[0].modules[0].modules[2].modules[0].modules[1].modules[1].modules[0].weight
model2[prefix+'conv_u.weight'] = model1.modules[42].modules[6].modules[0].modules[0].modules[140].modules[1].modules[2].modules[0].modules[0].weight
model2[prefix+'conv_r.weight'] = model1.modules[42].modules[6].modules[1].modules[0].modules[2].modules[0].modules[1].modules[1].modules[0].weight
model2[prefix+'conv_l.weight'] = model1.modules[42].modules[6].modules[1].modules[0].modules[396].modules[1].modules[2].modules[0].modules[0].weight

It works ! Thanks.

jjldr avatar Feb 24 '19 02:02 jjldr

Thank you for sharing your code. But when i run the t7_to_pth.py with PyTorch 0.4.1, some error happens,the error is as follows: torch.utils.serialization.read_lua_file.T7ReaderException: unknown type id 968499410. The file may be corrupted. And Baidu teaches me to use model trained by pytorch. How can I do? Please help me. Thank you very much.

HongJinZ avatar Apr 02 '19 14:04 HongJinZ

https://github.com/bobbens/sketch_simplification/issues/2#issuecomment-361601015

jcdubron avatar Jun 11 '19 00:06 jcdubron