NVIDIA / flownet2-pytorch

Pytorch implementation of FlowNet 2.0: Evolution of Optical Flow Estimation with Deep Networks
Other
3.12k stars 739 forks source link

About "Convert Official Caffe Pre-trained Models to PyTorch" #18

Closed PkuRainBow closed 6 years ago

PkuRainBow commented 6 years ago

I have followed your instructions to convert the models but failed! So I am wondering whether you could share the well-converted models, besides I am wondering that whether you have implemented the evaluation code to get the EPE performance over different dataset?

Regards

fitsumreda commented 6 years ago

Would you be able to provide more information about the failure?

Evaluation code is included in the repo for datasets with ground-truth optical flows, e.g. MPI-Sintel, FlyingChiars, etc. To get EPE values use --inference mode

PkuRainBow commented 6 years ago

There exist some environmental problem, might be complex to post here.

It would be great if you could share us the well-converted model, e.g., sharing a link would be great!

aelnouby commented 6 years ago

I have followed the instructions and had a failure as well. Step 1 executed fine. But with step 2 I get

Traceback (most recent call last): File "/fn2pytorch/convert.py", line 27, in <module> import models File "/fn2pytorch/models.py", line 8, in <module> from networks.resample2d_package.modules.resample2d import Resample2d File "/fn2pytorch/networks/resample2d_package/modules/resample2d.py", line 3, in <module> from ..functions.resample2d import Resample2dFunction File "/fn2pytorch/networks/resample2d_package/functions/resample2d.py", line 3, in <module> from .._ext import resample2d ImportError: No module named _ext

fitsumreda commented 6 years ago

@aelnouby It looks like you haven't installed the custom layers in your flownet2-pytorch. Please install the layers, and run step2 again.

The instruction in the readme has been updated with the same information. https://github.com/NVIDIA/flownet2-pytorch/blob/master/README.md#convert-official-caffe-pre-trained-models-to-pytorch

lshiwjx commented 6 years ago

I also meet a problem when run run-caffe2pytorch.sh:

F0103 07:35:50.917933 10 cudnn_conv_layer.cpp:52] Check failed: error == cudaSuccess (35 vs. 0) CUDA driver version is insufficient for CUDA runtime version *** Check failure stack trace: *** /bin/bash: line 1: 10 Aborted (core dumped) python /fn2pytorch/convert.py ./FlowNet2-C/FlowNet2-C_weights.caffemodel ./FlowNet2-C/FlowNet2-C_deploy.prototxt.template /fn2pytorch

Could you please release a well-converted model?

fitsumreda commented 6 years ago

Ok, we'll release the converted models.

On Tue, Jan 2, 2018 at 11:41 PM LShi notifications@github.com wrote:

I also meet a problem when run run-caffe2pytorch.sh:

F0103 07:35:50.917933 10 cudnn_conv_layer.cpp:52] Check failed: error == cudaSuccess (35 vs. 0) CUDA driver version is insufficient for CUDA runtime version Check failure stack trace: /bin/bash: line 1: 10 Aborted (core dumped) python /fn2pytorch/convert.py ./FlowNet2-C/FlowNet2-C_weights.caffemodel ./FlowNet2-C/FlowNet2-C_deploy.prototxt.template /fn2pytorch

Could you please release a well-converted model?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/NVIDIA/flownet2-pytorch/issues/18#issuecomment-354952069, or mute the thread https://github.com/notifications/unsubscribe-auth/AOpN0QzfUavhsvxVlbBEQ_4bwE9VlfKxks5tGy83gaJpZM4RQWpc .

aelnouby commented 6 years ago

Same error as @lshiwjx

Thanks @fitsumreda , looking forward releasing the models.

fitsumreda commented 6 years ago

we've added converted caffe pre-trained models.

aelnouby commented 6 years ago

Hi @fitsumreda ,

Thanks for sharing the models.

I have tried to load the state_dict for FlownetSD, however I found that the state_dict for the model and the pre-trained file does not match.

len(torch.load('models/flownet/FlowNet2-SD_checkpoint.pth.tar')['state_dict'].keys()) >> 60

While, self.flownet = FlowNetSD.FlowNetSD(args=None) len(self.flownet.state_dict().keys()) >>115

The difference:

[k for k in self.flownet.state_dict().keys() if k not in torch.load('models/flownet/FlowNet2-SD_checkpoint.pth.tar')['state_dict'].keys()] >> ['conv0.1.weight', 'conv0.1.bias', 'conv0.1.running_mean', 'conv0.1.running_var', 'conv1.1.weight', 'conv1.1.bias', 'conv1.1.running_mean', 'conv1.1.running_var', 'conv1_1.1.weight', 'conv1_1.1.bias', 'conv1_1.1.running_mean', 'conv1_1.1.running_var', 'conv2.1.weight', 'conv2.1.bias', 'conv2.1.running_mean', 'conv2.1.running_var', 'conv2_1.1.weight', 'conv2_1.1.bias', 'conv2_1.1.running_mean', 'conv2_1.1.running_var', 'conv3.1.weight', 'conv3.1.bias', 'conv3.1.running_mean', 'conv3.1.running_var', 'conv3_1.1.weight', 'conv3_1.1.bias', 'conv3_1.1.running_mean', 'conv3_1.1.running_var', 'conv4.1.weight', 'conv4.1.bias', 'conv4.1.running_mean', 'conv4.1.running_var', 'conv4_1.1.weight', 'conv4_1.1.bias', 'conv4_1.1.running_mean', 'conv4_1.1.running_var', 'conv5.1.weight', 'conv5.1.bias', 'conv5.1.running_mean', 'conv5.1.running_var', 'conv5_1.1.weight', 'conv5_1.1.bias', 'conv5_1.1.running_mean', 'conv5_1.1.running_var', 'conv6.1.weight', 'conv6.1.bias', 'conv6.1.running_mean', 'conv6.1.running_var', 'conv6_1.1.weight', 'conv6_1.1.bias', 'conv6_1.1.running_mean', 'conv6_1.1.running_var', 'inter_conv5.1.weight', 'inter_conv5.1.bias', 'inter_conv5.1.running_mean', 'inter_conv5.1.running_var', 'inter_conv4.1.weight', 'inter_conv4.1.bias', 'inter_conv4.1.running_mean', 'inter_conv4.1.running_var', 'inter_conv3.1.weight', 'inter_conv3.1.bias', 'inter_conv3.1.running_mean', 'inter_conv3.1.running_var', 'inter_conv2.1.weight', 'inter_conv2.1.bias', 'inter_conv2.1.running_mean', 'inter_conv2.1.running_var'] am I using a wrong model or file ? and if not what should I do instead.

fitsumreda commented 6 years ago

Your flownet-sd model is instantiatef with batchnorm set to true. If you set batchnorm to false, the mismatch will go away.

aelnouby commented 6 years ago

@fitsumreda Thanks, it worked (Y)