Adding forward_with_given_boxes to the ROI head
Summary: Adding forward_with_given_boxes to the ROI head to replace the inherited one, and compute the densepose outputs on it
@@ -180,6 +180,27 @@ class DensePoseROIHeads(StandardROIHeads):
if self.training:
losses.update(self._forward_densepose(features, instances))
- else:
- instances = self._forward_densepose(features, instances)
return instances, losses
+
+ def forward_with_given_boxes(self, features, instances):
+ """
+ Use the given boxes in `instances` to produce other (non-box) per-ROI outputs.
+
+ This is useful for downstream tasks where a box is known, but need to obtain
+ other attributes (outputs of other heads).
+ Test-time augmentation also uses this.
+
+ Args:
+ features: same as in `forward()`
+ instances (list[Instances]): instances to predict other outputs. Expect the keys
+ "pred_boxes" and "pred_classes" to exist.
+
+ Returns:
+ instances (list[Instances]):
+ the same `Instances` objects, with extra
+ fields such as `pred_masks` or `pred_keypoints`.
+ """
+
+ instances = super().forward_with_given_boxes(features, instances)
+ instances = self._forward_densepose(features, instances)
+ return instances
