Culane和TUSimple在generate_lines()时逻辑不一致?
Goooyi opened this issue · comments
Yi Gao commented
Culane的generate_line()会像论文中说的,按照k-th location来做expectation of predictions,详见line 24, line 26和line 44,
其中line 44有-1是因为画图的时候图像坐标从0开始对吗?
Ultra-Fast-Lane-Detection/evaluation/eval_wrapper.py
Lines 9 to 45 in 353df10
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:
Ultra-Fast-Lane-Detection/evaluation/eval_wrapper.py
Lines 64 to 83 in 353df10
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 commented
@Goooyi 有同样的疑问,为什么两个数据集处理方式不同