From 9e046e3495eb848a121d38cdd7d8555374e0aedd Mon Sep 17 00:00:00 2001 From: puhuk Date: Wed, 4 May 2022 00:04:13 +0900 Subject: [PATCH 1/3] docs: Added SSD300 to the new doc To resolve #5897 --- docs/source/models/ssd300.rst | 24 ++++++++++++++++++++++++ docs/source/models_new.rst | 1 + torchvision/models/detection/ssd.py | 20 ++++++++++++++------ 3 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 docs/source/models/ssd300.rst diff --git a/docs/source/models/ssd300.rst b/docs/source/models/ssd300.rst new file mode 100644 index 00000000000..4d57521b4db --- /dev/null +++ b/docs/source/models/ssd300.rst @@ -0,0 +1,24 @@ +SSD300 +========== + +.. currentmodule:: torchvision.models.detection + +The SSD300 model is based on the `SSD: Single Shot MultiBox Detector +`__ paper. + + +Model builders +-------------- + +The following model builders can be used to instanciate a SSD300 model, with or +without pre-trained weights. All the model builders internally rely on the +``torchvision.models.squeezenet.SqueezeNet`` base class. Please refer to the `source +code +`_ for +more details about this class. + +.. autosummary:: + :toctree: generated/ + :template: function.rst + + SSD300_VGG16 \ No newline at end of file diff --git a/docs/source/models_new.rst b/docs/source/models_new.rst index b4945938824..9841ced485c 100644 --- a/docs/source/models_new.rst +++ b/docs/source/models_new.rst @@ -47,6 +47,7 @@ weights: models/regnet models/resnet models/resnext + models/ssd300 models/squeezenet models/swin_transformer models/vgg diff --git a/torchvision/models/detection/ssd.py b/torchvision/models/detection/ssd.py index e0045a21640..280f289457c 100644 --- a/torchvision/models/detection/ssd.py +++ b/torchvision/models/detection/ssd.py @@ -578,9 +578,8 @@ def ssd300_vgg16( trainable_backbone_layers: Optional[int] = None, **kwargs: Any, ) -> SSD: - """Constructs an SSD model with input size 300x300 and a VGG16 backbone. - - Reference: `"SSD: Single Shot MultiBox Detector" `_. + """The SSD300 model is based on the `SSD: Single Shot MultiBox Detector + `_ paper. The input to the model is expected to be a list of tensors, each of shape [C, H, W], one for each image, and should be in 0-1 range. Different images can have different sizes but they will be resized @@ -615,13 +614,22 @@ def ssd300_vgg16( >>> predictions = model(x) Args: - weights (SSD300_VGG16_Weights, optional): The pretrained weights for the model - progress (bool): If True, displays a progress bar of the download to stderr + weights (:class:`~torchvision.models.detection.SSD300_VGG16_Weights`, optional): + The pretrained weights to use. See :class:`~torchvision.models.detection.SSD300_VGG16_Weights` + below for more details, and possible values. By default, no pre-trained weights are used. + progress (bool, optional): If True, displays a progress bar of the download to stderr + Default is True. num_classes (int, optional): number of output classes of the model (including the background) - weights_backbone (VGG16_Weights, optional): The pretrained weights for the backbone + weights_backbone (:class:`~torchvision.models.VGG16_Weights`, optional): The pretrained weights for the backbone trainable_backbone_layers (int, optional): number of trainable (not frozen) layers starting from final block. Valid values are between 0 and 5, with 5 meaning all backbone layers are trainable. If ``None`` is passed (the default) this value is set to 4. + **kwargs: parameters passed to the ``torchvision.models.detection.SSD`` + base class. Please refer to the `source code + `_ + for more details about this class. + .. autoclass:: torchvision.models.detection.SSD300_VGG16_Weights + :members: """ weights = SSD300_VGG16_Weights.verify(weights) weights_backbone = VGG16_Weights.verify(weights_backbone) From e865edd62a6948d56e53e8f47ce88c8cac1ee560 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 3 May 2022 16:16:38 +0100 Subject: [PATCH 2/3] Minor fixes --- docs/source/models/ssd300.rst | 6 +++--- torchvision/models/detection/ssd.py | 18 +++++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/source/models/ssd300.rst b/docs/source/models/ssd300.rst index 4d57521b4db..a9ceadcdf06 100644 --- a/docs/source/models/ssd300.rst +++ b/docs/source/models/ssd300.rst @@ -1,5 +1,5 @@ SSD300 -========== +====== .. currentmodule:: torchvision.models.detection @@ -12,7 +12,7 @@ Model builders The following model builders can be used to instanciate a SSD300 model, with or without pre-trained weights. All the model builders internally rely on the -``torchvision.models.squeezenet.SqueezeNet`` base class. Please refer to the `source +``torchvision.models.detection.SSD`` base class. Please refer to the `source code `_ for more details about this class. @@ -21,4 +21,4 @@ more details about this class. :toctree: generated/ :template: function.rst - SSD300_VGG16 \ No newline at end of file + ssd300_vgg16 diff --git a/torchvision/models/detection/ssd.py b/torchvision/models/detection/ssd.py index 280f289457c..1be588fd6b8 100644 --- a/torchvision/models/detection/ssd.py +++ b/torchvision/models/detection/ssd.py @@ -614,13 +614,16 @@ def ssd300_vgg16( >>> predictions = model(x) Args: - weights (:class:`~torchvision.models.detection.SSD300_VGG16_Weights`, optional): - The pretrained weights to use. See :class:`~torchvision.models.detection.SSD300_VGG16_Weights` - below for more details, and possible values. By default, no pre-trained weights are used. + weights (:class:`~torchvision.models.detection.SSD300_VGG16_Weights`, optional): The pretrained + weights to use. See + :class:`~torchvision.models.detection.SSD300_VGG16_Weights` + below for more details, and possible values. By default, no + pre-trained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr - Default is True. + Default is True. num_classes (int, optional): number of output classes of the model (including the background) - weights_backbone (:class:`~torchvision.models.VGG16_Weights`, optional): The pretrained weights for the backbone + weights_backbone (:class:`~torchvision.models.VGG16_Weights`, optional): The pretrained weights for the + backbone trainable_backbone_layers (int, optional): number of trainable (not frozen) layers starting from final block. Valid values are between 0 and 5, with 5 meaning all backbone layers are trainable. If ``None`` is passed (the default) this value is set to 4. @@ -628,8 +631,9 @@ def ssd300_vgg16( base class. Please refer to the `source code `_ for more details about this class. - .. autoclass:: torchvision.models.detection.SSD300_VGG16_Weights - :members: + + .. autoclass:: torchvision.models.detection.SSD300_VGG16_Weights + :members: """ weights = SSD300_VGG16_Weights.verify(weights) weights_backbone = VGG16_Weights.verify(weights_backbone) From 245e0ff8182156041ea256326c3ca0aaf510131e Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Tue, 3 May 2022 16:17:30 +0100 Subject: [PATCH 3/3] ufmt --- torchvision/models/detection/ssd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchvision/models/detection/ssd.py b/torchvision/models/detection/ssd.py index 1be588fd6b8..d83147f81f5 100644 --- a/torchvision/models/detection/ssd.py +++ b/torchvision/models/detection/ssd.py @@ -616,7 +616,7 @@ def ssd300_vgg16( Args: weights (:class:`~torchvision.models.detection.SSD300_VGG16_Weights`, optional): The pretrained weights to use. See - :class:`~torchvision.models.detection.SSD300_VGG16_Weights` + :class:`~torchvision.models.detection.SSD300_VGG16_Weights` below for more details, and possible values. By default, no pre-trained weights are used. progress (bool, optional): If True, displays a progress bar of the download to stderr