hmorimitsu / ptlflow

PyTorch Lightning Optical Flow models, scripts, and pretrained weights.
Apache License 2.0
250 stars 33 forks source link

Output OF vectors instead of colour wheel (flow_viz) #42

Closed TranNg65 closed 1 year ago

TranNg65 commented 1 year ago

Hi hmorimitsu,

This is not an issue but I'm not sure where to ask this question. Please feel free to move this thread if required.

I'm trying to get a dense flow map with vectors- an array that has the same size with the image that contains (x,y) displacement at each pixel.

Can you please help me with some hints? I'm using RAFT_s model

Thanks again for your great work.

hmorimitsu commented 1 year ago

Hi,

I'm not sure if I understand what your problem is, but I think what you want is to run an inference with an optical flow model.

You can check examples of how to get the optical flow (dense flow map) in the documentation:

https://ptlflow.readthedocs.io/en/latest/starting/inference.html

or in this example in Google Colab:

https://colab.research.google.com/drive/1YARBRUGplqTRnRuY9sKIs6LY_2kWAWZJ?usp=sharing

I hope that helps.

TranNg65 commented 1 year ago

Hi hmorimitsu,

Thank you very much for your reply. I have been looking at your recommendations

What I meant was how to get the dense flow map in vectors instead of colours. I'm using a RAFT model, does the vectors values of the whole images is the parameter flow_up?

https://github.com/hmorimitsu/ptlflow/blob/d5ec04e01c20e7680ff97f3bad5e57da9185034d/ptlflow/models/raft/raft.py#L164

Once again. Thank you.

hmorimitsu commented 1 year ago

If you want to get the motion vectors from inside the model, you can get them from flow_up. From outside the model, you can get from the output: output['flows'].

TranNg65 commented 1 year ago

Thank you very much.