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

add simple Github Actions workflow #193

Merged
merged 30 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
46bfcef
add simple Github Actions workflow
johnwlambert Feb 10, 2021
3edd1fa
fix typo in github actions yaml
johnwlambert Feb 10, 2021
4e87a85
remove travis yaml file
johnwlambert Feb 10, 2021
a8b7da1
fix typos in type hints
johnwlambert Feb 10, 2021
4dca157
fix incorrect type hints
johnwlambert Feb 11, 2021
e90ee27
fix incorrect type hints np.ndarray instead of np.array
johnwlambert Feb 11, 2021
c06965c
fix incorrect type hints
johnwlambert Feb 11, 2021
65cde47
fix incorrect type hints
johnwlambert Feb 11, 2021
30e323d
fix incorrect type hint
johnwlambert Feb 11, 2021
ccc0e97
fix incorrect type hints
johnwlambert Feb 11, 2021
03e5f71
fix incorrect type annotation
johnwlambert Feb 11, 2021
1c26911
fix incorrect type hint np.ndarray instead of np.array
johnwlambert Feb 11, 2021
e0aab43
fix type hint
johnwlambert Feb 11, 2021
b755ec1
fix incorrect type hints
johnwlambert Feb 11, 2021
dad8eab
fix incorrect type hint
johnwlambert Feb 11, 2021
e13d333
use 3.7.1 instead of defaulting to 3.7.9
johnwlambert Feb 11, 2021
880914d
fix incorrect type hints
johnwlambert Feb 11, 2021
ce400e1
remove redundant logic in generate_sequence_videos.py
johnwlambert Feb 11, 2021
86de582
use numpy 1.19, not 1.20
johnwlambert Feb 11, 2021
87b0ece
add nolint type ignore for mayavi
johnwlambert Feb 11, 2021
15d4444
add lint ignore for mypy on mayavi lines
johnwlambert Feb 11, 2021
5dfb31f
at least two spaces before inline comment
johnwlambert Feb 11, 2021
80b646c
fix line length > 120 error after adding nolint
johnwlambert Feb 11, 2021
d16c9bb
add mypy nolint for mayavi calls
johnwlambert Feb 11, 2021
28ec852
removed unused nolint mypy command
johnwlambert Feb 11, 2021
62c382d
run pre-commit on all files
johnwlambert Feb 11, 2021
fb4c173
reformat w/ python black
johnwlambert Feb 11, 2021
1f45ea3
remove temp file after creating it
johnwlambert Feb 11, 2021
f9d47a8
Delete json_save_test_file.json
johnwlambert Feb 11, 2021
426ff4c
Update test_json_utils.py
johnwlambert Feb 11, 2021
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
27 changes: 27 additions & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Python CI

# Run this workflow every time a new commit is pushed to repository
on: [pull_request]

jobs:
run-unit-tests:

name: Run all unit tests in codebase
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7.1

- name: Install dependencies
run: |
pip install tox==3.12.1 pre-commit==1.17.0

- name: Test with tox
run: |
tox
pre-commit run --all-files

18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions argoverse/data_loading/frame_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class FrameRecord:

def __init__(
self,
bbox_city_fr: np.array,
bbox_ego_frame: np.array,
bbox_city_fr: np.ndarray,
bbox_ego_frame: np.ndarray,
occlusion_val: int,
color: Tuple[float, float, float],
track_uuid: str,
Expand Down
14 changes: 7 additions & 7 deletions argoverse/data_loading/object_label_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
class ObjectLabelRecord:
def __init__(
self,
quaternion: np.array,
translation: np.array,
quaternion: np.ndarray,
translation: np.ndarray,
length: float,
width: float,
height: float,
Expand Down Expand Up @@ -136,9 +136,9 @@ def as_3d_bbox(self) -> np.ndarray:

def render_clip_frustum_cv2(
self,
img: np.array,
corners: np.array,
planes: List[Tuple[np.array, np.array, np.array, np.array, np.array]],
img: np.ndarray,
corners: np.ndarray,
planes: List[Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]],
camera_config: CameraConfig,
colors: Tuple[Tuple[int, int, int], Tuple[int, int, int], Tuple[int, int, int]] = (
BLUE_RGB,
Expand Down Expand Up @@ -181,7 +181,7 @@ def render_clip_frustum_cv2(
img: Numpy array of shape (M,N,3), representing updated image
"""

def draw_rect(selected_corners: np.array, color: Tuple[int, int, int]) -> None:
def draw_rect(selected_corners: np.ndarray, color: Tuple[int, int, int]) -> None:
prev = selected_corners[-1]
for corner in selected_corners:
draw_clipped_line_segment(
Expand Down Expand Up @@ -267,7 +267,7 @@ def draw_alpha_rectangle(
return vis_mask(img, mask, np.array(list(color_rgb[::-1])), alpha)


def form_obj_label_from_json(label: Dict[str, Any]) -> Tuple[np.array, str]:
def form_obj_label_from_json(label: Dict[str, Any]) -> Tuple[np.ndarray, str]:
"""Construct object from loaded json.

The dictionary loaded from saved json file is expected to have the
Expand Down
2 changes: 1 addition & 1 deletion argoverse/evaluation/eval_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def iou_polygon(poly1: Polygon, poly2: Polygon) -> float:
return float(1 - inter / union)


def get_distance_iou_3d(x1: np.ndarray, x2: np.ndarray, name: str = "bbox") -> float:
def get_distance_iou_3d(x1: Dict[str, np.ndarray], x2: Dict[str, np.ndarray], name: str = "bbox") -> float:
"""
Note this is not traditional 2d or 3d iou, but rather we align two cuboids
along their x-axes, and compare 3d volume differences.
Expand Down
4 changes: 2 additions & 2 deletions argoverse/map_representation/map_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def get_vector_map_lane_polygons(self, city_name: str) -> List[np.ndarray]:

return lane_polygons

def get_vector_map_driveable_areas(self, city_name: str) -> List[np.hstack]:
def get_vector_map_driveable_areas(self, city_name: str) -> List[np.ndarray]:
"""
Get driveable area for a specified city

Expand All @@ -118,7 +118,7 @@ def get_vector_map_driveable_areas(self, city_name: str) -> List[np.hstack]:
"""
return self.get_da_contours(city_name)

def get_da_contours(self, city_name: str) -> List[np.hstack]:
def get_da_contours(self, city_name: str) -> List[np.ndarray]:
"""
We threshold the binary driveable area or ROI image and obtain contour lines. These
contour lines represent the boundary.
Expand Down
18 changes: 9 additions & 9 deletions argoverse/utils/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, camera_config: CameraConfig, calib: Dict[str, Any]) -> None:

self.camera = calib["key"][10:]

def cart2hom(self, pts_3d: np.array) -> np.ndarray:
def cart2hom(self, pts_3d: np.ndarray) -> np.ndarray:
"""Convert Cartesian coordinates to Homogeneous.

Args:
Expand All @@ -107,7 +107,7 @@ def cart2hom(self, pts_3d: np.array) -> np.ndarray:
pts_3d_hom = np.hstack((pts_3d, np.ones((n, 1))))
return pts_3d_hom

def project_ego_to_image(self, pts_3d_ego: np.array) -> np.ndarray:
def project_ego_to_image(self, pts_3d_ego: np.ndarray) -> np.ndarray:
"""Project egovehicle coordinate to image.

Args:
Expand All @@ -120,7 +120,7 @@ def project_ego_to_image(self, pts_3d_ego: np.array) -> np.ndarray:
uv_cam = self.project_ego_to_cam(pts_3d_ego)
return self.project_cam_to_image(uv_cam)

def project_ego_to_cam(self, pts_3d_ego: np.array) -> np.ndarray:
def project_ego_to_cam(self, pts_3d_ego: np.ndarray) -> np.ndarray:
"""Project egovehicle point onto camera frame.

Args:
Expand All @@ -134,18 +134,18 @@ def project_ego_to_cam(self, pts_3d_ego: np.array) -> np.ndarray:

return uv_cam.transpose()[:, 0:3]

def project_cam_to_ego(self, pts_3d_rect: np.array) -> np.ndarray:
def project_cam_to_ego(self, pts_3d_rect: np.ndarray) -> np.ndarray:
"""Project point in camera frame to egovehicle frame.

Args:
pts_3d_rect (np.array): nx3 points in cam coord.
pts_3d_rect: nx3 points in cam coord.

Returns:
np.array: nx3 points in ego coord.
nx3 points in ego coord.
"""
return np.linalg.inv((self.extrinsic)).dot(self.cart2hom(pts_3d_rect).transpose()).transpose()[:, 0:3]

def project_image_to_ego(self, uv_depth: np.array) -> np.ndarray:
def project_image_to_ego(self, uv_depth: np.ndarray) -> np.ndarray:
"""Project 2D image with depth to egovehicle coordinate.

Args:
Expand All @@ -158,7 +158,7 @@ def project_image_to_ego(self, uv_depth: np.array) -> np.ndarray:
uv_cam = self.project_image_to_cam(uv_depth)
return self.project_cam_to_ego(uv_cam)

def project_image_to_cam(self, uv_depth: np.array) -> np.ndarray:
def project_image_to_cam(self, uv_depth: np.ndarray) -> np.ndarray:
"""Project 2D image with depth to camera coordinate.

Args:
Expand All @@ -180,7 +180,7 @@ def project_image_to_cam(self, uv_depth: np.array) -> np.ndarray:
pts_3d_cam[:, 2] = uv_depth[:, 2]
return pts_3d_cam

def project_cam_to_image(self, pts_3d_rect: np.array) -> np.ndarray:
def project_cam_to_image(self, pts_3d_rect: np.ndarray) -> np.ndarray:
"""Project camera coordinate to image.

Args:
Expand Down
6 changes: 4 additions & 2 deletions argoverse/utils/centerline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def remove_overlapping_lane_seq(lane_seqs: List[List[int]]) -> List[List[int]]:

def lane_waypt_to_query_dist(
query_xy_city_coords: np.ndarray, nearby_lane_objs: List[LaneSegment]
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
) -> Tuple[np.ndarray, np.ndarray, List[np.ndarray]]:
"""
Compute the distance from a query to the closest waypoint in nearby lanes.

Expand All @@ -386,7 +386,9 @@ def lane_waypt_to_query_dist(
nearby_lane_objs: list of LaneSegment objects

Returns:
Tuple of (per_lane_dists, min_dist_nn_indices, dense_centerlines); all numpy arrays
per_lane_dists: array with distance to closest waypoint for each centerline
min_dist_nn_indices: array with ranked indices of centerlines, closest first
dense_centerlines: list of arrays, each representing (N,2) centerline
"""
per_lane_dists: List[float] = []
dense_centerlines: List[np.ndarray] = []
Expand Down
2 changes: 1 addition & 1 deletion argoverse/utils/cuboid_interior.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def filter_point_cloud_to_bbox_3D_single_pt(bbox: np.ndarray, x: np.ndarray) ->
return valid


def filter_point_cloud_to_bbox_3D_vectorized(bbox: np.ndarray, pc_raw: np.ndarray) -> np.ndarray:
def filter_point_cloud_to_bbox_3D_vectorized(bbox: np.ndarray, pc_raw: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
r"""

Args:
Expand Down
8 changes: 4 additions & 4 deletions argoverse/utils/cv2_plotting_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ def add_text_cv2(img: np.ndarray, text: str, x: int, y: int, color: Tuple[int, i


def draw_clipped_line_segment(
img: np.array,
vert_a: np.array,
vert_b: np.array,
img: np.ndarray,
vert_a: np.ndarray,
vert_b: np.ndarray,
camera_config: CameraConfig,
linewidth: int,
planes: List[Tuple[np.array, np.array, np.array, np.array, np.array]],
planes: List[Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray]],
color: Tuple[int, int, int],
) -> None:
"""Plot the portion of a line segment that lives within a parameterized 3D camera frustum.
Expand Down
2 changes: 1 addition & 1 deletion argoverse/utils/frustum_clipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def plane_point_side_v3(p: np.ndarray, v: np.ndarray) -> Any:
return p[:3].dot(v) + p[3]


def cuboid_to_2d_frustum_bbox(corners: np.ndarray, planes: List[np.ndarray], K: np.ndarray) -> np.ndarray:
def cuboid_to_2d_frustum_bbox(corners: np.ndarray, planes: List[np.ndarray], K: np.ndarray) -> Optional[np.ndarray]:
"""Convert a 3D cuboid to a 2D frustum bounding box.

We bring the 3D points into each camera, and do the clipping there.
Expand Down
4 changes: 2 additions & 2 deletions argoverse/utils/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def compute_lane_width(left_even_pts: np.ndarray, right_even_pts: np.ndarray) ->
return lane_width


def compute_mid_pivot_arc(single_pt: np.ndarray, arc_pts: np.ndarray) -> np.ndarray:
def compute_mid_pivot_arc(single_pt: np.ndarray, arc_pts: np.ndarray) -> Tuple[np.ndarray, float]:
"""
Given a line of points on one boundary, and a single point on the other side,
produce the middle arc we get by pivoting around the single point.
Expand All @@ -51,7 +51,7 @@ def compute_midpoint_line(
left_ln_bnds: np.ndarray,
right_ln_bnds: np.ndarray,
num_interp_pts: int = NUM_CENTERLINE_INTERP_PTS,
) -> np.ndarray:
) -> Tuple[np.ndarray, float]:
"""
Compute the lane segment centerline by interpolating n points along each
boundary, and then averaging left and right waypoints.
Expand Down
6 changes: 3 additions & 3 deletions argoverse/utils/make_att_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def save_bev_img(
)


def bspline_1d(x: np.array, y: np.array, s: float = 20.0, k: int = 3) -> np.array:
def bspline_1d(x: np.ndarray, y: np.ndarray, s: float = 20.0, k: int = 3) -> np.ndarray:
"""Perform B-Spline smoothing of trajectories for temporal noise reduction

Args:
Expand All @@ -170,7 +170,7 @@ def bspline_1d(x: np.array, y: np.array, s: float = 20.0, k: int = 3) -> np.arra
return interpolate.splev(np.arange(y.shape[0]), tck)


def derivative(x: np.array) -> np.array:
def derivative(x: np.ndarray) -> np.ndarray:
"""Compute time derivatives for velocity and acceleration

Args:
Expand All @@ -192,7 +192,7 @@ def derivative(x: np.array) -> np.array:
return F.conv1d(x_padded, filters)[0, 0].numpy()


def compute_v_a(traj: np.array) -> Tuple[np.array, np.array]:
def compute_v_a(traj: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
"""
Compute velocity and acceleration

Expand Down
8 changes: 4 additions & 4 deletions argoverse/utils/plane_visualization_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def plot_frustum_planes_and_normals(
Returns:
None
"""
fig = mayavi_wrapper.mlab.figure(bgcolor=(1, 1, 1), size=(2000, 1000))
fig = mayavi_wrapper.mlab.figure(bgcolor=(1, 1, 1), size=(2000, 1000)) # type: ignore

if cuboid_verts is not None:
# fig = plot_bbox_3d_mayavi(fig, cuboid_verts)
Expand All @@ -91,7 +91,7 @@ def plot_frustum_planes_and_normals(
plane_pts = generate_grid_on_plane(a, b, c, d, P)
fig = plot_points_3D_mayavi(plane_pts, fig, color)
# plot the normals at (0,0,0.5) and normal vector (u,v,w) given by (a,b,c)
mayavi_wrapper.mlab.quiver3d(
mayavi_wrapper.mlab.quiver3d( # type: ignore
0,
0,
0.5,
Expand Down Expand Up @@ -125,8 +125,8 @@ def plot_frustum_planes_and_normals(
fig = populate_frustum_voxels(planes, fig, "xz")
fig = populate_frustum_voxels(planes, fig, "yz")

mayavi_wrapper.mlab.view(distance=200)
mayavi_wrapper.mlab.show()
mayavi_wrapper.mlab.view(distance=200) # type: ignore
mayavi_wrapper.mlab.show() # type: ignore


def get_perpendicular(n: np.ndarray) -> np.ndarray:
Expand Down
20 changes: 6 additions & 14 deletions argoverse/visualization/generate_sequence_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,12 @@ def main(arguments: List[str]) -> int:

df_cur = df.loc[df["TIMESTAMP"] <= time]

if time == time_list[-1]:
viz_sequence(
df_cur,
lane_centerlines=lane_centerlines,
show=False,
smoothen=False,
)
else:
viz_sequence(
df_cur,
lane_centerlines=lane_centerlines,
show=False,
smoothen=False,
)
viz_sequence(
df_cur,
lane_centerlines=lane_centerlines,
show=False,
smoothen=False,
)

os.makedirs(seq_out_dir, exist_ok=True)

Expand Down
Loading