Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about the Hungarian Algorithm Implementation #4

Open
fedyhajali opened this issue Jul 12, 2022 · 1 comment
Open

Question about the Hungarian Algorithm Implementation #4

fedyhajali opened this issue Jul 12, 2022 · 1 comment

Comments

@fedyhajali
Copy link

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)

@uakfdotb
Copy link
Member

Yes, this is the part that matches detections with track prefixes during training. It is not the Hungarian algorithm but an approximation in this implementation since doing the bipartite matching is more complex and unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants