"...python/git@developer.sourcefind.cn:change/sglang.git" did not exist on "08acdb5c3db3eef90d40ae0b7389d5fb604eae73"
Unverified Commit 557c5daa authored by F-G Fernandez's avatar F-G Fernandez Committed by GitHub
Browse files

docs: Added MaskRCNN to the new doc (#5900)



* docs: Added MaskRCNN to new doc

* docs: Updated docstring

* ufmt
Co-authored-by: default avatarFG Fernandez <–26927750+frgfm@users.noreply.github.com>
Co-authored-by: default avatarNicolas Hug <contact@nicolas-hug.com>
parent f0148413
Mask R-CNN
==========
.. currentmodule:: torchvision.models.detection
The Mask R-CNN model is based on the `Mask R-CNN <https://arxiv.org/abs/1703.06870>`__
paper.
Model builders
--------------
The following model builders can be used to instantiate a Mask R-CNN model, with or
without pre-trained weights. All the model builders internally rely on the
``torchvision.models.detection.mask_rcnn.MaskRCNN`` base class. Please refer to the `source
code
<https://github.com/pytorch/vision/blob/main/torchvision/models/detection/mask_rcnn.py>`_ for
more details about this class.
.. autosummary::
:toctree: generated/
:template: function.rst
maskrcnn_resnet50_fpn
maskrcnn_resnet50_fpn_v2
...@@ -94,6 +94,7 @@ weights: ...@@ -94,6 +94,7 @@ weights:
:maxdepth: 1 :maxdepth: 1
models/retinanet models/retinanet
models/mask_rcnn
Table of all available detection weights Table of all available detection weights
---------------------------------------- ----------------------------------------
......
...@@ -403,10 +403,8 @@ def maskrcnn_resnet50_fpn( ...@@ -403,10 +403,8 @@ def maskrcnn_resnet50_fpn(
trainable_backbone_layers: Optional[int] = None, trainable_backbone_layers: Optional[int] = None,
**kwargs: Any, **kwargs: Any,
) -> MaskRCNN: ) -> MaskRCNN:
""" """Mask R-CNN model with a ResNet-50-FPN backbone from the `Mask R-CNN
Constructs a Mask R-CNN model with a ResNet-50-FPN backbone. <https://arxiv.org/abs/1703.06870>`_ paper.
Reference: `"Mask R-CNN" <https://arxiv.org/abs/1703.06870>`_.
The input to the model is expected to be a list of tensors, each of shape ``[C, H, W]``, one for each 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. image, and should be in ``0-1`` range. Different images can have different sizes.
...@@ -451,13 +449,26 @@ def maskrcnn_resnet50_fpn( ...@@ -451,13 +449,26 @@ def maskrcnn_resnet50_fpn(
>>> torch.onnx.export(model, x, "mask_rcnn.onnx", opset_version = 11) >>> torch.onnx.export(model, x, "mask_rcnn.onnx", opset_version = 11)
Args: Args:
weights (MaskRCNN_ResNet50_FPN_Weights, optional): The pretrained weights for the model weights (:class:`~torchvision.models.detection.MaskRCNN_ResNet50_FPN_Weights`, optional): The
progress (bool): If True, displays a progress bar of the download to stderr pretrained weights to use. See
:class:`~torchvision.models.detection.MaskRCNN_ResNet50_FPN_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) num_classes (int, optional): number of output classes of the model (including the background)
weights_backbone (ResNet50_Weights, optional): The pretrained weights for the backbone weights_backbone (:class:`~torchvision.models.ResNet50_Weights`, optional): The
trainable_backbone_layers (int, optional): number of trainable (not frozen) layers starting from final block. pretrained weights for the backbone.
Valid values are between 0 and 5, with 5 meaning all backbone layers are trainable. If ``None`` is trainable_backbone_layers (int, optional): number of trainable (not frozen) layers starting from
passed (the default) this value is set to 3. 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 3.
**kwargs: parameters passed to the ``torchvision.models.detection.mask_rcnn.MaskRCNN``
base class. Please refer to the `source code
<https://github.com/pytorch/vision/blob/main/torchvision/models/detection/mask_rcnn.py>`_
for more details about this class.
.. autoclass:: torchvision.models.detection.MaskRCNN_ResNet50_FPN_Weights
:members:
""" """
weights = MaskRCNN_ResNet50_FPN_Weights.verify(weights) weights = MaskRCNN_ResNet50_FPN_Weights.verify(weights)
weights_backbone = ResNet50_Weights.verify(weights_backbone) weights_backbone = ResNet50_Weights.verify(weights_backbone)
...@@ -493,22 +504,32 @@ def maskrcnn_resnet50_fpn_v2( ...@@ -493,22 +504,32 @@ def maskrcnn_resnet50_fpn_v2(
trainable_backbone_layers: Optional[int] = None, trainable_backbone_layers: Optional[int] = None,
**kwargs: Any, **kwargs: Any,
) -> MaskRCNN: ) -> MaskRCNN:
""" """Improved Mask R-CNN model with a ResNet-50-FPN backbone from the `Benchmarking Detection Transfer
Constructs an improved MaskRCNN model with a ResNet-50-FPN backbone. Learning with Vision Transformers <https://arxiv.org/abs/2111.11429>`_ paper.
Reference: `"Benchmarking Detection Transfer Learning with Vision Transformers"
<https://arxiv.org/abs/2111.11429>`_.
:func:`~torchvision.models.detection.maskrcnn_resnet50_fpn` for more details. :func:`~torchvision.models.detection.maskrcnn_resnet50_fpn` for more details.
Args: Args:
weights (MaskRCNN_ResNet50_FPN_V2_Weights, optional): The pretrained weights for the model weights (:class:`~torchvision.models.detection.MaskRCNN_ResNet50_FPN_V2_Weights`, optional): The
progress (bool): If True, displays a progress bar of the download to stderr pretrained weights to use. See
:class:`~torchvision.models.detection.MaskRCNN_ResNet50_FPN_V2_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) num_classes (int, optional): number of output classes of the model (including the background)
weights_backbone (ResNet50_Weights, optional): The pretrained weights for the backbone weights_backbone (:class:`~torchvision.models.ResNet50_Weights`, optional): The
trainable_backbone_layers (int, optional): number of trainable (not frozen) layers starting from final block. pretrained weights for the backbone.
Valid values are between 0 and 5, with 5 meaning all backbone layers are trainable. If ``None`` is trainable_backbone_layers (int, optional): number of trainable (not frozen) layers starting from
passed (the default) this value is set to 3. 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 3.
**kwargs: parameters passed to the ``torchvision.models.detection.mask_rcnn.MaskRCNN``
base class. Please refer to the `source code
<https://github.com/pytorch/vision/blob/main/torchvision/models/detection/mask_rcnn.py>`_
for more details about this class.
.. autoclass:: torchvision.models.detection.MaskRCNN_ResNet50_FPN_V2_Weights
:members:
""" """
weights = MaskRCNN_ResNet50_FPN_V2_Weights.verify(weights) weights = MaskRCNN_ResNet50_FPN_V2_Weights.verify(weights)
weights_backbone = ResNet50_Weights.verify(weights_backbone) weights_backbone = ResNet50_Weights.verify(weights_backbone)
......
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