omnimatte icon indicating copy to clipboard operation
omnimatte copied to clipboard

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

Open sorata118 opened this issue 3 years ago • 3 comments

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

sorata118 avatar Oct 28 '21 07:10 sorata118

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.

erikalu avatar Oct 29 '21 14:10 erikalu

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_)

sorata118 avatar Nov 01 '21 01:11 sorata118

Yes, you can use their frame_utils.writeFLow

erikalu avatar Nov 01 '21 15:11 erikalu