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

Warn about changes in motmetrics.utils.compare_to_groundtruth() when using euclidean distance. #177

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion motmetrics/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_annotations_xor_predictions_present():
}
anno = _tracks_to_dataframe(anno_tracks)
pred = _tracks_to_dataframe(pred_tracks)
acc = mm.utils.compare_to_groundtruth(anno, pred, 'euc', distfields=['Position'], distth=2)
acc = mm.utils.compare_to_groundtruth(anno, pred, 'euclidean', distfields=['Position'], distth=2)
mh = mm.metrics.create()
metrics = mh.compute(acc, return_dataframe=False, metrics=[
'num_objects', 'num_predictions', 'num_unique_objects',
Expand Down
8 changes: 6 additions & 2 deletions motmetrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def compare_to_groundtruth(gt, dt, dist='iou', distfields=None, distth=0.5):
------
dist : str, optional
String identifying distance to be used. Defaults to intersection over union ('iou'). Euclidean
distance ('euc') and squared euclidean distance ('seuc') are also supported.
distance ('euclidean') and squared euclidean distance ('seuc') are also supported.
distfields: array, optional
Fields relevant for extracting distance information. Defaults to ['X', 'Y', 'Width', 'Height']
distth: float, optional
Expand All @@ -61,10 +61,14 @@ def compute_seuc(a, b):
compute_dist = compute_iou
elif dist.upper() == 'EUC':
compute_dist = compute_euc
import warnings
warnings.warn(f"'euc' flag changed its behavior. The euclidean distance is now used instead of the squared euclidean distance. Make sure the used threshold (distth={distth}) is not squared. Use 'euclidean' flag to avoid this warning.")
elif dist.upper() == 'EUCLIDEAN':
compute_dist = compute_euc
elif dist.upper() == 'SEUC':
compute_dist = compute_seuc
else:
raise f'Unknown distance metric {dist}. Use "IOU", "EUC" or "SEUC"'
raise f'Unknown distance metric {dist}. Use "IOU", "EUCLIDEAN", or "SEUC"'

acc = MOTAccumulator()

Expand Down