You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defbox1_in_box2(corners1:torch.Tensor, corners2:torch.Tensor):
a=corners2[:, :, 0:1, :] # (B, N, 1, 2)b=corners2[:, :, 1:2, :] # (B, N, 1, 2)d=corners2[:, :, 3:4, :] # (B, N, 1, 2)ab=b-a# (B, N, 1, 2)am=corners1-a# (B, N, 4, 2)ad=d-a# (B, N, 1, 2)p_ab=torch.sum(ab*am, dim=-1) # (B, N, 4)norm_ab=torch.sum(ab*ab, dim=-1) # (B, N, 1)p_ad=torch.sum(ad*am, dim=-1) # (B, N, 4)norm_ad=torch.sum(ad*ad, dim=-1) # (B, N, 1)# NOTE: the expression looks ugly but is stable if the two boxes are exactly the same# also stable with different scale of bboxescond1= (p_ab/norm_ab>-1e-6) * (p_ab/norm_ab<1+1e-6) # (B, N, 4)cond2= (p_ad/norm_ad>-1e-6) * (p_ad/norm_ad<1+1e-6) # (B, N, 4)returncond1*cond2
感谢你的issue。我觉得是数值误差引起的问题。数学上应该是等效的。
说实话我这整个repo的代码都是naive实现,只是proof of concept,写的时候突出一个quick and dirty,没有针对数值稳定性做过太多优化和测试(我也确实不擅长这个,对不住)。直接两个box1作输入的corner case之前确实没有考虑过。
我尝试在维基百科上查找了另外一种算法(叉积), 重写了此函数,是我对函数的理解有错误?或者你提供的原始的函数存在bug?
你有什么修正的建议吗?
The text was updated successfully, but these errors were encountered: