sniklaus / pytorch-pwc

a reimplementation of PWC-Net in PyTorch that matches the official Caffe version
GNU General Public License v3.0
608 stars 122 forks source link

Fix issue #47 #57

Closed Etienne66 closed 2 years ago

Etienne66 commented 2 years ago

This fixes issue #47 and allows Tensorboard's SummaryWriter.add_graph to work although there are some TracerWarnings.

The problem was that the trace injects tensors into the correlation functions and in this case it was putting the word tensor in the Cupy code when the string replace was being done.

ie:

float fltValue = input[(((intSample * tensor(196)) + intChannel) * tensor(6) * tensor(20)) + intIndex];

instead of:

float fltValue = input[(((intSample * 196) + intChannel) * 6 * 20) + intIndex];

The following warning still occurs but it seems it can be ignored as they are all in the correlation function and it couldn't be shown in the model anyway. TracerWarning: Converting a tensor to a Python number might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!

sniklaus commented 2 years ago

Thank you for your contribution, this is great!

Etienne66 commented 2 years ago

Not a problem. I've been trying to evaluate the pre-trained model. The numbers I'm getting are better than the original but I'm pretty sure I'm doing it correctly. Working on retraining it to see if I can get it to do better like they did for PWC-Net+

sniklaus commented 2 years ago

You might find this interesting: https://github.com/sniklaus/pytorch-pwc/issues/23