Skip to content

Commit 5fcee61

Browse files
angelayifacebook-github-bot
authored andcommitted
Remove type(UserDefinedObjectVariable)
Summary: Pull Request resolved: facebookresearch#4831 Dynamo is unable to handle getting the type of a user defined object variable, in this case proposals[0].proposal_boxes. However, I'm not sure if the type of this value changes. Reviewed By: wat3rBro Differential Revision: D43641624 fbshipit-source-id: d6b6b3f15124ae2c2945c40b8260d4452e8413f7
1 parent b33e813 commit 5fcee61

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

detectron2/export/c10.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from detectron2.modeling import poolers
1111
from detectron2.modeling.proposal_generator import rpn
1212
from detectron2.modeling.roi_heads.mask_head import mask_rcnn_inference
13-
from detectron2.structures import Boxes, ImageList, Instances, Keypoints
13+
from detectron2.structures import Boxes, ImageList, Instances, Keypoints, RotatedBoxes
1414

1515
from .shared import alias, to_device
1616

@@ -414,7 +414,19 @@ def __call__(self, box_predictor, predictions, proposals):
414414

415415
input_tensor_mode = proposals[0].proposal_boxes.tensor.shape[1] == box_dim + 1
416416

417-
rois = type(proposals[0].proposal_boxes).cat([p.proposal_boxes for p in proposals])
417+
proposal_boxes = proposals[0].proposal_boxes
418+
if isinstance(proposal_boxes, Caffe2Boxes):
419+
rois = Caffe2Boxes.cat([p.proposal_boxes for p in proposals])
420+
elif isinstance(proposal_boxes, RotatedBoxes):
421+
rois = RotatedBoxes.cat([p.proposal_boxes for p in proposals])
422+
elif isinstance(proposal_boxes, Boxes):
423+
rois = Boxes.cat([p.proposal_boxes for p in proposals])
424+
else:
425+
raise NotImplementedError(
426+
'Expected proposals[0].proposal_boxes to be type "Boxes", '
427+
f"instead got {type(proposal_boxes)}"
428+
)
429+
418430
device, dtype = rois.tensor.device, rois.tensor.dtype
419431
if input_tensor_mode:
420432
im_info = proposals[0].image_size

0 commit comments

Comments
 (0)