xxradon / PytorchToCaffe

Pytorch model to caffe model, supported pytorch 0.3, 0.3.1, 0.4, 0.4.1 ,1.0 , 1.0.1 , 1.2 ,1.3 .notice that only pytorch 1.1 have some bugs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example fails

neilyoung opened this issue · comments

Did run resnet_pytorch_2_caffe.pywith a downloaded resnet18-5c106cde.pth. Went good for a while, then it crashed:


744513648:fc_blob1 was added to blobs
WARNING: CANNOT FOUND blob 4744513488
Traceback (most recent call last):
  File "./example/test.py", line 17, in <module>
    pytorch_to_caffe.trans_net(resnet18,input,name)
  File "./pytorch_to_caffe.py", line 775, in trans_net
    out = net.forward(input_var)
  File "/usr/local/lib/python3.7/site-packages/torchvision/models/resnet.py", line 208, in forward
    x = self.fc(x)
  File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 541, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/linear.py", line 87, in forward
    return F.linear(input, self.weight, self.bias)
  File "./pytorch_to_caffe.py", line 678, in __call__
    out=self.obj(self.raw,*args,**kwargs)
  File "./pytorch_to_caffe.py", line 138, in _linear
    bottom=[log.blobs(input)],top=top_blobs)
  File "./Caffe/layer_param.py", line 33, in __init__
    self.bottom.extend(bottom)
TypeError: None has type NoneType, but expected one of: bytes, unicode

Any pointer?

@neilyoung Hi, I meet the same problem, have you solved it?

TBH, I don't recall

Same error, need help

@neilyoung @yaoqi-zd @zhangchuanyi96 I met the same problem as you guys. I solved this in pytorch 1.0 environment.

@neilyoung @yaoqi-zd @zhangchuanyi96 I met the same problem as you guys. I solved this in pytorch 1.0 environment.

Thanks. BTW, I have managed to tackle it by replacing 'flatten' with 'view'.

@zhangchuanyi96 hello bro, i have fix it with view() as you say, however, i have met a new question when i load the caffe model.

It says: 'F0711 16:12:40.803625 10250 insert_splits.cpp:29] Unknown bottom blob 'contiguous_blob1' (layer 'view1', bottom index 0)'
So how can i fix the new bug?

@zhangchuanyi96 hello bro, i have fix it with view() as you say, however, i have met a new question when i load the caffe model.

It says: 'F0711 16:12:40.803625 10250 insert_splits.cpp:29] Unknown bottom blob 'contiguous_blob1' (layer 'view1', bottom index 0)'
So how can i fix the new bug?

I didn't meet this bug and can't help. Maybe changing pytorch version will help, like 1.0

这是由于0.3之后的trochvision将view换成flatten层的转换未实现所致,你可以参考#26

这是由于0.3之后的trochvision将view换成flatten层的转换未实现所致,你可以参考#26

谢谢回复

commented

I change to torch==1.0.1 torchvision==0.2.2, which can solve this problem.