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

Integral regression for 2D human pose estimation #28

Open
Ericjiejie opened this issue Jun 12, 2020 · 5 comments
Open

Integral regression for 2D human pose estimation #28

Ericjiejie opened this issue Jun 12, 2020 · 5 comments

Comments

@Ericjiejie
Copy link

hi,@mks0601. Do you have the code of paper about Integral Human Pose Regresison,

@mks0601
Copy link
Owner

mks0601 commented Jun 12, 2020

I don't have it (I'm not author of that paper), but you can easily change this code to the 2D version.

@Ericjiejie
Copy link
Author

Yeah, i try to change the code to the 2D estimation, but the training result is bad and the generated heatmaps are almost visually ineffective.I added the following code to the network that has generated a good heatmaps, but the accuracy of the heatmaps produced after only one training will be worse,and it will get worse as the training times increase.Could you help me see what's wrong about the following code?
` def softmax_integral_tensor(self, preds, num_joints, output_2d, hm_width, hm_height): # preds (batch_size, 21, 64, 64), num_joints=21, output_2d=True, hm_width=64, hm_height=64
preds = preds.reshape((preds.shape[0], num_joints, -1)) # (batch_size, 21, 4096)
preds = F.softmax(preds, 2)

    if output_2d: # True
        x, y = self.generate_2d_integral_preds_tensor(preds, num_joints, hm_width, hm_height)
    else:
        assert 0, 'Not Implemented!'  # TODO: Not Implemented

    preds = torch.cat((x, y), dim=2) # (batch_size, 21, 2)
    return preds

def generate_2d_integral_preds_tensor(self, heatmaps, num_joints, x_dim, y_dim):
    assert isinstance(heatmaps, torch.Tensor)
    heatmaps = heatmaps.reshape((heatmaps.shape[0], num_joints, y_dim, x_dim)) # (batch_size, 21, 64, 64)

    accu_x = heatmaps.sum(dim=2)
    accu_y = heatmaps.sum(dim=3)

    accu_x = accu_x * torch.cuda.comm.broadcast(torch.arange(x_dim).type(torch.cuda.FloatTensor), devices=[accu_x.device.index])[0]
    accu_y = accu_y * torch.cuda.comm.broadcast(torch.arange(y_dim).type(torch.cuda.FloatTensor), devices=[accu_y.device.index])[0]

    accu_x = accu_x.sum(dim=2, keepdim=True)
    accu_y = accu_y.sum(dim=2, keepdim=True)
    return accu_x, accu_y`

@mks0601
Copy link
Owner

mks0601 commented Jun 12, 2020

I cannot get what are you doing, but you can just change soft-argmax function to 2D version. I experimented that in many many projects and worked fine.

@mks0601
Copy link
Owner

mks0601 commented Jun 12, 2020

If you want me to see the codes, please post the code more carefully. The above codes out of box are hard to see.

@Ericjiejie
Copy link
Author

I have sent this part of the code to your google email, please check it, thank you.

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