Skip to content

Question about the Hungarian Algorithm Implementation  #4

@fedyhajali

Description

@fedyhajali

Hi @uakfdotb,
Below I quote what is reported in the paper.

"On intermediate frames, we apply the Hungarian method on M(0,k) to match detections in Dk with tracks, updating each track with the matched detection (if any)."

I would ask if get_recur_sel() function, together with tf.gather(), represents the Hungarian algorithm implementation.

uns20/model.py

Lines 366 to 381 in 510833a

def get_recur_sel(mat):
if options.get('simple_sel', False):
return tf.argmax(mat, axis=1, output_type=tf.int32)
def f(mat):
# take argmax along rows (over columns)
# but only use it if it is higher value than other rows in same column
row_argmax = numpy.argmax(mat, axis=1)
col_argmax = numpy.argmax(mat, axis=0)
out = row_argmax
for i in range(out.shape[0]):
if col_argmax[out[i]] != i:
out[i] = mat.shape[1]-1
return out.astype('int32')
sel = tf.py_func(f, [mat], tf.int32, stateful=False)
return sel

uns20/model.py

Lines 456 to 466 in 510833a

n_prev = self.n_image[batch, 0]
if options.get('follow_longim', False):
sel = get_recur_sel(extra_mats_finesp[batch][prev_idx-1])
else:
sel = get_recur_sel(finesp_mats[batch][-1])
rnn_sel = tf.stack([
tf.range(n_prev, dtype=tf.int32),
sel,
], axis=1)
prev_features = tf.gather(features[batch][prev_idx], sel, axis=0)
rnn_features = tf.gather_nd(finesp_hiddens[batch][-1], rnn_sel)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions