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

Evaluating pck #66

Open
amin-asdzdh opened this issue Aug 16, 2020 · 1 comment
Open

Evaluating pck #66

amin-asdzdh opened this issue Aug 16, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@amin-asdzdh
Copy link

When evaluating the PCK using the following function:

simple-HRNet/misc/utils.py

Lines 213 to 244 in f4a8174

def evaluate_pck_accuracy(output, target, hm_type='gaussian', thr=0.5):
"""
Calculate accuracy according to PCK,
but uses ground truth heatmap rather than y,x locations
First value to be returned is average accuracy across 'idxs',
followed by individual accuracies
"""
idx = list(range(output.shape[1]))
if hm_type == 'gaussian':
pred, _ = get_max_preds(output)
target, _ = get_max_preds(target)
h = output.shape[2]
w = output.shape[3]
norm = torch.ones((pred.shape[0], 2)) * torch.tensor([h, w],
dtype=torch.float32) / 10 # Why they divide this by 10?
norm = norm.to(output.device)
else:
raise NotImplementedError
dists = calc_dists(pred, target, norm)
acc = torch.zeros(len(idx)).to(dists.device)
avg_acc = 0
cnt = 0
for i in range(len(idx)):
acc[i] = dist_acc(dists[idx[i]], thr=thr)
if acc[i] >= 0:
avg_acc = avg_acc + acc[i]
cnt += 1
avg_acc = avg_acc / cnt if cnt != 0 else torch.tensor(0)
return acc, avg_acc, cnt, pred, target

Why does the x_coordinate gets divided by the height and the y_coordinate by the width? Shouldn't it be the other way around?

Thanks

@stefanopini
Copy link
Owner

stefanopini commented Aug 25, 2020

Hi! I've checked it and I think you're right.

This code is derived from here and the same code is found also here and they may both contain the same issue.

I've raised your question in microsoft/human-pose-estimation.pytorch#144 to have another check on this. I'll keep you posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants