EasternJournalist / live_mocap

Single-view real-time motion capture built up upon Google Mediapipe.
Apache License 2.0
177 stars 37 forks source link

Problem of principle #9

Open Tongbook opened 1 year ago

Tongbook commented 1 year ago
    def _loss_closure():
        optimizer.zero_grad()
        optim_matrix_basis = euler_angle_to_matrix(self.optim_bone_euler, 'YXZ')
        matrix_basis = torch.gather(torch.cat([torch.eye(4).unsqueeze(0), optim_matrix_basis]), dim=0, index=self.gather_id)
        matrix_world = eval_matrix_world(self.bone_parents_id, self.bone_matrix, matrix_basis)
        joints = matrix_world[:, :3, 3]
        joint_dir = joints[joint_pairs_a] - joints[joint_pairs_b]
        dir_loss = F.mse_loss(kpt_dir, joint_dir)
        joint_prior_loss = barrier(self.optim_bone_euler[self.joint_contraint_id], self.joint_constraints_min, self.joint_constraints_max).mean()
        pose_reg_loss = self.optim_bone_euler.square().mean()
        loss = dir_loss + self.pose_reg_loss_weight * pose_reg_loss + self.joint_constraint_loss_weight * joint_prior_loss 
        loss.backward()
        return loss

Above code, what is the loss logic? If it is convenient for you, please introduce me to some unknown places. Thanks.