Closed Suppersine closed 1 year ago
我对你的回购的推导在这里:https ://github.com/Suppersine/YOLOv7_obb_KFIOU
根据 MMRotate,CSL 损失函数遵循“Long edge”角度定义,范围从 [-pi/, & pi/2,而 KLD 和 KFIOU 损失函数遵循“Old OpenCV (OOCV)”定义,范围来自 [-pi/2, 0)。在这些之间进行转换。我在下面的 rboxs_utils.py 文件中编写了函数:
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
并通过添加下面突出显示的部分以切换到 OOCV 角度定义来更改“poly2rbox”:
然而,在训练阶段的损失文件中,在 KLD 损失模式下,当我打印出预测角度时,它们应该是全负的,但有时它们的最大角度显示正值。(我想我可能没有改变他们的角度定义)。我想问你... 既然我可以通过上面的过程改变真值框的角度定义,那么我在哪里可以改变预测框的角度定义?
What I understand is that you want to reconstruct the source code according to your own ideas, right? You can refer to this link(https://www.zhihu.com/column/c_1358464959123390464), which contains detailed ideas and processes.
My derivation of your repo 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:
and changed the "poly2rbox" by adding the highlighted section below to switch to OOCV angular definition:
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?