INNER CODE UNIT · Python
top
htdt/godogen · asset-gen/tools/find_loop_frame.py:75
top = sorted(all_candidates, key=lambda c: -c[1])[:TOP_K]
# Deduplicate nearby frames
peaks = dedupe(top, min_gap)
if not peaks:
return None, 0.0, []
# Pick latest if its similarity is close to the top; otherwise prefer top sim
top_sim = max(p[1] for p in peaks)
latest = max(peaks, key=lambda c: c[0])
if top_sim - latest[1] < 0.01:
best = latest
else:
best = max(peaks, key=lambda c: c[1])
return best[0], best[1], peaks