create wrapper submodule for compute block to use in to_backend
Summary: Refactoring generate_proposals logic in Caffe2RPN to a separate method, allowing running it separately from the RPN head.
@@ -162,12 +162,9 @@ class Caffe2Compatible(object):
class Caffe2RPN(Caffe2Compatible, rpn.RPN):
- def forward(self, images, features, gt_instances=None):
- assert not self.training
-
- features = [features[f] for f in self.in_features]
- objectness_logits_pred, anchor_deltas_pred = self.rpn_head(features)
-
+ def _generate_proposals(
+ self, images, objectness_logits_pred, anchor_deltas_pred, gt_instances=None
+ ):
assert isinstance(images, ImageList)
if self.tensor_mode:
im_info = images.image_sizes
@@ -248,6 +245,17 @@ class Caffe2RPN(Caffe2Compatible, rpn.RPN):
proposals = self.c2_postprocess(im_info, rpn_rois, rpn_roi_probs, self.tensor_mode)
return proposals, {}
+ def forward(self, images, features, gt_instances=None):
+ assert not self.training
+ features = [features[f] for f in self.in_features]
+ objectness_logits_pred, anchor_deltas_pred = self.rpn_head(features)
+ return self._generate_proposals(
+ images,
+ objectness_logits_pred,
+ anchor_deltas_pred,
+ gt_instances,
+ )
+
@staticmethod
def c2_postprocess(im_info, rpn_rois, rpn_roi_probs, tensor_mode):
proposals = InstancesList(
