-
Notifications
You must be signed in to change notification settings - Fork 249
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
Motmetrics upgrade #263
Open
ahuller3
wants to merge
5
commits into
argoverse:master
Choose a base branch
from
ahuller3:motmetrics-upgrade
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Motmetrics upgrade #263
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,6 @@ | |
""" | ||
Computes multiple object tracking (MOT) metrics. Please refer to the following | ||
papers for definitions of the following metrics: | ||
|
||
#FRAG, #IDSW: Milan et al., MOT16, https://arxiv.org/pdf/1603.00831.pdf | ||
MT, ML: Leal-Taixe et al., MOT15, https://arxiv.org/pdf/1504.01942.pdf | ||
MOTA: Bernardin et al. https://link.springer.com/article/10.1155/2008/246309 | ||
|
@@ -34,13 +33,11 @@ | |
def in_distance_range_pose(ego_center: np.ndarray, pose: np.ndarray, d_min: float, d_max: float) -> bool: | ||
"""Determine whether a pose in the ego-vehicle frame falls within a specified distance range | ||
of the egovehicle's origin. | ||
|
||
Args: | ||
ego_center: ego center pose (zero if bbox is in ego frame). | ||
pose: pose to test. | ||
d_min: minimum distance range | ||
d_max: maximum distance range | ||
|
||
Returns: | ||
A boolean saying if input pose is with specified distance range. | ||
""" | ||
|
@@ -80,12 +77,10 @@ def get_distance_iou_3d(x1: Dict[str, np.ndarray], x2: Dict[str, np.ndarray], na | |
|
||
def get_distance(x1: Dict[str, np.ndarray], x2: Dict[str, np.ndarray], name: str) -> float: | ||
"""Get the distance between two poses, returns nan if distance is larger than detection threshold. | ||
|
||
Args: | ||
x1: first pose | ||
x2: second pose | ||
name: name of the field to test | ||
|
||
Returns: | ||
A distance value or NaN | ||
""" | ||
|
@@ -115,7 +110,6 @@ def eval_tracks( | |
category: str = "VEHICLE", | ||
) -> None: | ||
"""Evaluate tracking output. | ||
|
||
Args: | ||
path_tracker_output_root: path to tracker output root, containing log_id subdirs | ||
path_dataset_root: path to dataset root, containing log_id subdirs | ||
|
@@ -132,11 +126,12 @@ def eval_tracks( | |
However, `mostly tracked` and `mostly lost` will be accurate. | ||
category: such as "VEHICLE" "PEDESTRIAN" | ||
""" | ||
|
||
acc_c = mm.MOTAccumulator(auto_id=True) | ||
acc_i = mm.MOTAccumulator(auto_id=True) | ||
acc_o = mm.MOTAccumulator(auto_id=True) | ||
|
||
ID_gt_all: List[str] = [] | ||
ID_gt_all: List[int] = [] | ||
|
||
count_all: int = 0 | ||
if diffatt is not None: | ||
|
@@ -155,7 +150,6 @@ def eval_tracks( | |
num_total_gt = 0 | ||
|
||
for path_dataset in path_datasets: | ||
|
||
log_id = pathlib.Path(path_dataset).name | ||
if len(log_id) == 0 or log_id.startswith("_"): | ||
continue | ||
|
@@ -165,7 +159,7 @@ def eval_tracks( | |
path_track_data = sorted( | ||
glob.glob(os.path.join(os.fspath(path_tracker_output), "per_sweep_annotations_amodal", "*")) | ||
) | ||
|
||
all_uuids: Dict[str, int] = {} | ||
logger.info("log_id = %s", log_id) | ||
|
||
for ind_frame in range(len(path_track_data)): | ||
|
@@ -185,10 +179,10 @@ def eval_tracks( | |
|
||
gt_data = read_json_file(path_gt) | ||
|
||
gt: Dict[str, Dict[str, Any]] = {} | ||
gt: Dict[int, Dict[str, Any]] = {} | ||
id_gts = [] | ||
track_label_uuids: Dict[str, int] = {} | ||
for i in range(len(gt_data)): | ||
|
||
if gt_data[i]["label_class"] != category: | ||
continue | ||
|
||
|
@@ -206,8 +200,14 @@ def eval_tracks( | |
gt_data[i]["center"]["z"], | ||
] | ||
) | ||
|
||
if bbox[3] > 0 and in_distance_range_pose(np.zeros(3), center, d_min, d_max): | ||
track_label_uuid = gt_data[i]["track_label_uuid"] | ||
if gt_data[i]["track_label_uuid"] not in track_label_uuids: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Anna, could you add a brief inline comment here explaining the logic for what we are doing here? |
||
track_label_uuids[gt_data[i]["track_label_uuid"]] = i | ||
track_label_uuid = i | ||
else: | ||
track_label_uuid = track_label_uuids[gt_data[i]["track_label_uuid"]] | ||
|
||
gt[track_label_uuid] = {} | ||
gt[track_label_uuid]["centroid"] = center | ||
|
||
|
@@ -223,13 +223,15 @@ def eval_tracks( | |
id_gts.append(track_label_uuid) | ||
num_total_gt += 1 | ||
|
||
tracks: Dict[str, Dict[str, Any]] = {} | ||
id_tracks: List[str] = [] | ||
tracks: Dict[int, Dict[str, Any]] = {} | ||
id_tracks: List[int] = [] | ||
|
||
track_data = read_json_file(path_track_data[ind_frame]) | ||
|
||
for track in track_data: | ||
key = track["track_label_uuid"] | ||
if track["track_label_uuid"] not in all_uuids: | ||
all_uuids[track["track_label_uuid"]] = len(all_uuids) + 1 | ||
key = all_uuids[track["track_label_uuid"]] | ||
|
||
if track["label_class"] != category or track["height"] == 0: | ||
continue | ||
|
@@ -259,14 +261,19 @@ def eval_tracks( | |
dists_o.append(gt_track_data_o) | ||
for track_key, track_value in tracks.items(): | ||
count_all += 1 | ||
gt_track_data_c.append(get_distance(gt_value, track_value, "centroid")) | ||
gt_track_data_i.append(get_distance(gt_value, track_value, "iou")) | ||
gt_track_data_o.append(get_distance(gt_value, track_value, "orientation")) | ||
|
||
centroid_distance = get_distance(gt_value, track_value, "centroid") | ||
# appends distances if centroid distance is valid | ||
if np.isfinite(centroid_distance): | ||
gt_track_data_c.append(centroid_distance) | ||
gt_track_data_i.append(get_distance(gt_value, track_value, "iou")) | ||
gt_track_data_o.append(get_distance(gt_value, track_value, "orientation")) | ||
else: | ||
gt_track_data_c.append(float(np.nan)) | ||
gt_track_data_i.append(float(np.nan)) | ||
gt_track_data_o.append(float(np.nan)) | ||
acc_c.update(id_gts, id_tracks, dists_c) | ||
acc_i.update(id_gts, id_tracks, dists_i) | ||
acc_o.update(id_gts, id_tracks, dists_o) | ||
# print(count_all) | ||
if count_all == 0: | ||
# fix for when all hypothesis is empty, | ||
# pymotmetric currently doesn't support this, see https://github.com/cheind/py-motmetrics/issues/49 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we add a brief inline comment here explaining what the
all_uuids
dictionary is for?