610265158/face_landmark

关于loss权重

ycdhqzhiai opened this issue · 1 comments

@610265158 非常感谢您分享的代码,我这边有个问题想请教下,对于wing_loss中的weights

def _wing_loss(landmarks, labels, w=10.0, epsilon=2.0):
    """
    Arguments:
        landmarks, labels: float tensors with shape [batch_size, landmarks].  landmarks means x1,x2,x3,x4...y1,y2,y3,y4   1-D
        w, epsilon: a float numbers.
    Returns:
        a float tensor with shape [].
    """
    with tf.name_scope('wing_loss'):
        x = landmarks - labels
        c = w * (1.0 - math.log(1.0 + w / epsilon))
        absolute_x = tf.abs(x)
        losses = tf.where(
            tf.greater(w, absolute_x),
            w * tf.log(1.0 + absolute_x / epsilon),
            absolute_x - c
        )
        losses=losses*cfg.DATA.weights
        loss = tf.reduce_sum(tf.reduce_mean(losses, axis=[0]))
        return loss

我见config里面有加一个权重,

weights=[1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,                                    #####bouding
                               1.,1.,1.,1.,1.,1.,1.,1.,1.,                                      #####nose
                               1.5,1.5,1.5,1.5,1.5,       1.5,1.5,1.5,1.5,1.5,                  #####eyebows
                               1.5,1.5,1.5,1.5,1.5,1.5,    1.5,1.5,1.5,1.5,1.5,1.5,             ####eyes
                               1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.      #####mouth

我的问题是关于这个权重排列,是根据68点landmark分布排列的吗?在眉毛和眼睛上加了一个1.5的系数?但是这个1-17是bouding,18-27是眉毛,按照这个config里面的,1-17是bouding,18-26是鼻子,与68点landmarks分布好像不一致啊
image

Hi,
yes, you are right, it is a mistake, but seems it does not matter that much. I will correct it later, and retrain the model.
Thank you for pointing out that.