Closed lhao0301 closed 4 years ago
Thank you for investigating this, I greatly appreciate it! I found a typo on my end and updated the provided models. I also updated the flow visualization but it remains unaffected from this bug. Would you mind downloading the provided models again to see whether they are correct now? Thanks!
Thanks for your reply!
The updated model works well and is identical with the official model. Visualizing the flow, it changes a little only, which can be ignored.
flow_viz_before:
flow_viz_updated:
Thank you for confirming, and thanks again for bringing this to my attention!
This problem is also found when I compare your repo and the official repo. Hence, I just propose it here.
After looking into the official pwc-net
and flownet2
repo, I find that the mean_subtraction
is omitted in the image preprocessing period in this repo. What is interesting is that the predicted optical flow seems not so bad, when mean_subtraction
is omitted (Actually, rgb or bgr is also not so important for optical flow's prediction). I'm a litte confused about the mean_subtraction
because I didn't find it in the original pytorch implementation as well.
In the pwc_net_test.prototxt, recompute_mean
is not zero. And as the code in data_augmentation_layer.cu, both the training and test periods in official caffe version have mean_subtraction
.
@sniklaus
Thank you for your message! I was wondering that too when I converted the Caffe model, but I noticed that the results from this reimplementation are different from the official Caffe model if I add the following lines to the preprocessing.
tensorPreprocessedFirst = tensorPreprocessedFirst - tensorPreprocessedFirst.view(1, 3, -1).mean(2).view(1, 3, 1, 1)
tensorPreprocessedSecond = tensorPreprocessedSecond - tensorPreprocessedSecond.view(1, 3, -1).mean(2).view(1, 3, 1, 1)
Output from the official Caffe implementation:
Output from this reimplementation:
Output from this reimplementation with the additonal mean subtraction:
I never bothered to look into this further, Deqing stated that it makes no difference whether or not they use the mean subtraction: https://github.com/NVlabs/PWC-Net/issues/40
I would be happy if you can find the reason behind this, I am afraid that I am a little busy at the moment.
Thanks for your wonderful code!
I try to convert the official
pwc_net.caffemodel
to pytorch. And I find a interesing problem, thebias
of theFeatureUpsample
layers within all thedecoder
in this repo are not consistent with official model.I compare my pytorch weights (converted from official caffemodel) with
network-default.pytorch
in this repo as follows.All the parameters are actually same but the
bias
inFeatureUpsample
as aforementioned. And I find thebias
in my converted pytorch model are0
and in thenetwork-default.pytorch
they arenot 0
. I look into the official trianing prototxt file and find thelr_mult
for alldeconvolution layers
are0
and so does the initializer(constant
means0
also by default). So the real value ofbias
should be0
.I also check the
sintel.pytorch
in an older version of this repo. I comparesintel.pytorch
withnetwork-default.pytorch
and find the same phenomenon, all the parameters are actually same but thebias
inFeatureUpsample
. There may be some randomness during your conversion within theFeatureUpsample
layers. I guess thebias
are initialized differently everytime.@sniklaus