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

Bug report #63

Open
ChiHangChen opened this issue May 26, 2020 · 5 comments
Open

Bug report #63

ChiHangChen opened this issue May 26, 2020 · 5 comments

Comments

@ChiHangChen
Copy link

In lib/utils/transforms.py line 179, 180

        center_new[0] = center_new[0] * 1.0 / sf
        center_new[1] = center_new[1] * 1.0 / sf

It should be

        center_new[1] = center_new[1] * new_ht / ht
        center_new[0] = center_new[0] * new_wd / wd

Or the landmark will be shifted.

@zongjuede
Copy link

zongjuede commented Jun 6, 2020

Hi, Jim, @ChiHangChen
Thanks for your valuable issue. It seems that you are expert in heat map encoding and decoding from the issue.
Could you please help me explain some code ? I have tried my best to understand it, but failed.

  1. Could you please tell me the purpose of operation "-1" in the row new_pt = np.array([pt[0] - 1, pt[1] - 1, 1.]).T ?
    `def transform_pixel(pt, center, scale, output_size, invert=0, rot=0):
    t = get_transform(center, scale, output_size, rot=rot)
    if invert:
    t = np.linalg.inv(t)
    new_pt = np.array([pt[0] - 1, pt[1] - 1, 1.]).T
    new_pt = np.dot(t, new_pt)
    return new_pt[:2].astype(int) + 1

    `

  2. Could you please tell me the purpose of operation "+1" in the row preds[:, :, 0] = (preds[:, :, 0] - 1) % scores.size(3) + 1 and preds[:, :, 1] = torch.floor((preds[:, :, 1] - 1) / scores.size(3)) + 1 ?
    I think the highest respond point misses if plus 1 on its coordinate.
    `def get_preds(scores):
    """
    get predictions from score maps in torch Tensor
    return type: torch.LongTensor
    """
    assert scores.dim() == 4, 'Score maps should be 4-dim'
    maxval, idx = torch.max(scores.view(scores.size(0), scores.size(1), -1), 2)

    maxval = maxval.view(scores.size(0), scores.size(1), 1)
    idx = idx.view(scores.size(0), scores.size(1), 1) + 1

    preds = idx.repeat(1, 1, 2).float()

    preds[:, :, 0] = (preds[:, :, 0] - 1) % scores.size(3) + 1
    preds[:, :, 1] = torch.floor((preds[:, :, 1] - 1) / scores.size(3)) + 1

    pred_mask = maxval.gt(0).repeat(1, 1, 2).float()
    preds *= pred_mask
    return preds`

Could you please help me?
Any reply is appreciated.

@ChiHangChen
Copy link
Author

Hi @zongjuede ,
I'm not an expert, I'm also a beginner in this field.
I didn't used those functions you mentioned, maybe you can open a new issue and let the author answer your question.
Sorry for not being of any help.

@zongjuede
Copy link

OK,I will try. Thanks a lot for your reply.

@MengHao666
Copy link

Hi, Jim, @ChiHangChen Thanks for your valuable issue. It seems that you are expert in heat map encoding and decoding from the issue. Could you please help me explain some code ? I have tried my best to understand it, but failed.

  1. Could you please tell me the purpose of operation "-1" in the row new_pt = np.array([pt[0] - 1, pt[1] - 1, 1.]).T ?
    def transform_pixel(pt, center, scale, output_size, invert=0, rot=0): t = get_transform(center, scale, output_size, rot=rot) if invert: t = np.linalg.inv(t) new_pt = np.array([pt[0] - 1, pt[1] - 1, 1.]).T new_pt = np.dot(t, new_pt) return new_pt[:2].astype(int) + 1
  2. Could you please tell me the purpose of operation "+1" in the row preds[:, :, 0] = (preds[:, :, 0] - 1) % scores.size(3) + 1 and preds[:, :, 1] = torch.floor((preds[:, :, 1] - 1) / scores.size(3)) + 1 ?
    I think the highest respond point misses if plus 1 on its coordinate.
    def get_preds(scores): """ get predictions from score maps in torch Tensor return type: torch.LongTensor """ assert scores.dim() == 4, 'Score maps should be 4-dim' maxval, idx = torch.max(scores.view(scores.size(0), scores.size(1), -1), 2) maxval = maxval.view(scores.size(0), scores.size(1), 1) idx = idx.view(scores.size(0), scores.size(1), 1) + 1 preds = idx.repeat(1, 1, 2).float() preds[:, :, 0] = (preds[:, :, 0] - 1) % scores.size(3) + 1 preds[:, :, 1] = torch.floor((preds[:, :, 1] - 1) / scores.size(3)) + 1 pred_mask = maxval.gt(0).repeat(1, 1, 2).float() preds *= pred_mask return preds

Could you please help me? Any reply is appreciated.

Hey, have you figured it out?

@lhyfst
Copy link

lhyfst commented Apr 25, 2022

same question

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

4 participants