(matched, priors, variances)
return g_cxcy
Encode the variances from the priorbox layers into the ground truth boxes
    we have matched (based on jaccard overlap) with the prior boxes.
    Args:
        matched: (tensor) Coords of ground truth for each prior in point-form
            Shape: [num_priors, 10].
        priors: (tensor) Prior boxes in center-offset form
            Shape: [num_priors,4].
        variances: (list[float]) Variances of priorboxes
    Return:
        encoded landm (tensor), Shape: [num_priors, 10]
Encode the variances from the priorbox layers into the ground truth boxes
    we have matched (based on jaccard overlap) with the prior boxes.
    Args:
        matched: (tensor) Coords of ground truth for each prior in point-form
            Shape: [num_priors, 10].
        priors: (tensor) Prior boxes in center-offset form
            Shape: [num_priors,4].
        variances: (list[float]) Variances of priorboxes
    Return:
        encoded landm (tensor), Shape: [num_priors, 10]
Encode the variances from the priorbox layers into the ground truth boxes we have matched ( based on jaccard overlap ) with the prior boxes . Args : matched : ( tensor ) Coords of ground truth for each prior in point - form Shape : [ num_priors 10 ] . priors : ( tensor ) Prior boxes in center - offset form Shape : [ num_priors 4 ] . variances : ( list [ float ] ) Variances of priorboxes Return : encoded landm ( tensor ) Shape : [ num_priors 10 ]
def encode_landm(matched, priors, variances):
    """Encode the variances from the priorbox layers into the ground truth boxes
    we have matched (based on jaccard overlap) with the prior boxes.
    Args:
        matched: (tensor) Coords of ground truth for each prior in point-form
            Shape: [num_priors, 10].
        priors: (tensor) Prior boxes in center-offset form
            Shape: [num_priors,4].
        variances: (list[float]) Variances of priorboxes
    Return:
        encoded landm (tensor), Shape: [num_priors, 10]
    """

    # dist b/t match center and prior's center
    matched = torch.reshape(matched, (matched.size(0), 5, 2))
    priors_cx = priors[:, 0].unsqueeze(1).expand(matched.size(0), 5).unsqueeze(2)
    priors_cy = priors[:, 1].unsqueeze(1).expand(matched.size(0), 5).unsqueeze(2)
    priors_w = priors[:, 2].unsqueeze(1).expand(matched.size(0), 5).unsqueeze(2)
    priors_h = priors[:, 3].unsqueeze(1).expand(matched.size(0), 5).unsqueeze(2)
    priors = torch.cat([priors_cx, priors_cy, priors_w, priors_h], dim=2)
    g_cxcy = matched[:, :, :2] - priors[:, :, :2]
    # encode variance
    g_cxcy /= (variances[0] * priors[:, :, 2:])
    # g_cxcy /= priors[:, :, 2:]
    g_cxcy = g_cxcy.reshape(g_cxcy.size(0), -1)
    # return target for smooth_l1_loss
    return g_cxcy
def encode_landm ( matched , priors , variances ) : # dist b/t match center and prior's center matched = torch . reshape ( matched , ( matched . size ( 0 ) , 5 , 2 ) ) priors_cx = priors [ : , 0 ] . unsqueeze ( 1 ) . expand ( matched . size ( 0 ) , 5 ) . unsqueeze ( 2 ) priors_cy = priors [ : , 1 ] . unsqueeze ( 1 ) . expand ( matched . size ( 0 ) , 5 ) . unsqueeze ( 2 ) priors_w = priors [ : , 2 ] . unsqueeze ( 1 ) . expand ( matched . size ( 0 ) , 5 ) . unsqueeze ( 2 ) priors_h = priors [ : , 3 ] . unsqueeze ( 1 ) . expand ( matched . size ( 0 ) , 5 ) . unsqueeze ( 2 ) priors = torch . cat ( [ priors_cx , priors_cy , priors_w , priors_h ] , dim = 2 ) g_cxcy = matched [ : , : , : 2 ] - priors [ : , : , : 2 ] # encode variance g_cxcy /= ( variances [ 0 ] * priors [ : , : , 2 : ] ) # g_cxcy /= priors[:, :, 2:] g_cxcy = g_cxcy . reshape ( g_cxcy . size ( 0 ) , - 1 ) # return target for smooth_l1_loss return g_cxcy