IDEA-Research / detrex

detrex is a research platform for DETR-based object detection, segmentation, pose estimation and other visual recognition tasks.
https://detrex.readthedocs.io/en/latest/
Apache License 2.0
1.97k stars 206 forks source link

Wrong description of boxes. #175

Closed powermano closed 1 year ago

powermano commented 1 year ago

In DN-DETR, detrex/layers/denoising.py

https://github.com/IDEA-Research/detrex/blob/main/detrex/layers/denoising.py#:~:text=boxes%20(torch.Tensor)%3A%20Bounding%20boxes%20in%20format%20%60%60(x1%2C%20y1%2C%20x2%2C%20y2)%60%60%20with

It should be: Bounding boxes in format ``(x_c, y_c, w, h)

def apply_box_noise(
    boxes: torch.Tensor,
    box_noise_scale: float = 0.4,
):
    """
    Args:
        boxes (torch.Tensor): Bounding boxes in format ``(x_c, y_c, w, h)`` with
            shape ``(num_boxes, 4)``
        box_noise_scale (float): Scaling factor for box noising. Default: 0.4.
    """
    if box_noise_scale > 0:
        diff = torch.zeros_like(boxes)
        diff[:, :2] = boxes[:, 2:] / 2
        diff[:, 2:] = boxes[:, 2:]
        boxes += torch.mul((torch.rand_like(boxes) * 2 - 1.0), diff) * box_noise_scale
        boxes = boxes.clamp(min=0.0, max=1.0)
    return boxes
HaoZhang534 commented 1 year ago

Thank you for your correction. We will modify this.