From 8b177e290141640e87185dc5699cb3ba6d05ba75 Mon Sep 17 00:00:00 2001 From: Kai Zhang Date: Wed, 20 Oct 2021 11:36:55 -0700 Subject: [PATCH 1/2] Expand usage logging to detection models Summary: Track all detection model instantiation. Reviewed By: sallysyw Differential Revision: D31741603 fbshipit-source-id: 89467db5d89ea41c5a9ab95d1846264d0a1f4199 --- torchvision/models/detection/generalized_rcnn.py | 3 +++ torchvision/models/detection/retinanet.py | 2 ++ torchvision/models/detection/ssd.py | 2 ++ torchvision/models/detection/ssdlite.py | 2 ++ 4 files changed, 9 insertions(+) diff --git a/torchvision/models/detection/generalized_rcnn.py b/torchvision/models/detection/generalized_rcnn.py index c77c892e63e..1acfac29c7a 100644 --- a/torchvision/models/detection/generalized_rcnn.py +++ b/torchvision/models/detection/generalized_rcnn.py @@ -9,6 +9,8 @@ import torch from torch import nn, Tensor +from ...utils import _log_api_usage_once + class GeneralizedRCNN(nn.Module): """ @@ -25,6 +27,7 @@ class GeneralizedRCNN(nn.Module): def __init__(self, backbone, rpn, roi_heads, transform): super(GeneralizedRCNN, self).__init__() + _log_api_usage_once(self) self.transform = transform self.backbone = backbone self.rpn = rpn diff --git a/torchvision/models/detection/retinanet.py b/torchvision/models/detection/retinanet.py index 4b16d7edc7f..bc788d9bb32 100644 --- a/torchvision/models/detection/retinanet.py +++ b/torchvision/models/detection/retinanet.py @@ -12,6 +12,7 @@ from ...ops import misc as misc_nn_ops from ...ops.feature_pyramid_network import LastLevelP6P7 from ..resnet import resnet50 +from ...utils import _log_api_usage_once from . import _utils as det_utils from ._utils import overwrite_eps from .anchor_utils import AnchorGenerator @@ -336,6 +337,7 @@ def __init__( topk_candidates=1000, ): super().__init__() + _log_api_usage_once(self) if not hasattr(backbone, "out_channels"): raise ValueError( diff --git a/torchvision/models/detection/ssd.py b/torchvision/models/detection/ssd.py index 5a068a0f0cc..2ae8709972f 100644 --- a/torchvision/models/detection/ssd.py +++ b/torchvision/models/detection/ssd.py @@ -8,6 +8,7 @@ from ..._internally_replaced_utils import load_state_dict_from_url from ...ops import boxes as box_ops +from ...utils import _log_api_usage_once from .. import vgg from . import _utils as det_utils from .anchor_utils import DefaultBoxGenerator @@ -181,6 +182,7 @@ def __init__( positive_fraction: float = 0.25, ): super().__init__() + _log_api_usage_once(self) self.backbone = backbone diff --git a/torchvision/models/detection/ssdlite.py b/torchvision/models/detection/ssdlite.py index e32aebcf839..5a7b4d14738 100644 --- a/torchvision/models/detection/ssdlite.py +++ b/torchvision/models/detection/ssdlite.py @@ -8,6 +8,7 @@ from ..._internally_replaced_utils import load_state_dict_from_url from ...ops.misc import ConvNormActivation +from ...utils import _log_api_usage_once from .. import mobilenet from . import _utils as det_utils from .anchor_utils import DefaultBoxGenerator @@ -119,6 +120,7 @@ def __init__( min_depth: int = 16, ): super().__init__() + _log_api_usage_once(self) assert not backbone[c4_pos].use_res_connect self.features = nn.Sequential( From 395c989802f669702398dd8196396e541f8c0baa Mon Sep 17 00:00:00 2001 From: Francisco Massa Date: Mon, 25 Oct 2021 15:17:56 +0200 Subject: [PATCH 2/2] Fix lint --- torchvision/models/detection/retinanet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchvision/models/detection/retinanet.py b/torchvision/models/detection/retinanet.py index bc788d9bb32..98a9ec335d4 100644 --- a/torchvision/models/detection/retinanet.py +++ b/torchvision/models/detection/retinanet.py @@ -11,8 +11,8 @@ from ...ops import boxes as box_ops from ...ops import misc as misc_nn_ops from ...ops.feature_pyramid_network import LastLevelP6P7 -from ..resnet import resnet50 from ...utils import _log_api_usage_once +from ..resnet import resnet50 from . import _utils as det_utils from ._utils import overwrite_eps from .anchor_utils import AnchorGenerator