potterhsu / easy-faster-rcnn.pytorch

An easy implementation of Faster R-CNN (https://arxiv.org/pdf/1506.01497.pdf) in PyTorch.
MIT License
165 stars 57 forks source link

Questions about Bbox class and methods #35

Open kichoul64 opened 2 years ago

kichoul64 commented 2 years ago

Hi potterhsu. I'm studying deep learning detection with your code. It helps a lot. really thank you

I'm trying to train with custom data and to insert some 'spatial transform networks' things. Then I'm curious what exactly methods in class BBox is working for. Especially 'calc_transformer' and 'apply_transformer' Are they related to affine transform? or others?. Can i get some explains what they are?

I'm not sure this question is okay in 'Issues', but i don't know elsewhere to ask to you. Sorry for if i make some mistake. I will wait your answer. Thank U

@staticmethod def from_center_base(center_based_bboxes: Tensor) -> Tensor: return torch.stack([ center_based_bboxes[..., 0] - center_based_bboxes[..., 2] / 2, center_based_bboxes[..., 1] - center_based_bboxes[..., 3] / 2, center_based_bboxes[..., 0] + center_based_bboxes[..., 2] / 2, center_based_bboxes[..., 1] + center_based_bboxes[..., 3] / 2 ], dim=-1)

@staticmethod
def calc_transformer(src_bboxes: Tensor, dst_bboxes: Tensor) -> Tensor:
    center_based_src_bboxes = BBox.to_center_base(src_bboxes)
    center_based_dst_bboxes = BBox.to_center_base(dst_bboxes)
    transformers = torch.stack([
        (center_based_dst_bboxes[..., 0] - center_based_src_bboxes[..., 0]) / center_based_src_bboxes[..., 2],
        (center_based_dst_bboxes[..., 1] - center_based_src_bboxes[..., 1]) / center_based_src_bboxes[..., 3],
        torch.log(center_based_dst_bboxes[..., 2] / center_based_src_bboxes[..., 2]),
        torch.log(center_based_dst_bboxes[..., 3] / center_based_src_bboxes[..., 3])
    ], dim=-1)
    return transformers