Skip to content

Commit

Permalink
依赖项更新
Browse files Browse the repository at this point in the history
  • Loading branch information
Puiching-Memory committed Dec 15, 2024
1 parent da4d596 commit 93ef535
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ jobs:
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material[imaging]==9.5.47 mkdocs-git-revision-date-localized-plugin==1.3.0 mkdocs-git-authors-plugin==0.9.2 mkdocs-static-i18n==1.2.3
- run: pip install mkdocs-material[imaging]==9.5.48 mkdocs-git-revision-date-localized-plugin==1.3.0 mkdocs-git-authors-plugin==0.9.2 mkdocs-static-i18n==1.2.3
- run: mkdocs gh-deploy --force
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ python tools\export_pt.py --cfg C:\workspace\github\monolite\experiment\monolite

# Confirm致谢

我们衷心感谢所有为这个神经网络开源项目做出贡献的个人和组织。特别感谢以下贡献者
我们衷心感谢所有为这个神经网络开源项目做出贡献的个人和组织。特别感谢

| type | name | url | title |
| ---------- | ---------------- | --------------------------------------------------- | ------------------------------------------------------------------------ |
Expand Down
11 changes: 11 additions & 0 deletions lib/datasets/kitti_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,17 @@ def roty(t):
s = np.sin(t)
return np.array([[c, 0, s], [0, 1, 0], [-s, 0, c]])

def rotx(t):
"""Rotation about the x-axis."""
c = np.cos(t)
s = np.sin(t)
return np.array([[1, 0, 0], [0, c, -s], [0, s, c]])

def rotz(t):
"""Rotation about the z-axis."""
c = np.cos(t)
s = np.sin(t)
return np.array([[c, -s, 0], [s, c, 0], [0, 0, 1]])

if __name__ == "__main__":
from lib.datasets.kitti import KITTI
Expand Down
71 changes: 50 additions & 21 deletions lib/utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import torch.nn.functional as F
import math
import numpy as np
from typing import Optional,Union
from typing import Optional, Union


def bbox_iou(box1, box2, xywh=True, GIoU=False, DIoU=False, CIoU=False, eps=1e-7):
"""
Expand Down Expand Up @@ -121,31 +122,36 @@ def xyxy2xywh(x):
def filter_boxes(boxes, image_width, image_height):
"""
Filter out boxes that are outside the image boundaries.
Parameters:
- boxes (Tensor): Tensor of shape (n, 4) where each row is [x_min, y_min, x_max, y_max].
- image_width (int): The width of the image.
- image_height (int): The height of the image.
Returns:
- Tensor: Filtered boxes that are within the image boundaries.
"""
# 确保boxes是PyTorch张量
boxes = torch.as_tensor(boxes, dtype=torch.float32)

# 检查边界框的坐标是否在图像范围内
# x_min 和 y_min 应该大于等于0,x_max 和 y_max 应该小于等于图像的宽高
condition = (boxes[:, 0] >= 0) & (boxes[:, 1] >= 0) & \
(boxes[:, 2] <= image_width) & (boxes[:, 3] <= image_height)

condition = (
(boxes[:, 0] >= 0)
& (boxes[:, 1] >= 0)
& (boxes[:, 2] <= image_width)
& (boxes[:, 3] <= image_height)
)

# 同时x_max 应该大于 x_min, y_max 应该大于 y_min
condition = condition & (boxes[:, 2] > boxes[:, 0]) & (boxes[:, 3] > boxes[:, 1])

# 根据条件筛选出合法的边界框
valid_boxes = boxes[condition]

return valid_boxes


def crop_3d_points(
points: np.ndarray,
x_range: tuple[float, float],
Expand All @@ -169,16 +175,39 @@ def crop_3d_points(
return cropped_points


def inside_test(points, cube3d):
"""
cube3d = numpy array of the shape (8,3) with coordinates in the clockwise order. first the bottom plane is considered then the top one.
points = array of points with shape (N, 3).
Returns the indices of the points array which are outside the cube3d
"""
b1, b2, b3, b4, t1, t2, t3, t4 = cube3d

# 计算三个单位法向量dir1、dir2、dir3
dir1 = t1 - b1
size1 = np.linalg.norm(dir1)
dir1 = dir1 / size1

dir2 = b2 - b1
size2 = np.linalg.norm(dir2)
dir2 = dir2 / size2

dir3 = b4 - b1
size3 = np.linalg.norm(dir3)
dir3 = dir3 / size3

# 计算中心点cube3d_center
cube3d_center = (b1 + t3) / 2.0

# 点到中心点cube3d_center的向量
dir_vec = points - cube3d_center

# dir_vec到3个单位法向量的投影距离,再乘2
# 小于box三条边的长度,则符合要求
res1 = np.where((np.absolute(dir_vec @ dir1) * 2) <= size1)[0]
res2 = np.where((np.absolute(dir_vec @ dir2) * 2) <= size2)[0]
res3 = np.where((np.absolute(dir_vec @ dir3) * 2) <= size3)[0]

def rotation_matrix_ry(theta:Union[int,float,np.ndarray])->np.ndarray:
# 将角度转换为弧度
theta_rad = np.radians(theta)

# 创建旋转矩阵
rotation_matrix = np.array([
[np.cos(theta_rad), 0, np.sin(theta_rad)],
[0, 1, 0],
[-np.sin(theta_rad), 0, np.cos(theta_rad)]
])

return rotation_matrix
# 符合的结果取交集
return np.array(list(set(res1) & set(res2) & set(res3)))
17 changes: 10 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ torchinfo==1.8.0
opencv-python==4.10.0.84
pillow==10.4.0
psutil==6.1.0
matplotlib==3.9.3
matplotlib==3.10.0
pyecharts==2.0.7
open3d==0.18.0 # https://www.open3d.org/docs/latest/getting_started.html
#grad-cam==1.5.4
albumentations==1.4.21
albumentations==1.4.22

# log tools (must be installed)
loguru==0.7.2
loguru==0.7.3
rich==13.9.4
swanlab==0.3.27
#tqdm==4.66.5
swanlab==0.4.0
#tqdm==4.67.1

# export tools (optional)
onnx==1.17.0
Expand All @@ -33,14 +33,14 @@ monkeytype==23.3.0
# optimizer tools (optional)
# https://mmengine.readthedocs.io/zh-cn/latest/common_usage/better_optimizers.html
prodigyopt==1.0
lion-pytorch==0.2.2
lion-pytorch==0.2.3
Sophia-Optimizer==0.2.5

# hyperparameter (optional)
optuna==4.1.0

# doc tools (optional)
mkdocs-material[imaging]==9.5.47
mkdocs-material[imaging]==9.5.48
mkdocs-git-revision-date-localized-plugin==1.3.0
mkdocs-git-authors-plugin==0.9.2
mkdocs-static-i18n==1.2.3
Expand All @@ -49,5 +49,8 @@ mkdocs-static-i18n==1.2.3
pytest==8.3.4
pytest-cov==6.0.0

# performance anylysis tools (optional)
# scalene==1.5.49 # Not a eazy way to use

# check if torch.complie is supported on windows
# https://github.com/woct0rdho/triton-windows

0 comments on commit 93ef535

Please sign in to comment.