mks0601 / Integral-Human-Pose-Regression-for-3D-Human-Pose-Estimation

PyTorch implementation of "Integral Human Pose Regression", ECCV 2018
194 stars 25 forks source link

Integral regression for 2D human pose estimation #28

Open Ericjiejie opened 4 years ago

Ericjiejie commented 4 years ago

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

mks0601 commented 4 years ago

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

Ericjiejie commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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