seareale / SDIoU

This is an IoU metric that replaces DIoU using standardized distance.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SDIoU

This is an IoU metric that replaces DIoU using standardized distance.


Introduction

There are two problems when using DIoU[1]: Position, Scale. Those are caused by a normalization factor affected by the center point distance of bounding boxes. So we implemented Standardized Distance-based IoU metric using different normalization factors(SDIoU).

DIoU based on $\theta$ can be calculated as the following equation:

$$ \begin{equation} R_{DIoU} = \frac{(d\cdot cos\theta)^2 + (d\cdot sin\theta)^2} {(\frac{w}{2} + \frac{w'}{2} + d\cdot cos\theta)^2 + (\frac{h}{2} + \frac{h'}{2} + d\cdot sin\theta)^2} \end{equation} $$

For easy understanding, the figure below shows each elements of the equation.

An illustration of DIoU calculated based on θ

Following the equation based on $\theta$, the normalization factor is affected by the center point distance of bounding boxes. And the problems resulting from this can be seen in the figure below.

Illustrations of the position, scale problems of DIoU



Details

The standardized distance[2] uses the variance of each axis as a normalization factor. And we replaced the variance value with the equation for the height and width of two bounding boxes as follows:

Induction of the variance value of SDIoU

The values of $SD_x$ and $SD_y$ get 0 ~ 4 when the two bounding boxes overlap. So, we divided them by 4 for normalization. The final equation of SDIoU can be calculated as shown in the following figure.

Comparison between DIoU and SDIoU

And SDIoU(Standardized Distance-based IoU) solved all the problems of DIoU: Position, Scale.

Illustrations of SDIoU that solves the problems of DIoU.



How to use

  1. run the command
$ pip install -r requirements.txt
  1. initialize variables and add the code in your Loss function like below.
from sidou import * 

  ...
  pred = ... # prediction bounding box ((x, y, w, h), n)
  gt = ... # prediction bounding box (n, (x, y, w, h))

  iou = bbox_iou(pred, gt, SDIoU=True, std_type='mean')
  ...


References

  1. Zhaohui et al, Distance-IoU Loss: Faster and Better Learning for Bounding Box Regression, https://arxiv.org/abs/1911.08287
  2. Wikipedia, Distance, https://en.wikipedia.org/wiki/Distance


About

This is an IoU metric that replaces DIoU using standardized distance.


Languages

Language:Python 100.0%