"git@developer.sourcefind.cn:OpenDAS/mmcv.git" did not exist on "0e14ce2c1dac746831009e757500f77f0db526b5"
Unverified Commit d32bce08 authored by Francisco Massa's avatar Francisco Massa Committed by GitHub
Browse files

Make R-CNN models less verbose in script mode (#1671)

* Make R-CNN models less verbose in script mode

* Fix typo in warning message
parent c7c2085e
...@@ -30,6 +30,8 @@ class GeneralizedRCNN(nn.Module): ...@@ -30,6 +30,8 @@ class GeneralizedRCNN(nn.Module):
self.backbone = backbone self.backbone = backbone
self.rpn = rpn self.rpn = rpn
self.roi_heads = roi_heads self.roi_heads = roi_heads
# used only on torchscript mode
self._has_warned = False
@torch.jit.unused @torch.jit.unused
def eager_outputs(self, losses, detections): def eager_outputs(self, losses, detections):
...@@ -74,7 +76,9 @@ class GeneralizedRCNN(nn.Module): ...@@ -74,7 +76,9 @@ class GeneralizedRCNN(nn.Module):
losses.update(proposal_losses) losses.update(proposal_losses)
if torch.jit.is_scripting(): if torch.jit.is_scripting():
warnings.warn("RCNN always returns a (Losses, Detections tuple in scripting)") if not self._has_warned:
warnings.warn("RCNN always returns a (Losses, Detections) tuple in scripting")
self._has_warned = True
return (losses, detections) return (losses, detections)
else: else:
return self.eager_outputs(losses, detections) return self.eager_outputs(losses, detections)
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