Skip to content

Commit

Permalink
Warning added in motmetrics.utils.compare_to_groundtruth() to mitigat…
Browse files Browse the repository at this point in the history
…e backward compatibility issues.

When the dist='euc' option is used, a warning is shown to explain the change in behavior of the option.
  • Loading branch information
angelcarro committed May 30, 2023
1 parent 35ca830 commit f4a28bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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

0 comments on commit f4a28bf

Please sign in to comment.