Unverified Commit 68ef1d79 authored by Jingwei Zhang's avatar Jingwei Zhang Committed by GitHub
Browse files

[Fix] Fix memory overflow in the rotated box IoU calculation (#2134)

* fix iou3d bug

* replace clamp_min with clamp
parent 4e28378d
...@@ -463,11 +463,17 @@ class BaseInstance3DBoxes(object): ...@@ -463,11 +463,17 @@ class BaseInstance3DBoxes(object):
# height overlap # height overlap
overlaps_h = cls.height_overlaps(boxes1, boxes2) overlaps_h = cls.height_overlaps(boxes1, boxes2)
# Restrict the min values of W and H to avoid memory overflow in
# ``box_iou_rotated``.
boxes1_bev, boxes2_bev = boxes1.bev, boxes2.bev
boxes1_bev[:, 2:4] = boxes1_bev[:, 2:4].clamp(min=1e-4)
boxes2_bev[:, 2:4] = boxes2.bev[:, 2:4].clamp(min=1e-4)
# bev overlap # bev overlap
iou2d = box_iou_rotated(boxes1.bev, boxes2.bev) iou2d = box_iou_rotated(boxes1_bev, boxes2_bev)
areas1 = (boxes1.bev[:, 2] * boxes1.bev[:, 3]).unsqueeze(1).expand( areas1 = (boxes1_bev[:, 2] * boxes1_bev[:, 3]).unsqueeze(1).expand(
rows, cols) rows, cols)
areas2 = (boxes2.bev[:, 2] * boxes2.bev[:, 3]).unsqueeze(0).expand( areas2 = (boxes2_bev[:, 2] * boxes2_bev[:, 3]).unsqueeze(0).expand(
rows, cols) rows, cols)
overlaps_bev = iou2d * (areas1 + areas2) / (1 + iou2d) overlaps_bev = iou2d * (areas1 + areas2) / (1 + iou2d)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment