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

Culane和TUSimple在generate_lines()时逻辑不一致? #346

Open
Goooyi opened this issue Jul 7, 2023 · 1 comment
Open

Culane和TUSimple在generate_lines()时逻辑不一致? #346

Goooyi opened this issue Jul 7, 2023 · 1 comment

Comments

@Goooyi
Copy link

Goooyi commented Jul 7, 2023

Culane的generate_line()会像论文中说的,按照k-th location来做expectation of predictions,详见line 24, line 26和line 44,
其中line 44有-1是因为画图的时候图像坐标从0开始对吗?

def generate_lines(out, shape, names, output_path, griding_num, localization_type='abs', flip_updown=False):
col_sample = np.linspace(0, shape[1] - 1, griding_num)
col_sample_w = col_sample[1] - col_sample[0]
for j in range(out.shape[0]):
out_j = out[j].data.cpu().numpy()
if flip_updown:
out_j = out_j[:, ::-1, :]
if localization_type == 'abs':
out_j = np.argmax(out_j, axis=0)
out_j[out_j == griding_num] = -1
out_j = out_j + 1
elif localization_type == 'rel':
prob = scipy.special.softmax(out_j[:-1, :, :], axis=0)
idx = np.arange(griding_num) + 1
idx = idx.reshape(-1, 1, 1)
loc = np.sum(prob * idx, axis=0)
out_j = np.argmax(out_j, axis=0)
loc[out_j == griding_num] = 0
out_j = loc
else:
raise NotImplementedError
name = names[j]
line_save_path = os.path.join(output_path, name[:-3] + 'lines.txt')
save_dir, _ = os.path.split(line_save_path)
if not os.path.exists(save_dir):
os.makedirs(save_dir)
with open(line_save_path, 'w') as fp:
for i in range(out_j.shape[1]):
if np.sum(out_j[:, i] != 0) > 2:
for k in range(out_j.shape[0]):
if out_j[k, i] > 0:
fp.write(
'%d %d ' % (int(out_j[k, i] * col_sample_w * 1640 / 800) - 1, int(590 - k * 20) - 1))
fp.write('\n')

但是在TUSimple的generate_lines()函数中,见line 72, 74, 81:

def generate_tusimple_lines(out,shape,griding_num,localization_type='rel'):
out = out.data.cpu().numpy()
out_loc = np.argmax(out,axis=0)
if localization_type == 'rel':
prob = scipy.special.softmax(out[:-1, :, :], axis=0)
idx = np.arange(griding_num)
idx = idx.reshape(-1, 1, 1)
loc = np.sum(prob * idx, axis=0)
loc[out_loc == griding_num] = griding_num
out_loc = loc
lanes = []
for i in range(out_loc.shape[1]):
out_i = out_loc[:,i]
lane = [int(round((loc + 0.5) * 1280.0 / (griding_num - 1))) if loc != griding_num else -2 for loc in out_i]
lanes.append(lane)
return lanes

首先72行没像culane一样+1计算出k-th location, 相当于用了每个grid格子的左端点?
然后81行+0.5是因为由于tusimple的griding_num=100所以+0.5相当于从格子左端点变成了格子的中间点?那为什么要/(griding_num-1)来除以区间个数呢?

@hwang12345
Copy link

@Goooyi 有同样的疑问,为什么两个数据集处理方式不同

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants