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

3D Detection Eval docstrings + typing fixes. #40

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
9d33045
Add evaluation.
Mar 24, 2022
f7d708d
Small fixes.
Mar 24, 2022
74d0eb0
Add unit tests + eval mask fixes.
Mar 25, 2022
5589bf5
Update detection unit tests.
Mar 25, 2022
244100d
Fix typing + update pyproject.
Mar 25, 2022
5314ee4
Run autoflake.
Mar 25, 2022
4c0e6bb
Add ROI pruning.
Mar 26, 2022
8e59867
Remove arg.
Mar 26, 2022
343c219
Fix typo.
Mar 26, 2022
6a34f5b
Speed up argoverse maps.
Mar 28, 2022
23b2fec
Speed up evaluation.
Mar 28, 2022
ae42718
Small fixes.
Mar 28, 2022
a02e45c
Fix lint.
Mar 28, 2022
2f208d5
Small lint fixes.
Mar 28, 2022
c7797a5
Fix filtering.
benjaminrwilson Mar 29, 2022
0b15248
Small fixes.
benjaminrwilson Mar 29, 2022
c7a66de
Fix enums.
benjaminrwilson Mar 29, 2022
957e016
Remove unused lines.
benjaminrwilson Mar 29, 2022
b8ab038
Mypy fixes.
benjaminrwilson Mar 29, 2022
ceff8fa
Fix click mypy error.
benjaminrwilson Mar 29, 2022
c314775
Pytype fixes.
benjaminrwilson Mar 30, 2022
2e7af38
Fix pytype.
benjaminrwilson Mar 30, 2022
43f938a
Remove pytype.
benjaminrwilson Mar 30, 2022
90c791f
Small typing fixes.
benjaminrwilson Mar 30, 2022
515c6f2
Add unit tests.
benjaminrwilson Mar 31, 2022
8c5d1bc
Fix typing.
benjaminrwilson Mar 31, 2022
e7f2925
Remove click typing issue.
benjaminrwilson Mar 31, 2022
14f1141
Fix mypy.
benjaminrwilson Mar 31, 2022
7d4139c
Detection eval speed up.
benjaminrwilson Apr 2, 2022
c9de7cb
Rewrite detection eval for major speedup.
benjaminrwilson Apr 2, 2022
59a65f8
Typing fixes.
benjaminrwilson Apr 2, 2022
4327278
Typing fixes.
benjaminrwilson Apr 2, 2022
df479b9
Switch from record arrays to numpy arrays.
benjaminrwilson Apr 2, 2022
4c40a5f
Temp changes.
benjaminrwilson Apr 2, 2022
eccd4f0
Improve readability.
benjaminrwilson Apr 2, 2022
72dc702
Add comments.
benjaminrwilson Apr 2, 2022
fddd899
Modularize evaluate.
benjaminrwilson Apr 2, 2022
faa8317
Additional speedups.
benjaminrwilson Apr 3, 2022
f81ae17
Cleanup code.
benjaminrwilson Apr 3, 2022
d49105a
Additional speedup.
benjaminrwilson Apr 3, 2022
195b46a
Add roi pruning back.
benjaminrwilson Apr 3, 2022
dc2a954
Add multiprocessing.
benjaminrwilson Apr 3, 2022
06e2e96
Add verbosity.
benjaminrwilson Apr 3, 2022
54901b2
Mypy fixes.
benjaminrwilson Apr 3, 2022
856b4d4
Update cuboid fields.
benjaminrwilson Apr 3, 2022
be5a89c
Lint fixes.
benjaminrwilson Apr 3, 2022
5cb43ea
Fix map tutorial issues.
benjaminrwilson Apr 3, 2022
5214d9d
Merge branch 'map_notebook-fixes'
benjaminrwilson Apr 3, 2022
967cc39
Add test log.
benjaminrwilson Apr 3, 2022
ae8aeb5
Revert strings.
benjaminrwilson Apr 3, 2022
d8a0ae9
Remove outputs.
benjaminrwilson Apr 3, 2022
a343292
Merge branch 'map_notebook-fixes'
benjaminrwilson Apr 3, 2022
87239c3
Address missing detection edge cases.
benjaminrwilson Apr 4, 2022
9a2acc6
Address jhony comments.
benjaminrwilson Apr 5, 2022
ba6c337
Update docstring.
benjaminrwilson Apr 5, 2022
aa036aa
Clean docstrings.
benjaminrwilson Apr 5, 2022
a6b345d
Change roi method.
benjaminrwilson Apr 5, 2022
e725147
Clean up roi method.
benjaminrwilson Apr 5, 2022
ce896f0
Update roi returns.
benjaminrwilson Apr 5, 2022
aeea617
Autoflake.:
benjaminrwilson Apr 5, 2022
da897c1
Fix lint.
benjaminrwilson Apr 5, 2022
c459c26
Fix lint.
benjaminrwilson Apr 5, 2022
ca5d644
Update detection limiting logic.
Apr 7, 2022
375aaba
Fix indexing.
Apr 7, 2022
5113202
Fix tuple return.
Apr 7, 2022
97235a0
Merge https://github.com/argoai/av2-api into main
Apr 7, 2022
5a4c76d
Update CI.
Apr 7, 2022
07d3fbf
Add ROI unit tests.
Apr 9, 2022
0cd98f9
Remove val identity.
Apr 9, 2022
0ef221b
Fix import.
Apr 9, 2022
0b00475
Remove unused import.
Apr 9, 2022
82da97f
Update column names.
Apr 9, 2022
548ea93
Update eval.py
benjaminrwilson Apr 11, 2022
39465a6
Update detection eval.
benjaminrwilson Apr 11, 2022
7fe965f
Merge.
benjaminrwilson Apr 11, 2022
40ac0f1
Update docstrings.
benjaminrwilson Apr 11, 2022
960d29d
Revert docstring.
benjaminrwilson Apr 11, 2022
63125ea
Merge https://github.com/argoai/av2-api into detection-eval-followup
benjaminrwilson Apr 26, 2022
75e07bf
Fix formatting.
benjaminrwilson Apr 26, 2022
28fb345
Small fixes.
benjaminrwilson Apr 26, 2022
503caa9
Update ci.yml
benjaminrwilson Apr 26, 2022
942809b
Update ci.yml
benjaminrwilson Apr 26, 2022
c549ac2
Update ci.yml
benjaminrwilson Apr 26, 2022
b9d82cd
Update ci.yml
benjaminrwilson Apr 26, 2022
4732089
Update ci.yml
benjaminrwilson Apr 26, 2022
bda0724
Update ci.yml
benjaminrwilson Apr 26, 2022
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
python_version:
["3.8", "3.9", "3.10"]
venv_backend:
["virtualenv", "mamba"] # Testing two different resolvers (pip, mamba).
["virtualenv"]
defaults:
run:
shell: bash -l {0}
Expand Down
31 changes: 19 additions & 12 deletions src/av2/evaluation/detection/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
e.g. AP, ATE, ASE, AOE, CDS by default.
"""
import logging
from multiprocessing import get_context
from typing import Dict, Final, List, Optional, Tuple

import numpy as np
import pandas as pd
from joblib import Parallel, delayed

from av2.evaluation.detection.constants import NUM_DECIMALS, MetricNames, TruePositiveErrorNames
from av2.evaluation.detection.utils import (
Expand Down Expand Up @@ -95,7 +95,7 @@ def evaluate(
Each sweep is processed independently, computing assignment between detections and ground truth annotations.

Args:
dts: (N,15) Table of detections.
dts: (N,14) Table of detections.
gts: (M,15) Table of ground truth annotations.
cfg: Detection configuration.
n_jobs: Number of jobs running concurrently during evaluation.
Expand All @@ -106,23 +106,30 @@ def evaluate(

Raises:
RuntimeError: If accumulation fails.
ValueError: If ROI pruning is enabled but a dataset directory is not specified.
"""
if cfg.eval_only_roi_instances and cfg.dataset_dir is None:
raise ValueError(
"ROI pruning has been enabled, but the dataset directory has not be specified. "
"Please set `dataset_directory` to the split root, e.g. av2/sensor/val."
)

# Sort both the detections and annotations by lexicographic order for grouping.
dts = dts.sort_values(list(UUID_COLUMN_NAMES))
gts = gts.sort_values(list(UUID_COLUMN_NAMES))

dts_npy: NDArrayFloat = dts.loc[:, DTS_COLUMN_NAMES].to_numpy()
gts_npy: NDArrayFloat = gts.loc[:, GTS_COLUMN_NAMES].to_numpy()
dts_npy: NDArrayFloat = dts[list(DTS_COLUMN_NAMES)].to_numpy()
gts_npy: NDArrayFloat = gts[list(GTS_COLUMN_NAMES)].to_numpy()

dts_uuids: List[str] = dts.loc[:, UUID_COLUMN_NAMES].to_numpy().astype(str).tolist()
gts_uuids: List[str] = gts.loc[:, UUID_COLUMN_NAMES].to_numpy().astype(str).tolist()
dts_uuids: List[str] = dts[list(UUID_COLUMN_NAMES)].to_numpy().tolist()
gts_uuids: List[str] = gts[list(UUID_COLUMN_NAMES)].to_numpy().tolist()

# We merge the unique identifier -- the tuple of ("log_id", "timestamp_ns", "category")
# into a single string to optimize the subsequent grouping operation.
# `groupby_mapping` produces a mapping from the uuid to the group of detections / annotations
# which fall into that group.
uuid_to_dts = groupby([":".join(x) for x in dts_uuids], dts_npy)
uuid_to_gts = groupby([":".join(x) for x in gts_uuids], gts_npy)
uuid_to_dts = groupby([":".join(map(str, x)) for x in dts_uuids], dts_npy)
uuid_to_gts = groupby([":".join(map(str, x)) for x in gts_uuids], gts_npy)

log_id_to_avm: Optional[Dict[str, ArgoverseStaticMap]] = None
log_id_to_timestamped_poses: Optional[Dict[str, TimestampedCitySE3EgoPoses]] = None
Expand Down Expand Up @@ -154,9 +161,9 @@ def evaluate(
args_list.append(args)

logger.info("Starting evaluation ...")
outputs: Optional[List[Tuple[NDArrayFloat, NDArrayFloat]]] = Parallel(n_jobs=n_jobs, verbose=1)(
delayed(accumulate)(*args) for args in args_list
)
with get_context("spawn").Pool(processes=n_jobs) as p:
outputs: Optional[List[Tuple[NDArrayFloat, NDArrayFloat]]] = p.starmap(accumulate, args_list)

if outputs is None:
raise RuntimeError("Accumulation has failed! Please check the integrity of your detections and annotations.")
dts_list, gts_list = zip(*outputs)
Expand All @@ -182,7 +189,7 @@ def summarize_metrics(
"""Calculate and print the 3D object detection metrics.

Args:
dts: (N,15) Table of detections.
dts: (N,14) Table of detections.
gts: (M,15) Table of ground truth annotations.
cfg: Detection configuration.

Expand Down
2 changes: 0 additions & 2 deletions src/av2/evaluation/detection/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class DetectionCfg:
max_range_m: Max distance (under a specific metric in meters) for a detection or ground truth cuboid to be
considered for evaluation.
num_recall_samples: Number of recall points to sample uniformly in [0, 1].
splits: Tuple of split names to evaluate.
tp_threshold_m: Center distance threshold for the true positive metrics (in meters).
"""

Expand All @@ -70,7 +69,6 @@ class DetectionCfg:
max_num_dts_per_category: int = 100
max_range_m: float = 200.0
num_recall_samples: int = 100
split: str = "val"
tp_threshold_m: float = 2.0

@property
Expand Down
4 changes: 2 additions & 2 deletions src/av2/geometry/utm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
WGS84: https://en.wikipedia.org/wiki/World_Geodetic_System
"""

from enum import unique, Enum
from enum import Enum, unique
from typing import Dict, Final, Tuple, Union

import numpy as np
Expand Down Expand Up @@ -83,7 +83,7 @@ def convert_city_coords_to_utm(points_city: Union[NDArrayFloat, NDArrayInt], cit
latitude, longitude = CITY_ORIGIN_LATLONG_DICT[city_name]
# get (easting, northing) of origin
origin_utm = convert_gps_to_utm(latitude=latitude, longitude=longitude, city_name=city_name)

points_utm: NDArrayFloat = points_city.astype(float) + np.array(origin_utm, dtype=float)
return points_utm

Expand Down
2 changes: 1 addition & 1 deletion tests/geometry/test_utm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

import av2.geometry.utm as geo_utils
from av2.geometry.utm import CityName, CITY_ORIGIN_LATLONG_DICT
from av2.geometry.utm import CityName
from av2.utils.typing import NDArrayFloat


Expand Down