omnimatte
omnimatte copied to clipboard
How to compute flow and save the forward/backward .flo files
Would you please give detail guidline or example of how to get the forward/backword .flo files from RAFT?
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.
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_)
Yes, you can use their frame_utils.writeFLow