py-motmetrics
py-motmetrics copied to clipboard
`UnboundLocalError` when calculating HOTA
I am running this:
import os
import numpy as np
import motmetrics as mm
def compute_motchallenge(gt_file, test_file):
df_gt = mm.io.loadtxt(gt_file)
df_test = mm.io.loadtxt(test_file)
# Define thresholds for matching
th_list = np.arange(0.05, 0.99, 0.05)
# Compare ground truth and test data
res_list = mm.utils.compare_to_groundtruth_reweighting(df_gt, df_test, "iou", distth=th_list)
return res_list
def process_multiple_files(gt_files, test_files):
accumulators = []
for gt_file, test_file in zip(gt_files, test_files):
acc = compute_motchallenge(gt_file, test_file)
accumulators.append(acc)
return accumulators
gt_files = ['./gt.txt']
test_files = ['./test.txt']
accumulators = process_multiple_files(gt_files, test_files)
mh = mm.metrics.create()
summary = mh.compute_many(
acc,
metrics=[
"deta_alpha",
"assa_alpha",
"hota_alpha",
],
generate_overall=True, # `Overall` is the average we need only
)
strsummary = mm.io.render_summary(
summary.iloc[[-1], :], # Use list to preserve `DataFrame` type
formatters=mh.formatters,
namemap={"hota_alpha": "HOTA", "assa_alpha": "ASSA", "deta_alpha": "DETA"},
)
print(strsummary)
but I get the following error:
File "/Users/mikel.brostrom/boxmot/try_pymotmetrics.py", line 14, in compute_motchallenge
res_list = mm.utils.compare_to_groundtruth_reweighting(df_gt, df_test, "iou", distth=th_list)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mikel.brostrom/Library/Caches/pypoetry/virtualenvs/boxmot-YDNZdsaB-py3.11/lib/python3.11/site-packages/motmetrics/utils.py", line 156, in compare_to_groundtruth_reweighting
acc.update(oids, hids, 1 - weighted_dists, frameid=fid, similartiy_matrix=dists, th=th)
^^^^^
UnboundLocalError: cannot access local variable 'dists' where it is not associated with a value
The files used:
Any idea what the error may be here @Justin900429. Just following the README 😄