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

Detection eval max boxes fix #227

Merged
merged 12 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from 9 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
5 changes: 1 addition & 4 deletions argoverse/evaluation/detection/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,7 @@ def rank(dts: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
ranked_scores = scores[ranks]

# Ensure the number of boxes considered per class is at most `MAX_NUM_BOXES`.
if ranked_dts.shape[0] > MAX_NUM_BOXES:
ranked_dts = ranked_dts[:MAX_NUM_BOXES]
ranked_scores = ranked_scores[:MAX_NUM_BOXES]
return ranked_dts, ranked_scores
return ranked_dts[:MAX_NUM_BOXES], ranked_scores[:MAX_NUM_BOXES]


def interp(prec: np.ndarray, method: InterpType = InterpType.ALL) -> np.ndarray:
Expand Down
2 changes: 1 addition & 1 deletion argoverse/map_representation/map_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ArgoverseMap:
"""

def __init__(self, root: _PathLike = ROOT) -> None:
""" Initialize the Argoverse Map. """
"""Initialize the Argoverse Map."""
self.root = root

self.city_name_to_city_id_dict = {"PIT": PITTSBURGH_ID, "MIA": MIAMI_ID}
Expand Down
2 changes: 1 addition & 1 deletion argoverse/utils/make_att_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def compute_v_a(traj: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:


def make_att_files(root_dir: str) -> None:
""" Write a .pkl file with difficulty attributes per track """
"""Write a .pkl file with difficulty attributes per track"""
path_output_vis = "vis_output"
filename_output = "att_file.npy"

Expand Down
2 changes: 1 addition & 1 deletion argoverse/utils/sim2.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


class Sim2:
""" Implements the Similarity(2) class."""
"""Implements the Similarity(2) class."""

def __init__(self, R: np.ndarray, t: np.ndarray, s: Union[int, float]) -> None:
"""Initialize from rotation R, translation t, and scale s.
Expand Down
4 changes: 2 additions & 2 deletions argoverse/utils/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def quat_argo2scipy(q: np.ndarray) -> np.ndarray:


def quat_argo2scipy_vectorized(q: np.ndarray) -> np.ndarray:
""""Re-order Argoverse's scalar-first [w,x,y,z] quaternion order to Scipy's scalar-last [x,y,z,w]"""
"""Re-order Argoverse's scalar-first [w,x,y,z] quaternion order to Scipy's scalar-last [x,y,z,w]"""
return q[..., [1, 2, 3, 0]]


def quat_scipy2argo_vectorized(q: np.ndarray) -> np.ndarray:
""""Re-order Scipy's scalar-last [x,y,z,w] quaternion order to Argoverse's scalar-first [w,x,y,z]."""
"""Re-order Scipy's scalar-last [x,y,z,w] quaternion order to Argoverse's scalar-first [w,x,y,z]."""
return q[..., [3, 0, 1, 2]]
2 changes: 1 addition & 1 deletion argoverse/visualization/visualization_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def draw_box(


def show_image_with_boxes(img: np.ndarray, objects: Iterable[ObjectLabelRecord], calib: Calibration) -> np.ndarray:
""" Show image with 2D bounding boxes """
"""Show image with 2D bounding boxes."""
img1 = np.copy(img)
K = calib.K
d = calib.d
Expand Down
2 changes: 1 addition & 1 deletion demo_usage/visualize_30hz_benchmark_data_on_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def render_front_camera_on_axis(self, ax: plt.Axes, timestamp: int, log_id: str)


def visualize_30hz_benchmark_data_on_map(args: Any) -> None:
""""""
"""Function to render lidar, imagery, and map elements overlaid on both a bird's-eye-view and egoview."""
benjaminrwilson marked this conversation as resolved.
Show resolved Hide resolved
domv = DatasetOnMapVisualizer(
args.dataset_dir,
args.experiment_prefix,
Expand Down
73 changes: 9 additions & 64 deletions integration_tests/test_map_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


def add_lane_segment_to_ax(
ax: plt.axes.Axis,
ax: plt.Axes,
lane_centerline: np.ndarray,
lane_polygon: np.ndarray,
patch_color: str,
Expand All @@ -25,14 +25,14 @@ def add_lane_segment_to_ax(
ymin: float,
ymax: float,
) -> None:
""""""
"""Utility function to add a lane segment to an Matplotlib axis."""
plot_lane_segment_patch(lane_polygon, ax, color=patch_color, alpha=0.3)


def find_lane_segment_bounds_in_table(
avm: ArgoverseMap, city_name: str, lane_segment_id: int
) -> Tuple[float, float, float, float]:
""""""
""" """
benjaminrwilson marked this conversation as resolved.
Show resolved Hide resolved
match_found = False
# find the lane segment inside the table
for table_idx, table_lane_id in avm.city_halluc_tableidx_to_laneid_map[city_name].items():
Expand All @@ -47,7 +47,7 @@ def find_lane_segment_bounds_in_table(


def verify_halluc_lane_extent_index(enable_lane_boundaries: bool = False) -> None:
""""""
"""Produce graphs for verifying lane segment extents."""
avm = ArgoverseMap()

city_names = ["MIA", "PIT"]
Expand Down Expand Up @@ -157,64 +157,10 @@ def verify_halluc_lane_extent_index(enable_lane_boundaries: bool = False) -> Non
plt.close("all")


# def verify_manhattan_search_functionality() -> None:
# """
# Minimal example where we
# """
# avm = ArgoverseMap()
# # query_x = 254.
# # query_y = 1778.

# ref_query_x = 422.0
# ref_query_y = 1005.0

# city_name = "PIT" # 'MIA'
# for trial_idx in range(10):
# query_x = ref_query_x + (np.random.rand() - 0.5) * 10
# query_y = ref_query_y + (np.random.rand() - 0.5) * 10

# # query_x,query_y = (3092.49845414,1798.55426805)
# query_x, query_y = (3112.80160113, 1817.07585338)

# lane_segment_ids = avm.get_lane_ids_in_xy_bbox(query_x, query_y, city_name, 5000)

# fig = plt.figure(figsize=(22.5, 8))
# ax = fig.add_subplot(111)
# # ax.scatter([query_x], [query_y], 500, color='k', marker='.')

# plot_lane_segment_patch(pittsburgh_bounds, ax, color="m", alpha=0.1)

# if len(lane_segment_ids) > 0:
# for i, lane_segment_id in enumerate(lane_segment_ids):
# patch_color = "y" # patch_colors[i % 4]
# lane_centerline = avm.get_lane_segment_centerline(lane_segment_id, city_name)

# test_x, test_y = lane_centerline.mean(axis=0)
# inside = point_inside_polygon(
# n_poly_vertices, pittsburgh_bounds[:, 0], pittsburgh_bounds[:, 1], test_x, test_y
# )

# if inside:
# halluc_lane_polygon = avm.get_lane_segment_polygon(lane_segment_id, city_name)
# xmin, ymin, xmax, ymax = find_lane_segment_bounds_in_table(avm, city_name, lane_segment_id)
# add_lane_segment_to_ax(
# ax, lane_centerline, halluc_lane_polygon, patch_color, xmin, xmax, ymin, ymax
# )

# ax.axis("equal")
# plt.show()
# datetime_str = generate_datetime_string()
# plt.savefig(f"{trial_idx}_{datetime_str}.jpg")
# plt.close("all")


def verify_point_in_polygon_for_lanes() -> None:
""""""
"""Verify point in polygon for lane segments."""
avm = ArgoverseMap()

# ref_query_x = 422.
# ref_query_y = 1005.

ref_query_x = -662
ref_query_y = 2817

Expand Down Expand Up @@ -244,15 +190,15 @@ def verify_point_in_polygon_for_lanes() -> None:


def plot_nearby_halluc_lanes(
ax: plt.axes.Axis,
ax: plt.Axes,
city_name: str,
avm: ArgoverseMap,
query_x: float,
query_y: float,
patch_color: str = "r",
radius: float = 20.0,
) -> None:
""""""
"""Produce lane segment graphs for visual verification."""
nearby_lane_ids = avm.get_lane_ids_in_xy_bbox(query_x, query_y, city_name, radius)
for nearby_lane_id in nearby_lane_ids:
halluc_lane_polygon = avm.get_lane_segment_polygon(nearby_lane_id, city_name)
Expand All @@ -265,8 +211,7 @@ def plot_nearby_halluc_lanes(


def verify_lane_tangent_vector() -> None:
"""
debug low confidence lane tangent predictions
"""Debug low confidence lane tangent predictions.

I noticed that the confidence score of lane direction is
pretty low (almost zero) in some logs
Expand Down Expand Up @@ -511,7 +456,7 @@ def test_get_candidate_centerlines_for_traj() -> None:


def test_dfs() -> None:
"""Test dfs for lane graph
"""Test dfs for lane graph.

Lane Graph:
9629626
Expand Down
6 changes: 3 additions & 3 deletions integration_tests/test_plane_visualization_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@

@skip_if_mayavi_missing # type: ignore
def test_plot_frustum_planes_and_normals() -> None:
""""""
"""Test plotting frustum planes and normals for visualization in `mayavi`."""

assert planes is not None
plot_frustum_planes_and_normals(planes, cuboid_verts=None, near_clip_dist=0.5)


@skip_if_mayavi_missing # type: ignore
def test_populate_frustum_voxels() -> None:
""""""
"""Test populating frustum voxels for visualization in `mayavi`."""
fig, axis_pair = plt.subplots(1, 1, figsize=(20, 15))

assert planes is not None
Expand All @@ -56,6 +56,6 @@ def test_populate_frustum_voxels() -> None:

@skip_if_mayavi_missing # type: ignore
def test_get_perpendicular() -> None:
""""""
"""Test getting an orthogonal vector from a given query vector."""
n = [0, 1, 1]
result = get_perpendicular(n)
2 changes: 1 addition & 1 deletion tests/test_cuboid_interior.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_scenario_1() -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:


def test_extract_pc_in_box3d_hull() -> None:
""""""
"""Test extracting a point cloud from a 3D convex hull."""
pc_raw, bbox_3d, gt_segment, gt_is_valid = get_scenario_1()
segment, is_valid = extract_pc_in_box3d_hull(pc_raw, bbox_3d)

Expand Down
Loading