Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
110 changes: 110 additions & 0 deletions bookmarks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"version": "3.0.2",
"lastModified": "2026-01-14T08:17:18.734Z",
"folders": [],
"bookmarks": [
{
"id": "mj113126drhj06q881n",
"name": "Re-calculate extrinsic matrix based on ground coordinate",
"file": "data/Load_Data.py",
"line": 557,
"character": 16,
"lineContent": "gt_cam_height = cam_extrinsics[2, 3]",
"sortOrder": 2,
"color": "orange"
},
{
"id": "mj11isucznhzdm43lq",
"name": "Coordinate convertion for openlane_300 data",
"file": "data/Load_Data.py",
"line": 587,
"character": 16,
"lineContent": "lane = np.matmul(cam_extrinsics, np.matmul(cam_representation, lane))",
"sortOrder": 3,
"color": "orange"
},
{
"id": "mj11v2knq99epobgbcr",
"name": "convert 3d lanes to flat ground space",
"file": "data/Load_Data.py",
"line": 637,
"character": 8,
"lineContent": "self.convert_lanes_3d_to_gflat(gt_lanes, P_g2gflat)",
"sortOrder": 4,
"color": "orange"
},
{
"id": "mj6hadqnfgbwyfseb0r",
"name": "class Runner:",
"file": "experiments/runner.py",
"line": 43,
"character": 0,
"lineContent": "class Runner:",
"sortOrder": 0
},
{
"id": "mj6harrsdxvm3dmuyje",
"name": "def train(self):",
"file": "experiments/runner.py",
"line": 108,
"character": 4,
"lineContent": "def train(self):",
"sortOrder": 1
},
{
"id": "mj9fg5e8ip7goi8o6bq",
"name": "if not args.no_tb and args.proc_id == 0:",
"file": "experiments/runner.py",
"line": 149,
"character": 8,
"lineContent": "if not args.no_tb and args.proc_id == 0:",
"sortOrder": 7
},
{
"id": "mj9g25gd8p16a05cmsl",
"name": "def WIP__getitem__(self, idx):",
"file": "data/Load_Data.py",
"line": 529,
"character": 4,
"lineContent": "def WIP__getitem__(self, idx):",
"sortOrder": 8
},
{
"id": "mj9mj7jgurjuhpsx1kg",
"name": "train_dataset = LaneDataset(args.dataset_dir, args.data_dir + 'training/', args, data_aug=True, save_std=True, seg_bev=args.seg_bev)",
"file": "experiments/runner.py",
"line": 691,
"character": 12,
"lineContent": "train_dataset = LaneDataset(args.dataset_dir, args.data_dir + 'training/', args, data_aug=True, save_std=True, seg_bev=args.seg_bev)",
"sortOrder": 6
},
{
"id": "mjb74zjwojlzastp8na",
"name": "def init_dataset_openlane_beta(self, dataset_base_dir, json_file_path):",
"file": "data/Load_Data.py",
"line": 1203,
"character": 4,
"lineContent": "def init_dataset_openlane_beta(self, dataset_base_dir, json_file_path):",
"sortOrder": 9,
"color": "green"
},
{
"id": "mjem5vcvvnxgvphy8v",
"name": "x_off_values = x_values - self.anchor_grid_x # offset compared with all anchors instead of closest one",
"file": "data/Load_Data.py",
"line": 2211,
"character": 16,
"lineContent": "x_off_values = x_values - self.anchor_grid_x # offset compared with all anchors instead of closest one",
"sortOrder": 12
},
{
"id": "mjem7osmwbkw3lpimhq",
"name": "if not self.new_match:",
"file": "data/Load_Data.py",
"line": 588,
"character": 12,
"lineContent": "if not self.new_match:",
"sortOrder": 13
}
]
}
7 changes: 4 additions & 3 deletions config/persformer_openlane.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def config(args):

# 1000 sequence
args.dataset_name = 'openlane'
args.dataset_dir = '/mnt/disk01/openlane/images/'
args.data_dir = '/mnt/disk01/openlane/lane3d_1000/'
args.dataset_dir = '/root/autodl-tmp/dataset/openlane-v1.0/images/'
args.data_dir = '/root/autodl-tmp/dataset/openlane-v1.0/lane3d_1000/'

if 'openlane' in args.dataset_name:
openlane_config(args)
Expand Down Expand Up @@ -121,7 +121,8 @@ def config(args):
args.num_y_steps = len(args.anchor_y_steps)

# ddp related
args.dist = True
# args.dist = True
args.dist = False
args.sync_bn = True

args.cudnn = True
Expand Down
52 changes: 34 additions & 18 deletions data/Load_Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@

class LaneDataset(Dataset):
"""
Dataset with labeled lanes
This implementation considers:
w/o laneline 3D attributes
w/o centerline annotations
default considers 3D laneline, including centerlines

This new version of data loader prepare ground-truth anchor tensor in flat ground space.
It is assumed the dataset provides accurate visibility labels. Preparing ground-truth tensor depends on it.
带标注车道线的数据集
本实现考虑:
不含车道线的3D属性
不含中心线标注
默认考虑3D车道线,包括中心线

这个新版本的数据加载器在平地空间中准备真实锚点张量。
假设数据集提供了准确的可见性标签。准备真实张量依赖于这些标签。
"""
# dataset_base_dir is image path, json_file_path is json file path,
def __init__(self, dataset_base_dir, json_file_path, args, data_aug=False, save_std=False, seg_bev=False):
Expand Down Expand Up @@ -97,7 +97,7 @@ def __init__(self, dataset_base_dir, json_file_path, args, data_aug=False, save_

self.K = args.K
self.H_crop = homography_crop_resize([args.org_h, args.org_w], args.crop_y, [args.resize_h, args.resize_w])
# transformation from ipm to ground region
# 从 IPM 到地面区域的转换
self.H_ipm2g = cv2.getPerspectiveTransform(np.float32([[0, 0],
[self.ipm_w-1, 0],
[0, self.ipm_h-1],
Expand Down Expand Up @@ -263,7 +263,7 @@ def __init__(self, dataset_base_dir, json_file_path, args, data_aug=False, save_

self.save_json_path = args.save_json_path

# parse ground-truth file
# 解析真实数据文件
if 'openlane' in self.dataset_name:
self._x_off_std, \
self._y_off_std, \
Expand Down Expand Up @@ -529,6 +529,7 @@ def preprocess_data_from_json_openlane(self, idx_json_file):
_laneline_ass_id = None

with open(idx_json_file, 'r') as file:
# idx_json_file:具体的JSON文件
file_lines = [line for line in file]
info_dict = json.loads(file_lines[0])

Expand All @@ -539,12 +540,15 @@ def preprocess_data_from_json_openlane(self, idx_json_file):
if not self.fix_cam:
cam_extrinsics = np.array(info_dict['extrinsic'])
# Re-calculate extrinsic matrix based on ground coordinate
# 绕Z轴旋转-90°的矩阵
R_vg = np.array([[0, 1, 0],
[-1, 0, 0],
[0, 0, 1]], dtype=float)
# 绕X轴旋转-90°的矩阵
R_gc = np.array([[1, 0, 0],
[0, 0, 1],
[0, -1, 0]], dtype=float)
# 坐标系的相似变换加上一个坐标轴重新定向
cam_extrinsics[:3, :3] = np.matmul(np.matmul(
np.matmul(np.linalg.inv(R_vg), cam_extrinsics[:3, :3]),
R_vg), R_gc)
Expand Down Expand Up @@ -700,7 +704,7 @@ def __len__(self):
"""
return self.n_samples

# new getitem, WIP
# 新的getitem,进行中
def WIP__getitem__(self, idx):
"""
Args: idx (int): Index in list to load image
Expand Down Expand Up @@ -791,6 +795,13 @@ def WIP__getitem__(self, idx):
image = F.crop(image, self.h_crop, 0, self.h_org-self.h_crop, self.w_org)
image = F.resize(image, size=(self.h_net, self.w_net), interpolation=InterpolationMode.BILINEAR)

# Debug:Visualize resize image
import matplotlib.pyplot as plt
import numpy as np
plt.imshow(np.array(image))
plt.title(f'缩放后: {image.size}')
plt.show()

gt_anchor = np.zeros([self.anchor_num, self.num_types, self.anchor_dim], dtype=np.float32)
gt_anchor[:, :, self.anchor_dim - self.num_category] = 1.0
gt_lanes = _label_laneline
Expand Down Expand Up @@ -1193,12 +1204,15 @@ def read_cache_file_beta(self, cache_file):
def init_dataset_openlane_beta(self, dataset_base_dir, json_file_path):
"""
:param dataset_info_file:
:return: image paths, labels in unormalized net input coordinates
:return: 图像路径,标签在未归一化的网络输入坐标中

data processing:
ground truth labels map are scaled wrt network input sizes
数据处理:
真值标签映射相对于网络输入尺寸进行缩放
"""
# args.dataset_dir = '/root/autodl-tmp/dataset/openlane-v1.0/images/'
# args.data_dir = '/root/autodl-tmp/dataset/openlane-v1.0/lane3d_1000/training/'

# 返回所有匹配文件完整路径的列表,赋值给 label_list 变量
label_list = glob.glob(json_file_path + '**/*.json', recursive=True)

# save label list and this determine the idx order
Expand Down Expand Up @@ -1277,6 +1291,8 @@ def init_dataset_openlane_beta(self, dataset_base_dir, json_file_path):
file_lines = [line for line in file]
info_dict = json.loads(file_lines[0])

# args.dataset_dir = '/root/autodl-tmp/dataset/openlane-v1.0/images/'
# file_path "training/segment-15832924468527961_1564_160_1584_160_with_camera_labels/150767882687643500.jpg"
image_path = ops.join(dataset_base_dir, info_dict['file_path'])
assert ops.exists(image_path), '{:s} not exist'.format(image_path)

Expand Down Expand Up @@ -2499,7 +2515,7 @@ def seed_worker(worker_id):
def get_loader(transformed_dataset, args):
"""
create dataset from ground-truth
return a batch sampler based ont the dataset
return a batch sampler based on the dataset
"""

# transformed_dataset = LaneDataset(dataset_base_dir, json_file_path, args)
Expand Down Expand Up @@ -2554,9 +2570,9 @@ def get_loader(transformed_dataset, args):
worker_init_fn=seed_worker,
generator=g)

if args.dist:
return data_loader, data_sampler
return data_loader

return data_loader, data_sampler



def compute_2d_lanes(pred_anchor, h_samples, H_g2im, anchor_x_steps, anchor_y_steps, x_min, x_max, prob_th=0.5):
Expand Down
12 changes: 9 additions & 3 deletions experiments/ddp.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@
import random

def setup_dist_launch(args):
# 通过launch.json 文件中定义的PyTorch分布式启动器动态获取进程ID
args.proc_id = args.local_rank
world_size = int(os.getenv('WORLD_SIZE', 1))*args.nodes
# 包含隐形错误,pytorch分布式launch模块已为WORLD_SIZE分配值为总进程数 = args.nnodes * args.nproc_per_node


# 通过launch.json 文件中定义的PyTorch分布式启动器获取总进程数
# world_size = int(os.getenv('WORLD_SIZE', 1))*args.nodes
args.world_size = int(os.environ['WORLD_SIZE'])
print("proc_id: " + str(args.proc_id))
print("world size: " + str(world_size))
print("world size: " + str(args.world_size))
print("local_rank: " + str(args.local_rank))

os.environ['WORLD_SIZE'] = str(world_size)
os.environ['WORLD_SIZE'] = str(args.world_size)
os.environ['RANK'] = str(args.proc_id)
os.environ['LOCAL_RANK'] = str(args.local_rank)

Expand Down
Loading