lliuz / ARFlow

The official PyTorch implementation of the paper "Learning by Analogy: Reliable Supervision from Transformations for Unsupervised Optical Flow Estimation".

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Understanding Flow SPTransform

YoussefFathi opened this issue · comments

I would appreciate it if you can clarify for me the following points related to specific parts of the "sp_transforms.py" file :

  1. In transform_flow() , what is the purpose of the following block of code ?

    `        # inverse transform coords
     x0, y0 = self.inverse_transform_coords(
         width=width, height=height, thetas=theta1)
    
     x1, y1 = self.inverse_transform_coords(
         width=width, height=height, thetas=theta2, offset_x=u, offset_y=v)
    
     # subtract and create new flow
     u = x1 - x0
     v = y1 - y0
     new_flow = torch.stack([u, v], dim=1)`
    
  2. Why didn't you use only the following part of the code to transform the optical flow just like the transform_image() function ?

      `  # transform coords
     xq, yq = self.transform_coords(width=width, height=height, thetas=theta1)
    
     # interp2
     transformed = self._flow_interp2(new_flow, xq, yq)`
    
  3. What is the difference between the functionality of inverse_transform_coords() and transform_coords() ?

Since spatial transformations will lead in a change to coordinates, we should sample optical flow on the view of transformed coordinates rather than the original one.

In this code, inverse_transform_coords() transform coordinates:
image
and transform_coords() is its inverse operation.