Skip to content

Commit

Permalink
Merge pull request #234 from benjaminrwilson/autoflake
Browse files Browse the repository at this point in the history
Autoflake the repository.
  • Loading branch information
benjaminrwilson authored Jun 4, 2021
2 parents 706f783 + 895c849 commit 469bb46
Show file tree
Hide file tree
Showing 39 changed files with 25 additions and 102 deletions.
8 changes: 3 additions & 5 deletions argoverse/data_loading/frame_label_accumulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import glob
import logging
import os
import pickle as pkl
import tempfile
from pathlib import Path
from typing import Dict, List, Optional, Tuple
Expand All @@ -18,9 +17,7 @@
from argoverse.data_loading.synchronization_database import SynchronizationDB
from argoverse.data_loading.trajectory_loader import TrajectoryLabel, load_json_track_labels
from argoverse.utils.json_utils import read_json_file
from argoverse.utils.pkl_utils import load_pkl_dictionary, save_pkl_dictionary
from argoverse.utils.se3 import SE3
from argoverse.utils.transform import quat2rotmat
from argoverse.utils.pkl_utils import save_pkl_dictionary

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -65,7 +62,8 @@ def __init__(
log_egopose_dict_fpath = f"{tmp_dir}/log_egopose_dict_{experiment_prefix}.pkl"
log_timestamp_dict_fpath = f"{tmp_dir}/log_timestamp_dict_{experiment_prefix}.pkl"

coordinate_system = "map_world_fr"
# coordinate system is the map world frame

self.per_city_traj_dict: Dict[str, List[Tuple[np.ndarray, str]]] = {
"MIA": [],
"PIT": [],
Expand Down
4 changes: 1 addition & 3 deletions argoverse/data_loading/object_label_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

# <Copyright 2019, Argo AI, LLC. Released under the MIT license.>

import copy
import json
import os
from typing import Any, Dict, Iterable, List, Optional, Tuple
from typing import Any, Dict, List, Optional, Tuple

import cv2
import numpy as np

from argoverse.utils.calibration import CameraConfig, proj_cam_to_uv
Expand Down
4 changes: 0 additions & 4 deletions argoverse/data_loading/simple_track_dataloader.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# <Copyright 2019, Argo AI, LLC. Released under the MIT license.>

import glob
import sys
from pathlib import Path
from typing import Any, List, Mapping, Optional

import numpy as np

from argoverse.data_loading.pose_loader import get_city_SE3_egovehicle_at_sensor_t, read_city_name
from argoverse.data_loading.synchronization_database import SynchronizationDB
from argoverse.utils.json_utils import read_json_file
from argoverse.utils.se3 import SE3
from argoverse.utils.transform import quat2rotmat


class SimpleArgoverseTrackingDataLoader:
Expand Down
3 changes: 1 addition & 2 deletions argoverse/data_loading/synchronization_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import glob
import logging
from pathlib import Path
from typing import Dict, Iterable, List, Optional, Tuple, cast
from typing import Dict, Iterable, Optional, Tuple, cast

import numpy as np
from typing_extensions import Final

from argoverse.sensor_dataset_config import ArgoverseConfig
from argoverse.utils.camera_stats import RING_CAMERA_LIST, STEREO_CAMERA_LIST
from argoverse.utils.json_utils import read_json_file
from argoverse.utils.metric_time import TimeUnit, to_metric_time

logger = logging.getLogger(__name__)
Expand Down
1 change: 0 additions & 1 deletion argoverse/data_loading/trajectory_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import glob
import json
import logging
import sys
from pathlib import Path
from typing import List, NamedTuple

Expand Down
2 changes: 0 additions & 2 deletions argoverse/data_loading/vector_map_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@

import logging
import os
import pathlib
import sys
import xml.etree.ElementTree as ET
from typing import Any, Dict, List, Mapping, MutableMapping, Optional, Tuple, Union, cast

Expand Down
1 change: 0 additions & 1 deletion argoverse/evaluation/competition_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import shutil
import tempfile
import uuid
import zipfile
from typing import Dict, List, Optional, Tuple, Union

import h5py
Expand Down
3 changes: 1 addition & 2 deletions argoverse/evaluation/eval_forecasting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"""This module evaluates the forecasted trajectories against the ground truth."""

import math
import pickle as pkl
from typing import Dict, List, Optional, Tuple
from typing import Dict, List, Optional

import numpy as np

Expand Down
1 change: 0 additions & 1 deletion argoverse/evaluation/eval_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# <Copyright 2019, Argo AI, LLC. Released under the MIT license.>
"""Utilities used in evaluation of performance."""

import copy
from typing import Any, Dict, List, Tuple

import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion argoverse/map_representation/lane_segment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# <Copyright 2019, Argo AI, LLC. Released under the MIT license.>
from typing import List, Optional, Sequence
from typing import List, Optional

import numpy as np

Expand Down
1 change: 0 additions & 1 deletion argoverse/map_representation/map_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import copy
import os
from os import PathLike
from pathlib import Path
from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple, Union

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

"""Breadth-First-Search of Graphs."""

from typing import Any, Collection, List, Mapping, MutableMapping, Sequence
from typing import Any, List, Mapping, MutableMapping, Sequence


def bfs_enumerate_paths(graph: Mapping[str, Sequence[str]], start: str, max_depth: int = 4) -> List[List[str]]:
Expand Down
8 changes: 1 addition & 7 deletions argoverse/utils/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@
from typing_extensions import Literal

from argoverse.data_loading.pose_loader import get_city_SE3_egovehicle_at_sensor_t
from argoverse.utils.camera_stats import (
CAMERA_LIST,
RECTIFIED_STEREO_CAMERA_LIST,
RING_CAMERA_LIST,
STEREO_CAMERA_LIST,
get_image_dims_for_camera,
)
from argoverse.utils.camera_stats import CAMERA_LIST, RECTIFIED_STEREO_CAMERA_LIST, get_image_dims_for_camera
from argoverse.utils.se3 import SE3
from argoverse.utils.transform import quat2rotmat

Expand Down
2 changes: 1 addition & 1 deletion argoverse/utils/camera_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# <Copyright 2019, Argo AI, LLC. Released under the MIT license.>

import logging
from typing import List, Optional, Tuple
from typing import Optional, Tuple

from argoverse.sensor_dataset_config import ArgoverseConfig

Expand Down
7 changes: 1 addition & 6 deletions argoverse/utils/centerline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import matplotlib.pyplot as plt
import numpy as np
from shapely.geometry import LinearRing, LineString, Point, Polygon
from shapely.geometry import LinearRing, LineString, Point

from argoverse.map_representation.lane_segment import LaneSegment

Expand Down Expand Up @@ -81,10 +81,7 @@ def centerline_to_polygon(
# right centerline position depends on sign of dx and dy
subtract_cond1 = np.logical_and(dx > 0, dy < 0)
subtract_cond2 = np.logical_and(dx > 0, dy > 0)
add_cond1 = np.logical_and(dx < 0, dy < 0)
add_cond2 = np.logical_and(dx < 0, dy > 0)
subtract_cond = np.logical_or(subtract_cond1, subtract_cond2)
add_cond = np.logical_or(add_cond1, add_cond2)
left_centerline, right_centerline = swap_left_and_right(subtract_cond, left_centerline, right_centerline)

# right centerline also depended on if we added or subtracted y
Expand Down Expand Up @@ -258,8 +255,6 @@ def get_nt_distance(xy: np.ndarray, centerline: np.ndarray, viz: bool = False) -
traj_len = xy.shape[0]
nt_distance = np.zeros((traj_len, 2))

delta_offset = 0.01
last = 0
max_dist: float = -1

for i in range(traj_len):
Expand Down
1 change: 0 additions & 1 deletion argoverse/utils/cuboid_interior.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def filter_point_cloud_to_bbox_2D_vectorized(bbox: np.ndarray, pc_raw: np.ndarra
P1 = np.array([bbox[0][0:2]])
P2 = np.array([bbox[1][0:2]])
P4 = np.array([bbox[2][0:2]])
P5 = np.array([])

dot1 = np.matmul(U, pc_2d.transpose(1, 0))
dot2 = np.matmul(V, pc_2d.transpose(1, 0))
Expand Down
2 changes: 1 addition & 1 deletion argoverse/utils/cv2_plotting_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# <Copyright 2019, Argo AI, LLC. Released under the MIT license.>
"""OpenCV plotting utility functions."""

from typing import Dict, Iterable, List, Tuple, Union
from typing import List, Tuple

import cv2
import numpy as np
Expand Down
5 changes: 2 additions & 3 deletions argoverse/utils/frustum_clipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"""

import copy
import sys
from typing import Any, Iterable, List, Optional, Tuple
from typing import Any, List, Optional, Tuple

import numpy as np

Expand Down Expand Up @@ -232,7 +231,7 @@ def generate_frustum_planes(K: np.ndarray, camera_name: str, near_clip_dist: flo
if img_width is None or img_height is None:
return None

P = np.array([0.0, 0.0, 0.0])
# frustum starts at optical center [0,0,0]
fx = K[0, 0]
fy = K[1, 1]

Expand Down
9 changes: 2 additions & 7 deletions argoverse/utils/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from typing import Tuple, cast

import matplotlib.pyplot as plt
import numpy as np

# For a single line segment
Expand Down Expand Up @@ -177,20 +176,16 @@ def interp_arc(t: int, px: np.ndarray, py: np.ndarray) -> np.ndarray:
"""
px, py = eliminate_duplicates_2d(px, py)

# equally spaced in arclength
# equally spaced in arclength -- the number of points that will be uniformly interpolated
eq_spaced_points = np.linspace(0, 1, t)

# how many points will be uniformly interpolated?
nt = eq_spaced_points.size

# the number of points on the curve itself
n = px.size

# are px and py both vectors of the same length?
assert px.size == py.size

pxy = np.array((px, py)).T
ndim = 2
pxy = np.array((px, py)).T # 2d polyline

# Compute the chordal arclength of each segment.
# Compute differences between each x coord, to get the dx's
Expand Down
2 changes: 0 additions & 2 deletions argoverse/utils/make_att_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
from typing import Any, Dict, List, Tuple

import cv2
import matplotlib.pyplot as plt
import numpy as np
import open3d as o3d
import scipy.interpolate as interpolate
import torch
import torch.nn.functional as F

import argoverse
from argoverse.data_loading.argoverse_tracking_loader import ArgoverseTrackingLoader
from argoverse.utils.json_utils import read_json_file
from argoverse.utils.pkl_utils import save_pkl_dictionary
Expand Down
2 changes: 0 additions & 2 deletions argoverse/utils/make_track_label_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import sys
from typing import Any, Dict, List

from typing_extensions import TypedDict

from argoverse.utils.json_utils import read_json_file, save_json_dict

root_dir = sys.argv[1]
Expand Down
2 changes: 1 addition & 1 deletion argoverse/utils/manhattan_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""Fast search functions of nearest neighbor based on Manhattan distance."""

import logging
from typing import List, Tuple, Union
from typing import List, Tuple

import numpy as np

Expand Down
2 changes: 0 additions & 2 deletions argoverse/utils/plane_visualization_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# <Copyright 2019, Argo AI, LLC. Released under the MIT license.>

import sys
from typing import List, Optional

import numpy as np
Expand All @@ -11,7 +10,6 @@
Figure,
draw_mayavi_line_segment,
plot_3d_clipped_bbox_mayavi,
plot_bbox_3d_mayavi,
plot_points_3D_mayavi,
)

Expand Down
6 changes: 0 additions & 6 deletions argoverse/visualization/generate_sequence_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@

import argparse
import os
import re
import shutil
import sys
from collections import defaultdict
from typing import List

import matplotlib.animation as anim
import matplotlib.lines as mlines
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy.interpolate import interp1d

from argoverse.map_representation.map_api import ArgoverseMap
from argoverse.visualization.visualize_sequences import viz_sequence
Expand Down Expand Up @@ -49,7 +44,6 @@ def main(arguments: List[str]) -> int:
# Get API for Argo Dataset map
avm = ArgoverseMap()
city_name = df["CITY_NAME"].values[0]
seq_lane_bbox = avm.city_halluc_bbox_table[city_name]
seq_lane_props = avm.city_lane_centerlines_dict[city_name]

x_min = min(df["X"])
Expand Down
6 changes: 1 addition & 5 deletions argoverse/visualization/visualization_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
from collections import defaultdict
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union

import cv2
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image

from argoverse.data_loading.argoverse_tracking_loader import ArgoverseTrackingLoader
from argoverse.data_loading.object_classes import OBJ_CLASS_MAPPING_DICT
from argoverse.data_loading.object_label_record import ObjectLabelRecord
from argoverse.utils.calibration import Calibration, determine_valid_cam_coords, proj_cam_to_uv
from argoverse.utils.calibration import Calibration
from argoverse.utils.frustum_clipping import generate_frustum_planes

point_size = 0.01
Expand Down Expand Up @@ -208,8 +207,6 @@ def draw_box(
def show_image_with_boxes(img: np.ndarray, objects: Iterable[ObjectLabelRecord], calib: Calibration) -> np.ndarray:
"""Show image with 2D bounding boxes."""
img1 = np.copy(img)
K = calib.K
d = calib.d

h, w = np.shape(img1)[0:2]
planes = generate_frustum_planes(calib.K, calib.camera)
Expand All @@ -219,7 +216,6 @@ def show_image_with_boxes(img: np.ndarray, objects: Iterable[ObjectLabelRecord],
if obj.occlusion == 100:
continue
box3d_pts_3d = obj.as_3d_bbox()
uv = calib.project_ego_to_image(box3d_pts_3d)
uv_cam = calib.project_ego_to_cam(box3d_pts_3d)

img1 = obj.render_clip_frustum_cv2(
Expand Down
Loading

0 comments on commit 469bb46

Please sign in to comment.