Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular definition problem #118

Open
Suppersine opened this issue Feb 10, 2023 · 0 comments
Open

Angular definition problem #118

Suppersine opened this issue Feb 10, 2023 · 0 comments

Comments

@Suppersine
Copy link

My derivation of your repo (SSTato's +Yolov7OBB) is here: https://github.com/Suppersine/YOLOv7_obb_KFIOU

According to MMRotate, the CSL loss function abides by the "Long edge" angular definition, ranging from [-pi/, & pi/2, while the KLD & KFIOU loss functions abide by the "Old OpenCV (OOCV)" definition, ranging from [-pi/2, 0). To convert between these. I have written the function inside the rboxs_utils.py file below:

def regular_theta(theta, mode='180', start=-pi/2):
    """
    limit theta ∈ [-pi/2, pi/2)
    """
    assert mode in ['360', '180']
    cycle = 2 * pi if mode == '360' else pi

    theta = theta - start
    theta = theta % cycle
    return theta + start

def lebox2ocbox(x, y, w, h, theta):
    x, y, = x, y #ocbox[:2] = lebox[:2]
    #ocbox[-2:] = lebox[-2:]
    if theta < 0:
        return x, y, w, h, theta
    else:
        w, h = h, w
        theta -= pi/2
        return x, y, w, h, theta

def ocbox2lebox(x, y, w, h, theta):
    x, y, = x, y #lebox[:2] = ocbox[:2]
    #lebox[-2:] = ocbox[-2:]
    if w == max(w, h): 
        return x, y, w, h, theta
    else:
        w, h = h, w
        theta += pi/2
        return x, y, w, h, theta

and changed the "poly2rbox" by adding the highlighted section below to switch to OOCV angular definition:

image

In the loss file in the training phase, under the KLD loss mode, however, when I printed out the predicted angles, they were supposed to be all-negative, but sometimes their max angles show positive values. (I guess I may not have changed their angular definition). I want to ask you... Since I can change the truth boxes' angular definition by the process above, where can I change the predicted boxes' angular definition?

2023-02-07_15-22-32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant