Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to compute flow and save the forward/backward .flo files #19

Open
sorata118 opened this issue Oct 28, 2021 · 3 comments
Open

How to compute flow and save the forward/backward .flo files #19

sorata118 opened this issue Oct 28, 2021 · 3 comments

Comments

@sorata118
Copy link

Would you please give detail guidline or example of how to get the forward/backword .flo files from RAFT?

@erikalu
Copy link
Owner

erikalu commented Oct 29, 2021

Hi, you can run the demo in the RAFT repo: https://github.com/princeton-vl/RAFT
Run it on the directory of frames to get the forward flow, and to get the backward flow just modify the code to reverse the list of files.

@sorata118
Copy link
Author

Hi, you can run the demo in the RAFT repo: https://github.com/princeton-vl/RAFT Run it on the directory of frames to get the forward flow, and to get the backward flow just modify the code to reverse the list of files.

The demo in RAFT doesn't have any example of how to save the .flo file. So I save the results by using their frame_untils.writeFlow() as the code shown below. Not sure the outputs are ok for your project or not?

flow_low, flow_up = model(image1, image2, iters=20, test_mode=True)
flow_low, flow_down = model(image2, image1, iters=20, test_mode=True)
flow_up_ = padder.unpad(flow_up[0]).permute(1, 2, 0).cpu().numpy()
flow_down_ = padder.unpad(flow_down[0]).permute(1, 2, 0).cpu().numpy()
filename_fr = imfile1.split("/")[-1].split(".")[0]
filename_bk = imfile2.split("/")[-1].split(".")[0]
output_file_up = os.path.join("flo_forward_results/", '% s.flo' % filename_fr)
output_file_down = os.path.join('flo_backward_results/', '% s.flo' % filename_bk)
frame_utils.writeFlow(output_file_up, flow_up_)
frame_utils.writeFlow( output_file_down, flow_down_)

@erikalu
Copy link
Owner

erikalu commented Nov 1, 2021

Yes, you can use their frame_utils.writeFLow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants