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

更改评价标准的报错问题? #52

Open
zhizhz opened this issue Feb 3, 2023 · 3 comments
Open

更改评价标准的报错问题? #52

zhizhz opened this issue Feb 3, 2023 · 3 comments

Comments

@zhizhz
Copy link

zhizhz commented Feb 3, 2023

老师您好,在我测试您的代码的时候根据readme更换评价指标的时候,是否只需要更改hungarian_matching.py的判断语句:
for i in range(prediction_len):
for j in range(gt_len):
# if EA_metric(p_lines[i], g_lines[j]) >= threshold:
#if Chamfer_metric(p_lines[i], g_lines[j]) >= threshold:
if Emd_metric(p_lines[i], g_lines[j]) >= threshold:
G[i][j] = 1
return G

在我进行不同评价指标测试的时候发现Emd_metric的评价指标的时候会不出结果,而在Chamfer _metric的评价指标的时候会有如下报错:
Traceback (most recent call last):
File "/home/qiao/app/pycharm-community-2022.2.2/plugins/python-ce/helpers/pydev/pydevd.py", line 1496, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/qiao/app/pycharm-community-2022.2.2/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/qiao/Desktop/deep-hough-transform-master/metric.py", line 83, in
emd_score = Emd_metric(l1, l2)
File "/home/qiao/Desktop/deep-hough-transform-master/metric.py", line 50, in Emd_metric
M = ot.dist(points1, points2, metric='euclidean')
File "/home/qiao/anaconda3/lib/python3.7/site-packages/ot/utils.py", line 219, in dist
return euclidean_distances(x1, x2, squared=False)
File "/home/qiao/anaconda3/lib/python3.7/site-packages/ot/utils.py", line 165, in euclidean_distances
nx = get_backend(X, Y)
File "/home/qiao/anaconda3/lib/python3.7/site-packages/ot/backend.py", line 82, in get_backend
raise ValueError("Unknown type of non implemented backend.")
ValueError: Unknown type of non implemented backend.
python-BaseException

请问老师,是我更改评价标准的程序步骤没有完全吗还是这个ot.dist函数的原因?

@zeakey
Copy link
Collaborator

zeakey commented Feb 4, 2023

I guess this is related to the version of ot. OT has recently released a major update that enables multiple backends (e.g. torch and numpy). Your error message tells that it was a 'backend' problem.

You can try to reverse to an older version of ot without multi-backend support.

@zhizhz
Copy link
Author

zhizhz commented Feb 4, 2023

谢谢老师解答,我尝试了

def Emd_metric(l_pred, l_gt, size=(400, 400)):
points1 = get_points_coords(l_pred)
points2 = get_points_coords(l_gt)

points1 = np.array(points1)
points2 = np.array(points2)
#points1 = torch.cuda.FloatTensor(points1)
#points2 = torch.cuda.FloatTensor(points2)

M = ot.dist(points1, points2, metric='euclidean')

_, log = ot.emd([], [], M, log=True)
cost = log['cost']
return 1 - cost / np.sqrt(size[0] * size[0] + size[1] * size[1])

这样可以在不更改ot版本情况下,解决我上述问题,但是运行python testsel.py文件的时候不会报错但运行时间很长,在训练的时候显示信息如下:
Training Loss:0.004758382216095924: 100%|█████| 1300/1300 [08:46<00:00, 2.47it/s]
1%|▎ | 10/1300 [13:04<23:48:51, 66.46s/it]
在验证过程中耗费时间太多,请问老师这是正常的吗,还是说这还是与ot版本有关,需要将ot版本转回旧版本,方便问一下老师您当时POT版本是多少吗

@zeakey
Copy link
Collaborator

zeakey commented Feb 12, 2023

谢谢老师解答,我尝试了

def Emd_metric(l_pred, l_gt, size=(400, 400)): points1 = get_points_coords(l_pred) points2 = get_points_coords(l_gt)

points1 = np.array(points1)
points2 = np.array(points2)
#points1 = torch.cuda.FloatTensor(points1)
#points2 = torch.cuda.FloatTensor(points2)

M = ot.dist(points1, points2, metric='euclidean')

_, log = ot.emd([], [], M, log=True)
cost = log['cost']
return 1 - cost / np.sqrt(size[0] * size[0] + size[1] * size[1])

这样可以在不更改ot版本情况下,解决我上述问题,但是运行python testsel.py文件的时候不会报错但运行时间很长,在训练的时候显示信息如下: Training Loss:0.004758382216095924: 100%|█████| 1300/1300 [08:46<00:00, 2.47it/s] 1%|▎ | 10/1300 [13:04<23:48:51, 66.46s/it] 在验证过程中耗费时间太多,请问老师这是正常的吗,还是说这还是与ot版本有关,需要将ot版本转回旧版本,方便问一下老师您当时POT版本是多少吗

Any thoughts on this?

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