luuuyi / RefineDet.PyTorch

A higher performance PyTorch implementation of Single-Shot Refinement Neural Network for Object Detection
MIT License
235 stars 64 forks source link

some confusions in decode module #5

Closed cs-heibao closed 5 years ago

cs-heibao commented 5 years ago

@luuuyi def decode(loc, priors, variances): """Decode locations from predictions using priors to undo the encoding we did for offset regression at train time. Args: loc (tensor): location predictions for loc layers, Shape: [num_priors,4] priors (tensor): Prior boxes in center-offset form. Shape: [num_priors,4]. variances: (list[float]) Variances of priorboxes Return: decoded bounding box predictions """

boxes = torch.cat((
    priors[:, :2] + loc[:, :2] * variances[0] * priors[:, 2:],
    priors[:, 2:] * torch.exp(loc[:, 2:] * variances[1])), 1)
boxes[:, :2] -= boxes[:, 2:] / 2
boxes[:, 2:] += boxes[:, :2]
return boxes

here, we change the boxes format to (x1, y1, x2, y2), but the formula boxes[:, 2:] += boxes[:, :2] seems can not get the x2,y2

luuuyi commented 5 years ago

@junjieAI In this place, first step, boxes[0:4] should be (xc, yc, w, h), xc and yc is the center point of the box. Second step, boxes[0:4] should be (x1, y1 , x2, y2), boxes[:, :2] has changed after boxes[:, :2] -= boxes[:, 2:] / 2. You should check the code carefully whether i'm wrong.

cs-heibao commented 5 years ago

@luuuyi Yes, I get it , it's right, thanks