natanielruiz
2017-08-08 18a21d4b07c581a8954b08518115fb035c712b28
code/utils.py
@@ -22,8 +22,8 @@
        face_y = tdy - 0.50 * size
    else:
        height, width = img.shape[:2]
        face_x = width / 2 - 0.15 - size
        face_y = height / 2 - 0.15 - size
        face_x = width / 2 - 0.5 * size
        face_y = height / 2 - 0.5 * size
    x1 = size * (cos(y) * cos(r)) + face_x
    y1 = size * (cos(p) * sin(r) + cos(r) * sin(p) * sin(y)) + face_y
@@ -70,5 +70,11 @@
    pose_params = pre_pose_params[:3]
    return pose_params
def get_pt2d_from_mat(mat_path):
    # Get 2D landmarks
    mat = sio.loadmat(mat_path)
    pt2d = mat['pt2d']
    return pt2d
def mse_loss(input, target):
    return torch.sum(torch.abs(input.data - target.data) ** 2)