liruoteng/OpticalFlowToolkit

Asking for help.

chuchienshu opened this issue · 1 comments

Hello, ruoteng. Recently, I'm trying to reproduce Flownet2 in tensorflow. So, the coding implementation of AAE(average angular error) and AEE(average endpoint error) are what I need.I forked your rep(OpticalFlowTookkit) cause it is awesome and helpful, but there are some questions confused me at line 181 in flowlib.py.

def flow_error(tu, tv, u, v):
    """
    Calculate average end point error
    :param tu: ground-truth horizontal flow map
    :param tv: ground-truth vertical flow map
    :param u:  estimated horizontal flow map
    :param v:  estimated vertical flow map

Now, I have a numpy array(named ground_truth) converted from ground truth .flo file, which has shape of [1024, 436, 2].So, the param tu equals ground_truth[ : , : , 0] and param tv equals ground_truth[ : , : , 1], Is my understanding right? And can I get AAE by canceling the annotation in function flow_error?
what's more, I have an implementation by myself, I ALSO have no idea if it's understanding right.

def get_AEE(labels, predictions):
    num_sample, height, width , _= predictions.shape.as_list()
    squared_difference = tf.square(tf.subtract(predictions, labels))
    #此处axis很重要,有batch的四维数组的axis必须是 3 , 三维数组得是 2
    loss = tf.reduce_sum(squared_difference, 3, keep_dims=True)
    loss = tf.sqrt(loss)
    return tf.reduce_sum(loss) / (num_sample*height*width)

Thanks very much! Any suggestion will help.

Hi Chienshu, to answer your question,

  1. tu = ground_truth[:,:,0] and tv = ground_truth[:,:,1] is correct.

  2. I guess you are trying to ask whether you can remove the comment in my flow_error function to get AAE. The answer is probably not. I did not complete the implementation of AAE as I did not quite use it and there is something wrong to compute the tangent function in numpy.
    If you are interested in implementing this function, I am more than welcome to see your pull request 💃

  3. AEE is actually the euclidean distance between the estimated points and ground truth point.
    I am not very familiar with tensorflow syntax, but from what you've implemented here, you are trying to compute the sqrt(sum(square(x-x'))) for each pixel, which can be considered right.

Thanks
RT