lilanxiao / Rotated_IoU

Differentiable IoU of rotated bounding boxes using Pytorch
MIT License
415 stars 64 forks source link

AttributeError: 'Tensor' object has no attribute 'square' #22

Closed Savid-mask777 closed 3 years ago

Savid-mask777 commented 3 years ago

File "/home/a/code/box_iou_rotated_diff/min_enclosing_box.py", line 102, in point_line_distance_range num = torch.sqrt((y2 - y1).square() + (x2 - x1).square() + 1e-14) AttributeError: 'Tensor' object has no attribute 'square'

lilanxiao commented 3 years ago

I think you are probably using an old Pytorch version. According to the Pytorch home page, torch.square() is available since 1.5 version. You could either try a newer version or simply change that line to: num = torch.sqrt((y2 - y1)**2 + (x2 - x1)**2 + 1e-14) or num = torch.sqrt((y2 - y1)*(y2 - y1) + (x2 - x1)*(x2 - x1) + 1e-14)